Better performance from "Rush" (by using SDL_gfx rotozoom)

Applying patch from Pere.  ALSO, bumping Tux Paint Magic Tool API version.
This commit is contained in:
Bill Kendrick 2022-10-03 22:50:40 -07:00
parent f32023666e
commit 632459087e
5 changed files with 50 additions and 6 deletions

View file

@ -148,6 +148,11 @@ typedef struct magic_api_t {
'w' and 'h' elements to confirm the actual size) */
SDL_Surface * (*scale)(SDL_Surface *, int, int, int);
/* Returns a new surface containing the rotated/scaled contents of
an input surface, rotated to r degrees, scaled to the w dimension and keeping its aspect ratio. */
SDL_Surface * (*rotate_scale)(SDL_Surface *, int, int);
/* Returns whether a particular position of the canvas has been labeled
as 'touched,' since the mouse was first clicked; this function ALSO
assigns the position as touched, until the next time the mouse is

View file

@ -2289,6 +2289,7 @@ static Uint8 magic_linear_to_sRGB(float lin);
static float magic_sRGB_to_linear(Uint8 srgb);
static int magic_button_down(void);
static SDL_Surface *magic_scale(SDL_Surface * surf, int w, int h, int aspect);
static SDL_Surface *magic_rotate_scale(SDL_Surface * surf, int r, int w);
static void reset_touched(void);
static Uint8 magic_touched(int x, int y);
@ -21836,6 +21837,7 @@ static void load_magic_plugins(void)
magic_api_struct->canvas_w = canvas->w;
magic_api_struct->canvas_h = canvas->h;
magic_api_struct->scale = magic_scale;
magic_api_struct->rotate_scale = magic_rotate_scale;
magic_api_struct->touched = magic_touched;
@ -22509,6 +22511,14 @@ static SDL_Surface *magic_scale(SDL_Surface * surf, int w, int h, int aspect)
return (thumbnail2(surf, w, h, aspect, 1));
}
/**
* FIXME
*/
static SDL_Surface *magic_rotate_scale(SDL_Surface * surf, int r, int w)
{
return (rotozoomSurface(surf, r, (float)w / surf->w, SMOOTHING_ON));
}
/**
* FIXME
*/