Skip to content

Commit

Permalink
SDL1: Avoid redundant palette update
Browse files Browse the repository at this point in the history
When the display surface is 8-bit, skips a redundant call to `SDL_SetPalette`.
  • Loading branch information
glebm committed Oct 12, 2024
1 parent e1a08d3 commit d690eee
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion Source/utils/sdl_compat.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,9 @@ inline int SDLC_SetSurfaceAndPaletteColors(SDL_Surface *surface, SDL_Palette *pa

#if SDL1_VIDEO_MODE_BPP == 8
// When the video surface is 8bit, we need to set the output palette as well.
SDL_SetColors(SDL_GetVideoSurface(), colors, firstcolor, ncolors);
const Surface *videoSurface = SDL_GetVideoSurface();
SDL_SetColors(videoSurface, colors, firstcolor, ncolors);
if (videoSurface == surface) return 0;
#endif
// In SDL1, the surface always has its own distinct palette, so we need to
// update it as well.
Expand Down

0 comments on commit d690eee

Please sign in to comment.