Fixed swizzle of SDL_FillRect() on 24-bit surface (thanks, "nagydavid91"!).
authorRyan C. Gordon
Sun, 31 May 2015 11:38:10 -0400
changeset 9688596a3da0c9cb
parent 9687 ad9917a91c06
child 9689 34e1c3e1cd35
Fixed swizzle of SDL_FillRect() on 24-bit surface (thanks, "nagydavid91"!).

Fixes Bugzilla #2986.
src/video/SDL_fillrect.c
     1.1 --- a/src/video/SDL_fillrect.c	Sun May 31 01:45:20 2015 -0400
     1.2 +++ b/src/video/SDL_fillrect.c	Sun May 31 11:38:10 2015 -0400
     1.3 @@ -196,9 +196,15 @@
     1.4  static void
     1.5  SDL_FillRect3(Uint8 * pixels, int pitch, Uint32 color, int w, int h)
     1.6  {
     1.7 -    Uint8 r = (Uint8) ((color >> 16) & 0xFF);
     1.8 -    Uint8 g = (Uint8) ((color >> 8) & 0xFF);
     1.9 -    Uint8 b = (Uint8) (color & 0xFF);
    1.10 +#if SDL_BYTEORDER == SDL_LIL_ENDIAN
    1.11 +    Uint8 b1 = (Uint8) (color & 0xFF);
    1.12 +    Uint8 b2 = (Uint8) ((color >> 8) & 0xFF);
    1.13 +    Uint8 b3 = (Uint8) ((color >> 16) & 0xFF);
    1.14 +#elif SDL_BYTEORDER == SDL_BIG_ENDIAN
    1.15 +    Uint8 b1 = (Uint8) ((color >> 16) & 0xFF);
    1.16 +    Uint8 b2 = (Uint8) ((color >> 8) & 0xFF);
    1.17 +    Uint8 b3 = (Uint8) (color & 0xFF);
    1.18 +#endif
    1.19      int n;
    1.20      Uint8 *p = NULL;
    1.21  
    1.22 @@ -207,9 +213,9 @@
    1.23          p = pixels;
    1.24  
    1.25          while (n--) {
    1.26 -            *p++ = r;
    1.27 -            *p++ = g;
    1.28 -            *p++ = b;
    1.29 +            *p++ = b1;
    1.30 +            *p++ = b2;
    1.31 +            *p++ = b3;
    1.32          }
    1.33          pixels += pitch;
    1.34      }