Fixed a bug in detecting surface mapping changes
authorSam Lantinga <slouken@libsdl.org>
Thu, 19 Feb 2004 21:13:24 +0000
changeset 845 333db1d87876
parent 844 cd0c77df70a4
child 846 96ba4eab74fb
Fixed a bug in detecting surface mapping changes
src/video/SDL_pixels.c
src/video/SDL_surface.c
--- a/src/video/SDL_pixels.c	Wed Feb 18 03:57:13 2004 +0000
+++ b/src/video/SDL_pixels.c	Thu Feb 19 21:13:24 2004 +0000
@@ -246,7 +246,12 @@
  */
 void SDL_FormatChanged(SDL_Surface *surface)
 {
-	surface->format_version++;
+	static int format_version = 0;
+	++format_version;
+	if ( format_version < 0 ) { /* It wrapped... */
+		format_version = 1;
+	}
+	surface->format_version = format_version;
 	SDL_InvalidateMap(surface->map);
 }
 /*
--- a/src/video/SDL_surface.c	Wed Feb 18 03:57:13 2004 +0000
+++ b/src/video/SDL_surface.c	Thu Feb 19 21:13:24 2004 +0000
@@ -106,9 +106,9 @@
 	surface->hwdata = NULL;
 	surface->locked = 0;
 	surface->map = NULL;
-	surface->format_version = 0;
 	surface->unused1 = 0;
 	SDL_SetClipRect(surface, NULL);
+	SDL_FormatChanged(surface);
 
 	/* Get the pixels */
 	if ( ((flags&SDL_HWSURFACE) == SDL_SWSURFACE) ||