Fixed bug 2123 - SDL_BlitScaled crashes in src/video/SDL_blit_N.c:2145
authorSam Lantinga <slouken@libsdl.org>
Fri, 18 Oct 2013 00:47:22 -0700
changeset 7834 e22726c82922
parent 7833 b4a9cc7085f2
child 7835 4be86f76e710
Fixed bug 2123 - SDL_BlitScaled crashes in src/video/SDL_blit_N.c:2145 We need to reset the blit function when switching between scaled and unscaled blits.
src/video/SDL_surface.c
--- a/src/video/SDL_surface.c	Fri Oct 18 00:13:51 2013 -0700
+++ b/src/video/SDL_surface.c	Fri Oct 18 00:47:22 2013 -0700
@@ -596,6 +596,12 @@
             h -= dy;
     }
 
+    /* Switch back to a fast blit if we were previously stretching */
+    if (src->map->info.flags & SDL_COPY_NEAREST) {
+        src->map->info.flags &= ~SDL_COPY_NEAREST;
+        SDL_InvalidateMap(src->map);
+    }
+
     if (w > 0 && h > 0) {
         SDL_Rect sr;
         sr.x = srcx;
@@ -747,7 +753,10 @@
         return 0;
     }
 
-    src->map->info.flags |= SDL_COPY_NEAREST;
+    if (!(src->map->info.flags & SDL_COPY_NEAREST)) {
+        src->map->info.flags |= SDL_COPY_NEAREST;
+        SDL_InvalidateMap(src->map);
+    }
 
     if ( !(src->map->info.flags & complex_copy_flags) &&
          src->format->format == dst->format->format &&