diff --git a/sc2/ChangeLog b/sc2/ChangeLog index 2f7e5f791..351766d68 100644 --- a/sc2/ChangeLog +++ b/sc2/ChangeLog @@ -1,4 +1,6 @@ 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 - Fixed planet blinking when exiting scan (bug #799) - Alex - Restore menu sounds after editing a control set name (bug #1066) - Alex diff --git a/sc2/src/libs/graphics/context.c b/sc2/src/libs/graphics/context.c index 2f5204984..e57905617 100644 --- a/sc2/src/libs/graphics/context.c +++ b/sc2/src/libs/graphics/context.c @@ -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 diff --git a/sc2/src/libs/graphics/drawcmd.h b/sc2/src/libs/graphics/drawcmd.h index 97cfff1f7..cd86c99ee 100644 --- a/sc2/src/libs/graphics/drawcmd.h +++ b/sc2/src/libs/graphics/drawcmd.h @@ -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 diff --git a/sc2/src/libs/graphics/sdl/canvas.c b/sc2/src/libs/graphics/sdl/canvas.c index f8b4adac3..ee8cd53fd 100644 --- a/sc2/src/libs/graphics/sdl/canvas.c +++ b/sc2/src/libs/graphics/sdl/canvas.c @@ -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; diff --git a/sc2/src/libs/graphics/sdl/sdl_common.c b/sc2/src/libs/graphics/sdl/sdl_common.c index ec63ade34..c70570473 100644 --- a/sc2/src/libs/graphics/sdl/sdl_common.c +++ b/sc2/src/libs/graphics/sdl/sdl_common.c @@ -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) diff --git a/sc2/src/libs/graphics/tfb_draw.c b/sc2/src/libs/graphics/tfb_draw.c index 3285e24ef..971979972 100644 --- a/sc2/src/libs/graphics/tfb_draw.c +++ b/sc2/src/libs/graphics/tfb_draw.c @@ -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); } diff --git a/sc2/src/libs/graphics/tfb_draw.h b/sc2/src/libs/graphics/tfb_draw.h index 9903cabf9..a0a216095 100644 --- a/sc2/src/libs/graphics/tfb_draw.h +++ b/sc2/src/libs/graphics/tfb_draw.h @@ -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); diff --git a/sc2/src/libs/graphics/tfb_prim.c b/sc2/src/libs/graphics/tfb_prim.c index 3cc22d7f2..0b7fd0361 100644 --- a/sc2/src/libs/graphics/tfb_prim.c +++ b/sc2/src/libs/graphics/tfb_prim.c @@ -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); } } diff --git a/sc2/src/libs/video/vidplayer.c b/sc2/src/libs/video/vidplayer.c index 9f50307bb..0090837eb 100644 --- a/sc2/src/libs/video/vidplayer.c +++ b/sc2/src/libs/video/vidplayer.c @@ -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