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 committed 2024-07-10 23:22:06 -07:00
1 parent a16ff651e8
commit 0b2c80557c
2 files changed
+53 -11

No files matched your search

+8 -10
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);