Update the blit mapping when the palette is set on a surface

Make sure you do this even if the palette pointer hasn't changed, as the contents may have.

Fixes https://github.com/libsdl-org/SDL/issues/10225
This commit is contained in:
Sam Lantinga
2024-07-10 23:20:51 -07:00
parent a16ff651e8
commit 0b2c80557c
2 changed files with 53 additions and 11 deletions

View File

@@ -396,18 +396,16 @@ int SDL_SetSurfacePalette(SDL_Surface *surface, SDL_Palette *palette)
return SDL_SetError("SDL_SetSurfacePalette() passed a palette that doesn't match the surface format");
}
if (palette == surface->internal->palette) {
return 0;
}
if (palette != surface->internal->palette) {
if (surface->internal->palette) {
SDL_DestroyPalette(surface->internal->palette);
}
if (surface->internal->palette) {
SDL_DestroyPalette(surface->internal->palette);
}
surface->internal->palette = palette;
surface->internal->palette = palette;
if (surface->internal->palette) {
++surface->internal->palette->refcount;
if (surface->internal->palette) {
++surface->internal->palette->refcount;
}
}
SDL_InvalidateMap(&surface->internal->map);