diff --git a/sc2/src/sc2code/libs/graphics/drawcmd.h b/sc2/src/sc2code/libs/graphics/drawcmd.h index 097d581ce..4836d1308 100644 --- a/sc2/src/sc2code/libs/graphics/drawcmd.h +++ b/sc2/src/sc2code/libs/graphics/drawcmd.h @@ -35,6 +35,7 @@ enum TFB_DRAWCOMMANDTYPE_SCISSORDISABLE, TFB_DRAWCOMMANDTYPE_SETPALETTE, + TFB_DRAWCOMMANDTYPE_SETMIPMAP, TFB_DRAWCOMMANDTYPE_DELETEIMAGE, TFB_DRAWCOMMANDTYPE_SENDSIGNAL, }; @@ -95,6 +96,12 @@ typedef struct tfb_dc_setpal int r, g, b; } TFB_DrawCommand_SetPalette; +typedef struct tfb_dc_setmip +{ + TFB_Image *image; + TFB_Canvas mipmap; +} TFB_DrawCommand_SetMipmap; + typedef struct tfb_dc_delimg { TFB_Image *image; @@ -117,6 +124,7 @@ typedef struct tfb_drawcommand TFB_DrawCommand_CopyToImage copytoimage; TFB_DrawCommand_Scissor scissor; TFB_DrawCommand_SetPalette setpalette; + TFB_DrawCommand_SetMipmap setmipmap; TFB_DrawCommand_DeleteImage deleteimage; TFB_DrawCommand_SendSignal sendsignal; } data; diff --git a/sc2/src/sc2code/libs/graphics/sdl/sdl_common.c b/sc2/src/sc2code/libs/graphics/sdl/sdl_common.c index 598b77245..7c98ba848 100644 --- a/sc2/src/sc2code/libs/graphics/sdl/sdl_common.c +++ b/sc2/src/sc2code/libs/graphics/sdl/sdl_common.c @@ -502,6 +502,11 @@ TFB_FlushGraphics () // Only call from main thread!! } break; } + case TFB_DRAWCOMMANDTYPE_SETMIPMAP: + LockMutex (DC.data.setmipmap.image->mutex); + DC.data.setmipmap.image->MipmapImg = DC.data.setmipmap.mipmap; + UnlockMutex (DC.data.setmipmap.image->mutex); + break; case TFB_DRAWCOMMANDTYPE_IMAGE: { TFB_Image *DC_image = DC.data.image.image; diff --git a/sc2/src/sc2code/process.c b/sc2/src/sc2code/process.c index 6986c210e..e21ab8e7a 100644 --- a/sc2/src/sc2code/process.c +++ b/sc2/src/sc2code/process.c @@ -19,6 +19,8 @@ #include "starcon.h" #include "libs/graphics/gfx_common.h" #include "libs/graphics/drawable.h" +#include "libs/graphics/drawcmd.h" +#include "options.h" COUNT DisplayFreeList; PRIMITIVE DisplayArray[MAX_DISPLAY_PRIMS]; @@ -981,22 +983,25 @@ PostProcessQueue (register VIEW_STATE view_state, register SIZE scroll_x, [index], ElementPtr->next.image.frame); #endif /* SAFE */ - - LockMutex (((PFRAME_DESC)ElementPtr->next.image.frame)->image->mutex); - if (index < 2 && scale != 256) + if (optMeleeScale == TFB_SCALE_TRILINEAR && index < 2 && scale != 256) { - // assigns next (smaller) zoom level image as mipmap, needed for trilinear scaling - ((PFRAME_DESC)ElementPtr->next.image.frame)->image->MipmapImg = + // enqueues drawcommand to assign next (smaller) zoom + // level image as mipmap, needed for trilinear scaling + + TFB_DrawCommand DC; + TFB_Image *mmimg = ((PFRAME_DESC)SetEquFrameIndex ( ElementPtr->next.image.farray [index + 1], - ElementPtr->next.image.frame))->image->NormalImg; + ElementPtr->next.image.frame))->image; + + DC.Type = TFB_DRAWCOMMANDTYPE_SETMIPMAP; + DC.data.setmipmap.image = ((PFRAME_DESC)ElementPtr->next.image.frame)->image; + LockMutex (mmimg->mutex); + DC.data.setmipmap.mipmap = mmimg->NormalImg; + UnlockMutex (mmimg->mutex); + TFB_EnqueueDrawCommand (&DC); } - else - { - ((PFRAME_DESC)ElementPtr->next.image.frame)->image->MipmapImg = NULL; - } - UnlockMutex (((PFRAME_DESC)ElementPtr->next.image.frame)->image->mutex); #endif } DisplayArray[ElementPtr->PrimIndex].Object.Stamp.frame =