Applying these changes to external code doesn't actually improve anything, and within the context of the other Get* functions for renderers and surfaces, these stand out as outliers, so I'm going to back this change out.
This commit is contained in:
Sam Lantinga
2024-07-17 09:40:25 -07:00
parent b3df46e4bc
commit 5f5e91eab6
12 changed files with 102 additions and 67 deletions

View File

@@ -78,7 +78,11 @@ Returns colorkey info for a surface
*/
static Uint32 get_colorkey(SDL_Surface *src)
{
return SDL_GetSurfaceColorKey(src);
Uint32 key = 0;
if (SDL_SurfaceHasColorKey(src)) {
SDL_GetSurfaceColorKey(src, &key);
}
return key;
}
/* rotate (sx, sy) by (angle, center) into (dx, dy) */
@@ -497,8 +501,9 @@ SDL_Surface *SDLgfx_rotateSurface(SDL_Surface *src, double angle, int smooth, in
}
if (SDL_SurfaceHasColorKey(src)) {
colorkey = SDL_GetSurfaceColorKey(src);
colorKeyAvailable = SDL_TRUE;
if (SDL_GetSurfaceColorKey(src, &colorkey) == 0) {
colorKeyAvailable = SDL_TRUE;
}
}
/* This function requires a 32-bit surface or 8-bit surface with a colorkey */
is8bit = src->internal->format->bits_per_pixel == 8 && colorKeyAvailable;
@@ -531,7 +536,7 @@ SDL_Surface *SDLgfx_rotateSurface(SDL_Surface *src, double angle, int smooth, in
/* Adjust for guard rows */
rz_dst->h = rect_dest->h;
blendmode = SDL_GetSurfaceBlendMode(src);
SDL_GetSurfaceBlendMode(src, &blendmode);
if (colorKeyAvailable == SDL_TRUE) {
/* If available, the colorkey will be used to discard the pixels that are outside of the rotated area. */