Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Commit

Permalink
Fixed bug 1224 - Blit map not updated if source palette changed
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
slouken committed Jan 7, 2012
1 parent 87f1b90 commit 3f8ce08
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
3 changes: 2 additions & 1 deletion src/video/SDL_blit.h
Expand Up @@ -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 */
Expand Down
13 changes: 10 additions & 3 deletions src/video/SDL_pixels.c
Expand Up @@ -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;
Expand Down Expand Up @@ -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 */
Expand Down
4 changes: 3 additions & 1 deletion src/video/SDL_surface.c
Expand Up @@ -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);
}
Expand Down

0 comments on commit 3f8ce08

Please sign in to comment.