Fixed bug 2628 - invalidate surface->map in SDL_SurfacePalette()
authorSam Lantinga <slouken@libsdl.org>
Mon, 07 Jul 2014 21:21:05 -0700
changeset 89907e3f54f2b16f
parent 8989 25582ffe1dec
child 8991 13b0df1793e8
Fixed bug 2628 - invalidate surface->map in SDL_SurfacePalette()

Wei Mingzhi

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.
src/video/SDL_surface.c
     1.1 --- a/src/video/SDL_surface.c	Mon Jul 07 20:26:21 2014 -0700
     1.2 +++ b/src/video/SDL_surface.c	Mon Jul 07 21:21:05 2014 -0700
     1.3 @@ -145,7 +145,12 @@
     1.4      if (!surface) {
     1.5          return SDL_SetError("SDL_SetSurfacePalette() passed a NULL surface");
     1.6      }
     1.7 -    return SDL_SetPixelFormatPalette(surface->format, palette);
     1.8 +    if (SDL_SetPixelFormatPalette(surface->format, palette) < 0) {
     1.9 +        return -1;
    1.10 +    }
    1.11 +    SDL_InvalidateMap(surface->map);
    1.12 +
    1.13 +    return 0;
    1.14  }
    1.15  
    1.16  int