Force masks to zero if creating an 8-bit surface.
authorRyan C. Gordon <icculus@icculus.org>
Fri, 01 Mar 2019 10:51:25 -0500
changeset 92b62ce3deedf4
parent 91 ecc70507b655
child 93 20605b15ca8c
Force masks to zero if creating an 8-bit surface.

Otherwise, SDL2 doesn't do what we want here.
src/SDL12_compat.c
     1.1 --- a/src/SDL12_compat.c	Fri Mar 01 10:50:23 2019 -0500
     1.2 +++ b/src/SDL12_compat.c	Fri Mar 01 10:51:25 2019 -0500
     1.3 @@ -2114,6 +2114,9 @@
     1.4  DECLSPEC SDL12_Surface * SDLCALL
     1.5  SDL_CreateRGBSurface(Uint32 sdl12flags, int width, int height, int depth, Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask)
     1.6  {
     1.7 +    if (depth == 8) {
     1.8 +        Rmask = Gmask = Bmask = Amask = 0;  // force a paletted surface.
     1.9 +    }
    1.10      SDL_Surface *surface20 = SDL20_CreateRGBSurface(0, width, height, depth, Rmask, Gmask, Bmask, Amask);
    1.11      SDL12_Surface *surface12 = Surface20to12(surface20);
    1.12      if (!surface12) {
    1.13 @@ -2128,6 +2131,9 @@
    1.14  DECLSPEC SDL12_Surface * SDLCALL
    1.15  SDL_CreateRGBSurfaceFrom(void *pixels, int width, int height, int depth, int pitch, Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask)
    1.16  {
    1.17 +    if (depth == 8) {
    1.18 +        Rmask = Gmask = Bmask = Amask = 0;  // force a paletted surface.
    1.19 +    }
    1.20      SDL_Surface *surface20 = SDL20_CreateRGBSurfaceFrom(pixels, width, height, depth, pitch, Rmask, Gmask, Bmask, Amask);
    1.21      SDL12_Surface *surface12 = Surface20to12(surface20);
    1.22      if (!surface12) {