Fixed bug 1224 - Blit map not updated if source palette changed
authorSam Lantinga
Sat, 07 Jan 2012 01:28:06 -0500
changeset 61660bc1f6da9c74
parent 6165 b7347e716ab6
child 6167 c071e1372341
Fixed bug 1224 - Blit map not updated if source palette changed

bastien.bouclet@gmail.com 2011-06-12 11:08:58 PDT

SDL_LowerBlit doesn't update the blit color map if the source surface has
changed.

A proposed fix is attached, storing the source palette version in the color
map.
src/video/SDL_blit.h
src/video/SDL_pixels.c
src/video/SDL_surface.c
     1.1 --- a/src/video/SDL_blit.h	Sat Jan 07 01:25:55 2012 -0500
     1.2 +++ b/src/video/SDL_blit.h	Sat Jan 07 01:28:06 2012 -0500
     1.3 @@ -92,7 +92,8 @@
     1.4  
     1.5      /* the version count matches the destination; mismatch indicates
     1.6         an invalid mapping */
     1.7 -    Uint32 palette_version;
     1.8 +    Uint32 dst_palette_version;
     1.9 +    Uint32 src_palette_version;
    1.10  } SDL_BlitMap;
    1.11  
    1.12  /* Functions found in SDL_blit.c */
     2.1 --- a/src/video/SDL_pixels.c	Sat Jan 07 01:25:55 2012 -0500
     2.2 +++ b/src/video/SDL_pixels.c	Sat Jan 07 01:28:06 2012 -0500
     2.3 @@ -969,7 +969,8 @@
     2.4          return;
     2.5      }
     2.6      map->dst = NULL;
     2.7 -    map->palette_version = 0;
     2.8 +    map->src_palette_version = 0;
     2.9 +    map->dst_palette_version = 0;
    2.10      if (map->info.table) {
    2.11          SDL_free(map->info.table);
    2.12          map->info.table = NULL;
    2.13 @@ -1036,9 +1037,15 @@
    2.14      map->dst = dst;
    2.15  
    2.16      if (dstfmt->palette) {
    2.17 -        map->palette_version = dstfmt->palette->version;
    2.18 +        map->dst_palette_version = dstfmt->palette->version;
    2.19      } else {
    2.20 -        map->palette_version = 0;
    2.21 +        map->dst_palette_version = 0;
    2.22 +    }
    2.23 +
    2.24 +    if (srcfmt->palette) {
    2.25 +        map->src_palette_version = srcfmt->palette->version;
    2.26 +    } else {
    2.27 +        map->src_palette_version = 0;
    2.28      }
    2.29  
    2.30      /* Choose your blitters wisely */
     3.1 --- a/src/video/SDL_surface.c	Sat Jan 07 01:25:55 2012 -0500
     3.2 +++ b/src/video/SDL_surface.c	Sat Jan 07 01:28:06 2012 -0500
     3.3 @@ -494,7 +494,9 @@
     3.4      /* Check to make sure the blit mapping is valid */
     3.5      if ((src->map->dst != dst) ||
     3.6          (dst->format->palette &&
     3.7 -         src->map->palette_version != dst->format->palette->version)) {
     3.8 +         src->map->dst_palette_version != dst->format->palette->version) ||
     3.9 +        (src->format->palette &&
    3.10 +         src->map->src_palette_version != src->format->palette->version)) {
    3.11          if (SDL_MapSurface(src, dst) < 0) {
    3.12              return (-1);
    3.13          }