Fixed bug updating the clip rect for the software renderer
authorSam Lantinga <slouken@libsdl.org>
Thu, 27 Jun 2013 11:27:19 -0700
changeset 73225b94da2650a6
parent 7321 46de847fef38
child 7323 590e596a8efc
Fixed bug updating the clip rect for the software renderer
src/render/software/SDL_render_sw.c
     1.1 --- a/src/render/software/SDL_render_sw.c	Thu Jun 27 11:21:37 2013 -0700
     1.2 +++ b/src/render/software/SDL_render_sw.c	Thu Jun 27 11:27:19 2013 -0700
     1.3 @@ -118,6 +118,7 @@
     1.4              renderer->viewport.h = surface->h;
     1.5  
     1.6              SW_UpdateViewport(renderer);
     1.7 +            SW_UpdateClipRect(renderer);
     1.8          }
     1.9      }
    1.10      return data->surface;
    1.11 @@ -346,13 +347,16 @@
    1.12  static int
    1.13  SW_UpdateClipRect(SDL_Renderer * renderer)
    1.14  {
    1.15 +    SW_RenderData *data = (SW_RenderData *) renderer->driverdata;
    1.16 +    SDL_Surface *surface = data->surface;
    1.17      const SDL_Rect *rect = &renderer->clip_rect;
    1.18 -    SDL_Surface* framebuffer = (SDL_Surface *) renderer->driverdata;
    1.19  
    1.20 -    if (!SDL_RectEmpty(rect)) {
    1.21 -        SDL_SetClipRect(framebuffer, rect);
    1.22 -    } else {
    1.23 -        SDL_SetClipRect(framebuffer, NULL);
    1.24 +    if (surface) {
    1.25 +        if (!SDL_RectEmpty(rect)) {
    1.26 +            SDL_SetClipRect(surface, rect);
    1.27 +        } else {
    1.28 +            SDL_SetClipRect(surface, NULL);
    1.29 +        }
    1.30      }
    1.31      return 0;
    1.32  }