From c8df373f2d2888c660816574e75714eff2c95c5a Mon Sep 17 00:00:00 2001 From: gewlitys Date: Sun, 22 Dec 2002 19:17:08 +0000 Subject: [PATCH] Optimizations to standard scaling (16 and 32bpp) git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@468 8092fc87-c524-0410-9efc-e669fe64eaf9 --- sc2/src/sc2code/libs/graphics/sdl/pure.c | 27 ++++++++---------------- 1 file changed, 9 insertions(+), 18 deletions(-) diff --git a/sc2/src/sc2code/libs/graphics/sdl/pure.c b/sc2/src/sc2code/libs/graphics/sdl/pure.c index dc7837332..7630924c1 100644 --- a/sc2/src/sc2code/libs/graphics/sdl/pure.c +++ b/sc2/src/sc2code/libs/graphics/sdl/pure.c @@ -139,29 +139,25 @@ TFB_Pure_InitGraphics (int driver, int flags, int width, int height, int bpp) static void Scale_Nearest (SDL_Surface *src, SDL_Surface *dst) { int x, y; - const int w = src->w, h = src->h; + const int w = src->w, h = src->h, dw = dst->w; switch (dst->format->BytesPerPixel) { case 2: { - Uint16 *src_p = (Uint16 *)src->pixels, *dst_p = (Uint16 *)dst->pixels, *src_p2; + Uint16 *src_p = (Uint16 *)src->pixels, *dst_p = (Uint16 *)dst->pixels; Uint16 pixval_16; for (y = 0; y < h; ++y) { - src_p2 = dst_p; for (x = 0; x < w; ++x) { pixval_16 = *src_p++; + dst_p[dw] = pixval_16; *dst_p++ = pixval_16; + dst_p[dw] = pixval_16; *dst_p++ = pixval_16; } - for (x = 0; x < w; ++x) - { - *(Uint32*)dst_p = *(Uint32*)src_p2; - dst_p += 2; - src_p2 += 2; - } + dst_p += dw; } break; } @@ -196,24 +192,19 @@ static void Scale_Nearest (SDL_Surface *src, SDL_Surface *dst) } case 4: { - Uint32 *src_p = (Uint32 *)src->pixels, *dst_p = (Uint32 *)dst->pixels, *src_p2; + Uint32 *src_p = (Uint32 *)src->pixels, *dst_p = (Uint32 *)dst->pixels; Uint32 pixval_32; for (y = 0; y < h; ++y) { - src_p2 = src_p; - for (x = 0; x < w; ++x) - { - pixval_32 = *src_p++; - *dst_p++ = pixval_32; - *dst_p++ = pixval_32; - } - src_p = src_p2; for (x = 0; x < w; ++x) { pixval_32 = *src_p++; + dst_p[dw] = pixval_32; *dst_p++ = pixval_32; + dst_p[dw] = pixval_32; *dst_p++ = pixval_32; } + dst_p += dw; } break; }