ScaledImg now allocated only if it's needed; also removed
TFB_SCALETARGET_FACTOR as redundant git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@875 8092fc87-c524-0410-9efc-e669fe64eaf9
This commit is contained in:
@@ -162,14 +162,12 @@ TFB_DrawCanvas_New_Paletted (int w, int h, TFB_Palette *palette, int transparent
|
|||||||
return new_surf;
|
return new_surf;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define TFB_SCALETARGET_FACTOR 4
|
|
||||||
|
|
||||||
TFB_Canvas
|
TFB_Canvas
|
||||||
TFB_DrawCanvas_New_ScaleTarget (TFB_Canvas canvas)
|
TFB_DrawCanvas_New_ScaleTarget (TFB_Canvas canvas)
|
||||||
{
|
{
|
||||||
SDL_Surface *src = (SDL_Surface *)canvas;
|
SDL_Surface *src = (SDL_Surface *)canvas;
|
||||||
SDL_Surface *newsurf = SDL_CreateRGBSurface (SDL_SWSURFACE, src->w * TFB_SCALETARGET_FACTOR,
|
SDL_Surface *newsurf = SDL_CreateRGBSurface (SDL_SWSURFACE, src->w,
|
||||||
src->h * TFB_SCALETARGET_FACTOR,
|
src->h,
|
||||||
src->format->BitsPerPixel,
|
src->format->BitsPerPixel,
|
||||||
src->format->Rmask,
|
src->format->Rmask,
|
||||||
src->format->Gmask,
|
src->format->Gmask,
|
||||||
@@ -290,6 +288,12 @@ TFB_DrawCanvas_Rescale (TFB_Canvas src_canvas, TFB_Canvas dest_canvas, EXTENT si
|
|||||||
fprintf (stderr, "TFB_DrawCanvas_Scale: Tried to zoom an image to be larger than the screen! Failing.\n");
|
fprintf (stderr, "TFB_DrawCanvas_Scale: Tried to zoom an image to be larger than the screen! Failing.\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (size.width > dst->w || size.height > dst->h)
|
||||||
|
{
|
||||||
|
fprintf (stderr, "TFB_DrawCanvas_Scale: Tried to scale image to size %d %d when dest_canvas has only dimensions of %d %d! Failing.\n",
|
||||||
|
size.width, size.height, dst->w, dst->h);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
sx = (int) (65536.0 * (float) src->w / (float) size.width);
|
sx = (int) (65536.0 * (float) src->w / (float) size.width);
|
||||||
sy = (int) (65536.0 * (float) src->h / (float) size.height);
|
sy = (int) (65536.0 * (float) src->h / (float) size.height);
|
||||||
|
|||||||
@@ -263,7 +263,7 @@ TFB_DrawImage_New (TFB_Canvas canvas)
|
|||||||
img->NormalImg = TFB_DrawCanvas_ToScreenFormat (canvas);
|
img->NormalImg = TFB_DrawCanvas_ToScreenFormat (canvas);
|
||||||
}
|
}
|
||||||
|
|
||||||
img->ScaledImg = TFB_DrawCanvas_New_ScaleTarget (img->NormalImg);
|
img->ScaledImg = NULL;
|
||||||
|
|
||||||
return img;
|
return img;
|
||||||
}
|
}
|
||||||
@@ -303,6 +303,8 @@ TFB_DrawImage_FixScaling (TFB_Image *image, int target)
|
|||||||
if ((old.width != image->extent.width) || (old.height != image->extent.height) || image->dirty)
|
if ((old.width != image->extent.width) || (old.height != image->extent.height) || image->dirty)
|
||||||
{
|
{
|
||||||
image->dirty = FALSE;
|
image->dirty = FALSE;
|
||||||
|
if (!image->ScaledImg)
|
||||||
|
image->ScaledImg = TFB_DrawCanvas_New_ScaleTarget (image->NormalImg);
|
||||||
TFB_DrawCanvas_Rescale (image->NormalImg, image->ScaledImg, image->extent);
|
TFB_DrawCanvas_Rescale (image->NormalImg, image->ScaledImg, image->extent);
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
|
|||||||
Reference in New Issue
Block a user