From caca4505197d60de5b64640e25dfb7dab7f63ab6 Mon Sep 17 00:00:00 2001 From: gewlitys Date: Sun, 22 Dec 2002 17:38:22 +0000 Subject: [PATCH] Some optimizations to bilinear scaling git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@464 8092fc87-c524-0410-9efc-e669fe64eaf9 --- sc2/src/sc2code/libs/graphics/sdl/pure.c | 84 ++++++++++++++---------- 1 file changed, 50 insertions(+), 34 deletions(-) diff --git a/sc2/src/sc2code/libs/graphics/sdl/pure.c b/sc2/src/sc2code/libs/graphics/sdl/pure.c index 317f8889f..9510f7692 100644 --- a/sc2/src/sc2code/libs/graphics/sdl/pure.c +++ b/sc2/src/sc2code/libs/graphics/sdl/pure.c @@ -254,32 +254,38 @@ static void Scale_Bilinear (SDL_Surface *src, SDL_Surface *dst) src_p2 = src_p; j = i; + p[0] = src_p[0]; + if (y < h - 2) + p[2] = src_p[src->w]; + else + p[2] = 0; + for (x = 0; x < w; ++x) { - p[0] = src_p[0]; - if (y < h - 2) + if (j == i) { - p[2] = src_p[src->w]; - if (x < w - 2) + if (y < h - 2) { - p[3] = src_p[src->w + 1]; - p[1] = src_p[1]; + if (x < w - 2) + { + p[1] = src_p[1]; + p[3] = src_p[src->w + 1]; + } + else + { + p[1] = 0; + p[3] = 0; + } } else { - p[3] = p[2]; - p[1] = p[0]; + if (x < w - 2) + p[1] = src_p[1]; + else + p[1] = 0; + p[3] = 0; } } - else - { - if (x < w - 2) - p[1] = src_p[1]; - else - p[1] = p[0]; - p[2] = p[0]; - p[3] = p[1]; - } fa = bilinear_table[j][0]; fb = bilinear_table[j][1]; @@ -304,6 +310,8 @@ static void Scale_Bilinear (SDL_Surface *src, SDL_Surface *dst) { j = i; src_p++; + p[0] = p[1]; + p[2] = p[3]; } else { @@ -336,32 +344,38 @@ static void Scale_Bilinear (SDL_Surface *src, SDL_Surface *dst) src_p2 = src_p; j = i; + p[0] = src_p[0]; + if (y < h - 2) + p[2] = src_p[src->w]; + else + p[2] = 0; + for (x = 0; x < w; ++x) { - p[0] = src_p[0]; - if (y < h - 2) + if (j == i) { - p[2] = src_p[src->w]; - if (x < w - 2) + if (y < h - 2) { - p[3] = src_p[src->w + 1]; - p[1] = src_p[1]; + if (x < w - 2) + { + p[1] = src_p[1]; + p[3] = src_p[src->w + 1]; + } + else + { + p[1] = 0; + p[3] = 0; + } } else { - p[3] = p[2]; - p[1] = p[0]; + if (x < w - 2) + p[1] = src_p[1]; + else + p[1] = 0; + p[3] = 0; } } - else - { - if (x < w - 2) - p[1] = src_p[1]; - else - p[1] = p[0]; - p[2] = p[0]; - p[3] = p[1]; - } fa = bilinear_table[j][0]; fb = bilinear_table[j][1]; @@ -386,6 +400,8 @@ static void Scale_Bilinear (SDL_Surface *src, SDL_Surface *dst) { j = i; src_p++; + p[0] = p[1]; + p[2] = p[3]; } else {