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
This commit is contained in:
gewlitys
2002-12-22 19:17:08 +00:00
parent c76abc9660
commit c8df373f2d
+9 -18
View File
@@ -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) static void Scale_Nearest (SDL_Surface *src, SDL_Surface *dst)
{ {
int x, y; 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) switch (dst->format->BytesPerPixel)
{ {
case 2: 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; Uint16 pixval_16;
for (y = 0; y < h; ++y) for (y = 0; y < h; ++y)
{ {
src_p2 = dst_p;
for (x = 0; x < w; ++x) for (x = 0; x < w; ++x)
{ {
pixval_16 = *src_p++; pixval_16 = *src_p++;
dst_p[dw] = pixval_16;
*dst_p++ = pixval_16; *dst_p++ = pixval_16;
dst_p[dw] = pixval_16;
*dst_p++ = pixval_16; *dst_p++ = pixval_16;
} }
for (x = 0; x < w; ++x) dst_p += dw;
{
*(Uint32*)dst_p = *(Uint32*)src_p2;
dst_p += 2;
src_p2 += 2;
}
} }
break; break;
} }
@@ -196,24 +192,19 @@ static void Scale_Nearest (SDL_Surface *src, SDL_Surface *dst)
} }
case 4: 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; Uint32 pixval_32;
for (y = 0; y < h; ++y) 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) for (x = 0; x < w; ++x)
{ {
pixval_32 = *src_p++; pixval_32 = *src_p++;
dst_p[dw] = pixval_32;
*dst_p++ = pixval_32; *dst_p++ = pixval_32;
dst_p[dw] = pixval_32;
*dst_p++ = pixval_32; *dst_p++ = pixval_32;
} }
dst_p += dw;
} }
break; break;
} }