Pass graphics scaling mode properly through DCQ; fixes black pixel gaps between the planet and shield when entering orbit

git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@3463 8092fc87-c524-0410-9efc-e669fe64eaf9
This commit is contained in:
avolkov
2009-12-22 02:35:16 +00:00
parent b926c2f8d6
commit f84ec2d4c1
9 changed files with 57 additions and 54 deletions
+1 -1
View File
@@ -306,7 +306,7 @@ FixContextFontEffect (void)
TFB_DrawImage_Image (EffectFrame->image,
-EffectFrame->HotSpot.x, -EffectFrame->HotSpot.y,
0, NULL, img);
0, 0, NULL, img);
}
else
{ // solid color backing
+2
View File
@@ -64,6 +64,7 @@ typedef struct tfb_dc_img
SCREEN destBuffer;
TFB_ColorMap *colormap;
int scale;
int scaleMode;
} TFB_DrawCommand_Image;
typedef struct tfb_dc_filledimg
@@ -73,6 +74,7 @@ typedef struct tfb_dc_filledimg
Color color;
SCREEN destBuffer;
int scale;
int scaleMode;
} TFB_DrawCommand_FilledImage;
typedef struct tfb_dc_fontchar
+11 -15
View File
@@ -86,7 +86,7 @@ TFB_DrawCanvas_Rect (RECT *rect, Color color, TFB_Canvas target)
// TFB_GetColorMap(). We release the colormap at the end.
void
TFB_DrawCanvas_Image (TFB_Image *img, int x, int y, int scale,
TFB_ColorMap *cmap, TFB_Canvas target)
int scaleMode, TFB_ColorMap *cmap, TFB_Canvas target)
{
SDL_Rect srcRect, targetRect, *pSrcRect;
SDL_Surface *surf;
@@ -108,21 +108,19 @@ TFB_DrawCanvas_Image (TFB_Image *img, int x, int y, int scale,
if (scale != 0 && scale != GSCALE_IDENTITY)
{
int type = GetGraphicScaleMode ();
if (type == TFB_SCALE_TRILINEAR && img->MipmapImg)
if (scaleMode == TFB_SCALE_TRILINEAR && img->MipmapImg)
{
// only set the new palette if it changed
if (TFB_DrawCanvas_IsPaletted (img->MipmapImg)
&& cmap && img->colormap_version != cmap->version)
SDL_SetColors (img->MipmapImg, cmap->palette->colors, 0, 256);
}
else if (type == TFB_SCALE_TRILINEAR && !img->MipmapImg)
{
type = TFB_SCALE_BILINEAR;
else if (scaleMode == TFB_SCALE_TRILINEAR && !img->MipmapImg)
{ // Do bilinear scaling instead when mipmap is unavailable
scaleMode = TFB_SCALE_BILINEAR;
}
TFB_DrawImage_FixScaling (img, scale, type);
TFB_DrawImage_FixScaling (img, scale, scaleMode);
surf = img->ScaledImg;
if (TFB_DrawCanvas_IsPaletted (surf))
{
@@ -251,7 +249,7 @@ TFB_DrawCanvas_Fill (TFB_Canvas source, int width, int height,
void
TFB_DrawCanvas_FilledImage (TFB_Image *img, int x, int y, int scale,
Color color, TFB_Canvas target)
int scaleMode, Color color, TFB_Canvas target)
{
SDL_Rect srcRect, targetRect, *pSrcRect;
SDL_Surface *surf;
@@ -270,16 +268,14 @@ TFB_DrawCanvas_FilledImage (TFB_Image *img, int x, int y, int scale,
if (scale != 0 && scale != GSCALE_IDENTITY)
{
int type = GetGraphicScaleMode ();
if (type == TFB_SCALE_TRILINEAR)
type = TFB_SCALE_BILINEAR;
if (scaleMode == TFB_SCALE_TRILINEAR)
scaleMode = TFB_SCALE_BILINEAR;
// no point in trilinear for filled images
if (scale != img->last_scale || type != img->last_scale_type)
if (scale != img->last_scale || scaleMode != img->last_scale_type)
force_fill = true;
TFB_DrawImage_FixScaling (img, scale, type);
TFB_DrawImage_FixScaling (img, scale, scaleMode);
surf = img->ScaledImg;
srcRect.x = 0;
srcRect.y = 0;
+15 -15
View File
@@ -692,16 +692,16 @@ TFB_FlushGraphics (void) // Only call from main thread!!
break;
case TFB_DRAWCOMMANDTYPE_IMAGE:
{
TFB_Image *DC_image = DC.data.image.image;
TFB_ColorMap *cmap = DC.data.image.colormap;
int x = DC.data.image.x;
int y = DC.data.image.y;
TFB_DrawCommand_Image *cmd = &DC.data.image;
TFB_Image *DC_image = cmd->image;
int x = cmd->x;
int y = cmd->y;
TFB_DrawCanvas_Image (DC_image, x, y,
DC.data.image.scale, cmap,
SDL_Screens[DC.data.image.destBuffer]);
cmd->scale, cmd->scaleMode, cmd->colormap,
SDL_Screens[cmd->destBuffer]);
if (DC.data.image.destBuffer == 0)
if (cmd->destBuffer == 0)
{
LockMutex (DC_image->mutex);
if (DC.data.image.scale)
@@ -719,16 +719,16 @@ TFB_FlushGraphics (void) // Only call from main thread!!
}
case TFB_DRAWCOMMANDTYPE_FILLEDIMAGE:
{
TFB_Image *DC_image = DC.data.filledimage.image;
int x = DC.data.filledimage.x;
int y = DC.data.filledimage.y;
TFB_DrawCommand_FilledImage *cmd = &DC.data.filledimage;
TFB_Image *DC_image = cmd->image;
int x = cmd->x;
int y = cmd->y;
TFB_DrawCanvas_FilledImage (DC.data.filledimage.image,
DC.data.filledimage.x, DC.data.filledimage.y,
DC.data.filledimage.scale, DC.data.filledimage.color,
SDL_Screens[DC.data.filledimage.destBuffer]);
TFB_DrawCanvas_FilledImage (DC_image, x, y,
cmd->scale, cmd->scaleMode, cmd->color,
SDL_Screens[cmd->destBuffer]);
if (DC.data.filledimage.destBuffer == 0)
if (cmd->destBuffer == 0)
{
LockMutex (DC_image->mutex);
if (DC.data.filledimage.scale)
+10 -6
View File
@@ -63,7 +63,7 @@ TFB_DrawScreen_Rect (RECT *rect, Color color, SCREEN dest)
void
TFB_DrawScreen_Image (TFB_Image *img, int x, int y, int scale,
TFB_ColorMap *cmap, SCREEN dest)
int scaleMode, TFB_ColorMap *cmap, SCREEN dest)
{
TFB_DrawCommand DC;
@@ -73,6 +73,7 @@ TFB_DrawScreen_Image (TFB_Image *img, int x, int y, int scale,
DC.data.image.x = x;
DC.data.image.y = y;
DC.data.image.scale = (scale == GSCALE_IDENTITY) ? 0 : scale;
DC.data.image.scaleMode = scaleMode;
DC.data.image.destBuffer = dest;
TFB_EnqueueDrawCommand (&DC);
@@ -80,7 +81,7 @@ TFB_DrawScreen_Image (TFB_Image *img, int x, int y, int scale,
void
TFB_DrawScreen_FilledImage (TFB_Image *img, int x, int y, int scale,
Color color, SCREEN dest)
int scaleMode, Color color, SCREEN dest)
{
TFB_DrawCommand DC;
@@ -89,6 +90,7 @@ TFB_DrawScreen_FilledImage (TFB_Image *img, int x, int y, int scale,
DC.data.filledimage.x = x;
DC.data.filledimage.y = y;
DC.data.filledimage.scale = (scale == GSCALE_IDENTITY) ? 0 : scale;
DC.data.filledimage.scaleMode = scaleMode;
DC.data.filledimage.color = color;
DC.data.filledimage.destBuffer = dest;
@@ -253,20 +255,22 @@ TFB_DrawImage_Rect (RECT *rect, Color color, TFB_Image *image)
void
TFB_DrawImage_Image (TFB_Image *img, int x, int y, int scale,
TFB_ColorMap *cmap, TFB_Image *target)
int scaleMode, TFB_ColorMap *cmap, TFB_Image *target)
{
LockMutex (target->mutex);
TFB_DrawCanvas_Image (img, x, y, scale, cmap, target->NormalImg);
TFB_DrawCanvas_Image (img, x, y, scale, scaleMode, cmap,
target->NormalImg);
target->dirty = TRUE;
UnlockMutex (target->mutex);
}
void
TFB_DrawImage_FilledImage (TFB_Image *img, int x, int y, int scale,
Color color, TFB_Image *target)
int scaleMode, Color color, TFB_Image *target)
{
LockMutex (target->mutex);
TFB_DrawCanvas_FilledImage (img, x, y, scale, color, target->NormalImg);
TFB_DrawCanvas_FilledImage (img, x, y, scale, scaleMode, color,
target->NormalImg);
target->dirty = TRUE;
UnlockMutex (target->mutex);
}
+6 -6
View File
@@ -82,10 +82,10 @@ void TFB_DrawScreen_Line (int x1, int y1, int x2, int y2, Color color,
SCREEN dest);
void TFB_DrawScreen_Rect (RECT *rect, Color color, SCREEN dest);
void TFB_DrawScreen_Image (TFB_Image *img, int x, int y, int scale,
TFB_ColorMap *cmap, SCREEN dest);
int scaleMode, TFB_ColorMap *cmap, SCREEN dest);
void TFB_DrawScreen_Copy (RECT *r, SCREEN src, SCREEN dest);
void TFB_DrawScreen_FilledImage (TFB_Image *img, int x, int y, int scale,
Color color, SCREEN dest);
int scaleMode, Color color, SCREEN dest);
void TFB_DrawScreen_FontChar (TFB_Char *, TFB_Image *backing, int x, int y,
SCREEN dest);
@@ -110,9 +110,9 @@ void TFB_DrawImage_Line (int x1, int y1, int x2, int y2, Color color,
TFB_Image *dest);
void TFB_DrawImage_Rect (RECT *rect, Color color, TFB_Image *image);
void TFB_DrawImage_Image (TFB_Image *img, int x, int y, int scale,
TFB_ColorMap *cmap, TFB_Image *target);
int scaleMode, TFB_ColorMap *cmap, TFB_Image *target);
void TFB_DrawImage_FilledImage (TFB_Image *img, int x, int y, int scale,
Color color, TFB_Image *target);
int scaleMode, Color color, TFB_Image *target);
void TFB_DrawImage_FontChar (TFB_Char *, TFB_Image *backing, int x, int y,
TFB_Image *target);
@@ -146,9 +146,9 @@ void TFB_DrawCanvas_Line (int x1, int y1, int x2, int y2, Color color,
TFB_Canvas dest);
void TFB_DrawCanvas_Rect (RECT *rect, Color color, TFB_Canvas image);
void TFB_DrawCanvas_Image (TFB_Image *img, int x, int y, int scale,
TFB_ColorMap *cmap, TFB_Canvas target);
int scaleMode, TFB_ColorMap *cmap, TFB_Canvas target);
void TFB_DrawCanvas_FilledImage (TFB_Image *img, int x, int y, int scale,
Color color, TFB_Canvas target);
int scaleMode, Color color, TFB_Canvas target);
void TFB_DrawCanvas_FontChar (TFB_Char *, TFB_Image *backing, int x, int y,
TFB_Canvas target);
+8 -9
View File
@@ -126,7 +126,6 @@ TFB_Prim_Stamp (STAMP *stmp, POINT ctxOrigin)
FRAME SrcFramePtr;
TFB_Image *img;
TFB_ColorMap *cmap = NULL;
int gscale;
SrcFramePtr = stmp->frame;
if (!SrcFramePtr)
@@ -136,7 +135,6 @@ TFB_Prim_Stamp (STAMP *stmp, POINT ctxOrigin)
return;
}
img = SrcFramePtr->image;
gscale = GetGraphicScale ();
if (!img)
{
@@ -161,11 +159,13 @@ TFB_Prim_Stamp (STAMP *stmp, POINT ctxOrigin)
if (_CurFramePtr->Type == SCREEN_DRAWABLE)
{
TFB_DrawScreen_Image (img, x, y, gscale, cmap, TFB_SCREEN_MAIN);
TFB_DrawScreen_Image (img, x, y, GetGraphicScale (),
GetGraphicScaleMode (), cmap, TFB_SCREEN_MAIN);
}
else
{
TFB_DrawImage_Image (img, x, y, gscale, cmap, _CurFramePtr->image);
TFB_DrawImage_Image (img, x, y, GetGraphicScale (),
GetGraphicScaleMode (), cmap, _CurFramePtr->image);
}
}
@@ -175,7 +175,6 @@ TFB_Prim_StampFill (STAMP *stmp, Color color, POINT ctxOrigin)
int x, y;
FRAME SrcFramePtr;
TFB_Image *img;
int gscale;
SrcFramePtr = stmp->frame;
if (!SrcFramePtr)
@@ -185,7 +184,6 @@ TFB_Prim_StampFill (STAMP *stmp, Color color, POINT ctxOrigin)
return;
}
img = SrcFramePtr->image;
gscale = GetGraphicScale ();
if (!img)
{
@@ -204,12 +202,13 @@ TFB_Prim_StampFill (STAMP *stmp, Color color, POINT ctxOrigin)
if (_CurFramePtr->Type == SCREEN_DRAWABLE)
{
TFB_DrawScreen_FilledImage (img, x, y, gscale, color, TFB_SCREEN_MAIN);
TFB_DrawScreen_FilledImage (img, x, y, GetGraphicScale (),
GetGraphicScaleMode (), color, TFB_SCREEN_MAIN);
}
else
{
TFB_DrawImage_FilledImage (img, x, y, gscale, color,
_CurFramePtr->image);
TFB_DrawImage_FilledImage (img, x, y, GetGraphicScale (),
GetGraphicScaleMode (), color, _CurFramePtr->image);
}
}
+2 -2
View File
@@ -148,7 +148,7 @@ processAudioSyncedFrame (VIDEO_REF vid)
oldContext = SetContext (NULL);
TFB_DrawScreen_Image (vid->frame,
vid->dst_rect.corner.x, vid->dst_rect.corner.y,
GSCALE_IDENTITY, NULL, TFB_SCREEN_MAIN);
0, 0, NULL, TFB_SCREEN_MAIN);
SetContext (oldContext);
UnlockMutex (GraphicsLock);
FlushGraphics (); // needed to prevent half-frame updates
@@ -200,7 +200,7 @@ processMuteFrame (VIDEO_REF vid)
oldContext = SetContext (NULL);
TFB_DrawScreen_Image (vid->frame,
vid->dst_rect.corner.x, vid->dst_rect.corner.y,
GSCALE_IDENTITY, NULL, TFB_SCREEN_MAIN);
0, 0, NULL, TFB_SCREEN_MAIN);
SetContext (oldContext);
UnlockMutex (GraphicsLock);
FlushGraphics (); // needed to prevent half-frame updates