Fixed bug updating the clip rect for the software renderer
authorSam Lantinga <slouken@libsdl.org>
Thu, 27 Jun 2013 11:27:19 -0700
changeset 7322 5b94da2650a6
parent 7321 46de847fef38
child 7323 590e596a8efc
Fixed bug updating the clip rect for the software renderer
src/render/software/SDL_render_sw.c
--- a/src/render/software/SDL_render_sw.c	Thu Jun 27 11:21:37 2013 -0700
+++ b/src/render/software/SDL_render_sw.c	Thu Jun 27 11:27:19 2013 -0700
@@ -118,6 +118,7 @@
             renderer->viewport.h = surface->h;
 
             SW_UpdateViewport(renderer);
+            SW_UpdateClipRect(renderer);
         }
     }
     return data->surface;
@@ -346,13 +347,16 @@
 static int
 SW_UpdateClipRect(SDL_Renderer * renderer)
 {
+    SW_RenderData *data = (SW_RenderData *) renderer->driverdata;
+    SDL_Surface *surface = data->surface;
     const SDL_Rect *rect = &renderer->clip_rect;
-    SDL_Surface* framebuffer = (SDL_Surface *) renderer->driverdata;
 
-    if (!SDL_RectEmpty(rect)) {
-        SDL_SetClipRect(framebuffer, rect);
-    } else {
-        SDL_SetClipRect(framebuffer, NULL);
+    if (surface) {
+        if (!SDL_RectEmpty(rect)) {
+            SDL_SetClipRect(surface, rect);
+        } else {
+            SDL_SetClipRect(surface, NULL);
+        }
     }
     return 0;
 }