src/video/SDL_rect.c
changeset 5950 36fa6d12784b
parent 5902 d3d839b15c2f
child 5953 fecf71a834ed
     1.1 --- a/src/video/SDL_rect.c	Sat Sep 17 22:35:10 2011 -0700
     1.2 +++ b/src/video/SDL_rect.c	Sat Sep 17 22:35:57 2011 -0700
     1.3 @@ -33,6 +33,11 @@
     1.4          return SDL_FALSE;
     1.5      }
     1.6  
     1.7 +    /* Special cases for empty rects */
     1.8 +    if (SDL_RectEmpty(A) || SDL_RectEmpty(B)) {
     1.9 +        return SDL_FALSE;
    1.10 +    }
    1.11 +
    1.12      /* Horizontal intersection */
    1.13      Amin = A->x;
    1.14      Amax = Amin + A->w;
    1.15 @@ -70,6 +75,11 @@
    1.16          return SDL_FALSE;
    1.17      }
    1.18  
    1.19 +    /* Special cases for empty rects */
    1.20 +    if (SDL_RectEmpty(A) || SDL_RectEmpty(B)) {
    1.21 +        return SDL_FALSE;
    1.22 +    }
    1.23 +    
    1.24      /* Horizontal intersection */
    1.25      Amin = A->x;
    1.26      Amax = Amin + A->w;
    1.27 @@ -106,6 +116,24 @@
    1.28          return;
    1.29      }
    1.30  
    1.31 +    /* Special cases for empty Rects */
    1.32 +    if (SDL_RectEmpty(A)) {
    1.33 +      if (SDL_RectEmpty(B)) {
    1.34 +       /* A and B empty */
    1.35 +       return;
    1.36 +      } else {
    1.37 +       /* A empty, B not empty */
    1.38 +       *result = *B;
    1.39 +       return;
    1.40 +      }
    1.41 +    } else {      
    1.42 +      if (SDL_RectEmpty(B)) {
    1.43 +       /* A not empty, B empty */
    1.44 +       *result = *A;
    1.45 +       return;
    1.46 +      } 
    1.47 +    }
    1.48 +    
    1.49      /* Horizontal union */
    1.50      Amin = A->x;
    1.51      Amax = Amin + A->w;
    1.52 @@ -118,7 +146,7 @@
    1.53          Amax = Bmax;
    1.54      result->w = Amax - Amin;
    1.55  
    1.56 -    /* Vertical intersection */
    1.57 +    /* Vertical union */
    1.58      Amin = A->y;
    1.59      Amax = Amin + A->h;
    1.60      Bmin = B->y;
    1.61 @@ -152,6 +180,11 @@
    1.62      }
    1.63  
    1.64      if (clip) {
    1.65 +        /* Special case for empty rectangle */
    1.66 +        if (SDL_RectEmpty(clip)) {
    1.67 +            return SDL_FALSE;
    1.68 +        }
    1.69 +        
    1.70          SDL_bool added = SDL_FALSE;
    1.71          int clip_minx = clip->x;
    1.72          int clip_miny = clip->y;
    1.73 @@ -269,6 +302,11 @@
    1.74          return SDL_FALSE;
    1.75      }
    1.76  
    1.77 +    /* Special case for empty rect */
    1.78 +    if (SDL_RectEmpty(rect)) {
    1.79 +        return SDL_FALSE;
    1.80 +    }
    1.81 +    
    1.82      x1 = *X1;
    1.83      y1 = *Y1;
    1.84      x2 = *X2;