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:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user