From 3f8ce08454230f41399403453692ddd89ea4f510 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Sat, 7 Jan 2012 01:28:06 -0500 Subject: [PATCH] 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 | 3 ++- src/video/SDL_pixels.c | 13 ++++++++++--- src/video/SDL_surface.c | 4 +++- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/video/SDL_blit.h b/src/video/SDL_blit.h index 1e953afca..6a5983d30 100755 --- a/src/video/SDL_blit.h +++ b/src/video/SDL_blit.h @@ -92,7 +92,8 @@ typedef struct SDL_BlitMap /* the version count matches the destination; mismatch indicates an invalid mapping */ - Uint32 palette_version; + Uint32 dst_palette_version; + Uint32 src_palette_version; } SDL_BlitMap; /* Functions found in SDL_blit.c */ diff --git a/src/video/SDL_pixels.c b/src/video/SDL_pixels.c index 900ed522d..455612c50 100755 --- a/src/video/SDL_pixels.c +++ b/src/video/SDL_pixels.c @@ -969,7 +969,8 @@ SDL_InvalidateMap(SDL_BlitMap * map) return; } map->dst = NULL; - map->palette_version = 0; + map->src_palette_version = 0; + map->dst_palette_version = 0; if (map->info.table) { SDL_free(map->info.table); map->info.table = NULL; @@ -1036,9 +1037,15 @@ SDL_MapSurface(SDL_Surface * src, SDL_Surface * dst) map->dst = dst; if (dstfmt->palette) { - map->palette_version = dstfmt->palette->version; + map->dst_palette_version = dstfmt->palette->version; } else { - map->palette_version = 0; + map->dst_palette_version = 0; + } + + if (srcfmt->palette) { + map->src_palette_version = srcfmt->palette->version; + } else { + map->src_palette_version = 0; } /* Choose your blitters wisely */ diff --git a/src/video/SDL_surface.c b/src/video/SDL_surface.c index 3ac55396f..05b259d81 100755 --- a/src/video/SDL_surface.c +++ b/src/video/SDL_surface.c @@ -494,7 +494,9 @@ SDL_LowerBlit(SDL_Surface * src, SDL_Rect * srcrect, /* Check to make sure the blit mapping is valid */ if ((src->map->dst != dst) || (dst->format->palette && - src->map->palette_version != dst->format->palette->version)) { + src->map->dst_palette_version != dst->format->palette->version) || + (src->format->palette && + src->map->src_palette_version != src->format->palette->version)) { if (SDL_MapSurface(src, dst) < 0) { return (-1); }