From 291749630d731d45f7a5ff3d4b2429fbeb58ac4c Mon Sep 17 00:00:00 2001
From: David Gow <[EMAIL REDACTED]>
Date: Tue, 20 May 2025 20:53:19 +0800
Subject: [PATCH] Update palette in Surface2to3
As with some other surface properties, it's possible that an application will
modify a surface's palette behind SDL2's back. In particular, this is often
used as a shortcut to emulate DirectDraw's blitting behaviour (which ignores
the palette).
Synchronise the palette in Surface2to3 alongside other properties which are
modified in this manner. It should be safe to use SDL3_SetSurfacePalette(), as
if the surface's palette is unchanged, the refcount should also end up
unchanged.
Signed-off-by: David Gow <david@ingeniumdigital.com>
---
src/sdl2_compat.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/sdl2_compat.c b/src/sdl2_compat.c
index 4815eb0..74119ae 100644
--- a/src/sdl2_compat.c
+++ b/src/sdl2_compat.c
@@ -3924,6 +3924,7 @@ static SDL_Surface *Surface2to3(SDL2_Surface *surface)
surface3->flags |= (surface->flags & SHARED_SURFACE_FLAGS);
surface3->pixels = surface->pixels;
surface3->pitch = surface->pitch;
+ SDL3_SetSurfacePalette(surface3, surface->format->palette);
}
return surface3;
}