We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 2628

Summary: invalidate surface->map in SDL_SurfacePalette()
Product: SDL Reporter: Wei Mingzhi <weimingzhi>
Component: videoAssignee: Sam Lantinga <slouken>
Status: RESOLVED FIXED QA Contact: Sam Lantinga <slouken>
Severity: normal    
Priority: P2    
Version: 2.0.3   
Hardware: All   
OS: All   

Description Wei Mingzhi 2014-07-05 18:33:20 UTC
surface->map should be invalidated in SDL_SetSurfacePalette(), otherwise the palette would not be effective when blitting to another non-8bit surface which we previously blitted to.
Comment 1 Wei Mingzhi 2014-07-05 18:34:46 UTC
just a note: I'm currently using a hack like this as I don't think there is a public API to invalidate surface->map:

   SDL_SetSurfacePalette(gpScreen, palette);
   SDL_SetSurfacePalette(gpScreenBak, palette);

   //
   // HACKHACK: need to invalidate gpScreen->map otherwise the palette
   // would not be effective during blit
   //
   SDL_SetSurfaceColorMod(gpScreen, 0, 0, 0);
   SDL_SetSurfaceColorMod(gpScreen, 0xFF, 0xFF, 0xFF);
   SDL_SetSurfaceColorMod(gpScreenBak, 0, 0, 0);
   SDL_SetSurfaceColorMod(gpScreenBak, 0xFF, 0xFF, 0xFF);
Comment 2 Sam Lantinga 2014-07-08 04:22:56 UTC
This should be fixed, thanks!
https://hg.libsdl.org/SDL/rev/7e3f54f2b16f