src/video/SDL_surface.c
changeset 6527 c04879cd3b57
parent 6526 e9c3a540c52f
child 6663 2cbffb5aa19d
     1.1 --- a/src/video/SDL_surface.c	Mon Oct 01 00:40:26 2012 -0700
     1.2 +++ b/src/video/SDL_surface.c	Mon Oct 01 00:56:58 2012 -0700
     1.3 @@ -693,26 +693,39 @@
     1.4      /* Save off the original dst width, height */
     1.5      int dstW = dstrect->w;
     1.6      int dstH = dstrect->h;
     1.7 +    SDL_Rect full_rect;
     1.8      SDL_Rect final_dst = *dstrect;
     1.9      SDL_Rect final_src = *srcrect;
    1.10  
    1.11      /* Clip the dst surface to the dstrect */
    1.12 -    SDL_SetClipRect( dst, &final_dst );
    1.13 +    full_rect.x = 0;
    1.14 +    full_rect.y = 0;
    1.15 +    full_rect.w = dst->w;
    1.16 +    full_rect.h = dst->h;
    1.17 +    if (!SDL_IntersectRect(&final_dst, &full_rect, &final_dst)) {
    1.18 +        return 0;
    1.19 +    }
    1.20  
    1.21      /* Did the dst width change? */
    1.22 -    if ( dstW != dst->clip_rect.w ) {
    1.23 +    if ( dstW != final_dst.w ) {
    1.24          /* scale the src width appropriately */
    1.25          final_src.w = final_src.w * dst->clip_rect.w / dstW;
    1.26      }
    1.27  
    1.28      /* Did the dst height change? */
    1.29 -    if ( dstH != dst->clip_rect.h ) {
    1.30 +    if ( dstH != final_dst.h ) {
    1.31          /* scale the src width appropriately */
    1.32          final_src.h = final_src.h * dst->clip_rect.h / dstH;
    1.33      }
    1.34  
    1.35      /* Clip the src surface to the srcrect */
    1.36 -    SDL_SetClipRect( src, &final_src );
    1.37 +    full_rect.x = 0;
    1.38 +    full_rect.y = 0;
    1.39 +    full_rect.w = src->w;
    1.40 +    full_rect.h = src->h;
    1.41 +    if (!SDL_IntersectRect(&final_src, &full_rect, &final_src)) {
    1.42 +        return 0;
    1.43 +    }
    1.44  
    1.45      src->map->info.flags |= SDL_COPY_NEAREST;
    1.46