Trilinear scaler overhaul: moving image hotspot processing to tfb_draw/DCQ
git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@2028 8092fc87-c524-0410-9efc-e669fe64eaf9
This commit is contained in:
@@ -101,6 +101,7 @@ typedef struct tfb_dc_setmip
|
||||
{
|
||||
TFB_Image *image;
|
||||
TFB_Canvas mipmap;
|
||||
int hotx, hoty;
|
||||
} TFB_DrawCommand_SetMipmap;
|
||||
|
||||
typedef struct tfb_dc_delimg
|
||||
|
||||
@@ -607,6 +607,8 @@ TFB_FlushGraphics () // Only call from main thread!!
|
||||
case TFB_DRAWCOMMANDTYPE_SETMIPMAP:
|
||||
LockMutex (DC.data.setmipmap.image->mutex);
|
||||
DC.data.setmipmap.image->MipmapImg = DC.data.setmipmap.mipmap;
|
||||
DC.data.setmipmap.image->MipmapHs.x = DC.data.setmipmap.hotx;
|
||||
DC.data.setmipmap.image->MipmapHs.y = DC.data.setmipmap.hoty;
|
||||
UnlockMutex (DC.data.setmipmap.image->mutex);
|
||||
break;
|
||||
case TFB_DRAWCOMMANDTYPE_IMAGE:
|
||||
@@ -629,9 +631,13 @@ TFB_FlushGraphics () // Only call from main thread!!
|
||||
{
|
||||
LockMutex (DC_image->mutex);
|
||||
if (DC.data.image.scale)
|
||||
TFB_BBox_RegisterCanvas (DC_image->ScaledImg, x, y);
|
||||
TFB_BBox_RegisterCanvas (DC_image->ScaledImg,
|
||||
x - DC_image->last_scale_hs.x,
|
||||
y - DC_image->last_scale_hs.y);
|
||||
else
|
||||
TFB_BBox_RegisterCanvas (DC_image->NormalImg, x, y);
|
||||
TFB_BBox_RegisterCanvas (DC_image->NormalImg,
|
||||
x - DC_image->NormalHs.x,
|
||||
y - DC_image->NormalHs.y);
|
||||
UnlockMutex (DC_image->mutex);
|
||||
}
|
||||
|
||||
@@ -653,9 +659,13 @@ TFB_FlushGraphics () // Only call from main thread!!
|
||||
{
|
||||
LockMutex (DC_image->mutex);
|
||||
if (DC.data.filledimage.scale)
|
||||
TFB_BBox_RegisterCanvas (DC_image->ScaledImg, x, y);
|
||||
TFB_BBox_RegisterCanvas (DC_image->ScaledImg,
|
||||
x - DC_image->last_scale_hs.x,
|
||||
y - DC_image->last_scale_hs.y);
|
||||
else
|
||||
TFB_BBox_RegisterCanvas (DC_image->NormalImg, x, y);
|
||||
TFB_BBox_RegisterCanvas (DC_image->NormalImg,
|
||||
x - DC_image->NormalHs.x,
|
||||
y - DC_image->NormalHs.y);
|
||||
UnlockMutex (DC_image->mutex);
|
||||
}
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
#include "drawcmd.h"
|
||||
#include "units.h"
|
||||
|
||||
static const HOT_SPOT NullHs = {0, 0};
|
||||
|
||||
void
|
||||
TFB_DrawScreen_Line (int x1, int y1, int x2, int y2, int r, int g, int b,
|
||||
@@ -291,6 +292,9 @@ TFB_DrawImage_New (TFB_Canvas canvas)
|
||||
img->MipmapImg = NULL;
|
||||
img->FilledImg = NULL;
|
||||
img->colormap_index = -1;
|
||||
img->NormalHs = NullHs;
|
||||
img->MipmapHs = NullHs;
|
||||
img->last_scale_hs = NullHs;
|
||||
img->last_scale_type = -1;
|
||||
TFB_DrawCanvas_GetExtent (canvas, &img->extent);
|
||||
|
||||
@@ -317,6 +321,9 @@ TFB_DrawImage_CreateForScreen (int w, int h, BOOLEAN withalpha)
|
||||
img->MipmapImg = NULL;
|
||||
img->FilledImg = NULL;
|
||||
img->colormap_index = -1;
|
||||
img->NormalHs = NullHs;
|
||||
img->MipmapHs = NullHs;
|
||||
img->last_scale_hs = NullHs;
|
||||
img->last_scale_type = -1;
|
||||
img->Palette = NULL;
|
||||
img->extent.width = w;
|
||||
@@ -386,12 +393,16 @@ void
|
||||
TFB_DrawImage_FixScaling (TFB_Image *image, int target, int type)
|
||||
{
|
||||
EXTENT old = image->extent;
|
||||
TFB_DrawCanvas_GetScaledExtent (image->NormalImg, image->MipmapImg,
|
||||
target, &image->extent);
|
||||
HOT_SPOT oldhs = image->last_scale_hs;
|
||||
TFB_DrawCanvas_GetScaledExtent (image->NormalImg, image->NormalHs,
|
||||
image->MipmapImg, image->MipmapHs, target,
|
||||
&image->extent, &image->last_scale_hs);
|
||||
|
||||
if ((old.width != image->extent.width) ||
|
||||
(old.height != image->extent.height) || image->dirty ||
|
||||
!image->ScaledImg || type != image->last_scale_type)
|
||||
!image->ScaledImg || type != image->last_scale_type ||
|
||||
(oldhs.x != image->last_scale_hs.x) ||
|
||||
(oldhs.y != image->last_scale_hs.y))
|
||||
{
|
||||
image->dirty = FALSE;
|
||||
image->ScaledImg = TFB_DrawCanvas_New_ScaleTarget (image->NormalImg,
|
||||
|
||||
@@ -56,6 +56,9 @@ typedef struct tfb_image
|
||||
TFB_Canvas FilledImg;
|
||||
TFB_Palette *Palette;
|
||||
int colormap_index;
|
||||
HOT_SPOT NormalHs;
|
||||
HOT_SPOT MipmapHs;
|
||||
HOT_SPOT last_scale_hs;
|
||||
int last_scale_type;
|
||||
TFB_Palette last_fill;
|
||||
EXTENT extent;
|
||||
@@ -107,7 +110,9 @@ TFB_Canvas TFB_DrawCanvas_ToScreenFormat (TFB_Canvas canvas);
|
||||
BOOLEAN TFB_DrawCanvas_IsPaletted (TFB_Canvas canvas);
|
||||
void TFB_DrawCanvas_Rescale_Nearest (TFB_Canvas src, TFB_Canvas dst, EXTENT size);
|
||||
void TFB_DrawCanvas_Rescale_Trilinear (TFB_Canvas src, TFB_Canvas dst, TFB_Canvas mipmap, EXTENT size);
|
||||
void TFB_DrawCanvas_GetScaledExtent (TFB_Canvas src_canvas, TFB_Canvas src_mipmap, int scale, PEXTENT size);
|
||||
void TFB_DrawCanvas_GetScaledExtent (TFB_Canvas src_canvas, HOT_SPOT src_hs,
|
||||
TFB_Canvas src_mipmap, HOT_SPOT mm_hs,
|
||||
int scale, PEXTENT size, HOT_SPOT *hs);
|
||||
void TFB_DrawCanvas_Rotate (TFB_Canvas src, TFB_Canvas dst, int angle, EXTENT size);
|
||||
void TFB_DrawCanvas_GetRotatedExtent (TFB_Canvas src, int angle, PEXTENT size);
|
||||
void TFB_DrawCanvas_GetExtent (TFB_Canvas canvas, PEXTENT size);
|
||||
|
||||
@@ -140,18 +140,11 @@ TFB_Prim_Stamp (PSTAMP stmp)
|
||||
|
||||
LockMutex (img->mutex);
|
||||
|
||||
x = stmp->origin.x - _CurFramePtr->HotSpot.x - SrcFramePtr->HotSpot.x;
|
||||
y = stmp->origin.y - _CurFramePtr->HotSpot.y - SrcFramePtr->HotSpot.y;
|
||||
img->NormalHs = SrcFramePtr->HotSpot;
|
||||
x = stmp->origin.x - _CurFramePtr->HotSpot.x;
|
||||
y = stmp->origin.y - _CurFramePtr->HotSpot.y;
|
||||
paletted = FALSE;
|
||||
|
||||
if (gscale != GSCALE_IDENTITY)
|
||||
{ // rounding error correction here
|
||||
x += (SrcFramePtr->HotSpot.x * (GSCALE_IDENTITY - gscale)
|
||||
+ (GSCALE_IDENTITY >> 1)) / GSCALE_IDENTITY;
|
||||
y += (SrcFramePtr->HotSpot.y * (GSCALE_IDENTITY - gscale)
|
||||
+ (GSCALE_IDENTITY >> 1)) / GSCALE_IDENTITY;
|
||||
}
|
||||
|
||||
if (TFB_DrawCanvas_IsPaletted(img->NormalImg) && img->colormap_index != -1)
|
||||
{
|
||||
TFB_ColorMapToRGB (palette, img->colormap_index);
|
||||
@@ -198,20 +191,14 @@ TFB_Prim_StampFill (PSTAMP stmp, TFB_Palette *color)
|
||||
|
||||
LockMutex (img->mutex);
|
||||
|
||||
x = stmp->origin.x - _CurFramePtr->HotSpot.x - SrcFramePtr->HotSpot.x;
|
||||
y = stmp->origin.y - _CurFramePtr->HotSpot.y - SrcFramePtr->HotSpot.y;
|
||||
img->NormalHs = SrcFramePtr->HotSpot;
|
||||
x = stmp->origin.x - _CurFramePtr->HotSpot.x;
|
||||
y = stmp->origin.y - _CurFramePtr->HotSpot.y;
|
||||
|
||||
r = color->r;
|
||||
g = color->g;
|
||||
b = color->b;
|
||||
|
||||
if (gscale != GSCALE_IDENTITY)
|
||||
{ // rounding error correction here
|
||||
x += (SrcFramePtr->HotSpot.x * (GSCALE_IDENTITY - gscale)
|
||||
+ (GSCALE_IDENTITY >> 1)) / GSCALE_IDENTITY;
|
||||
y += (SrcFramePtr->HotSpot.y * (GSCALE_IDENTITY - gscale)
|
||||
+ (GSCALE_IDENTITY >> 1)) / GSCALE_IDENTITY;
|
||||
}
|
||||
|
||||
UnlockMutex (img->mutex);
|
||||
|
||||
if (TYPE_GET (_CurFramePtr->TypeIndexAndFlags) == SCREEN_DRAWABLE)
|
||||
|
||||
@@ -947,6 +947,8 @@ PostProcessQueue (VIEW_STATE view_state, SIZE scroll_x,
|
||||
TFB_Image *mmimg = frame->image;
|
||||
DC.Type = TFB_DRAWCOMMANDTYPE_SETMIPMAP;
|
||||
DC.data.setmipmap.image = ((PFRAME_DESC)ElementPtr->next.image.frame)->image;
|
||||
DC.data.setmipmap.hotx = frame->HotSpot.x;
|
||||
DC.data.setmipmap.hoty = frame->HotSpot.y;
|
||||
LockMutex (mmimg->mutex);
|
||||
DC.data.setmipmap.mipmap = mmimg->NormalImg;
|
||||
UnlockMutex (mmimg->mutex);
|
||||
|
||||
Reference in New Issue
Block a user