Fix issue with colorkey, palette and format conversion
authorSylvain Becker <sylvain.becker@gmail.com>
Sun, 17 May 2020 20:45:55 +0200
changeset 138125c4ad9fc7b21
parent 13811 eff2d605bef5
child 13813 c0689749d4b4
Fix issue with colorkey, palette and format conversion
Set the colorkey information on the converted surface.
Test-case in bug 3826/2979, conflicting with bug 4798
src/video/SDL_surface.c
     1.1 --- a/src/video/SDL_surface.c	Fri May 15 21:33:47 2020 +0200
     1.2 +++ b/src/video/SDL_surface.c	Sun May 17 20:45:55 2020 +0200
     1.3 @@ -1106,6 +1106,7 @@
     1.4  
     1.5      if (copy_flags & SDL_COPY_COLORKEY) {
     1.6          SDL_bool set_colorkey_by_color = SDL_FALSE;
     1.7 +        SDL_bool convert_colorkey = SDL_TRUE;
     1.8  
     1.9          if (surface->format->palette) {
    1.10              if (format->palette &&
    1.11 @@ -1115,7 +1116,9 @@
    1.12                  /* The palette is identical, just set the same colorkey */
    1.13                  SDL_SetColorKey(convert, 1, surface->map->info.colorkey);
    1.14              } else if (!format->palette) {
    1.15 +                set_colorkey_by_color = SDL_TRUE;
    1.16                  /* Was done by 'palette_ck_transform' */
    1.17 +                convert_colorkey = SDL_FALSE;
    1.18              } else {
    1.19                  set_colorkey_by_color = SDL_TRUE;
    1.20              }
    1.21 @@ -1156,7 +1159,9 @@
    1.22              SDL_SetColorKey(convert, 1, converted_colorkey);
    1.23  
    1.24              /* This is needed when converting for 3D texture upload */
    1.25 -            SDL_ConvertColorkeyToAlpha(convert, SDL_TRUE);
    1.26 +            if (convert_colorkey) {
    1.27 +                SDL_ConvertColorkeyToAlpha(convert, SDL_TRUE);
    1.28 +            }
    1.29          }
    1.30      }
    1.31      SDL_SetClipRect(convert, &surface->clip_rect);