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
+2
View File
@@ -1,4 +1,6 @@
Changes towards version 0.7: Changes towards version 0.7:
- Fixed black pixel gaps between the planet and shield when entering the
orbit of a shielded planet (bug #32) - Alex
- Split off SDL-specific colormap bits into SDL domain - Alex - Split off SDL-specific colormap bits into SDL domain - Alex
- Fixed planet blinking when exiting scan (bug #799) - Alex - Fixed planet blinking when exiting scan (bug #799) - Alex
- Restore menu sounds after editing a control set name (bug #1066) - Alex - Restore menu sounds after editing a control set name (bug #1066) - Alex
+1 -1
View File
@@ -306,7 +306,7 @@ FixContextFontEffect (void)
TFB_DrawImage_Image (EffectFrame->image, TFB_DrawImage_Image (EffectFrame->image,
-EffectFrame->HotSpot.x, -EffectFrame->HotSpot.y, -EffectFrame->HotSpot.x, -EffectFrame->HotSpot.y,
0, NULL, img); 0, 0, NULL, img);
} }
else else
{ // solid color backing { // solid color backing
+2
View File
@@ -64,6 +64,7 @@ typedef struct tfb_dc_img
SCREEN destBuffer; SCREEN destBuffer;
TFB_ColorMap *colormap; TFB_ColorMap *colormap;
int scale; int scale;
int scaleMode;
} TFB_DrawCommand_Image; } TFB_DrawCommand_Image;
typedef struct tfb_dc_filledimg typedef struct tfb_dc_filledimg
@@ -73,6 +74,7 @@ typedef struct tfb_dc_filledimg
Color color; Color color;
SCREEN destBuffer; SCREEN destBuffer;
int scale; int scale;
int scaleMode;
} TFB_DrawCommand_FilledImage; } TFB_DrawCommand_FilledImage;
typedef struct tfb_dc_fontchar 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. // TFB_GetColorMap(). We release the colormap at the end.
void void
TFB_DrawCanvas_Image (TFB_Image *img, int x, int y, int scale, 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_Rect srcRect, targetRect, *pSrcRect;
SDL_Surface *surf; 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) if (scale != 0 && scale != GSCALE_IDENTITY)
{ {
int type = GetGraphicScaleMode (); if (scaleMode == TFB_SCALE_TRILINEAR && img->MipmapImg)
if (type == TFB_SCALE_TRILINEAR && img->MipmapImg)
{ {
// only set the new palette if it changed // only set the new palette if it changed
if (TFB_DrawCanvas_IsPaletted (img->MipmapImg) if (TFB_DrawCanvas_IsPaletted (img->MipmapImg)
&& cmap && img->colormap_version != cmap->version) && cmap && img->colormap_version != cmap->version)
SDL_SetColors (img->MipmapImg, cmap->palette->colors, 0, 256); SDL_SetColors (img->MipmapImg, cmap->palette->colors, 0, 256);
} }
else if (type == TFB_SCALE_TRILINEAR && !img->MipmapImg) else if (scaleMode == TFB_SCALE_TRILINEAR && !img->MipmapImg)
{ { // Do bilinear scaling instead when mipmap is unavailable
type = TFB_SCALE_BILINEAR; scaleMode = TFB_SCALE_BILINEAR;
} }
TFB_DrawImage_FixScaling (img, scale, type); TFB_DrawImage_FixScaling (img, scale, scaleMode);
surf = img->ScaledImg; surf = img->ScaledImg;
if (TFB_DrawCanvas_IsPaletted (surf)) if (TFB_DrawCanvas_IsPaletted (surf))
{ {
@@ -251,7 +249,7 @@ TFB_DrawCanvas_Fill (TFB_Canvas source, int width, int height,
void void
TFB_DrawCanvas_FilledImage (TFB_Image *img, int x, int y, int scale, 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_Rect srcRect, targetRect, *pSrcRect;
SDL_Surface *surf; 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) if (scale != 0 && scale != GSCALE_IDENTITY)
{ {
int type = GetGraphicScaleMode (); if (scaleMode == TFB_SCALE_TRILINEAR)
scaleMode = TFB_SCALE_BILINEAR;
if (type == TFB_SCALE_TRILINEAR)
type = TFB_SCALE_BILINEAR;
// no point in trilinear for filled images // 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; force_fill = true;
TFB_DrawImage_FixScaling (img, scale, type); TFB_DrawImage_FixScaling (img, scale, scaleMode);
surf = img->ScaledImg; surf = img->ScaledImg;
srcRect.x = 0; srcRect.x = 0;
srcRect.y = 0; srcRect.y = 0;
+15 -15
View File
@@ -692,16 +692,16 @@ TFB_FlushGraphics (void) // Only call from main thread!!
break; break;
case TFB_DRAWCOMMANDTYPE_IMAGE: case TFB_DRAWCOMMANDTYPE_IMAGE:
{ {
TFB_Image *DC_image = DC.data.image.image; TFB_DrawCommand_Image *cmd = &DC.data.image;
TFB_ColorMap *cmap = DC.data.image.colormap; TFB_Image *DC_image = cmd->image;
int x = DC.data.image.x; int x = cmd->x;
int y = DC.data.image.y; int y = cmd->y;
TFB_DrawCanvas_Image (DC_image, x, y, TFB_DrawCanvas_Image (DC_image, x, y,
DC.data.image.scale, cmap, cmd->scale, cmd->scaleMode, cmd->colormap,
SDL_Screens[DC.data.image.destBuffer]); SDL_Screens[cmd->destBuffer]);
if (DC.data.image.destBuffer == 0) if (cmd->destBuffer == 0)
{ {
LockMutex (DC_image->mutex); LockMutex (DC_image->mutex);
if (DC.data.image.scale) if (DC.data.image.scale)
@@ -719,16 +719,16 @@ TFB_FlushGraphics (void) // Only call from main thread!!
} }
case TFB_DRAWCOMMANDTYPE_FILLEDIMAGE: case TFB_DRAWCOMMANDTYPE_FILLEDIMAGE:
{ {
TFB_Image *DC_image = DC.data.filledimage.image; TFB_DrawCommand_FilledImage *cmd = &DC.data.filledimage;
int x = DC.data.filledimage.x; TFB_Image *DC_image = cmd->image;
int y = DC.data.filledimage.y; int x = cmd->x;
int y = cmd->y;
TFB_DrawCanvas_FilledImage (DC.data.filledimage.image, TFB_DrawCanvas_FilledImage (DC_image, x, y,
DC.data.filledimage.x, DC.data.filledimage.y, cmd->scale, cmd->scaleMode, cmd->color,
DC.data.filledimage.scale, DC.data.filledimage.color, SDL_Screens[cmd->destBuffer]);
SDL_Screens[DC.data.filledimage.destBuffer]);
if (DC.data.filledimage.destBuffer == 0) if (cmd->destBuffer == 0)
{ {
LockMutex (DC_image->mutex); LockMutex (DC_image->mutex);
if (DC.data.filledimage.scale) if (DC.data.filledimage.scale)
+10 -6
View File
@@ -63,7 +63,7 @@ TFB_DrawScreen_Rect (RECT *rect, Color color, SCREEN dest)
void void
TFB_DrawScreen_Image (TFB_Image *img, int x, int y, int scale, 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; 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.x = x;
DC.data.image.y = y; DC.data.image.y = y;
DC.data.image.scale = (scale == GSCALE_IDENTITY) ? 0 : scale; DC.data.image.scale = (scale == GSCALE_IDENTITY) ? 0 : scale;
DC.data.image.scaleMode = scaleMode;
DC.data.image.destBuffer = dest; DC.data.image.destBuffer = dest;
TFB_EnqueueDrawCommand (&DC); TFB_EnqueueDrawCommand (&DC);
@@ -80,7 +81,7 @@ TFB_DrawScreen_Image (TFB_Image *img, int x, int y, int scale,
void void
TFB_DrawScreen_FilledImage (TFB_Image *img, int x, int y, int scale, 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; 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.x = x;
DC.data.filledimage.y = y; DC.data.filledimage.y = y;
DC.data.filledimage.scale = (scale == GSCALE_IDENTITY) ? 0 : scale; DC.data.filledimage.scale = (scale == GSCALE_IDENTITY) ? 0 : scale;
DC.data.filledimage.scaleMode = scaleMode;
DC.data.filledimage.color = color; DC.data.filledimage.color = color;
DC.data.filledimage.destBuffer = dest; DC.data.filledimage.destBuffer = dest;
@@ -253,20 +255,22 @@ TFB_DrawImage_Rect (RECT *rect, Color color, TFB_Image *image)
void void
TFB_DrawImage_Image (TFB_Image *img, int x, int y, int scale, 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); 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; target->dirty = TRUE;
UnlockMutex (target->mutex); UnlockMutex (target->mutex);
} }
void void
TFB_DrawImage_FilledImage (TFB_Image *img, int x, int y, int scale, 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); 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; target->dirty = TRUE;
UnlockMutex (target->mutex); 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); SCREEN dest);
void TFB_DrawScreen_Rect (RECT *rect, 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, 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_Copy (RECT *r, SCREEN src, SCREEN dest);
void TFB_DrawScreen_FilledImage (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);
void TFB_DrawScreen_FontChar (TFB_Char *, TFB_Image *backing, int x, int y, void TFB_DrawScreen_FontChar (TFB_Char *, TFB_Image *backing, int x, int y,
SCREEN dest); SCREEN dest);
@@ -110,9 +110,9 @@ void TFB_DrawImage_Line (int x1, int y1, int x2, int y2, Color color,
TFB_Image *dest); TFB_Image *dest);
void TFB_DrawImage_Rect (RECT *rect, Color color, TFB_Image *image); void TFB_DrawImage_Rect (RECT *rect, Color color, TFB_Image *image);
void TFB_DrawImage_Image (TFB_Image *img, int x, int y, int scale, 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, 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, void TFB_DrawImage_FontChar (TFB_Char *, TFB_Image *backing, int x, int y,
TFB_Image *target); TFB_Image *target);
@@ -146,9 +146,9 @@ void TFB_DrawCanvas_Line (int x1, int y1, int x2, int y2, Color color,
TFB_Canvas dest); TFB_Canvas dest);
void TFB_DrawCanvas_Rect (RECT *rect, Color color, TFB_Canvas image); void TFB_DrawCanvas_Rect (RECT *rect, Color color, TFB_Canvas image);
void TFB_DrawCanvas_Image (TFB_Image *img, int x, int y, int scale, 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, 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, void TFB_DrawCanvas_FontChar (TFB_Char *, TFB_Image *backing, int x, int y,
TFB_Canvas target); TFB_Canvas target);
+8 -9
View File
@@ -126,7 +126,6 @@ TFB_Prim_Stamp (STAMP *stmp, POINT ctxOrigin)
FRAME SrcFramePtr; FRAME SrcFramePtr;
TFB_Image *img; TFB_Image *img;
TFB_ColorMap *cmap = NULL; TFB_ColorMap *cmap = NULL;
int gscale;
SrcFramePtr = stmp->frame; SrcFramePtr = stmp->frame;
if (!SrcFramePtr) if (!SrcFramePtr)
@@ -136,7 +135,6 @@ TFB_Prim_Stamp (STAMP *stmp, POINT ctxOrigin)
return; return;
} }
img = SrcFramePtr->image; img = SrcFramePtr->image;
gscale = GetGraphicScale ();
if (!img) if (!img)
{ {
@@ -161,11 +159,13 @@ TFB_Prim_Stamp (STAMP *stmp, POINT ctxOrigin)
if (_CurFramePtr->Type == SCREEN_DRAWABLE) 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 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; int x, y;
FRAME SrcFramePtr; FRAME SrcFramePtr;
TFB_Image *img; TFB_Image *img;
int gscale;
SrcFramePtr = stmp->frame; SrcFramePtr = stmp->frame;
if (!SrcFramePtr) if (!SrcFramePtr)
@@ -185,7 +184,6 @@ TFB_Prim_StampFill (STAMP *stmp, Color color, POINT ctxOrigin)
return; return;
} }
img = SrcFramePtr->image; img = SrcFramePtr->image;
gscale = GetGraphicScale ();
if (!img) if (!img)
{ {
@@ -204,12 +202,13 @@ TFB_Prim_StampFill (STAMP *stmp, Color color, POINT ctxOrigin)
if (_CurFramePtr->Type == SCREEN_DRAWABLE) 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 else
{ {
TFB_DrawImage_FilledImage (img, x, y, gscale, color, TFB_DrawImage_FilledImage (img, x, y, GetGraphicScale (),
_CurFramePtr->image); GetGraphicScaleMode (), color, _CurFramePtr->image);
} }
} }
+2 -2
View File
@@ -148,7 +148,7 @@ processAudioSyncedFrame (VIDEO_REF vid)
oldContext = SetContext (NULL); oldContext = SetContext (NULL);
TFB_DrawScreen_Image (vid->frame, TFB_DrawScreen_Image (vid->frame,
vid->dst_rect.corner.x, vid->dst_rect.corner.y, vid->dst_rect.corner.x, vid->dst_rect.corner.y,
GSCALE_IDENTITY, NULL, TFB_SCREEN_MAIN); 0, 0, NULL, TFB_SCREEN_MAIN);
SetContext (oldContext); SetContext (oldContext);
UnlockMutex (GraphicsLock); UnlockMutex (GraphicsLock);
FlushGraphics (); // needed to prevent half-frame updates FlushGraphics (); // needed to prevent half-frame updates
@@ -200,7 +200,7 @@ processMuteFrame (VIDEO_REF vid)
oldContext = SetContext (NULL); oldContext = SetContext (NULL);
TFB_DrawScreen_Image (vid->frame, TFB_DrawScreen_Image (vid->frame,
vid->dst_rect.corner.x, vid->dst_rect.corner.y, vid->dst_rect.corner.x, vid->dst_rect.corner.y,
GSCALE_IDENTITY, NULL, TFB_SCREEN_MAIN); 0, 0, NULL, TFB_SCREEN_MAIN);
SetContext (oldContext); SetContext (oldContext);
UnlockMutex (GraphicsLock); UnlockMutex (GraphicsLock);
FlushGraphics (); // needed to prevent half-frame updates FlushGraphics (); // needed to prevent half-frame updates