Some optimizations to TFB_Pure_SwapBuffers
git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@78 8092fc87-c524-0410-9efc-e669fe64eaf9
This commit is contained in:
@@ -132,39 +132,9 @@ TFB_Pure_InitGraphics (int driver, int flags, int width, int height, int bpp)
|
|||||||
void
|
void
|
||||||
TFB_Pure_SwapBuffers ()
|
TFB_Pure_SwapBuffers ()
|
||||||
{
|
{
|
||||||
SDL_Surface *backbuffer = SDL_Screen;
|
|
||||||
int fade_amount = FadeAmount;
|
int fade_amount = FadeAmount;
|
||||||
int transition_amount = TransitionAmount;
|
int transition_amount = TransitionAmount;
|
||||||
|
|
||||||
if (transition_amount != 255)
|
|
||||||
{
|
|
||||||
backbuffer = fade_temp;
|
|
||||||
SDL_BlitSurface (SDL_Screen, NULL, backbuffer, NULL);
|
|
||||||
|
|
||||||
SDL_SetAlpha (TransitionScreen, SDL_SRCALPHA, 255 - transition_amount);
|
|
||||||
SDL_BlitSurface (TransitionScreen, &TransitionClipRect, backbuffer, &TransitionClipRect);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (fade_amount != 255)
|
|
||||||
{
|
|
||||||
if (transition_amount == 255)
|
|
||||||
{
|
|
||||||
backbuffer = fade_temp;
|
|
||||||
SDL_BlitSurface (SDL_Screen, NULL, backbuffer, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (fade_amount < 255)
|
|
||||||
{
|
|
||||||
SDL_SetAlpha (fade_black, SDL_SRCALPHA, 255 - fade_amount);
|
|
||||||
SDL_BlitSurface (fade_black, NULL, backbuffer, NULL);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
SDL_SetAlpha (fade_white, SDL_SRCALPHA, fade_amount - 255);
|
|
||||||
SDL_BlitSurface (fade_white, NULL, backbuffer, NULL);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ScreenWidth == 320 && ScreenHeight == 240 &&
|
if (ScreenWidth == 320 && ScreenHeight == 240 &&
|
||||||
ScreenWidthActual == 640 && ScreenHeightActual == 480)
|
ScreenWidthActual == 640 && ScreenHeightActual == 480)
|
||||||
{
|
{
|
||||||
@@ -172,6 +142,36 @@ TFB_Pure_SwapBuffers ()
|
|||||||
|
|
||||||
int x, y;
|
int x, y;
|
||||||
Uint8 *src_p, *src_p2, *dst_p;
|
Uint8 *src_p, *src_p2, *dst_p;
|
||||||
|
SDL_Surface *backbuffer = SDL_Screen;
|
||||||
|
|
||||||
|
if (transition_amount != 255)
|
||||||
|
{
|
||||||
|
backbuffer = fade_temp;
|
||||||
|
SDL_BlitSurface (SDL_Screen, NULL, backbuffer, NULL);
|
||||||
|
|
||||||
|
SDL_SetAlpha (TransitionScreen, SDL_SRCALPHA, 255 - transition_amount);
|
||||||
|
SDL_BlitSurface (TransitionScreen, &TransitionClipRect, backbuffer, &TransitionClipRect);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fade_amount != 255)
|
||||||
|
{
|
||||||
|
if (transition_amount == 255)
|
||||||
|
{
|
||||||
|
backbuffer = fade_temp;
|
||||||
|
SDL_BlitSurface (SDL_Screen, NULL, backbuffer, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fade_amount < 255)
|
||||||
|
{
|
||||||
|
SDL_SetAlpha (fade_black, SDL_SRCALPHA, 255 - fade_amount);
|
||||||
|
SDL_BlitSurface (fade_black, NULL, backbuffer, NULL);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SDL_SetAlpha (fade_white, SDL_SRCALPHA, fade_amount - 255);
|
||||||
|
SDL_BlitSurface (fade_white, NULL, backbuffer, NULL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
SDL_LockSurface (SDL_Video);
|
SDL_LockSurface (SDL_Video);
|
||||||
SDL_LockSurface (backbuffer);
|
SDL_LockSurface (backbuffer);
|
||||||
@@ -186,7 +186,7 @@ TFB_Pure_SwapBuffers ()
|
|||||||
Uint8 pixval_8;
|
Uint8 pixval_8;
|
||||||
for (y = 0; y < 240; ++y)
|
for (y = 0; y < 240; ++y)
|
||||||
{
|
{
|
||||||
src_p2 = src_p;
|
src_p2 = dst_p;
|
||||||
for (x = 0; x < 320; ++x)
|
for (x = 0; x < 320; ++x)
|
||||||
{
|
{
|
||||||
pixval_8 = *src_p++;
|
pixval_8 = *src_p++;
|
||||||
@@ -194,13 +194,11 @@ TFB_Pure_SwapBuffers ()
|
|||||||
*dst_p++ = pixval_8;
|
*dst_p++ = pixval_8;
|
||||||
*dst_p++ = pixval_8;
|
*dst_p++ = pixval_8;
|
||||||
}
|
}
|
||||||
src_p = src_p2;
|
for (x = 0; x < 160; ++x)
|
||||||
for (x = 0; x < 320; ++x)
|
|
||||||
{
|
{
|
||||||
pixval_8 = *src_p++;
|
*(Uint32*)dst_p = *(Uint32*)src_p2;
|
||||||
|
dst_p += 4;
|
||||||
*dst_p++ = pixval_8;
|
src_p2 += 4;
|
||||||
*dst_p++ = pixval_8;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -210,27 +208,22 @@ TFB_Pure_SwapBuffers ()
|
|||||||
Uint16 pixval_16;
|
Uint16 pixval_16;
|
||||||
for (y = 0; y < 240; ++y)
|
for (y = 0; y < 240; ++y)
|
||||||
{
|
{
|
||||||
src_p2 = src_p;
|
src_p2 = dst_p;
|
||||||
for (x = 0; x < 320; ++x)
|
for (x = 0; x < 320; ++x)
|
||||||
{
|
{
|
||||||
pixval_16 = *(Uint16*)src_p++;
|
pixval_16 = *(Uint16*)src_p;
|
||||||
src_p++;
|
src_p += 2;
|
||||||
|
|
||||||
*(Uint16*)dst_p++ = pixval_16;
|
*(Uint16*)dst_p = pixval_16;
|
||||||
dst_p++;
|
dst_p += 2;
|
||||||
*(Uint16*)dst_p++ = pixval_16;
|
*(Uint16*)dst_p = pixval_16;
|
||||||
dst_p++;
|
dst_p += 2;
|
||||||
}
|
}
|
||||||
src_p = src_p2;
|
|
||||||
for (x = 0; x < 320; ++x)
|
for (x = 0; x < 320; ++x)
|
||||||
{
|
{
|
||||||
pixval_16 = *(Uint16*)src_p++;
|
*(Uint32*)dst_p = *(Uint32*)src_p2;
|
||||||
src_p++;
|
dst_p += 4;
|
||||||
|
src_p2 += 4;
|
||||||
*(Uint16*)dst_p++ = pixval_16;
|
|
||||||
dst_p++;
|
|
||||||
*(Uint16*)dst_p++ = pixval_16;
|
|
||||||
dst_p++;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -304,7 +297,28 @@ TFB_Pure_SwapBuffers ()
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// resolution is 320x240 so we can blit directly
|
// resolution is 320x240 so we can blit directly
|
||||||
SDL_BlitSurface (backbuffer, NULL, SDL_Video, NULL);
|
|
||||||
|
SDL_BlitSurface (SDL_Screen, NULL, SDL_Video, NULL);
|
||||||
|
|
||||||
|
if (transition_amount != 255)
|
||||||
|
{
|
||||||
|
SDL_SetAlpha (TransitionScreen, SDL_SRCALPHA, 255 - transition_amount);
|
||||||
|
SDL_BlitSurface (TransitionScreen, &TransitionClipRect, SDL_Video, &TransitionClipRect);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fade_amount != 255)
|
||||||
|
{
|
||||||
|
if (fade_amount < 255)
|
||||||
|
{
|
||||||
|
SDL_SetAlpha (fade_black, SDL_SRCALPHA, 255 - fade_amount);
|
||||||
|
SDL_BlitSurface (fade_black, NULL, SDL_Video, NULL);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SDL_SetAlpha (fade_white, SDL_SRCALPHA, fade_amount - 255);
|
||||||
|
SDL_BlitSurface (fade_white, NULL, SDL_Video, NULL);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_UpdateRect (SDL_Video, 0, 0, 0, 0);
|
SDL_UpdateRect (SDL_Video, 0, 0, 0, 0);
|
||||||
|
|||||||
Reference in New Issue
Block a user