Some optimizations: bbox is updated only if destbuffer is screen
surface; if bbox isn't valid, swapbuffer does nothing; better locking of imgmutex git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@1082 8092fc87-c524-0410-9efc-e669fe64eaf9
This commit is contained in:
@@ -60,20 +60,20 @@ TFB_DrawCanvas_Image (TFB_Image *img, int x, int y, int scale, TFB_Palette *pale
|
|||||||
targetRect.x = x;
|
targetRect.x = x;
|
||||||
targetRect.y = y;
|
targetRect.y = y;
|
||||||
|
|
||||||
|
if (palette == 0)
|
||||||
|
palette = img->Palette;
|
||||||
|
|
||||||
if (scale != 0 && scale != GSCALE_IDENTITY)
|
if (scale != 0 && scale != GSCALE_IDENTITY)
|
||||||
{
|
{
|
||||||
int type;
|
int type;
|
||||||
if (optMeleeScale == TFB_SCALE_TRILINEAR && img->MipmapImg)
|
if (optMeleeScale == TFB_SCALE_TRILINEAR && img->MipmapImg)
|
||||||
{
|
{
|
||||||
type = TFB_SCALE_TRILINEAR;
|
type = TFB_SCALE_TRILINEAR;
|
||||||
if (palette)
|
|
||||||
{
|
|
||||||
if (((SDL_Surface *)img->NormalImg)->format->palette)
|
if (((SDL_Surface *)img->NormalImg)->format->palette)
|
||||||
SDL_SetColors (img->NormalImg, (SDL_Color*)palette, 0, 256);
|
SDL_SetColors (img->NormalImg, (SDL_Color*)palette, 0, 256);
|
||||||
if (((SDL_Surface *)img->MipmapImg)->format->palette)
|
if (((SDL_Surface *)img->MipmapImg)->format->palette)
|
||||||
SDL_SetColors (img->MipmapImg, (SDL_Color*)palette, 0, 256);
|
SDL_SetColors (img->MipmapImg, (SDL_Color*)palette, 0, 256);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
type = TFB_SCALE_NEAREST;
|
type = TFB_SCALE_NEAREST;
|
||||||
@@ -94,16 +94,7 @@ TFB_DrawCanvas_Image (TFB_Image *img, int x, int y, int scale, TFB_Palette *pale
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (surf->format->palette)
|
if (surf->format->palette)
|
||||||
{
|
|
||||||
if (palette)
|
|
||||||
{
|
|
||||||
SDL_SetColors (surf, (SDL_Color*)palette, 0, 256);
|
SDL_SetColors (surf, (SDL_Color*)palette, 0, 256);
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
SDL_SetColors (surf, (SDL_Color*)img->Palette, 0, 256);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
SDL_BlitSurface(surf, pSrcRect, (NativeCanvas) target, &targetRect);
|
SDL_BlitSurface(surf, pSrcRect, (NativeCanvas) target, &targetRect);
|
||||||
UnlockMutex (img->mutex);
|
UnlockMutex (img->mutex);
|
||||||
|
|||||||
@@ -271,14 +271,12 @@ TFB_GL_DrawQuad (void)
|
|||||||
void
|
void
|
||||||
TFB_GL_SwapBuffers (int force_full_redraw)
|
TFB_GL_SwapBuffers (int force_full_redraw)
|
||||||
{
|
{
|
||||||
int fade_amount;
|
int fade_amount = FadeAmount;
|
||||||
int transition_amount;
|
int transition_amount = TransitionAmount;
|
||||||
SDL_Rect updated;
|
|
||||||
|
|
||||||
updated.x = TFB_BBox.region.corner.x;
|
if (!force_full_redraw && !TFB_BBox.valid &&
|
||||||
updated.y = TFB_BBox.region.corner.y;
|
fade_amount == 255 && transition_amount == 255)
|
||||||
updated.w = TFB_BBox.region.extent.width;
|
return;
|
||||||
updated.h = TFB_BBox.region.extent.height;
|
|
||||||
|
|
||||||
glMatrixMode (GL_PROJECTION);
|
glMatrixMode (GL_PROJECTION);
|
||||||
glLoadIdentity ();
|
glLoadIdentity ();
|
||||||
@@ -293,6 +291,15 @@ TFB_GL_SwapBuffers (int force_full_redraw)
|
|||||||
glDisable (GL_BLEND);
|
glDisable (GL_BLEND);
|
||||||
glColor4f (1, 1, 1, 1);
|
glColor4f (1, 1, 1, 1);
|
||||||
|
|
||||||
|
if (TFB_BBox.valid)
|
||||||
|
{
|
||||||
|
SDL_Rect updated;
|
||||||
|
|
||||||
|
updated.x = TFB_BBox.region.corner.x;
|
||||||
|
updated.y = TFB_BBox.region.corner.y;
|
||||||
|
updated.w = TFB_BBox.region.extent.width;
|
||||||
|
updated.h = TFB_BBox.region.extent.height;
|
||||||
|
|
||||||
if (GfxFlags & TFB_GFXFLAGS_SCALE_BIADAPT ||
|
if (GfxFlags & TFB_GFXFLAGS_SCALE_BIADAPT ||
|
||||||
GfxFlags & TFB_GFXFLAGS_SCALE_BIADAPTADV)
|
GfxFlags & TFB_GFXFLAGS_SCALE_BIADAPTADV)
|
||||||
{
|
{
|
||||||
@@ -319,10 +326,10 @@ TFB_GL_SwapBuffers (int force_full_redraw)
|
|||||||
GL_RGBA, GL_UNSIGNED_BYTE, SDL_Screen->pixels);
|
GL_RGBA, GL_UNSIGNED_BYTE, SDL_Screen->pixels);
|
||||||
SDL_UnlockSurface (SDL_Screen);
|
SDL_UnlockSurface (SDL_Screen);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
TFB_GL_DrawQuad ();
|
TFB_GL_DrawQuad ();
|
||||||
|
|
||||||
transition_amount = TransitionAmount;
|
|
||||||
if (transition_amount != 255)
|
if (transition_amount != 255)
|
||||||
{
|
{
|
||||||
float scale_x = (ScreenWidthActual / (float)ScreenWidth);
|
float scale_x = (ScreenWidthActual / (float)ScreenWidth);
|
||||||
@@ -382,7 +389,6 @@ TFB_GL_SwapBuffers (int force_full_redraw)
|
|||||||
glDisable (GL_SCISSOR_TEST);
|
glDisable (GL_SCISSOR_TEST);
|
||||||
}
|
}
|
||||||
|
|
||||||
fade_amount = FadeAmount;
|
|
||||||
if (fade_amount != 255)
|
if (fade_amount != 255)
|
||||||
{
|
{
|
||||||
float c;
|
float c;
|
||||||
|
|||||||
@@ -231,26 +231,26 @@ TFB_Pure_SwapBuffers (int force_full_redraw)
|
|||||||
int transition_amount = TransitionAmount;
|
int transition_amount = TransitionAmount;
|
||||||
SDL_Rect updated;
|
SDL_Rect updated;
|
||||||
|
|
||||||
if (fade_amount != 255 || transition_amount != 255 ||
|
if (force_full_redraw ||
|
||||||
|
fade_amount != 255 || transition_amount != 255 ||
|
||||||
last_fade_amount != 255 || last_transition_amount != 255)
|
last_fade_amount != 255 || last_transition_amount != 255)
|
||||||
force_full_redraw = 1;
|
|
||||||
|
|
||||||
last_fade_amount = fade_amount;
|
|
||||||
last_transition_amount = transition_amount;
|
|
||||||
|
|
||||||
if (!force_full_redraw)
|
|
||||||
{
|
|
||||||
updated.x = TFB_BBox.region.corner.x;
|
|
||||||
updated.y = TFB_BBox.region.corner.y;
|
|
||||||
updated.w = TFB_BBox.region.extent.width;
|
|
||||||
updated.h = TFB_BBox.region.extent.height;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
updated.x = updated.y = 0;
|
updated.x = updated.y = 0;
|
||||||
updated.w = ScreenWidth;
|
updated.w = ScreenWidth;
|
||||||
updated.h = ScreenHeight;
|
updated.h = ScreenHeight;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (!TFB_BBox.valid)
|
||||||
|
return;
|
||||||
|
updated.x = TFB_BBox.region.corner.x;
|
||||||
|
updated.y = TFB_BBox.region.corner.y;
|
||||||
|
updated.w = TFB_BBox.region.extent.width;
|
||||||
|
updated.h = TFB_BBox.region.extent.height;
|
||||||
|
}
|
||||||
|
|
||||||
|
last_fade_amount = fade_amount;
|
||||||
|
last_transition_amount = transition_amount;
|
||||||
|
|
||||||
if (ScreenWidth == 320 && ScreenHeight == 240 &&
|
if (ScreenWidth == 320 && ScreenHeight == 240 &&
|
||||||
ScreenWidthActual == 640 && ScreenHeightActual == 480)
|
ScreenWidthActual == 640 && ScreenHeightActual == 480)
|
||||||
|
|||||||
@@ -525,27 +525,24 @@ TFB_FlushGraphics () // Only call from main thread!!
|
|||||||
int x = DC.data.image.x;
|
int x = DC.data.image.x;
|
||||||
int y = DC.data.image.y;
|
int y = DC.data.image.y;
|
||||||
|
|
||||||
LockMutex (DC_image->mutex);
|
|
||||||
if (DC.data.image.UsePalette)
|
if (DC.data.image.UsePalette)
|
||||||
{
|
|
||||||
pal = palette;
|
pal = palette;
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
pal = 0;
|
||||||
pal = DC_image->Palette;
|
|
||||||
}
|
|
||||||
UnlockMutex (DC_image->mutex);
|
|
||||||
|
|
||||||
TFB_DrawCanvas_Image (DC_image, x, y,
|
TFB_DrawCanvas_Image (DC_image, x, y,
|
||||||
DC.data.image.scale, pal,
|
DC.data.image.scale, pal,
|
||||||
SDL_Screens[DC.data.image.destBuffer]);
|
SDL_Screens[DC.data.image.destBuffer]);
|
||||||
|
|
||||||
|
if (DC.data.image.destBuffer == 0)
|
||||||
|
{
|
||||||
LockMutex (DC_image->mutex);
|
LockMutex (DC_image->mutex);
|
||||||
if (DC.data.image.scale)
|
if (DC.data.image.scale)
|
||||||
TFB_BBox_RegisterCanvas (DC_image->ScaledImg, x, y);
|
TFB_BBox_RegisterCanvas (DC_image->ScaledImg, x, y);
|
||||||
else
|
else
|
||||||
TFB_BBox_RegisterCanvas (DC_image->NormalImg, x, y);
|
TFB_BBox_RegisterCanvas (DC_image->NormalImg, x, y);
|
||||||
UnlockMutex (DC_image->mutex);
|
UnlockMutex (DC_image->mutex);
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -559,19 +556,25 @@ TFB_FlushGraphics () // Only call from main thread!!
|
|||||||
DC.data.filledimage.scale, DC.data.filledimage.r, DC.data.filledimage.g,
|
DC.data.filledimage.scale, DC.data.filledimage.r, DC.data.filledimage.g,
|
||||||
DC.data.filledimage.b, SDL_Screens[DC.data.filledimage.destBuffer]);
|
DC.data.filledimage.b, SDL_Screens[DC.data.filledimage.destBuffer]);
|
||||||
|
|
||||||
|
if (DC.data.filledimage.destBuffer == 0)
|
||||||
|
{
|
||||||
LockMutex (DC_image->mutex);
|
LockMutex (DC_image->mutex);
|
||||||
if (DC.data.filledimage.scale)
|
if (DC.data.filledimage.scale)
|
||||||
TFB_BBox_RegisterCanvas (DC_image->ScaledImg, x, y);
|
TFB_BBox_RegisterCanvas (DC_image->ScaledImg, x, y);
|
||||||
else
|
else
|
||||||
TFB_BBox_RegisterCanvas (DC_image->NormalImg, x, y);
|
TFB_BBox_RegisterCanvas (DC_image->NormalImg, x, y);
|
||||||
UnlockMutex (DC_image->mutex);
|
UnlockMutex (DC_image->mutex);
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case TFB_DRAWCOMMANDTYPE_LINE:
|
case TFB_DRAWCOMMANDTYPE_LINE:
|
||||||
|
{
|
||||||
|
if (DC.data.line.destBuffer == 0)
|
||||||
{
|
{
|
||||||
TFB_BBox_RegisterPoint (DC.data.line.x1, DC.data.line.y1);
|
TFB_BBox_RegisterPoint (DC.data.line.x1, DC.data.line.y1);
|
||||||
TFB_BBox_RegisterPoint (DC.data.line.x2, DC.data.line.y2);
|
TFB_BBox_RegisterPoint (DC.data.line.x2, DC.data.line.y2);
|
||||||
|
}
|
||||||
TFB_DrawCanvas_Line (DC.data.line.x1, DC.data.line.y1,
|
TFB_DrawCanvas_Line (DC.data.line.x1, DC.data.line.y1,
|
||||||
DC.data.line.x2, DC.data.line.y2,
|
DC.data.line.x2, DC.data.line.y2,
|
||||||
DC.data.line.r, DC.data.line.g, DC.data.line.b,
|
DC.data.line.r, DC.data.line.g, DC.data.line.b,
|
||||||
@@ -580,6 +583,7 @@ TFB_FlushGraphics () // Only call from main thread!!
|
|||||||
}
|
}
|
||||||
case TFB_DRAWCOMMANDTYPE_RECTANGLE:
|
case TFB_DRAWCOMMANDTYPE_RECTANGLE:
|
||||||
{
|
{
|
||||||
|
if (DC.data.rect.destBuffer == 0)
|
||||||
TFB_BBox_RegisterRect (&DC.data.rect.rect);
|
TFB_BBox_RegisterRect (&DC.data.rect.rect);
|
||||||
TFB_DrawCanvas_Rect (&DC.data.rect.rect, DC.data.rect.r,
|
TFB_DrawCanvas_Rect (&DC.data.rect.rect, DC.data.rect.r,
|
||||||
DC.data.rect.g, DC.data.rect.b,
|
DC.data.rect.g, DC.data.rect.b,
|
||||||
@@ -635,8 +639,11 @@ TFB_FlushGraphics () // Only call from main thread!!
|
|||||||
src.w = DC.data.copy.w;
|
src.w = DC.data.copy.w;
|
||||||
src.h = DC.data.copy.h;
|
src.h = DC.data.copy.h;
|
||||||
|
|
||||||
|
if (DC.data.copy.destBuffer == 0)
|
||||||
|
{
|
||||||
TFB_BBox_RegisterPoint (src.x, src.y);
|
TFB_BBox_RegisterPoint (src.x, src.y);
|
||||||
TFB_BBox_RegisterPoint (src.x + src.w, src.y + src.h);
|
TFB_BBox_RegisterPoint (src.x + src.w, src.y + src.h);
|
||||||
|
}
|
||||||
|
|
||||||
SDL_BlitSurface(SDL_Screens[DC.data.copy.srcBuffer], &src, SDL_Screens[DC.data.copy.destBuffer], &dest);
|
SDL_BlitSurface(SDL_Screens[DC.data.copy.srcBuffer], &src, SDL_Screens[DC.data.copy.destBuffer], &dest);
|
||||||
break;
|
break;
|
||||||
|
|||||||
Reference in New Issue
Block a user