Added ARGB8888 destination format (used on Mac OS X)
authorSam Lantinga <slouken@libsdl.org>
Sat, 29 Nov 2008 00:08:29 +0000
changeset 28008969da2ef606
parent 2799 bbf3aac2672a
child 2801 5eb95b8adc1a
Added ARGB8888 destination format (used on Mac OS X)
src/video/SDL_blit_auto.c
src/video/sdlgenblit.pl
     1.1 --- a/src/video/SDL_blit_auto.c	Fri Nov 28 20:09:32 2008 +0000
     1.2 +++ b/src/video/SDL_blit_auto.c	Sat Nov 29 00:08:29 2008 +0000
     1.3 @@ -897,7 +897,7 @@
     1.4      }
     1.5  }
     1.6  
     1.7 -static void SDL_Blit_BGR888_RGB888_Scale(SDL_BlitInfo *info)
     1.8 +static void SDL_Blit_RGB888_ARGB8888_Scale(SDL_BlitInfo *info)
     1.9  {
    1.10      const int flags = info->flags;
    1.11      Uint32 pixel;
    1.12 @@ -930,8 +930,8 @@
    1.13                  src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
    1.14              }
    1.15              pixel = *src;
    1.16 -            B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; A = 0xFF;
    1.17 -            pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B;
    1.18 +            R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; A = 0xFF;
    1.19 +            pixel = ((Uint32)A << 24) | ((Uint32)R << 16) | ((Uint32)G << 8) | B;
    1.20              *dst = pixel;
    1.21              posx += incx;
    1.22              ++dst;
    1.23 @@ -941,7 +941,7 @@
    1.24      }
    1.25  }
    1.26  
    1.27 -static void SDL_Blit_BGR888_RGB888_Blend(SDL_BlitInfo *info)
    1.28 +static void SDL_Blit_RGB888_ARGB8888_Blend(SDL_BlitInfo *info)
    1.29  {
    1.30      const int flags = info->flags;
    1.31      Uint32 srcpixel;
    1.32 @@ -955,9 +955,9 @@
    1.33          int n = info->dst_w;
    1.34          while (n--) {
    1.35              srcpixel = *src;
    1.36 -            srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = 0xFF;
    1.37 +            srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = 0xFF;
    1.38              dstpixel = *dst;
    1.39 -            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
    1.40 +            dstA = (Uint8)(dstpixel >> 24); dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
    1.41              if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
    1.42                  /* This goes away if we ever use premultiplied alpha */
    1.43                  if (srcA < 255) {
    1.44 @@ -990,7 +990,7 @@
    1.45                  dstB = (srcB * dstB) / 255;
    1.46                  break;
    1.47              }
    1.48 -            dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
    1.49 +            dstpixel = ((Uint32)dstA << 24) | ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
    1.50              *dst = dstpixel;
    1.51              ++src;
    1.52              ++dst;
    1.53 @@ -1000,7 +1000,7 @@
    1.54      }
    1.55  }
    1.56  
    1.57 -static void SDL_Blit_BGR888_RGB888_Blend_Scale(SDL_BlitInfo *info)
    1.58 +static void SDL_Blit_RGB888_ARGB8888_Blend_Scale(SDL_BlitInfo *info)
    1.59  {
    1.60      const int flags = info->flags;
    1.61      Uint32 srcpixel;
    1.62 @@ -1035,9 +1035,9 @@
    1.63                  src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
    1.64              }
    1.65              srcpixel = *src;
    1.66 -            srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = 0xFF;
    1.67 +            srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = 0xFF;
    1.68              dstpixel = *dst;
    1.69 -            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
    1.70 +            dstA = (Uint8)(dstpixel >> 24); dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
    1.71              if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
    1.72                  /* This goes away if we ever use premultiplied alpha */
    1.73                  if (srcA < 255) {
    1.74 @@ -1070,7 +1070,7 @@
    1.75                  dstB = (srcB * dstB) / 255;
    1.76                  break;
    1.77              }
    1.78 -            dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
    1.79 +            dstpixel = ((Uint32)dstA << 24) | ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
    1.80              *dst = dstpixel;
    1.81              posx += incx;
    1.82              ++dst;
    1.83 @@ -1080,7 +1080,7 @@
    1.84      }
    1.85  }
    1.86  
    1.87 -static void SDL_Blit_BGR888_RGB888_Modulate(SDL_BlitInfo *info)
    1.88 +static void SDL_Blit_RGB888_ARGB8888_Modulate(SDL_BlitInfo *info)
    1.89  {
    1.90      const int flags = info->flags;
    1.91      const Uint32 modulateR = info->r;
    1.92 @@ -1096,7 +1096,7 @@
    1.93          int n = info->dst_w;
    1.94          while (n--) {
    1.95              pixel = *src;
    1.96 -            B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; A = 0xFF;
    1.97 +            R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; A = 0xFF;
    1.98              if (flags & SDL_COPY_MODULATE_COLOR) {
    1.99                  R = (R * modulateR) / 255;
   1.100                  G = (G * modulateG) / 255;
   1.101 @@ -1105,7 +1105,7 @@
   1.102              if (flags & SDL_COPY_MODULATE_ALPHA) {
   1.103                  A = (A * modulateA) / 255;
   1.104              }
   1.105 -            pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B;
   1.106 +            pixel = ((Uint32)A << 24) | ((Uint32)R << 16) | ((Uint32)G << 8) | B;
   1.107              *dst = pixel;
   1.108              ++src;
   1.109              ++dst;
   1.110 @@ -1115,7 +1115,7 @@
   1.111      }
   1.112  }
   1.113  
   1.114 -static void SDL_Blit_BGR888_RGB888_Modulate_Scale(SDL_BlitInfo *info)
   1.115 +static void SDL_Blit_RGB888_ARGB8888_Modulate_Scale(SDL_BlitInfo *info)
   1.116  {
   1.117      const int flags = info->flags;
   1.118      const Uint32 modulateR = info->r;
   1.119 @@ -1152,7 +1152,7 @@
   1.120                  src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
   1.121              }
   1.122              pixel = *src;
   1.123 -            B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; A = 0xFF;
   1.124 +            R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; A = 0xFF;
   1.125              if (flags & SDL_COPY_MODULATE_COLOR) {
   1.126                  R = (R * modulateR) / 255;
   1.127                  G = (G * modulateG) / 255;
   1.128 @@ -1161,7 +1161,7 @@
   1.129              if (flags & SDL_COPY_MODULATE_ALPHA) {
   1.130                  A = (A * modulateA) / 255;
   1.131              }
   1.132 -            pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B;
   1.133 +            pixel = ((Uint32)A << 24) | ((Uint32)R << 16) | ((Uint32)G << 8) | B;
   1.134              *dst = pixel;
   1.135              posx += incx;
   1.136              ++dst;
   1.137 @@ -1171,7 +1171,7 @@
   1.138      }
   1.139  }
   1.140  
   1.141 -static void SDL_Blit_BGR888_RGB888_Modulate_Blend(SDL_BlitInfo *info)
   1.142 +static void SDL_Blit_RGB888_ARGB8888_Modulate_Blend(SDL_BlitInfo *info)
   1.143  {
   1.144      const int flags = info->flags;
   1.145      const Uint32 modulateR = info->r;
   1.146 @@ -1189,9 +1189,9 @@
   1.147          int n = info->dst_w;
   1.148          while (n--) {
   1.149              srcpixel = *src;
   1.150 -            srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = 0xFF;
   1.151 +            srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = 0xFF;
   1.152              dstpixel = *dst;
   1.153 -            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
   1.154 +            dstA = (Uint8)(dstpixel >> 24); dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
   1.155              if (flags & SDL_COPY_MODULATE_COLOR) {
   1.156                  srcR = (srcR * modulateR) / 255;
   1.157                  srcG = (srcG * modulateG) / 255;
   1.158 @@ -1232,7 +1232,7 @@
   1.159                  dstB = (srcB * dstB) / 255;
   1.160                  break;
   1.161              }
   1.162 -            dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
   1.163 +            dstpixel = ((Uint32)dstA << 24) | ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
   1.164              *dst = dstpixel;
   1.165              ++src;
   1.166              ++dst;
   1.167 @@ -1242,7 +1242,7 @@
   1.168      }
   1.169  }
   1.170  
   1.171 -static void SDL_Blit_BGR888_RGB888_Modulate_Blend_Scale(SDL_BlitInfo *info)
   1.172 +static void SDL_Blit_RGB888_ARGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
   1.173  {
   1.174      const int flags = info->flags;
   1.175      const Uint32 modulateR = info->r;
   1.176 @@ -1281,9 +1281,9 @@
   1.177                  src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
   1.178              }
   1.179              srcpixel = *src;
   1.180 -            srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = 0xFF;
   1.181 +            srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = 0xFF;
   1.182              dstpixel = *dst;
   1.183 -            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
   1.184 +            dstA = (Uint8)(dstpixel >> 24); dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
   1.185              if (flags & SDL_COPY_MODULATE_COLOR) {
   1.186                  srcR = (srcR * modulateR) / 255;
   1.187                  srcG = (srcG * modulateG) / 255;
   1.188 @@ -1324,7 +1324,7 @@
   1.189                  dstB = (srcB * dstB) / 255;
   1.190                  break;
   1.191              }
   1.192 -            dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
   1.193 +            dstpixel = ((Uint32)dstA << 24) | ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
   1.194              *dst = dstpixel;
   1.195              posx += incx;
   1.196              ++dst;
   1.197 @@ -1334,9 +1334,11 @@
   1.198      }
   1.199  }
   1.200  
   1.201 -static void SDL_Blit_BGR888_BGR888_Scale(SDL_BlitInfo *info)
   1.202 -{
   1.203 -    const int flags = info->flags;
   1.204 +static void SDL_Blit_BGR888_RGB888_Scale(SDL_BlitInfo *info)
   1.205 +{
   1.206 +    const int flags = info->flags;
   1.207 +    Uint32 pixel;
   1.208 +    Uint32 R, G, B, A;
   1.209      int srcy, srcx;
   1.210      int posy, posx;
   1.211      int incy, incx;
   1.212 @@ -1364,7 +1366,10 @@
   1.213                  }
   1.214                  src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
   1.215              }
   1.216 -            *dst = *src;
   1.217 +            pixel = *src;
   1.218 +            B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; A = 0xFF;
   1.219 +            pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B;
   1.220 +            *dst = pixel;
   1.221              posx += incx;
   1.222              ++dst;
   1.223          }
   1.224 @@ -1373,7 +1378,7 @@
   1.225      }
   1.226  }
   1.227  
   1.228 -static void SDL_Blit_BGR888_BGR888_Blend(SDL_BlitInfo *info)
   1.229 +static void SDL_Blit_BGR888_RGB888_Blend(SDL_BlitInfo *info)
   1.230  {
   1.231      const int flags = info->flags;
   1.232      Uint32 srcpixel;
   1.233 @@ -1389,7 +1394,7 @@
   1.234              srcpixel = *src;
   1.235              srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = 0xFF;
   1.236              dstpixel = *dst;
   1.237 -            dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
   1.238 +            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
   1.239              if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
   1.240                  /* This goes away if we ever use premultiplied alpha */
   1.241                  if (srcA < 255) {
   1.242 @@ -1422,7 +1427,7 @@
   1.243                  dstB = (srcB * dstB) / 255;
   1.244                  break;
   1.245              }
   1.246 -            dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
   1.247 +            dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
   1.248              *dst = dstpixel;
   1.249              ++src;
   1.250              ++dst;
   1.251 @@ -1432,7 +1437,7 @@
   1.252      }
   1.253  }
   1.254  
   1.255 -static void SDL_Blit_BGR888_BGR888_Blend_Scale(SDL_BlitInfo *info)
   1.256 +static void SDL_Blit_BGR888_RGB888_Blend_Scale(SDL_BlitInfo *info)
   1.257  {
   1.258      const int flags = info->flags;
   1.259      Uint32 srcpixel;
   1.260 @@ -1469,7 +1474,7 @@
   1.261              srcpixel = *src;
   1.262              srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = 0xFF;
   1.263              dstpixel = *dst;
   1.264 -            dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
   1.265 +            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
   1.266              if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
   1.267                  /* This goes away if we ever use premultiplied alpha */
   1.268                  if (srcA < 255) {
   1.269 @@ -1502,7 +1507,7 @@
   1.270                  dstB = (srcB * dstB) / 255;
   1.271                  break;
   1.272              }
   1.273 -            dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
   1.274 +            dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
   1.275              *dst = dstpixel;
   1.276              posx += incx;
   1.277              ++dst;
   1.278 @@ -1512,7 +1517,7 @@
   1.279      }
   1.280  }
   1.281  
   1.282 -static void SDL_Blit_BGR888_BGR888_Modulate(SDL_BlitInfo *info)
   1.283 +static void SDL_Blit_BGR888_RGB888_Modulate(SDL_BlitInfo *info)
   1.284  {
   1.285      const int flags = info->flags;
   1.286      const Uint32 modulateR = info->r;
   1.287 @@ -1537,7 +1542,7 @@
   1.288              if (flags & SDL_COPY_MODULATE_ALPHA) {
   1.289                  A = (A * modulateA) / 255;
   1.290              }
   1.291 -            pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R;
   1.292 +            pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B;
   1.293              *dst = pixel;
   1.294              ++src;
   1.295              ++dst;
   1.296 @@ -1547,7 +1552,7 @@
   1.297      }
   1.298  }
   1.299  
   1.300 -static void SDL_Blit_BGR888_BGR888_Modulate_Scale(SDL_BlitInfo *info)
   1.301 +static void SDL_Blit_BGR888_RGB888_Modulate_Scale(SDL_BlitInfo *info)
   1.302  {
   1.303      const int flags = info->flags;
   1.304      const Uint32 modulateR = info->r;
   1.305 @@ -1593,7 +1598,7 @@
   1.306              if (flags & SDL_COPY_MODULATE_ALPHA) {
   1.307                  A = (A * modulateA) / 255;
   1.308              }
   1.309 -            pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R;
   1.310 +            pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B;
   1.311              *dst = pixel;
   1.312              posx += incx;
   1.313              ++dst;
   1.314 @@ -1603,7 +1608,7 @@
   1.315      }
   1.316  }
   1.317  
   1.318 -static void SDL_Blit_BGR888_BGR888_Modulate_Blend(SDL_BlitInfo *info)
   1.319 +static void SDL_Blit_BGR888_RGB888_Modulate_Blend(SDL_BlitInfo *info)
   1.320  {
   1.321      const int flags = info->flags;
   1.322      const Uint32 modulateR = info->r;
   1.323 @@ -1623,7 +1628,7 @@
   1.324              srcpixel = *src;
   1.325              srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = 0xFF;
   1.326              dstpixel = *dst;
   1.327 -            dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
   1.328 +            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
   1.329              if (flags & SDL_COPY_MODULATE_COLOR) {
   1.330                  srcR = (srcR * modulateR) / 255;
   1.331                  srcG = (srcG * modulateG) / 255;
   1.332 @@ -1664,7 +1669,7 @@
   1.333                  dstB = (srcB * dstB) / 255;
   1.334                  break;
   1.335              }
   1.336 -            dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
   1.337 +            dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
   1.338              *dst = dstpixel;
   1.339              ++src;
   1.340              ++dst;
   1.341 @@ -1674,7 +1679,7 @@
   1.342      }
   1.343  }
   1.344  
   1.345 -static void SDL_Blit_BGR888_BGR888_Modulate_Blend_Scale(SDL_BlitInfo *info)
   1.346 +static void SDL_Blit_BGR888_RGB888_Modulate_Blend_Scale(SDL_BlitInfo *info)
   1.347  {
   1.348      const int flags = info->flags;
   1.349      const Uint32 modulateR = info->r;
   1.350 @@ -1715,7 +1720,7 @@
   1.351              srcpixel = *src;
   1.352              srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = 0xFF;
   1.353              dstpixel = *dst;
   1.354 -            dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
   1.355 +            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
   1.356              if (flags & SDL_COPY_MODULATE_COLOR) {
   1.357                  srcR = (srcR * modulateR) / 255;
   1.358                  srcG = (srcG * modulateG) / 255;
   1.359 @@ -1756,7 +1761,7 @@
   1.360                  dstB = (srcB * dstB) / 255;
   1.361                  break;
   1.362              }
   1.363 -            dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
   1.364 +            dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
   1.365              *dst = dstpixel;
   1.366              posx += incx;
   1.367              ++dst;
   1.368 @@ -1766,11 +1771,9 @@
   1.369      }
   1.370  }
   1.371  
   1.372 -static void SDL_Blit_ARGB8888_RGB888_Scale(SDL_BlitInfo *info)
   1.373 -{
   1.374 -    const int flags = info->flags;
   1.375 -    Uint32 pixel;
   1.376 -    Uint32 R, G, B, A;
   1.377 +static void SDL_Blit_BGR888_BGR888_Scale(SDL_BlitInfo *info)
   1.378 +{
   1.379 +    const int flags = info->flags;
   1.380      int srcy, srcx;
   1.381      int posy, posx;
   1.382      int incy, incx;
   1.383 @@ -1798,10 +1801,7 @@
   1.384                  }
   1.385                  src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
   1.386              }
   1.387 -            pixel = *src;
   1.388 -            A = (Uint8)(pixel >> 24); R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel;
   1.389 -            pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B;
   1.390 -            *dst = pixel;
   1.391 +            *dst = *src;
   1.392              posx += incx;
   1.393              ++dst;
   1.394          }
   1.395 @@ -1810,7 +1810,7 @@
   1.396      }
   1.397  }
   1.398  
   1.399 -static void SDL_Blit_ARGB8888_RGB888_Blend(SDL_BlitInfo *info)
   1.400 +static void SDL_Blit_BGR888_BGR888_Blend(SDL_BlitInfo *info)
   1.401  {
   1.402      const int flags = info->flags;
   1.403      Uint32 srcpixel;
   1.404 @@ -1824,9 +1824,9 @@
   1.405          int n = info->dst_w;
   1.406          while (n--) {
   1.407              srcpixel = *src;
   1.408 -            srcA = (Uint8)(srcpixel >> 24); srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel;
   1.409 +            srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = 0xFF;
   1.410              dstpixel = *dst;
   1.411 -            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
   1.412 +            dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
   1.413              if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
   1.414                  /* This goes away if we ever use premultiplied alpha */
   1.415                  if (srcA < 255) {
   1.416 @@ -1859,7 +1859,7 @@
   1.417                  dstB = (srcB * dstB) / 255;
   1.418                  break;
   1.419              }
   1.420 -            dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
   1.421 +            dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
   1.422              *dst = dstpixel;
   1.423              ++src;
   1.424              ++dst;
   1.425 @@ -1869,7 +1869,7 @@
   1.426      }
   1.427  }
   1.428  
   1.429 -static void SDL_Blit_ARGB8888_RGB888_Blend_Scale(SDL_BlitInfo *info)
   1.430 +static void SDL_Blit_BGR888_BGR888_Blend_Scale(SDL_BlitInfo *info)
   1.431  {
   1.432      const int flags = info->flags;
   1.433      Uint32 srcpixel;
   1.434 @@ -1904,9 +1904,9 @@
   1.435                  src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
   1.436              }
   1.437              srcpixel = *src;
   1.438 -            srcA = (Uint8)(srcpixel >> 24); srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel;
   1.439 +            srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = 0xFF;
   1.440              dstpixel = *dst;
   1.441 -            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
   1.442 +            dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
   1.443              if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
   1.444                  /* This goes away if we ever use premultiplied alpha */
   1.445                  if (srcA < 255) {
   1.446 @@ -1939,7 +1939,7 @@
   1.447                  dstB = (srcB * dstB) / 255;
   1.448                  break;
   1.449              }
   1.450 -            dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
   1.451 +            dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
   1.452              *dst = dstpixel;
   1.453              posx += incx;
   1.454              ++dst;
   1.455 @@ -1949,7 +1949,7 @@
   1.456      }
   1.457  }
   1.458  
   1.459 -static void SDL_Blit_ARGB8888_RGB888_Modulate(SDL_BlitInfo *info)
   1.460 +static void SDL_Blit_BGR888_BGR888_Modulate(SDL_BlitInfo *info)
   1.461  {
   1.462      const int flags = info->flags;
   1.463      const Uint32 modulateR = info->r;
   1.464 @@ -1965,7 +1965,7 @@
   1.465          int n = info->dst_w;
   1.466          while (n--) {
   1.467              pixel = *src;
   1.468 -            A = (Uint8)(pixel >> 24); R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel;
   1.469 +            B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; A = 0xFF;
   1.470              if (flags & SDL_COPY_MODULATE_COLOR) {
   1.471                  R = (R * modulateR) / 255;
   1.472                  G = (G * modulateG) / 255;
   1.473 @@ -1974,7 +1974,7 @@
   1.474              if (flags & SDL_COPY_MODULATE_ALPHA) {
   1.475                  A = (A * modulateA) / 255;
   1.476              }
   1.477 -            pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B;
   1.478 +            pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R;
   1.479              *dst = pixel;
   1.480              ++src;
   1.481              ++dst;
   1.482 @@ -1984,7 +1984,7 @@
   1.483      }
   1.484  }
   1.485  
   1.486 -static void SDL_Blit_ARGB8888_RGB888_Modulate_Scale(SDL_BlitInfo *info)
   1.487 +static void SDL_Blit_BGR888_BGR888_Modulate_Scale(SDL_BlitInfo *info)
   1.488  {
   1.489      const int flags = info->flags;
   1.490      const Uint32 modulateR = info->r;
   1.491 @@ -2021,7 +2021,7 @@
   1.492                  src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
   1.493              }
   1.494              pixel = *src;
   1.495 -            A = (Uint8)(pixel >> 24); R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel;
   1.496 +            B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; A = 0xFF;
   1.497              if (flags & SDL_COPY_MODULATE_COLOR) {
   1.498                  R = (R * modulateR) / 255;
   1.499                  G = (G * modulateG) / 255;
   1.500 @@ -2030,7 +2030,7 @@
   1.501              if (flags & SDL_COPY_MODULATE_ALPHA) {
   1.502                  A = (A * modulateA) / 255;
   1.503              }
   1.504 -            pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B;
   1.505 +            pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R;
   1.506              *dst = pixel;
   1.507              posx += incx;
   1.508              ++dst;
   1.509 @@ -2040,7 +2040,7 @@
   1.510      }
   1.511  }
   1.512  
   1.513 -static void SDL_Blit_ARGB8888_RGB888_Modulate_Blend(SDL_BlitInfo *info)
   1.514 +static void SDL_Blit_BGR888_BGR888_Modulate_Blend(SDL_BlitInfo *info)
   1.515  {
   1.516      const int flags = info->flags;
   1.517      const Uint32 modulateR = info->r;
   1.518 @@ -2058,9 +2058,9 @@
   1.519          int n = info->dst_w;
   1.520          while (n--) {
   1.521              srcpixel = *src;
   1.522 -            srcA = (Uint8)(srcpixel >> 24); srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel;
   1.523 +            srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = 0xFF;
   1.524              dstpixel = *dst;
   1.525 -            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
   1.526 +            dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
   1.527              if (flags & SDL_COPY_MODULATE_COLOR) {
   1.528                  srcR = (srcR * modulateR) / 255;
   1.529                  srcG = (srcG * modulateG) / 255;
   1.530 @@ -2101,7 +2101,7 @@
   1.531                  dstB = (srcB * dstB) / 255;
   1.532                  break;
   1.533              }
   1.534 -            dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
   1.535 +            dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
   1.536              *dst = dstpixel;
   1.537              ++src;
   1.538              ++dst;
   1.539 @@ -2111,7 +2111,7 @@
   1.540      }
   1.541  }
   1.542  
   1.543 -static void SDL_Blit_ARGB8888_RGB888_Modulate_Blend_Scale(SDL_BlitInfo *info)
   1.544 +static void SDL_Blit_BGR888_BGR888_Modulate_Blend_Scale(SDL_BlitInfo *info)
   1.545  {
   1.546      const int flags = info->flags;
   1.547      const Uint32 modulateR = info->r;
   1.548 @@ -2150,9 +2150,9 @@
   1.549                  src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
   1.550              }
   1.551              srcpixel = *src;
   1.552 -            srcA = (Uint8)(srcpixel >> 24); srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel;
   1.553 +            srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = 0xFF;
   1.554              dstpixel = *dst;
   1.555 -            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
   1.556 +            dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
   1.557              if (flags & SDL_COPY_MODULATE_COLOR) {
   1.558                  srcR = (srcR * modulateR) / 255;
   1.559                  srcG = (srcG * modulateG) / 255;
   1.560 @@ -2193,7 +2193,7 @@
   1.561                  dstB = (srcB * dstB) / 255;
   1.562                  break;
   1.563              }
   1.564 -            dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
   1.565 +            dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
   1.566              *dst = dstpixel;
   1.567              posx += incx;
   1.568              ++dst;
   1.569 @@ -2203,7 +2203,7 @@
   1.570      }
   1.571  }
   1.572  
   1.573 -static void SDL_Blit_ARGB8888_BGR888_Scale(SDL_BlitInfo *info)
   1.574 +static void SDL_Blit_BGR888_ARGB8888_Scale(SDL_BlitInfo *info)
   1.575  {
   1.576      const int flags = info->flags;
   1.577      Uint32 pixel;
   1.578 @@ -2236,8 +2236,8 @@
   1.579                  src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
   1.580              }
   1.581              pixel = *src;
   1.582 -            A = (Uint8)(pixel >> 24); R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel;
   1.583 -            pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R;
   1.584 +            B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; A = 0xFF;
   1.585 +            pixel = ((Uint32)A << 24) | ((Uint32)R << 16) | ((Uint32)G << 8) | B;
   1.586              *dst = pixel;
   1.587              posx += incx;
   1.588              ++dst;
   1.589 @@ -2247,7 +2247,7 @@
   1.590      }
   1.591  }
   1.592  
   1.593 -static void SDL_Blit_ARGB8888_BGR888_Blend(SDL_BlitInfo *info)
   1.594 +static void SDL_Blit_BGR888_ARGB8888_Blend(SDL_BlitInfo *info)
   1.595  {
   1.596      const int flags = info->flags;
   1.597      Uint32 srcpixel;
   1.598 @@ -2261,9 +2261,9 @@
   1.599          int n = info->dst_w;
   1.600          while (n--) {
   1.601              srcpixel = *src;
   1.602 -            srcA = (Uint8)(srcpixel >> 24); srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel;
   1.603 +            srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = 0xFF;
   1.604              dstpixel = *dst;
   1.605 -            dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
   1.606 +            dstA = (Uint8)(dstpixel >> 24); dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
   1.607              if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
   1.608                  /* This goes away if we ever use premultiplied alpha */
   1.609                  if (srcA < 255) {
   1.610 @@ -2296,7 +2296,7 @@
   1.611                  dstB = (srcB * dstB) / 255;
   1.612                  break;
   1.613              }
   1.614 -            dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
   1.615 +            dstpixel = ((Uint32)dstA << 24) | ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
   1.616              *dst = dstpixel;
   1.617              ++src;
   1.618              ++dst;
   1.619 @@ -2306,7 +2306,7 @@
   1.620      }
   1.621  }
   1.622  
   1.623 -static void SDL_Blit_ARGB8888_BGR888_Blend_Scale(SDL_BlitInfo *info)
   1.624 +static void SDL_Blit_BGR888_ARGB8888_Blend_Scale(SDL_BlitInfo *info)
   1.625  {
   1.626      const int flags = info->flags;
   1.627      Uint32 srcpixel;
   1.628 @@ -2341,9 +2341,9 @@
   1.629                  src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
   1.630              }
   1.631              srcpixel = *src;
   1.632 -            srcA = (Uint8)(srcpixel >> 24); srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel;
   1.633 +            srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = 0xFF;
   1.634              dstpixel = *dst;
   1.635 -            dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
   1.636 +            dstA = (Uint8)(dstpixel >> 24); dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
   1.637              if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
   1.638                  /* This goes away if we ever use premultiplied alpha */
   1.639                  if (srcA < 255) {
   1.640 @@ -2376,7 +2376,7 @@
   1.641                  dstB = (srcB * dstB) / 255;
   1.642                  break;
   1.643              }
   1.644 -            dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
   1.645 +            dstpixel = ((Uint32)dstA << 24) | ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
   1.646              *dst = dstpixel;
   1.647              posx += incx;
   1.648              ++dst;
   1.649 @@ -2386,7 +2386,7 @@
   1.650      }
   1.651  }
   1.652  
   1.653 -static void SDL_Blit_ARGB8888_BGR888_Modulate(SDL_BlitInfo *info)
   1.654 +static void SDL_Blit_BGR888_ARGB8888_Modulate(SDL_BlitInfo *info)
   1.655  {
   1.656      const int flags = info->flags;
   1.657      const Uint32 modulateR = info->r;
   1.658 @@ -2402,7 +2402,7 @@
   1.659          int n = info->dst_w;
   1.660          while (n--) {
   1.661              pixel = *src;
   1.662 -            A = (Uint8)(pixel >> 24); R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel;
   1.663 +            B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; A = 0xFF;
   1.664              if (flags & SDL_COPY_MODULATE_COLOR) {
   1.665                  R = (R * modulateR) / 255;
   1.666                  G = (G * modulateG) / 255;
   1.667 @@ -2411,7 +2411,7 @@
   1.668              if (flags & SDL_COPY_MODULATE_ALPHA) {
   1.669                  A = (A * modulateA) / 255;
   1.670              }
   1.671 -            pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R;
   1.672 +            pixel = ((Uint32)A << 24) | ((Uint32)R << 16) | ((Uint32)G << 8) | B;
   1.673              *dst = pixel;
   1.674              ++src;
   1.675              ++dst;
   1.676 @@ -2421,7 +2421,7 @@
   1.677      }
   1.678  }
   1.679  
   1.680 -static void SDL_Blit_ARGB8888_BGR888_Modulate_Scale(SDL_BlitInfo *info)
   1.681 +static void SDL_Blit_BGR888_ARGB8888_Modulate_Scale(SDL_BlitInfo *info)
   1.682  {
   1.683      const int flags = info->flags;
   1.684      const Uint32 modulateR = info->r;
   1.685 @@ -2458,7 +2458,7 @@
   1.686                  src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
   1.687              }
   1.688              pixel = *src;
   1.689 -            A = (Uint8)(pixel >> 24); R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel;
   1.690 +            B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; A = 0xFF;
   1.691              if (flags & SDL_COPY_MODULATE_COLOR) {
   1.692                  R = (R * modulateR) / 255;
   1.693                  G = (G * modulateG) / 255;
   1.694 @@ -2467,7 +2467,7 @@
   1.695              if (flags & SDL_COPY_MODULATE_ALPHA) {
   1.696                  A = (A * modulateA) / 255;
   1.697              }
   1.698 -            pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R;
   1.699 +            pixel = ((Uint32)A << 24) | ((Uint32)R << 16) | ((Uint32)G << 8) | B;
   1.700              *dst = pixel;
   1.701              posx += incx;
   1.702              ++dst;
   1.703 @@ -2477,7 +2477,7 @@
   1.704      }
   1.705  }
   1.706  
   1.707 -static void SDL_Blit_ARGB8888_BGR888_Modulate_Blend(SDL_BlitInfo *info)
   1.708 +static void SDL_Blit_BGR888_ARGB8888_Modulate_Blend(SDL_BlitInfo *info)
   1.709  {
   1.710      const int flags = info->flags;
   1.711      const Uint32 modulateR = info->r;
   1.712 @@ -2495,9 +2495,9 @@
   1.713          int n = info->dst_w;
   1.714          while (n--) {
   1.715              srcpixel = *src;
   1.716 -            srcA = (Uint8)(srcpixel >> 24); srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel;
   1.717 +            srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = 0xFF;
   1.718              dstpixel = *dst;
   1.719 -            dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
   1.720 +            dstA = (Uint8)(dstpixel >> 24); dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
   1.721              if (flags & SDL_COPY_MODULATE_COLOR) {
   1.722                  srcR = (srcR * modulateR) / 255;
   1.723                  srcG = (srcG * modulateG) / 255;
   1.724 @@ -2538,7 +2538,7 @@
   1.725                  dstB = (srcB * dstB) / 255;
   1.726                  break;
   1.727              }
   1.728 -            dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
   1.729 +            dstpixel = ((Uint32)dstA << 24) | ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
   1.730              *dst = dstpixel;
   1.731              ++src;
   1.732              ++dst;
   1.733 @@ -2548,7 +2548,7 @@
   1.734      }
   1.735  }
   1.736  
   1.737 -static void SDL_Blit_ARGB8888_BGR888_Modulate_Blend_Scale(SDL_BlitInfo *info)
   1.738 +static void SDL_Blit_BGR888_ARGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
   1.739  {
   1.740      const int flags = info->flags;
   1.741      const Uint32 modulateR = info->r;
   1.742 @@ -2587,9 +2587,9 @@
   1.743                  src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
   1.744              }
   1.745              srcpixel = *src;
   1.746 -            srcA = (Uint8)(srcpixel >> 24); srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel;
   1.747 +            srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = 0xFF;
   1.748              dstpixel = *dst;
   1.749 -            dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
   1.750 +            dstA = (Uint8)(dstpixel >> 24); dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
   1.751              if (flags & SDL_COPY_MODULATE_COLOR) {
   1.752                  srcR = (srcR * modulateR) / 255;
   1.753                  srcG = (srcG * modulateG) / 255;
   1.754 @@ -2630,7 +2630,7 @@
   1.755                  dstB = (srcB * dstB) / 255;
   1.756                  break;
   1.757              }
   1.758 -            dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
   1.759 +            dstpixel = ((Uint32)dstA << 24) | ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
   1.760              *dst = dstpixel;
   1.761              posx += incx;
   1.762              ++dst;
   1.763 @@ -2640,7 +2640,7 @@
   1.764      }
   1.765  }
   1.766  
   1.767 -static void SDL_Blit_RGBA8888_RGB888_Scale(SDL_BlitInfo *info)
   1.768 +static void SDL_Blit_ARGB8888_RGB888_Scale(SDL_BlitInfo *info)
   1.769  {
   1.770      const int flags = info->flags;
   1.771      Uint32 pixel;
   1.772 @@ -2673,7 +2673,7 @@
   1.773                  src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
   1.774              }
   1.775              pixel = *src;
   1.776 -            R = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); B = (Uint8)(pixel >> 8); A = (Uint8)pixel;
   1.777 +            A = (Uint8)(pixel >> 24); R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel;
   1.778              pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B;
   1.779              *dst = pixel;
   1.780              posx += incx;
   1.781 @@ -2684,7 +2684,7 @@
   1.782      }
   1.783  }
   1.784  
   1.785 -static void SDL_Blit_RGBA8888_RGB888_Blend(SDL_BlitInfo *info)
   1.786 +static void SDL_Blit_ARGB8888_RGB888_Blend(SDL_BlitInfo *info)
   1.787  {
   1.788      const int flags = info->flags;
   1.789      Uint32 srcpixel;
   1.790 @@ -2698,7 +2698,7 @@
   1.791          int n = info->dst_w;
   1.792          while (n--) {
   1.793              srcpixel = *src;
   1.794 -            srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
   1.795 +            srcA = (Uint8)(srcpixel >> 24); srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel;
   1.796              dstpixel = *dst;
   1.797              dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
   1.798              if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
   1.799 @@ -2743,7 +2743,7 @@
   1.800      }
   1.801  }
   1.802  
   1.803 -static void SDL_Blit_RGBA8888_RGB888_Blend_Scale(SDL_BlitInfo *info)
   1.804 +static void SDL_Blit_ARGB8888_RGB888_Blend_Scale(SDL_BlitInfo *info)
   1.805  {
   1.806      const int flags = info->flags;
   1.807      Uint32 srcpixel;
   1.808 @@ -2778,7 +2778,7 @@
   1.809                  src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
   1.810              }
   1.811              srcpixel = *src;
   1.812 -            srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
   1.813 +            srcA = (Uint8)(srcpixel >> 24); srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel;
   1.814              dstpixel = *dst;
   1.815              dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
   1.816              if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
   1.817 @@ -2823,7 +2823,7 @@
   1.818      }
   1.819  }
   1.820  
   1.821 -static void SDL_Blit_RGBA8888_RGB888_Modulate(SDL_BlitInfo *info)
   1.822 +static void SDL_Blit_ARGB8888_RGB888_Modulate(SDL_BlitInfo *info)
   1.823  {
   1.824      const int flags = info->flags;
   1.825      const Uint32 modulateR = info->r;
   1.826 @@ -2839,7 +2839,7 @@
   1.827          int n = info->dst_w;
   1.828          while (n--) {
   1.829              pixel = *src;
   1.830 -            R = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); B = (Uint8)(pixel >> 8); A = (Uint8)pixel;
   1.831 +            A = (Uint8)(pixel >> 24); R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel;
   1.832              if (flags & SDL_COPY_MODULATE_COLOR) {
   1.833                  R = (R * modulateR) / 255;
   1.834                  G = (G * modulateG) / 255;
   1.835 @@ -2858,7 +2858,7 @@
   1.836      }
   1.837  }
   1.838  
   1.839 -static void SDL_Blit_RGBA8888_RGB888_Modulate_Scale(SDL_BlitInfo *info)
   1.840 +static void SDL_Blit_ARGB8888_RGB888_Modulate_Scale(SDL_BlitInfo *info)
   1.841  {
   1.842      const int flags = info->flags;
   1.843      const Uint32 modulateR = info->r;
   1.844 @@ -2895,7 +2895,7 @@
   1.845                  src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
   1.846              }
   1.847              pixel = *src;
   1.848 -            R = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); B = (Uint8)(pixel >> 8); A = (Uint8)pixel;
   1.849 +            A = (Uint8)(pixel >> 24); R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel;
   1.850              if (flags & SDL_COPY_MODULATE_COLOR) {
   1.851                  R = (R * modulateR) / 255;
   1.852                  G = (G * modulateG) / 255;
   1.853 @@ -2914,7 +2914,7 @@
   1.854      }
   1.855  }
   1.856  
   1.857 -static void SDL_Blit_RGBA8888_RGB888_Modulate_Blend(SDL_BlitInfo *info)
   1.858 +static void SDL_Blit_ARGB8888_RGB888_Modulate_Blend(SDL_BlitInfo *info)
   1.859  {
   1.860      const int flags = info->flags;
   1.861      const Uint32 modulateR = info->r;
   1.862 @@ -2932,7 +2932,7 @@
   1.863          int n = info->dst_w;
   1.864          while (n--) {
   1.865              srcpixel = *src;
   1.866 -            srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
   1.867 +            srcA = (Uint8)(srcpixel >> 24); srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel;
   1.868              dstpixel = *dst;
   1.869              dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
   1.870              if (flags & SDL_COPY_MODULATE_COLOR) {
   1.871 @@ -2985,7 +2985,7 @@
   1.872      }
   1.873  }
   1.874  
   1.875 -static void SDL_Blit_RGBA8888_RGB888_Modulate_Blend_Scale(SDL_BlitInfo *info)
   1.876 +static void SDL_Blit_ARGB8888_RGB888_Modulate_Blend_Scale(SDL_BlitInfo *info)
   1.877  {
   1.878      const int flags = info->flags;
   1.879      const Uint32 modulateR = info->r;
   1.880 @@ -3024,7 +3024,7 @@
   1.881                  src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
   1.882              }
   1.883              srcpixel = *src;
   1.884 -            srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
   1.885 +            srcA = (Uint8)(srcpixel >> 24); srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel;
   1.886              dstpixel = *dst;
   1.887              dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
   1.888              if (flags & SDL_COPY_MODULATE_COLOR) {
   1.889 @@ -3077,7 +3077,7 @@
   1.890      }
   1.891  }
   1.892  
   1.893 -static void SDL_Blit_RGBA8888_BGR888_Scale(SDL_BlitInfo *info)
   1.894 +static void SDL_Blit_ARGB8888_BGR888_Scale(SDL_BlitInfo *info)
   1.895  {
   1.896      const int flags = info->flags;
   1.897      Uint32 pixel;
   1.898 @@ -3110,7 +3110,7 @@
   1.899                  src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
   1.900              }
   1.901              pixel = *src;
   1.902 -            R = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); B = (Uint8)(pixel >> 8); A = (Uint8)pixel;
   1.903 +            A = (Uint8)(pixel >> 24); R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel;
   1.904              pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R;
   1.905              *dst = pixel;
   1.906              posx += incx;
   1.907 @@ -3121,7 +3121,7 @@
   1.908      }
   1.909  }
   1.910  
   1.911 -static void SDL_Blit_RGBA8888_BGR888_Blend(SDL_BlitInfo *info)
   1.912 +static void SDL_Blit_ARGB8888_BGR888_Blend(SDL_BlitInfo *info)
   1.913  {
   1.914      const int flags = info->flags;
   1.915      Uint32 srcpixel;
   1.916 @@ -3135,7 +3135,7 @@
   1.917          int n = info->dst_w;
   1.918          while (n--) {
   1.919              srcpixel = *src;
   1.920 -            srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
   1.921 +            srcA = (Uint8)(srcpixel >> 24); srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel;
   1.922              dstpixel = *dst;
   1.923              dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
   1.924              if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
   1.925 @@ -3180,7 +3180,7 @@
   1.926      }
   1.927  }
   1.928  
   1.929 -static void SDL_Blit_RGBA8888_BGR888_Blend_Scale(SDL_BlitInfo *info)
   1.930 +static void SDL_Blit_ARGB8888_BGR888_Blend_Scale(SDL_BlitInfo *info)
   1.931  {
   1.932      const int flags = info->flags;
   1.933      Uint32 srcpixel;
   1.934 @@ -3215,7 +3215,7 @@
   1.935                  src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
   1.936              }
   1.937              srcpixel = *src;
   1.938 -            srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
   1.939 +            srcA = (Uint8)(srcpixel >> 24); srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel;
   1.940              dstpixel = *dst;
   1.941              dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
   1.942              if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
   1.943 @@ -3260,7 +3260,7 @@
   1.944      }
   1.945  }
   1.946  
   1.947 -static void SDL_Blit_RGBA8888_BGR888_Modulate(SDL_BlitInfo *info)
   1.948 +static void SDL_Blit_ARGB8888_BGR888_Modulate(SDL_BlitInfo *info)
   1.949  {
   1.950      const int flags = info->flags;
   1.951      const Uint32 modulateR = info->r;
   1.952 @@ -3276,7 +3276,7 @@
   1.953          int n = info->dst_w;
   1.954          while (n--) {
   1.955              pixel = *src;
   1.956 -            R = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); B = (Uint8)(pixel >> 8); A = (Uint8)pixel;
   1.957 +            A = (Uint8)(pixel >> 24); R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel;
   1.958              if (flags & SDL_COPY_MODULATE_COLOR) {
   1.959                  R = (R * modulateR) / 255;
   1.960                  G = (G * modulateG) / 255;
   1.961 @@ -3295,7 +3295,7 @@
   1.962      }
   1.963  }
   1.964  
   1.965 -static void SDL_Blit_RGBA8888_BGR888_Modulate_Scale(SDL_BlitInfo *info)
   1.966 +static void SDL_Blit_ARGB8888_BGR888_Modulate_Scale(SDL_BlitInfo *info)
   1.967  {
   1.968      const int flags = info->flags;
   1.969      const Uint32 modulateR = info->r;
   1.970 @@ -3332,7 +3332,7 @@
   1.971                  src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
   1.972              }
   1.973              pixel = *src;
   1.974 -            R = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); B = (Uint8)(pixel >> 8); A = (Uint8)pixel;
   1.975 +            A = (Uint8)(pixel >> 24); R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel;
   1.976              if (flags & SDL_COPY_MODULATE_COLOR) {
   1.977                  R = (R * modulateR) / 255;
   1.978                  G = (G * modulateG) / 255;
   1.979 @@ -3351,7 +3351,7 @@
   1.980      }
   1.981  }
   1.982  
   1.983 -static void SDL_Blit_RGBA8888_BGR888_Modulate_Blend(SDL_BlitInfo *info)
   1.984 +static void SDL_Blit_ARGB8888_BGR888_Modulate_Blend(SDL_BlitInfo *info)
   1.985  {
   1.986      const int flags = info->flags;
   1.987      const Uint32 modulateR = info->r;
   1.988 @@ -3369,7 +3369,7 @@
   1.989          int n = info->dst_w;
   1.990          while (n--) {
   1.991              srcpixel = *src;
   1.992 -            srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
   1.993 +            srcA = (Uint8)(srcpixel >> 24); srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel;
   1.994              dstpixel = *dst;
   1.995              dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
   1.996              if (flags & SDL_COPY_MODULATE_COLOR) {
   1.997 @@ -3422,7 +3422,7 @@
   1.998      }
   1.999  }
  1.1000  
  1.1001 -static void SDL_Blit_RGBA8888_BGR888_Modulate_Blend_Scale(SDL_BlitInfo *info)
  1.1002 +static void SDL_Blit_ARGB8888_BGR888_Modulate_Blend_Scale(SDL_BlitInfo *info)
  1.1003  {
  1.1004      const int flags = info->flags;
  1.1005      const Uint32 modulateR = info->r;
  1.1006 @@ -3461,7 +3461,7 @@
  1.1007                  src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  1.1008              }
  1.1009              srcpixel = *src;
  1.1010 -            srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
  1.1011 +            srcA = (Uint8)(srcpixel >> 24); srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel;
  1.1012              dstpixel = *dst;
  1.1013              dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
  1.1014              if (flags & SDL_COPY_MODULATE_COLOR) {
  1.1015 @@ -3514,11 +3514,9 @@
  1.1016      }
  1.1017  }
  1.1018  
  1.1019 -static void SDL_Blit_ABGR8888_RGB888_Scale(SDL_BlitInfo *info)
  1.1020 -{
  1.1021 -    const int flags = info->flags;
  1.1022 -    Uint32 pixel;
  1.1023 -    Uint32 R, G, B, A;
  1.1024 +static void SDL_Blit_ARGB8888_ARGB8888_Scale(SDL_BlitInfo *info)
  1.1025 +{
  1.1026 +    const int flags = info->flags;
  1.1027      int srcy, srcx;
  1.1028      int posy, posx;
  1.1029      int incy, incx;
  1.1030 @@ -3546,10 +3544,7 @@
  1.1031                  }
  1.1032                  src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  1.1033              }
  1.1034 -            pixel = *src;
  1.1035 -            A = (Uint8)(pixel >> 24); B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel;
  1.1036 -            pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B;
  1.1037 -            *dst = pixel;
  1.1038 +            *dst = *src;
  1.1039              posx += incx;
  1.1040              ++dst;
  1.1041          }
  1.1042 @@ -3558,7 +3553,7 @@
  1.1043      }
  1.1044  }
  1.1045  
  1.1046 -static void SDL_Blit_ABGR8888_RGB888_Blend(SDL_BlitInfo *info)
  1.1047 +static void SDL_Blit_ARGB8888_ARGB8888_Blend(SDL_BlitInfo *info)
  1.1048  {
  1.1049      const int flags = info->flags;
  1.1050      Uint32 srcpixel;
  1.1051 @@ -3572,9 +3567,9 @@
  1.1052          int n = info->dst_w;
  1.1053          while (n--) {
  1.1054              srcpixel = *src;
  1.1055 -            srcA = (Uint8)(srcpixel >> 24); srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel;
  1.1056 +            srcA = (Uint8)(srcpixel >> 24); srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel;
  1.1057              dstpixel = *dst;
  1.1058 -            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
  1.1059 +            dstA = (Uint8)(dstpixel >> 24); dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
  1.1060              if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  1.1061                  /* This goes away if we ever use premultiplied alpha */
  1.1062                  if (srcA < 255) {
  1.1063 @@ -3607,7 +3602,7 @@
  1.1064                  dstB = (srcB * dstB) / 255;
  1.1065                  break;
  1.1066              }
  1.1067 -            dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
  1.1068 +            dstpixel = ((Uint32)dstA << 24) | ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
  1.1069              *dst = dstpixel;
  1.1070              ++src;
  1.1071              ++dst;
  1.1072 @@ -3617,7 +3612,7 @@
  1.1073      }
  1.1074  }
  1.1075  
  1.1076 -static void SDL_Blit_ABGR8888_RGB888_Blend_Scale(SDL_BlitInfo *info)
  1.1077 +static void SDL_Blit_ARGB8888_ARGB8888_Blend_Scale(SDL_BlitInfo *info)
  1.1078  {
  1.1079      const int flags = info->flags;
  1.1080      Uint32 srcpixel;
  1.1081 @@ -3652,9 +3647,9 @@
  1.1082                  src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  1.1083              }
  1.1084              srcpixel = *src;
  1.1085 -            srcA = (Uint8)(srcpixel >> 24); srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel;
  1.1086 +            srcA = (Uint8)(srcpixel >> 24); srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel;
  1.1087              dstpixel = *dst;
  1.1088 -            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
  1.1089 +            dstA = (Uint8)(dstpixel >> 24); dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
  1.1090              if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  1.1091                  /* This goes away if we ever use premultiplied alpha */
  1.1092                  if (srcA < 255) {
  1.1093 @@ -3687,7 +3682,7 @@
  1.1094                  dstB = (srcB * dstB) / 255;
  1.1095                  break;
  1.1096              }
  1.1097 -            dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
  1.1098 +            dstpixel = ((Uint32)dstA << 24) | ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
  1.1099              *dst = dstpixel;
  1.1100              posx += incx;
  1.1101              ++dst;
  1.1102 @@ -3697,7 +3692,7 @@
  1.1103      }
  1.1104  }
  1.1105  
  1.1106 -static void SDL_Blit_ABGR8888_RGB888_Modulate(SDL_BlitInfo *info)
  1.1107 +static void SDL_Blit_ARGB8888_ARGB8888_Modulate(SDL_BlitInfo *info)
  1.1108  {
  1.1109      const int flags = info->flags;
  1.1110      const Uint32 modulateR = info->r;
  1.1111 @@ -3713,7 +3708,7 @@
  1.1112          int n = info->dst_w;
  1.1113          while (n--) {
  1.1114              pixel = *src;
  1.1115 -            A = (Uint8)(pixel >> 24); B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel;
  1.1116 +            A = (Uint8)(pixel >> 24); R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel;
  1.1117              if (flags & SDL_COPY_MODULATE_COLOR) {
  1.1118                  R = (R * modulateR) / 255;
  1.1119                  G = (G * modulateG) / 255;
  1.1120 @@ -3722,7 +3717,7 @@
  1.1121              if (flags & SDL_COPY_MODULATE_ALPHA) {
  1.1122                  A = (A * modulateA) / 255;
  1.1123              }
  1.1124 -            pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B;
  1.1125 +            pixel = ((Uint32)A << 24) | ((Uint32)R << 16) | ((Uint32)G << 8) | B;
  1.1126              *dst = pixel;
  1.1127              ++src;
  1.1128              ++dst;
  1.1129 @@ -3732,7 +3727,7 @@
  1.1130      }
  1.1131  }
  1.1132  
  1.1133 -static void SDL_Blit_ABGR8888_RGB888_Modulate_Scale(SDL_BlitInfo *info)
  1.1134 +static void SDL_Blit_ARGB8888_ARGB8888_Modulate_Scale(SDL_BlitInfo *info)
  1.1135  {
  1.1136      const int flags = info->flags;
  1.1137      const Uint32 modulateR = info->r;
  1.1138 @@ -3769,7 +3764,7 @@
  1.1139                  src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  1.1140              }
  1.1141              pixel = *src;
  1.1142 -            A = (Uint8)(pixel >> 24); B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel;
  1.1143 +            A = (Uint8)(pixel >> 24); R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel;
  1.1144              if (flags & SDL_COPY_MODULATE_COLOR) {
  1.1145                  R = (R * modulateR) / 255;
  1.1146                  G = (G * modulateG) / 255;
  1.1147 @@ -3778,7 +3773,7 @@
  1.1148              if (flags & SDL_COPY_MODULATE_ALPHA) {
  1.1149                  A = (A * modulateA) / 255;
  1.1150              }
  1.1151 -            pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B;
  1.1152 +            pixel = ((Uint32)A << 24) | ((Uint32)R << 16) | ((Uint32)G << 8) | B;
  1.1153              *dst = pixel;
  1.1154              posx += incx;
  1.1155              ++dst;
  1.1156 @@ -3788,7 +3783,7 @@
  1.1157      }
  1.1158  }
  1.1159  
  1.1160 -static void SDL_Blit_ABGR8888_RGB888_Modulate_Blend(SDL_BlitInfo *info)
  1.1161 +static void SDL_Blit_ARGB8888_ARGB8888_Modulate_Blend(SDL_BlitInfo *info)
  1.1162  {
  1.1163      const int flags = info->flags;
  1.1164      const Uint32 modulateR = info->r;
  1.1165 @@ -3806,9 +3801,9 @@
  1.1166          int n = info->dst_w;
  1.1167          while (n--) {
  1.1168              srcpixel = *src;
  1.1169 -            srcA = (Uint8)(srcpixel >> 24); srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel;
  1.1170 +            srcA = (Uint8)(srcpixel >> 24); srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel;
  1.1171              dstpixel = *dst;
  1.1172 -            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
  1.1173 +            dstA = (Uint8)(dstpixel >> 24); dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
  1.1174              if (flags & SDL_COPY_MODULATE_COLOR) {
  1.1175                  srcR = (srcR * modulateR) / 255;
  1.1176                  srcG = (srcG * modulateG) / 255;
  1.1177 @@ -3849,7 +3844,7 @@
  1.1178                  dstB = (srcB * dstB) / 255;
  1.1179                  break;
  1.1180              }
  1.1181 -            dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
  1.1182 +            dstpixel = ((Uint32)dstA << 24) | ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
  1.1183              *dst = dstpixel;
  1.1184              ++src;
  1.1185              ++dst;
  1.1186 @@ -3859,7 +3854,7 @@
  1.1187      }
  1.1188  }
  1.1189  
  1.1190 -static void SDL_Blit_ABGR8888_RGB888_Modulate_Blend_Scale(SDL_BlitInfo *info)
  1.1191 +static void SDL_Blit_ARGB8888_ARGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
  1.1192  {
  1.1193      const int flags = info->flags;
  1.1194      const Uint32 modulateR = info->r;
  1.1195 @@ -3898,9 +3893,9 @@
  1.1196                  src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  1.1197              }
  1.1198              srcpixel = *src;
  1.1199 -            srcA = (Uint8)(srcpixel >> 24); srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel;
  1.1200 +            srcA = (Uint8)(srcpixel >> 24); srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel;
  1.1201              dstpixel = *dst;
  1.1202 -            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
  1.1203 +            dstA = (Uint8)(dstpixel >> 24); dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
  1.1204              if (flags & SDL_COPY_MODULATE_COLOR) {
  1.1205                  srcR = (srcR * modulateR) / 255;
  1.1206                  srcG = (srcG * modulateG) / 255;
  1.1207 @@ -3941,7 +3936,7 @@
  1.1208                  dstB = (srcB * dstB) / 255;
  1.1209                  break;
  1.1210              }
  1.1211 -            dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
  1.1212 +            dstpixel = ((Uint32)dstA << 24) | ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
  1.1213              *dst = dstpixel;
  1.1214              posx += incx;
  1.1215              ++dst;
  1.1216 @@ -3951,7 +3946,7 @@
  1.1217      }
  1.1218  }
  1.1219  
  1.1220 -static void SDL_Blit_ABGR8888_BGR888_Scale(SDL_BlitInfo *info)
  1.1221 +static void SDL_Blit_RGBA8888_RGB888_Scale(SDL_BlitInfo *info)
  1.1222  {
  1.1223      const int flags = info->flags;
  1.1224      Uint32 pixel;
  1.1225 @@ -3984,8 +3979,8 @@
  1.1226                  src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  1.1227              }
  1.1228              pixel = *src;
  1.1229 -            A = (Uint8)(pixel >> 24); B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel;
  1.1230 -            pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R;
  1.1231 +            R = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); B = (Uint8)(pixel >> 8); A = (Uint8)pixel;
  1.1232 +            pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B;
  1.1233              *dst = pixel;
  1.1234              posx += incx;
  1.1235              ++dst;
  1.1236 @@ -3995,7 +3990,7 @@
  1.1237      }
  1.1238  }
  1.1239  
  1.1240 -static void SDL_Blit_ABGR8888_BGR888_Blend(SDL_BlitInfo *info)
  1.1241 +static void SDL_Blit_RGBA8888_RGB888_Blend(SDL_BlitInfo *info)
  1.1242  {
  1.1243      const int flags = info->flags;
  1.1244      Uint32 srcpixel;
  1.1245 @@ -4009,9 +4004,9 @@
  1.1246          int n = info->dst_w;
  1.1247          while (n--) {
  1.1248              srcpixel = *src;
  1.1249 -            srcA = (Uint8)(srcpixel >> 24); srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel;
  1.1250 +            srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
  1.1251              dstpixel = *dst;
  1.1252 -            dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
  1.1253 +            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
  1.1254              if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  1.1255                  /* This goes away if we ever use premultiplied alpha */
  1.1256                  if (srcA < 255) {
  1.1257 @@ -4044,7 +4039,7 @@
  1.1258                  dstB = (srcB * dstB) / 255;
  1.1259                  break;
  1.1260              }
  1.1261 -            dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
  1.1262 +            dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
  1.1263              *dst = dstpixel;
  1.1264              ++src;
  1.1265              ++dst;
  1.1266 @@ -4054,7 +4049,7 @@
  1.1267      }
  1.1268  }
  1.1269  
  1.1270 -static void SDL_Blit_ABGR8888_BGR888_Blend_Scale(SDL_BlitInfo *info)
  1.1271 +static void SDL_Blit_RGBA8888_RGB888_Blend_Scale(SDL_BlitInfo *info)
  1.1272  {
  1.1273      const int flags = info->flags;
  1.1274      Uint32 srcpixel;
  1.1275 @@ -4089,9 +4084,9 @@
  1.1276                  src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  1.1277              }
  1.1278              srcpixel = *src;
  1.1279 -            srcA = (Uint8)(srcpixel >> 24); srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel;
  1.1280 +            srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
  1.1281              dstpixel = *dst;
  1.1282 -            dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
  1.1283 +            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
  1.1284              if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  1.1285                  /* This goes away if we ever use premultiplied alpha */
  1.1286                  if (srcA < 255) {
  1.1287 @@ -4124,7 +4119,7 @@
  1.1288                  dstB = (srcB * dstB) / 255;
  1.1289                  break;
  1.1290              }
  1.1291 -            dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
  1.1292 +            dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
  1.1293              *dst = dstpixel;
  1.1294              posx += incx;
  1.1295              ++dst;
  1.1296 @@ -4134,7 +4129,7 @@
  1.1297      }
  1.1298  }
  1.1299  
  1.1300 -static void SDL_Blit_ABGR8888_BGR888_Modulate(SDL_BlitInfo *info)
  1.1301 +static void SDL_Blit_RGBA8888_RGB888_Modulate(SDL_BlitInfo *info)
  1.1302  {
  1.1303      const int flags = info->flags;
  1.1304      const Uint32 modulateR = info->r;
  1.1305 @@ -4150,7 +4145,7 @@
  1.1306          int n = info->dst_w;
  1.1307          while (n--) {
  1.1308              pixel = *src;
  1.1309 -            A = (Uint8)(pixel >> 24); B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel;
  1.1310 +            R = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); B = (Uint8)(pixel >> 8); A = (Uint8)pixel;
  1.1311              if (flags & SDL_COPY_MODULATE_COLOR) {
  1.1312                  R = (R * modulateR) / 255;
  1.1313                  G = (G * modulateG) / 255;
  1.1314 @@ -4159,7 +4154,7 @@
  1.1315              if (flags & SDL_COPY_MODULATE_ALPHA) {
  1.1316                  A = (A * modulateA) / 255;
  1.1317              }
  1.1318 -            pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R;
  1.1319 +            pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B;
  1.1320              *dst = pixel;
  1.1321              ++src;
  1.1322              ++dst;
  1.1323 @@ -4169,7 +4164,7 @@
  1.1324      }
  1.1325  }
  1.1326  
  1.1327 -static void SDL_Blit_ABGR8888_BGR888_Modulate_Scale(SDL_BlitInfo *info)
  1.1328 +static void SDL_Blit_RGBA8888_RGB888_Modulate_Scale(SDL_BlitInfo *info)
  1.1329  {
  1.1330      const int flags = info->flags;
  1.1331      const Uint32 modulateR = info->r;
  1.1332 @@ -4206,7 +4201,7 @@
  1.1333                  src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  1.1334              }
  1.1335              pixel = *src;
  1.1336 -            A = (Uint8)(pixel >> 24); B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel;
  1.1337 +            R = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); B = (Uint8)(pixel >> 8); A = (Uint8)pixel;
  1.1338              if (flags & SDL_COPY_MODULATE_COLOR) {
  1.1339                  R = (R * modulateR) / 255;
  1.1340                  G = (G * modulateG) / 255;
  1.1341 @@ -4215,7 +4210,7 @@
  1.1342              if (flags & SDL_COPY_MODULATE_ALPHA) {
  1.1343                  A = (A * modulateA) / 255;
  1.1344              }
  1.1345 -            pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R;
  1.1346 +            pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B;
  1.1347              *dst = pixel;
  1.1348              posx += incx;
  1.1349              ++dst;
  1.1350 @@ -4225,7 +4220,7 @@
  1.1351      }
  1.1352  }
  1.1353  
  1.1354 -static void SDL_Blit_ABGR8888_BGR888_Modulate_Blend(SDL_BlitInfo *info)
  1.1355 +static void SDL_Blit_RGBA8888_RGB888_Modulate_Blend(SDL_BlitInfo *info)
  1.1356  {
  1.1357      const int flags = info->flags;
  1.1358      const Uint32 modulateR = info->r;
  1.1359 @@ -4243,9 +4238,9 @@
  1.1360          int n = info->dst_w;
  1.1361          while (n--) {
  1.1362              srcpixel = *src;
  1.1363 -            srcA = (Uint8)(srcpixel >> 24); srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel;
  1.1364 +            srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
  1.1365              dstpixel = *dst;
  1.1366 -            dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
  1.1367 +            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
  1.1368              if (flags & SDL_COPY_MODULATE_COLOR) {
  1.1369                  srcR = (srcR * modulateR) / 255;
  1.1370                  srcG = (srcG * modulateG) / 255;
  1.1371 @@ -4286,7 +4281,7 @@
  1.1372                  dstB = (srcB * dstB) / 255;
  1.1373                  break;
  1.1374              }
  1.1375 -            dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
  1.1376 +            dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
  1.1377              *dst = dstpixel;
  1.1378              ++src;
  1.1379              ++dst;
  1.1380 @@ -4296,7 +4291,7 @@
  1.1381      }
  1.1382  }
  1.1383  
  1.1384 -static void SDL_Blit_ABGR8888_BGR888_Modulate_Blend_Scale(SDL_BlitInfo *info)
  1.1385 +static void SDL_Blit_RGBA8888_RGB888_Modulate_Blend_Scale(SDL_BlitInfo *info)
  1.1386  {
  1.1387      const int flags = info->flags;
  1.1388      const Uint32 modulateR = info->r;
  1.1389 @@ -4335,9 +4330,9 @@
  1.1390                  src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  1.1391              }
  1.1392              srcpixel = *src;
  1.1393 -            srcA = (Uint8)(srcpixel >> 24); srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel;
  1.1394 +            srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
  1.1395              dstpixel = *dst;
  1.1396 -            dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
  1.1397 +            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
  1.1398              if (flags & SDL_COPY_MODULATE_COLOR) {
  1.1399                  srcR = (srcR * modulateR) / 255;
  1.1400                  srcG = (srcG * modulateG) / 255;
  1.1401 @@ -4378,7 +4373,7 @@
  1.1402                  dstB = (srcB * dstB) / 255;
  1.1403                  break;
  1.1404              }
  1.1405 -            dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
  1.1406 +            dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
  1.1407              *dst = dstpixel;
  1.1408              posx += incx;
  1.1409              ++dst;
  1.1410 @@ -4388,7 +4383,7 @@
  1.1411      }
  1.1412  }
  1.1413  
  1.1414 -static void SDL_Blit_BGRA8888_RGB888_Scale(SDL_BlitInfo *info)
  1.1415 +static void SDL_Blit_RGBA8888_BGR888_Scale(SDL_BlitInfo *info)
  1.1416  {
  1.1417      const int flags = info->flags;
  1.1418      Uint32 pixel;
  1.1419 @@ -4421,8 +4416,8 @@
  1.1420                  src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  1.1421              }
  1.1422              pixel = *src;
  1.1423 -            B = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); R = (Uint8)(pixel >> 8); A = (Uint8)pixel;
  1.1424 -            pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B;
  1.1425 +            R = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); B = (Uint8)(pixel >> 8); A = (Uint8)pixel;
  1.1426 +            pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R;
  1.1427              *dst = pixel;
  1.1428              posx += incx;
  1.1429              ++dst;
  1.1430 @@ -4432,7 +4427,7 @@
  1.1431      }
  1.1432  }
  1.1433  
  1.1434 -static void SDL_Blit_BGRA8888_RGB888_Blend(SDL_BlitInfo *info)
  1.1435 +static void SDL_Blit_RGBA8888_BGR888_Blend(SDL_BlitInfo *info)
  1.1436  {
  1.1437      const int flags = info->flags;
  1.1438      Uint32 srcpixel;
  1.1439 @@ -4446,9 +4441,9 @@
  1.1440          int n = info->dst_w;
  1.1441          while (n--) {
  1.1442              srcpixel = *src;
  1.1443 -            srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
  1.1444 +            srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
  1.1445              dstpixel = *dst;
  1.1446 -            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
  1.1447 +            dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
  1.1448              if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  1.1449                  /* This goes away if we ever use premultiplied alpha */
  1.1450                  if (srcA < 255) {
  1.1451 @@ -4481,7 +4476,7 @@
  1.1452                  dstB = (srcB * dstB) / 255;
  1.1453                  break;
  1.1454              }
  1.1455 -            dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
  1.1456 +            dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
  1.1457              *dst = dstpixel;
  1.1458              ++src;
  1.1459              ++dst;
  1.1460 @@ -4491,7 +4486,7 @@
  1.1461      }
  1.1462  }
  1.1463  
  1.1464 -static void SDL_Blit_BGRA8888_RGB888_Blend_Scale(SDL_BlitInfo *info)
  1.1465 +static void SDL_Blit_RGBA8888_BGR888_Blend_Scale(SDL_BlitInfo *info)
  1.1466  {
  1.1467      const int flags = info->flags;
  1.1468      Uint32 srcpixel;
  1.1469 @@ -4526,9 +4521,9 @@
  1.1470                  src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  1.1471              }
  1.1472              srcpixel = *src;
  1.1473 -            srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
  1.1474 +            srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
  1.1475              dstpixel = *dst;
  1.1476 -            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
  1.1477 +            dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
  1.1478              if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  1.1479                  /* This goes away if we ever use premultiplied alpha */
  1.1480                  if (srcA < 255) {
  1.1481 @@ -4561,7 +4556,7 @@
  1.1482                  dstB = (srcB * dstB) / 255;
  1.1483                  break;
  1.1484              }
  1.1485 -            dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
  1.1486 +            dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
  1.1487              *dst = dstpixel;
  1.1488              posx += incx;
  1.1489              ++dst;
  1.1490 @@ -4571,7 +4566,7 @@
  1.1491      }
  1.1492  }
  1.1493  
  1.1494 -static void SDL_Blit_BGRA8888_RGB888_Modulate(SDL_BlitInfo *info)
  1.1495 +static void SDL_Blit_RGBA8888_BGR888_Modulate(SDL_BlitInfo *info)
  1.1496  {
  1.1497      const int flags = info->flags;
  1.1498      const Uint32 modulateR = info->r;
  1.1499 @@ -4587,7 +4582,7 @@
  1.1500          int n = info->dst_w;
  1.1501          while (n--) {
  1.1502              pixel = *src;
  1.1503 -            B = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); R = (Uint8)(pixel >> 8); A = (Uint8)pixel;
  1.1504 +            R = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); B = (Uint8)(pixel >> 8); A = (Uint8)pixel;
  1.1505              if (flags & SDL_COPY_MODULATE_COLOR) {
  1.1506                  R = (R * modulateR) / 255;
  1.1507                  G = (G * modulateG) / 255;
  1.1508 @@ -4596,7 +4591,7 @@
  1.1509              if (flags & SDL_COPY_MODULATE_ALPHA) {
  1.1510                  A = (A * modulateA) / 255;
  1.1511              }
  1.1512 -            pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B;
  1.1513 +            pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R;
  1.1514              *dst = pixel;
  1.1515              ++src;
  1.1516              ++dst;
  1.1517 @@ -4606,7 +4601,7 @@
  1.1518      }
  1.1519  }
  1.1520  
  1.1521 -static void SDL_Blit_BGRA8888_RGB888_Modulate_Scale(SDL_BlitInfo *info)
  1.1522 +static void SDL_Blit_RGBA8888_BGR888_Modulate_Scale(SDL_BlitInfo *info)
  1.1523  {
  1.1524      const int flags = info->flags;
  1.1525      const Uint32 modulateR = info->r;
  1.1526 @@ -4643,7 +4638,7 @@
  1.1527                  src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  1.1528              }
  1.1529              pixel = *src;
  1.1530 -            B = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); R = (Uint8)(pixel >> 8); A = (Uint8)pixel;
  1.1531 +            R = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); B = (Uint8)(pixel >> 8); A = (Uint8)pixel;
  1.1532              if (flags & SDL_COPY_MODULATE_COLOR) {
  1.1533                  R = (R * modulateR) / 255;
  1.1534                  G = (G * modulateG) / 255;
  1.1535 @@ -4652,7 +4647,7 @@
  1.1536              if (flags & SDL_COPY_MODULATE_ALPHA) {
  1.1537                  A = (A * modulateA) / 255;
  1.1538              }
  1.1539 -            pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B;
  1.1540 +            pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R;
  1.1541              *dst = pixel;
  1.1542              posx += incx;
  1.1543              ++dst;
  1.1544 @@ -4662,7 +4657,7 @@
  1.1545      }
  1.1546  }
  1.1547  
  1.1548 -static void SDL_Blit_BGRA8888_RGB888_Modulate_Blend(SDL_BlitInfo *info)
  1.1549 +static void SDL_Blit_RGBA8888_BGR888_Modulate_Blend(SDL_BlitInfo *info)
  1.1550  {
  1.1551      const int flags = info->flags;
  1.1552      const Uint32 modulateR = info->r;
  1.1553 @@ -4680,9 +4675,9 @@
  1.1554          int n = info->dst_w;
  1.1555          while (n--) {
  1.1556              srcpixel = *src;
  1.1557 -            srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
  1.1558 +            srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
  1.1559              dstpixel = *dst;
  1.1560 -            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
  1.1561 +            dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
  1.1562              if (flags & SDL_COPY_MODULATE_COLOR) {
  1.1563                  srcR = (srcR * modulateR) / 255;
  1.1564                  srcG = (srcG * modulateG) / 255;
  1.1565 @@ -4723,7 +4718,7 @@
  1.1566                  dstB = (srcB * dstB) / 255;
  1.1567                  break;
  1.1568              }
  1.1569 -            dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
  1.1570 +            dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
  1.1571              *dst = dstpixel;
  1.1572              ++src;
  1.1573              ++dst;
  1.1574 @@ -4733,7 +4728,7 @@
  1.1575      }
  1.1576  }
  1.1577  
  1.1578 -static void SDL_Blit_BGRA8888_RGB888_Modulate_Blend_Scale(SDL_BlitInfo *info)
  1.1579 +static void SDL_Blit_RGBA8888_BGR888_Modulate_Blend_Scale(SDL_BlitInfo *info)
  1.1580  {
  1.1581      const int flags = info->flags;
  1.1582      const Uint32 modulateR = info->r;
  1.1583 @@ -4772,9 +4767,9 @@
  1.1584                  src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  1.1585              }
  1.1586              srcpixel = *src;
  1.1587 -            srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
  1.1588 +            srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
  1.1589              dstpixel = *dst;
  1.1590 -            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
  1.1591 +            dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
  1.1592              if (flags & SDL_COPY_MODULATE_COLOR) {
  1.1593                  srcR = (srcR * modulateR) / 255;
  1.1594                  srcG = (srcG * modulateG) / 255;
  1.1595 @@ -4815,7 +4810,7 @@
  1.1596                  dstB = (srcB * dstB) / 255;
  1.1597                  break;
  1.1598              }
  1.1599 -            dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
  1.1600 +            dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
  1.1601              *dst = dstpixel;
  1.1602              posx += incx;
  1.1603              ++dst;
  1.1604 @@ -4825,7 +4820,7 @@
  1.1605      }
  1.1606  }
  1.1607  
  1.1608 -static void SDL_Blit_BGRA8888_BGR888_Scale(SDL_BlitInfo *info)
  1.1609 +static void SDL_Blit_RGBA8888_ARGB8888_Scale(SDL_BlitInfo *info)
  1.1610  {
  1.1611      const int flags = info->flags;
  1.1612      Uint32 pixel;
  1.1613 @@ -4858,8 +4853,8 @@
  1.1614                  src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  1.1615              }
  1.1616              pixel = *src;
  1.1617 -            B = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); R = (Uint8)(pixel >> 8); A = (Uint8)pixel;
  1.1618 -            pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R;
  1.1619 +            R = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); B = (Uint8)(pixel >> 8); A = (Uint8)pixel;
  1.1620 +            pixel = ((Uint32)A << 24) | ((Uint32)R << 16) | ((Uint32)G << 8) | B;
  1.1621              *dst = pixel;
  1.1622              posx += incx;
  1.1623              ++dst;
  1.1624 @@ -4869,7 +4864,7 @@
  1.1625      }
  1.1626  }
  1.1627  
  1.1628 -static void SDL_Blit_BGRA8888_BGR888_Blend(SDL_BlitInfo *info)
  1.1629 +static void SDL_Blit_RGBA8888_ARGB8888_Blend(SDL_BlitInfo *info)
  1.1630  {
  1.1631      const int flags = info->flags;
  1.1632      Uint32 srcpixel;
  1.1633 @@ -4883,9 +4878,9 @@
  1.1634          int n = info->dst_w;
  1.1635          while (n--) {
  1.1636              srcpixel = *src;
  1.1637 -            srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
  1.1638 +            srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
  1.1639              dstpixel = *dst;
  1.1640 -            dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
  1.1641 +            dstA = (Uint8)(dstpixel >> 24); dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
  1.1642              if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  1.1643                  /* This goes away if we ever use premultiplied alpha */
  1.1644                  if (srcA < 255) {
  1.1645 @@ -4918,7 +4913,7 @@
  1.1646                  dstB = (srcB * dstB) / 255;
  1.1647                  break;
  1.1648              }
  1.1649 -            dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
  1.1650 +            dstpixel = ((Uint32)dstA << 24) | ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
  1.1651              *dst = dstpixel;
  1.1652              ++src;
  1.1653              ++dst;
  1.1654 @@ -4928,7 +4923,7 @@
  1.1655      }
  1.1656  }
  1.1657  
  1.1658 -static void SDL_Blit_BGRA8888_BGR888_Blend_Scale(SDL_BlitInfo *info)
  1.1659 +static void SDL_Blit_RGBA8888_ARGB8888_Blend_Scale(SDL_BlitInfo *info)
  1.1660  {
  1.1661      const int flags = info->flags;
  1.1662      Uint32 srcpixel;
  1.1663 @@ -4963,9 +4958,9 @@
  1.1664                  src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  1.1665              }
  1.1666              srcpixel = *src;
  1.1667 -            srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
  1.1668 +            srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
  1.1669              dstpixel = *dst;
  1.1670 -            dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
  1.1671 +            dstA = (Uint8)(dstpixel >> 24); dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
  1.1672              if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  1.1673                  /* This goes away if we ever use premultiplied alpha */
  1.1674                  if (srcA < 255) {
  1.1675 @@ -4998,7 +4993,7 @@
  1.1676                  dstB = (srcB * dstB) / 255;
  1.1677                  break;
  1.1678              }
  1.1679 -            dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
  1.1680 +            dstpixel = ((Uint32)dstA << 24) | ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
  1.1681              *dst = dstpixel;
  1.1682              posx += incx;
  1.1683              ++dst;
  1.1684 @@ -5008,7 +5003,7 @@
  1.1685      }
  1.1686  }
  1.1687  
  1.1688 -static void SDL_Blit_BGRA8888_BGR888_Modulate(SDL_BlitInfo *info)
  1.1689 +static void SDL_Blit_RGBA8888_ARGB8888_Modulate(SDL_BlitInfo *info)
  1.1690  {
  1.1691      const int flags = info->flags;
  1.1692      const Uint32 modulateR = info->r;
  1.1693 @@ -5024,7 +5019,7 @@
  1.1694          int n = info->dst_w;
  1.1695          while (n--) {
  1.1696              pixel = *src;
  1.1697 -            B = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); R = (Uint8)(pixel >> 8); A = (Uint8)pixel;
  1.1698 +            R = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); B = (Uint8)(pixel >> 8); A = (Uint8)pixel;
  1.1699              if (flags & SDL_COPY_MODULATE_COLOR) {
  1.1700                  R = (R * modulateR) / 255;
  1.1701                  G = (G * modulateG) / 255;
  1.1702 @@ -5033,7 +5028,7 @@
  1.1703              if (flags & SDL_COPY_MODULATE_ALPHA) {
  1.1704                  A = (A * modulateA) / 255;
  1.1705              }
  1.1706 -            pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R;
  1.1707 +            pixel = ((Uint32)A << 24) | ((Uint32)R << 16) | ((Uint32)G << 8) | B;
  1.1708              *dst = pixel;
  1.1709              ++src;
  1.1710              ++dst;
  1.1711 @@ -5043,7 +5038,7 @@
  1.1712      }
  1.1713  }
  1.1714  
  1.1715 -static void SDL_Blit_BGRA8888_BGR888_Modulate_Scale(SDL_BlitInfo *info)
  1.1716 +static void SDL_Blit_RGBA8888_ARGB8888_Modulate_Scale(SDL_BlitInfo *info)
  1.1717  {
  1.1718      const int flags = info->flags;
  1.1719      const Uint32 modulateR = info->r;
  1.1720 @@ -5080,7 +5075,7 @@
  1.1721                  src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  1.1722              }
  1.1723              pixel = *src;
  1.1724 -            B = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); R = (Uint8)(pixel >> 8); A = (Uint8)pixel;
  1.1725 +            R = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); B = (Uint8)(pixel >> 8); A = (Uint8)pixel;
  1.1726              if (flags & SDL_COPY_MODULATE_COLOR) {
  1.1727                  R = (R * modulateR) / 255;
  1.1728                  G = (G * modulateG) / 255;
  1.1729 @@ -5089,7 +5084,7 @@
  1.1730              if (flags & SDL_COPY_MODULATE_ALPHA) {
  1.1731                  A = (A * modulateA) / 255;
  1.1732              }
  1.1733 -            pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R;
  1.1734 +            pixel = ((Uint32)A << 24) | ((Uint32)R << 16) | ((Uint32)G << 8) | B;
  1.1735              *dst = pixel;
  1.1736              posx += incx;
  1.1737              ++dst;
  1.1738 @@ -5099,7 +5094,7 @@
  1.1739      }
  1.1740  }
  1.1741  
  1.1742 -static void SDL_Blit_BGRA8888_BGR888_Modulate_Blend(SDL_BlitInfo *info)
  1.1743 +static void SDL_Blit_RGBA8888_ARGB8888_Modulate_Blend(SDL_BlitInfo *info)
  1.1744  {
  1.1745      const int flags = info->flags;
  1.1746      const Uint32 modulateR = info->r;
  1.1747 @@ -5117,9 +5112,9 @@
  1.1748          int n = info->dst_w;
  1.1749          while (n--) {
  1.1750              srcpixel = *src;
  1.1751 -            srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
  1.1752 +            srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
  1.1753              dstpixel = *dst;
  1.1754 -            dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
  1.1755 +            dstA = (Uint8)(dstpixel >> 24); dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
  1.1756              if (flags & SDL_COPY_MODULATE_COLOR) {
  1.1757                  srcR = (srcR * modulateR) / 255;
  1.1758                  srcG = (srcG * modulateG) / 255;
  1.1759 @@ -5160,7 +5155,7 @@
  1.1760                  dstB = (srcB * dstB) / 255;
  1.1761                  break;
  1.1762              }
  1.1763 -            dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
  1.1764 +            dstpixel = ((Uint32)dstA << 24) | ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
  1.1765              *dst = dstpixel;
  1.1766              ++src;
  1.1767              ++dst;
  1.1768 @@ -5170,7 +5165,7 @@
  1.1769      }
  1.1770  }
  1.1771  
  1.1772 -static void SDL_Blit_BGRA8888_BGR888_Modulate_Blend_Scale(SDL_BlitInfo *info)
  1.1773 +static void SDL_Blit_RGBA8888_ARGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
  1.1774  {
  1.1775      const int flags = info->flags;
  1.1776      const Uint32 modulateR = info->r;
  1.1777 @@ -5209,6 +5204,2099 @@
  1.1778                  src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  1.1779              }
  1.1780              srcpixel = *src;
  1.1781 +            srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
  1.1782 +            dstpixel = *dst;
  1.1783 +            dstA = (Uint8)(dstpixel >> 24); dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
  1.1784 +            if (flags & SDL_COPY_MODULATE_COLOR) {
  1.1785 +                srcR = (srcR * modulateR) / 255;
  1.1786 +                srcG = (srcG * modulateG) / 255;
  1.1787 +                srcB = (srcB * modulateB) / 255;
  1.1788 +            }
  1.1789 +            if (flags & SDL_COPY_MODULATE_ALPHA) {
  1.1790 +                srcA = (srcA * modulateA) / 255;
  1.1791 +            }
  1.1792 +            if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  1.1793 +                /* This goes away if we ever use premultiplied alpha */
  1.1794 +                if (srcA < 255) {
  1.1795 +                    srcR = (srcR * srcA) / 255;
  1.1796 +                    srcG = (srcG * srcA) / 255;
  1.1797 +                    srcB = (srcB * srcA) / 255;
  1.1798 +                }
  1.1799 +            }
  1.1800 +            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
  1.1801 +            case SDL_COPY_MASK:
  1.1802 +                if (srcA) {
  1.1803 +                    dstR = srcR;
  1.1804 +                    dstG = srcG;
  1.1805 +                    dstB = srcB;
  1.1806 +                }
  1.1807 +                break;
  1.1808 +            case SDL_COPY_BLEND:
  1.1809 +                dstR = srcR + ((255 - srcA) * dstR) / 255;
  1.1810 +                dstG = srcG + ((255 - srcA) * dstG) / 255;
  1.1811 +                dstB = srcB + ((255 - srcA) * dstB) / 255;
  1.1812 +                break;
  1.1813 +            case SDL_COPY_ADD:
  1.1814 +                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  1.1815 +                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  1.1816 +                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  1.1817 +                break;
  1.1818 +            case SDL_COPY_MOD:
  1.1819 +                dstR = (srcR * dstR) / 255;
  1.1820 +                dstG = (srcG * dstG) / 255;
  1.1821 +                dstB = (srcB * dstB) / 255;
  1.1822 +                break;
  1.1823 +            }
  1.1824 +            dstpixel = ((Uint32)dstA << 24) | ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
  1.1825 +            *dst = dstpixel;
  1.1826 +            posx += incx;
  1.1827 +            ++dst;
  1.1828 +        }
  1.1829 +        posy += incy;
  1.1830 +        info->dst += info->dst_pitch;
  1.1831 +    }
  1.1832 +}
  1.1833 +
  1.1834 +static void SDL_Blit_ABGR8888_RGB888_Scale(SDL_BlitInfo *info)
  1.1835 +{
  1.1836 +    const int flags = info->flags;
  1.1837 +    Uint32 pixel;
  1.1838 +    Uint32 R, G, B, A;
  1.1839 +    int srcy, srcx;
  1.1840 +    int posy, posx;
  1.1841 +    int incy, incx;
  1.1842 +
  1.1843 +    srcy = 0;
  1.1844 +    posy = 0;
  1.1845 +    incy = (info->src_h << 16) / info->dst_h;
  1.1846 +    incx = (info->src_w << 16) / info->dst_w;
  1.1847 +
  1.1848 +    while (info->dst_h--) {
  1.1849 +        Uint32 *src;
  1.1850 +        Uint32 *dst = (Uint32 *)info->dst;
  1.1851 +        int n = info->dst_w;
  1.1852 +        srcx = -1;
  1.1853 +        posx = 0x10000L;
  1.1854 +        while (posy >= 0x10000L) {
  1.1855 +            ++srcy;
  1.1856 +            posy -= 0x10000L;
  1.1857 +        }
  1.1858 +        while (n--) {
  1.1859 +            if (posx >= 0x10000L) {
  1.1860 +                while (posx >= 0x10000L) {
  1.1861 +                    ++srcx;
  1.1862 +                    posx -= 0x10000L;
  1.1863 +                }
  1.1864 +                src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  1.1865 +            }
  1.1866 +            pixel = *src;
  1.1867 +            A = (Uint8)(pixel >> 24); B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel;
  1.1868 +            pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B;
  1.1869 +            *dst = pixel;
  1.1870 +            posx += incx;
  1.1871 +            ++dst;
  1.1872 +        }
  1.1873 +        posy += incy;
  1.1874 +        info->dst += info->dst_pitch;
  1.1875 +    }
  1.1876 +}
  1.1877 +
  1.1878 +static void SDL_Blit_ABGR8888_RGB888_Blend(SDL_BlitInfo *info)
  1.1879 +{
  1.1880 +    const int flags = info->flags;
  1.1881 +    Uint32 srcpixel;
  1.1882 +    Uint32 srcR, srcG, srcB, srcA;
  1.1883 +    Uint32 dstpixel;
  1.1884 +    Uint32 dstR, dstG, dstB, dstA;
  1.1885 +
  1.1886 +    while (info->dst_h--) {
  1.1887 +        Uint32 *src = (Uint32 *)info->src;
  1.1888 +        Uint32 *dst = (Uint32 *)info->dst;
  1.1889 +        int n = info->dst_w;
  1.1890 +        while (n--) {
  1.1891 +            srcpixel = *src;
  1.1892 +            srcA = (Uint8)(srcpixel >> 24); srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel;
  1.1893 +            dstpixel = *dst;
  1.1894 +            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
  1.1895 +            if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  1.1896 +                /* This goes away if we ever use premultiplied alpha */
  1.1897 +                if (srcA < 255) {
  1.1898 +                    srcR = (srcR * srcA) / 255;
  1.1899 +                    srcG = (srcG * srcA) / 255;
  1.1900 +                    srcB = (srcB * srcA) / 255;
  1.1901 +                }
  1.1902 +            }
  1.1903 +            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
  1.1904 +            case SDL_COPY_MASK:
  1.1905 +                if (srcA) {
  1.1906 +                    dstR = srcR;
  1.1907 +                    dstG = srcG;
  1.1908 +                    dstB = srcB;
  1.1909 +                }
  1.1910 +                break;
  1.1911 +            case SDL_COPY_BLEND:
  1.1912 +                dstR = srcR + ((255 - srcA) * dstR) / 255;
  1.1913 +                dstG = srcG + ((255 - srcA) * dstG) / 255;
  1.1914 +                dstB = srcB + ((255 - srcA) * dstB) / 255;
  1.1915 +                break;
  1.1916 +            case SDL_COPY_ADD:
  1.1917 +                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  1.1918 +                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  1.1919 +                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  1.1920 +                break;
  1.1921 +            case SDL_COPY_MOD:
  1.1922 +                dstR = (srcR * dstR) / 255;
  1.1923 +                dstG = (srcG * dstG) / 255;
  1.1924 +                dstB = (srcB * dstB) / 255;
  1.1925 +                break;
  1.1926 +            }
  1.1927 +            dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
  1.1928 +            *dst = dstpixel;
  1.1929 +            ++src;
  1.1930 +            ++dst;
  1.1931 +        }
  1.1932 +        info->src += info->src_pitch;
  1.1933 +        info->dst += info->dst_pitch;
  1.1934 +    }
  1.1935 +}
  1.1936 +
  1.1937 +static void SDL_Blit_ABGR8888_RGB888_Blend_Scale(SDL_BlitInfo *info)
  1.1938 +{
  1.1939 +    const int flags = info->flags;
  1.1940 +    Uint32 srcpixel;
  1.1941 +    Uint32 srcR, srcG, srcB, srcA;
  1.1942 +    Uint32 dstpixel;
  1.1943 +    Uint32 dstR, dstG, dstB, dstA;
  1.1944 +    int srcy, srcx;
  1.1945 +    int posy, posx;
  1.1946 +    int incy, incx;
  1.1947 +
  1.1948 +    srcy = 0;
  1.1949 +    posy = 0;
  1.1950 +    incy = (info->src_h << 16) / info->dst_h;
  1.1951 +    incx = (info->src_w << 16) / info->dst_w;
  1.1952 +
  1.1953 +    while (info->dst_h--) {
  1.1954 +        Uint32 *src;
  1.1955 +        Uint32 *dst = (Uint32 *)info->dst;
  1.1956 +        int n = info->dst_w;
  1.1957 +        srcx = -1;
  1.1958 +        posx = 0x10000L;
  1.1959 +        while (posy >= 0x10000L) {
  1.1960 +            ++srcy;
  1.1961 +            posy -= 0x10000L;
  1.1962 +        }
  1.1963 +        while (n--) {
  1.1964 +            if (posx >= 0x10000L) {
  1.1965 +                while (posx >= 0x10000L) {
  1.1966 +                    ++srcx;
  1.1967 +                    posx -= 0x10000L;
  1.1968 +                }
  1.1969 +                src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  1.1970 +            }
  1.1971 +            srcpixel = *src;
  1.1972 +            srcA = (Uint8)(srcpixel >> 24); srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel;
  1.1973 +            dstpixel = *dst;
  1.1974 +            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
  1.1975 +            if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  1.1976 +                /* This goes away if we ever use premultiplied alpha */
  1.1977 +                if (srcA < 255) {
  1.1978 +                    srcR = (srcR * srcA) / 255;
  1.1979 +                    srcG = (srcG * srcA) / 255;
  1.1980 +                    srcB = (srcB * srcA) / 255;
  1.1981 +                }
  1.1982 +            }
  1.1983 +            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
  1.1984 +            case SDL_COPY_MASK:
  1.1985 +                if (srcA) {
  1.1986 +                    dstR = srcR;
  1.1987 +                    dstG = srcG;
  1.1988 +                    dstB = srcB;
  1.1989 +                }
  1.1990 +                break;
  1.1991 +            case SDL_COPY_BLEND:
  1.1992 +                dstR = srcR + ((255 - srcA) * dstR) / 255;
  1.1993 +                dstG = srcG + ((255 - srcA) * dstG) / 255;
  1.1994 +                dstB = srcB + ((255 - srcA) * dstB) / 255;
  1.1995 +                break;
  1.1996 +            case SDL_COPY_ADD:
  1.1997 +                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  1.1998 +                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  1.1999 +                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  1.2000 +                break;
  1.2001 +            case SDL_COPY_MOD:
  1.2002 +                dstR = (srcR * dstR) / 255;
  1.2003 +                dstG = (srcG * dstG) / 255;
  1.2004 +                dstB = (srcB * dstB) / 255;
  1.2005 +                break;
  1.2006 +            }
  1.2007 +            dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
  1.2008 +            *dst = dstpixel;
  1.2009 +            posx += incx;
  1.2010 +            ++dst;
  1.2011 +        }
  1.2012 +        posy += incy;
  1.2013 +        info->dst += info->dst_pitch;
  1.2014 +    }
  1.2015 +}
  1.2016 +
  1.2017 +static void SDL_Blit_ABGR8888_RGB888_Modulate(SDL_BlitInfo *info)
  1.2018 +{
  1.2019 +    const int flags = info->flags;
  1.2020 +    const Uint32 modulateR = info->r;
  1.2021 +    const Uint32 modulateG = info->g;
  1.2022 +    const Uint32 modulateB = info->b;
  1.2023 +    const Uint32 modulateA = info->a;
  1.2024 +    Uint32 pixel;
  1.2025 +    Uint32 R, G, B, A;
  1.2026 +
  1.2027 +    while (info->dst_h--) {
  1.2028 +        Uint32 *src = (Uint32 *)info->src;
  1.2029 +        Uint32 *dst = (Uint32 *)info->dst;
  1.2030 +        int n = info->dst_w;
  1.2031 +        while (n--) {
  1.2032 +            pixel = *src;
  1.2033 +            A = (Uint8)(pixel >> 24); B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel;
  1.2034 +            if (flags & SDL_COPY_MODULATE_COLOR) {
  1.2035 +                R = (R * modulateR) / 255;
  1.2036 +                G = (G * modulateG) / 255;
  1.2037 +                B = (B * modulateB) / 255;
  1.2038 +            }
  1.2039 +            if (flags & SDL_COPY_MODULATE_ALPHA) {
  1.2040 +                A = (A * modulateA) / 255;
  1.2041 +            }
  1.2042 +            pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B;
  1.2043 +            *dst = pixel;
  1.2044 +            ++src;
  1.2045 +            ++dst;
  1.2046 +        }
  1.2047 +        info->src += info->src_pitch;
  1.2048 +        info->dst += info->dst_pitch;
  1.2049 +    }
  1.2050 +}
  1.2051 +
  1.2052 +static void SDL_Blit_ABGR8888_RGB888_Modulate_Scale(SDL_BlitInfo *info)
  1.2053 +{
  1.2054 +    const int flags = info->flags;
  1.2055 +    const Uint32 modulateR = info->r;
  1.2056 +    const Uint32 modulateG = info->g;
  1.2057 +    const Uint32 modulateB = info->b;
  1.2058 +    const Uint32 modulateA = info->a;
  1.2059 +    Uint32 pixel;
  1.2060 +    Uint32 R, G, B, A;
  1.2061 +    int srcy, srcx;
  1.2062 +    int posy, posx;
  1.2063 +    int incy, incx;
  1.2064 +
  1.2065 +    srcy = 0;
  1.2066 +    posy = 0;
  1.2067 +    incy = (info->src_h << 16) / info->dst_h;
  1.2068 +    incx = (info->src_w << 16) / info->dst_w;
  1.2069 +
  1.2070 +    while (info->dst_h--) {
  1.2071 +        Uint32 *src;
  1.2072 +        Uint32 *dst = (Uint32 *)info->dst;
  1.2073 +        int n = info->dst_w;
  1.2074 +        srcx = -1;
  1.2075 +        posx = 0x10000L;
  1.2076 +        while (posy >= 0x10000L) {
  1.2077 +            ++srcy;
  1.2078 +            posy -= 0x10000L;
  1.2079 +        }
  1.2080 +        while (n--) {
  1.2081 +            if (posx >= 0x10000L) {
  1.2082 +                while (posx >= 0x10000L) {
  1.2083 +                    ++srcx;
  1.2084 +                    posx -= 0x10000L;
  1.2085 +                }
  1.2086 +                src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  1.2087 +            }
  1.2088 +            pixel = *src;
  1.2089 +            A = (Uint8)(pixel >> 24); B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel;
  1.2090 +            if (flags & SDL_COPY_MODULATE_COLOR) {
  1.2091 +                R = (R * modulateR) / 255;
  1.2092 +                G = (G * modulateG) / 255;
  1.2093 +                B = (B * modulateB) / 255;
  1.2094 +            }
  1.2095 +            if (flags & SDL_COPY_MODULATE_ALPHA) {
  1.2096 +                A = (A * modulateA) / 255;
  1.2097 +            }
  1.2098 +            pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B;
  1.2099 +            *dst = pixel;
  1.2100 +            posx += incx;
  1.2101 +            ++dst;
  1.2102 +        }
  1.2103 +        posy += incy;
  1.2104 +        info->dst += info->dst_pitch;
  1.2105 +    }
  1.2106 +}
  1.2107 +
  1.2108 +static void SDL_Blit_ABGR8888_RGB888_Modulate_Blend(SDL_BlitInfo *info)
  1.2109 +{
  1.2110 +    const int flags = info->flags;
  1.2111 +    const Uint32 modulateR = info->r;
  1.2112 +    const Uint32 modulateG = info->g;
  1.2113 +    const Uint32 modulateB = info->b;
  1.2114 +    const Uint32 modulateA = info->a;
  1.2115 +    Uint32 srcpixel;
  1.2116 +    Uint32 srcR, srcG, srcB, srcA;
  1.2117 +    Uint32 dstpixel;
  1.2118 +    Uint32 dstR, dstG, dstB, dstA;
  1.2119 +
  1.2120 +    while (info->dst_h--) {
  1.2121 +        Uint32 *src = (Uint32 *)info->src;
  1.2122 +        Uint32 *dst = (Uint32 *)info->dst;
  1.2123 +        int n = info->dst_w;
  1.2124 +        while (n--) {
  1.2125 +            srcpixel = *src;
  1.2126 +            srcA = (Uint8)(srcpixel >> 24); srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel;
  1.2127 +            dstpixel = *dst;
  1.2128 +            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
  1.2129 +            if (flags & SDL_COPY_MODULATE_COLOR) {
  1.2130 +                srcR = (srcR * modulateR) / 255;
  1.2131 +                srcG = (srcG * modulateG) / 255;
  1.2132 +                srcB = (srcB * modulateB) / 255;
  1.2133 +            }
  1.2134 +            if (flags & SDL_COPY_MODULATE_ALPHA) {
  1.2135 +                srcA = (srcA * modulateA) / 255;
  1.2136 +            }
  1.2137 +            if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  1.2138 +                /* This goes away if we ever use premultiplied alpha */
  1.2139 +                if (srcA < 255) {
  1.2140 +                    srcR = (srcR * srcA) / 255;
  1.2141 +                    srcG = (srcG * srcA) / 255;
  1.2142 +                    srcB = (srcB * srcA) / 255;
  1.2143 +                }
  1.2144 +            }
  1.2145 +            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
  1.2146 +            case SDL_COPY_MASK:
  1.2147 +                if (srcA) {
  1.2148 +                    dstR = srcR;
  1.2149 +                    dstG = srcG;
  1.2150 +                    dstB = srcB;
  1.2151 +                }
  1.2152 +                break;
  1.2153 +            case SDL_COPY_BLEND:
  1.2154 +                dstR = srcR + ((255 - srcA) * dstR) / 255;
  1.2155 +                dstG = srcG + ((255 - srcA) * dstG) / 255;
  1.2156 +                dstB = srcB + ((255 - srcA) * dstB) / 255;
  1.2157 +                break;
  1.2158 +            case SDL_COPY_ADD:
  1.2159 +                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  1.2160 +                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  1.2161 +                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  1.2162 +                break;
  1.2163 +            case SDL_COPY_MOD:
  1.2164 +                dstR = (srcR * dstR) / 255;
  1.2165 +                dstG = (srcG * dstG) / 255;
  1.2166 +                dstB = (srcB * dstB) / 255;
  1.2167 +                break;
  1.2168 +            }
  1.2169 +            dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
  1.2170 +            *dst = dstpixel;
  1.2171 +            ++src;
  1.2172 +            ++dst;
  1.2173 +        }
  1.2174 +        info->src += info->src_pitch;
  1.2175 +        info->dst += info->dst_pitch;
  1.2176 +    }
  1.2177 +}
  1.2178 +
  1.2179 +static void SDL_Blit_ABGR8888_RGB888_Modulate_Blend_Scale(SDL_BlitInfo *info)
  1.2180 +{
  1.2181 +    const int flags = info->flags;
  1.2182 +    const Uint32 modulateR = info->r;
  1.2183 +    const Uint32 modulateG = info->g;
  1.2184 +    const Uint32 modulateB = info->b;
  1.2185 +    const Uint32 modulateA = info->a;
  1.2186 +    Uint32 srcpixel;
  1.2187 +    Uint32 srcR, srcG, srcB, srcA;
  1.2188 +    Uint32 dstpixel;
  1.2189 +    Uint32 dstR, dstG, dstB, dstA;
  1.2190 +    int srcy, srcx;
  1.2191 +    int posy, posx;
  1.2192 +    int incy, incx;
  1.2193 +
  1.2194 +    srcy = 0;
  1.2195 +    posy = 0;
  1.2196 +    incy = (info->src_h << 16) / info->dst_h;
  1.2197 +    incx = (info->src_w << 16) / info->dst_w;
  1.2198 +
  1.2199 +    while (info->dst_h--) {
  1.2200 +        Uint32 *src;
  1.2201 +        Uint32 *dst = (Uint32 *)info->dst;
  1.2202 +        int n = info->dst_w;
  1.2203 +        srcx = -1;
  1.2204 +        posx = 0x10000L;
  1.2205 +        while (posy >= 0x10000L) {
  1.2206 +            ++srcy;
  1.2207 +            posy -= 0x10000L;
  1.2208 +        }
  1.2209 +        while (n--) {
  1.2210 +            if (posx >= 0x10000L) {
  1.2211 +                while (posx >= 0x10000L) {
  1.2212 +                    ++srcx;
  1.2213 +                    posx -= 0x10000L;
  1.2214 +                }
  1.2215 +                src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  1.2216 +            }
  1.2217 +            srcpixel = *src;
  1.2218 +            srcA = (Uint8)(srcpixel >> 24); srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel;
  1.2219 +            dstpixel = *dst;
  1.2220 +            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
  1.2221 +            if (flags & SDL_COPY_MODULATE_COLOR) {
  1.2222 +                srcR = (srcR * modulateR) / 255;
  1.2223 +                srcG = (srcG * modulateG) / 255;
  1.2224 +                srcB = (srcB * modulateB) / 255;
  1.2225 +            }
  1.2226 +            if (flags & SDL_COPY_MODULATE_ALPHA) {
  1.2227 +                srcA = (srcA * modulateA) / 255;
  1.2228 +            }
  1.2229 +            if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  1.2230 +                /* This goes away if we ever use premultiplied alpha */
  1.2231 +                if (srcA < 255) {
  1.2232 +                    srcR = (srcR * srcA) / 255;
  1.2233 +                    srcG = (srcG * srcA) / 255;
  1.2234 +                    srcB = (srcB * srcA) / 255;
  1.2235 +                }
  1.2236 +            }
  1.2237 +            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
  1.2238 +            case SDL_COPY_MASK:
  1.2239 +                if (srcA) {
  1.2240 +                    dstR = srcR;
  1.2241 +                    dstG = srcG;
  1.2242 +                    dstB = srcB;
  1.2243 +                }
  1.2244 +                break;
  1.2245 +            case SDL_COPY_BLEND:
  1.2246 +                dstR = srcR + ((255 - srcA) * dstR) / 255;
  1.2247 +                dstG = srcG + ((255 - srcA) * dstG) / 255;
  1.2248 +                dstB = srcB + ((255 - srcA) * dstB) / 255;
  1.2249 +                break;
  1.2250 +            case SDL_COPY_ADD:
  1.2251 +                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  1.2252 +                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  1.2253 +                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  1.2254 +                break;
  1.2255 +            case SDL_COPY_MOD:
  1.2256 +                dstR = (srcR * dstR) / 255;
  1.2257 +                dstG = (srcG * dstG) / 255;
  1.2258 +                dstB = (srcB * dstB) / 255;
  1.2259 +                break;
  1.2260 +            }
  1.2261 +            dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
  1.2262 +            *dst = dstpixel;
  1.2263 +            posx += incx;
  1.2264 +            ++dst;
  1.2265 +        }
  1.2266 +        posy += incy;
  1.2267 +        info->dst += info->dst_pitch;
  1.2268 +    }
  1.2269 +}
  1.2270 +
  1.2271 +static void SDL_Blit_ABGR8888_BGR888_Scale(SDL_BlitInfo *info)
  1.2272 +{
  1.2273 +    const int flags = info->flags;
  1.2274 +    Uint32 pixel;
  1.2275 +    Uint32 R, G, B, A;
  1.2276 +    int srcy, srcx;
  1.2277 +    int posy, posx;
  1.2278 +    int incy, incx;
  1.2279 +
  1.2280 +    srcy = 0;
  1.2281 +    posy = 0;
  1.2282 +    incy = (info->src_h << 16) / info->dst_h;
  1.2283 +    incx = (info->src_w << 16) / info->dst_w;
  1.2284 +
  1.2285 +    while (info->dst_h--) {
  1.2286 +        Uint32 *src;
  1.2287 +        Uint32 *dst = (Uint32 *)info->dst;
  1.2288 +        int n = info->dst_w;
  1.2289 +        srcx = -1;
  1.2290 +        posx = 0x10000L;
  1.2291 +        while (posy >= 0x10000L) {
  1.2292 +            ++srcy;
  1.2293 +            posy -= 0x10000L;
  1.2294 +        }
  1.2295 +        while (n--) {
  1.2296 +            if (posx >= 0x10000L) {
  1.2297 +                while (posx >= 0x10000L) {
  1.2298 +                    ++srcx;
  1.2299 +                    posx -= 0x10000L;
  1.2300 +                }
  1.2301 +                src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  1.2302 +            }
  1.2303 +            pixel = *src;
  1.2304 +            A = (Uint8)(pixel >> 24); B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel;
  1.2305 +            pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R;
  1.2306 +            *dst = pixel;
  1.2307 +            posx += incx;
  1.2308 +            ++dst;
  1.2309 +        }
  1.2310 +        posy += incy;
  1.2311 +        info->dst += info->dst_pitch;
  1.2312 +    }
  1.2313 +}
  1.2314 +
  1.2315 +static void SDL_Blit_ABGR8888_BGR888_Blend(SDL_BlitInfo *info)
  1.2316 +{
  1.2317 +    const int flags = info->flags;
  1.2318 +    Uint32 srcpixel;
  1.2319 +    Uint32 srcR, srcG, srcB, srcA;
  1.2320 +    Uint32 dstpixel;
  1.2321 +    Uint32 dstR, dstG, dstB, dstA;
  1.2322 +
  1.2323 +    while (info->dst_h--) {
  1.2324 +        Uint32 *src = (Uint32 *)info->src;
  1.2325 +        Uint32 *dst = (Uint32 *)info->dst;
  1.2326 +        int n = info->dst_w;
  1.2327 +        while (n--) {
  1.2328 +            srcpixel = *src;
  1.2329 +            srcA = (Uint8)(srcpixel >> 24); srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel;
  1.2330 +            dstpixel = *dst;
  1.2331 +            dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
  1.2332 +            if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  1.2333 +                /* This goes away if we ever use premultiplied alpha */
  1.2334 +                if (srcA < 255) {
  1.2335 +                    srcR = (srcR * srcA) / 255;
  1.2336 +                    srcG = (srcG * srcA) / 255;
  1.2337 +                    srcB = (srcB * srcA) / 255;
  1.2338 +                }
  1.2339 +            }
  1.2340 +            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
  1.2341 +            case SDL_COPY_MASK:
  1.2342 +                if (srcA) {
  1.2343 +                    dstR = srcR;
  1.2344 +                    dstG = srcG;
  1.2345 +                    dstB = srcB;
  1.2346 +                }
  1.2347 +                break;
  1.2348 +            case SDL_COPY_BLEND:
  1.2349 +                dstR = srcR + ((255 - srcA) * dstR) / 255;
  1.2350 +                dstG = srcG + ((255 - srcA) * dstG) / 255;
  1.2351 +                dstB = srcB + ((255 - srcA) * dstB) / 255;
  1.2352 +                break;
  1.2353 +            case SDL_COPY_ADD:
  1.2354 +                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  1.2355 +                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  1.2356 +                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  1.2357 +                break;
  1.2358 +            case SDL_COPY_MOD:
  1.2359 +                dstR = (srcR * dstR) / 255;
  1.2360 +                dstG = (srcG * dstG) / 255;
  1.2361 +                dstB = (srcB * dstB) / 255;
  1.2362 +                break;
  1.2363 +            }
  1.2364 +            dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
  1.2365 +            *dst = dstpixel;
  1.2366 +            ++src;
  1.2367 +            ++dst;
  1.2368 +        }
  1.2369 +        info->src += info->src_pitch;
  1.2370 +        info->dst += info->dst_pitch;
  1.2371 +    }
  1.2372 +}
  1.2373 +
  1.2374 +static void SDL_Blit_ABGR8888_BGR888_Blend_Scale(SDL_BlitInfo *info)
  1.2375 +{
  1.2376 +    const int flags = info->flags;
  1.2377 +    Uint32 srcpixel;
  1.2378 +    Uint32 srcR, srcG, srcB, srcA;
  1.2379 +    Uint32 dstpixel;
  1.2380 +    Uint32 dstR, dstG, dstB, dstA;
  1.2381 +    int srcy, srcx;
  1.2382 +    int posy, posx;
  1.2383 +    int incy, incx;
  1.2384 +
  1.2385 +    srcy = 0;
  1.2386 +    posy = 0;
  1.2387 +    incy = (info->src_h << 16) / info->dst_h;
  1.2388 +    incx = (info->src_w << 16) / info->dst_w;
  1.2389 +
  1.2390 +    while (info->dst_h--) {
  1.2391 +        Uint32 *src;
  1.2392 +        Uint32 *dst = (Uint32 *)info->dst;
  1.2393 +        int n = info->dst_w;
  1.2394 +        srcx = -1;
  1.2395 +        posx = 0x10000L;
  1.2396 +        while (posy >= 0x10000L) {
  1.2397 +            ++srcy;
  1.2398 +            posy -= 0x10000L;
  1.2399 +        }
  1.2400 +        while (n--) {
  1.2401 +            if (posx >= 0x10000L) {
  1.2402 +                while (posx >= 0x10000L) {
  1.2403 +                    ++srcx;
  1.2404 +                    posx -= 0x10000L;
  1.2405 +                }
  1.2406 +                src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  1.2407 +            }
  1.2408 +            srcpixel = *src;
  1.2409 +            srcA = (Uint8)(srcpixel >> 24); srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel;
  1.2410 +            dstpixel = *dst;
  1.2411 +            dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
  1.2412 +            if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  1.2413 +                /* This goes away if we ever use premultiplied alpha */
  1.2414 +                if (srcA < 255) {
  1.2415 +                    srcR = (srcR * srcA) / 255;
  1.2416 +                    srcG = (srcG * srcA) / 255;
  1.2417 +                    srcB = (srcB * srcA) / 255;
  1.2418 +                }
  1.2419 +            }
  1.2420 +            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
  1.2421 +            case SDL_COPY_MASK:
  1.2422 +                if (srcA) {
  1.2423 +                    dstR = srcR;
  1.2424 +                    dstG = srcG;
  1.2425 +                    dstB = srcB;
  1.2426 +                }
  1.2427 +                break;
  1.2428 +            case SDL_COPY_BLEND:
  1.2429 +                dstR = srcR + ((255 - srcA) * dstR) / 255;
  1.2430 +                dstG = srcG + ((255 - srcA) * dstG) / 255;
  1.2431 +                dstB = srcB + ((255 - srcA) * dstB) / 255;
  1.2432 +                break;
  1.2433 +            case SDL_COPY_ADD:
  1.2434 +                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  1.2435 +                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  1.2436 +                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  1.2437 +                break;
  1.2438 +            case SDL_COPY_MOD:
  1.2439 +                dstR = (srcR * dstR) / 255;
  1.2440 +                dstG = (srcG * dstG) / 255;
  1.2441 +                dstB = (srcB * dstB) / 255;
  1.2442 +                break;
  1.2443 +            }
  1.2444 +            dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
  1.2445 +            *dst = dstpixel;
  1.2446 +            posx += incx;
  1.2447 +            ++dst;
  1.2448 +        }
  1.2449 +        posy += incy;
  1.2450 +        info->dst += info->dst_pitch;
  1.2451 +    }
  1.2452 +}
  1.2453 +
  1.2454 +static void SDL_Blit_ABGR8888_BGR888_Modulate(SDL_BlitInfo *info)
  1.2455 +{
  1.2456 +    const int flags = info->flags;
  1.2457 +    const Uint32 modulateR = info->r;
  1.2458 +    const Uint32 modulateG = info->g;
  1.2459 +    const Uint32 modulateB = info->b;
  1.2460 +    const Uint32 modulateA = info->a;
  1.2461 +    Uint32 pixel;
  1.2462 +    Uint32 R, G, B, A;
  1.2463 +
  1.2464 +    while (info->dst_h--) {
  1.2465 +        Uint32 *src = (Uint32 *)info->src;
  1.2466 +        Uint32 *dst = (Uint32 *)info->dst;
  1.2467 +        int n = info->dst_w;
  1.2468 +        while (n--) {
  1.2469 +            pixel = *src;
  1.2470 +            A = (Uint8)(pixel >> 24); B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel;
  1.2471 +            if (flags & SDL_COPY_MODULATE_COLOR) {
  1.2472 +                R = (R * modulateR) / 255;
  1.2473 +                G = (G * modulateG) / 255;
  1.2474 +                B = (B * modulateB) / 255;
  1.2475 +            }
  1.2476 +            if (flags & SDL_COPY_MODULATE_ALPHA) {
  1.2477 +                A = (A * modulateA) / 255;
  1.2478 +            }
  1.2479 +            pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R;
  1.2480 +            *dst = pixel;
  1.2481 +            ++src;
  1.2482 +            ++dst;
  1.2483 +        }
  1.2484 +        info->src += info->src_pitch;
  1.2485 +        info->dst += info->dst_pitch;
  1.2486 +    }
  1.2487 +}
  1.2488 +
  1.2489 +static void SDL_Blit_ABGR8888_BGR888_Modulate_Scale(SDL_BlitInfo *info)
  1.2490 +{
  1.2491 +    const int flags = info->flags;
  1.2492 +    const Uint32 modulateR = info->r;
  1.2493 +    const Uint32 modulateG = info->g;
  1.2494 +    const Uint32 modulateB = info->b;
  1.2495 +    const Uint32 modulateA = info->a;
  1.2496 +    Uint32 pixel;
  1.2497 +    Uint32 R, G, B, A;
  1.2498 +    int srcy, srcx;
  1.2499 +    int posy, posx;
  1.2500 +    int incy, incx;
  1.2501 +
  1.2502 +    srcy = 0;
  1.2503 +    posy = 0;
  1.2504 +    incy = (info->src_h << 16) / info->dst_h;
  1.2505 +    incx = (info->src_w << 16) / info->dst_w;
  1.2506 +
  1.2507 +    while (info->dst_h--) {
  1.2508 +        Uint32 *src;
  1.2509 +        Uint32 *dst = (Uint32 *)info->dst;
  1.2510 +        int n = info->dst_w;
  1.2511 +        srcx = -1;
  1.2512 +        posx = 0x10000L;
  1.2513 +        while (posy >= 0x10000L) {
  1.2514 +            ++srcy;
  1.2515 +            posy -= 0x10000L;
  1.2516 +        }
  1.2517 +        while (n--) {
  1.2518 +            if (posx >= 0x10000L) {
  1.2519 +                while (posx >= 0x10000L) {
  1.2520 +                    ++srcx;
  1.2521 +                    posx -= 0x10000L;
  1.2522 +                }
  1.2523 +                src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  1.2524 +            }
  1.2525 +            pixel = *src;
  1.2526 +            A = (Uint8)(pixel >> 24); B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel;
  1.2527 +            if (flags & SDL_COPY_MODULATE_COLOR) {
  1.2528 +                R = (R * modulateR) / 255;
  1.2529 +                G = (G * modulateG) / 255;
  1.2530 +                B = (B * modulateB) / 255;
  1.2531 +            }
  1.2532 +            if (flags & SDL_COPY_MODULATE_ALPHA) {
  1.2533 +                A = (A * modulateA) / 255;
  1.2534 +            }
  1.2535 +            pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R;
  1.2536 +            *dst = pixel;
  1.2537 +            posx += incx;
  1.2538 +            ++dst;
  1.2539 +        }
  1.2540 +        posy += incy;
  1.2541 +        info->dst += info->dst_pitch;
  1.2542 +    }
  1.2543 +}
  1.2544 +
  1.2545 +static void SDL_Blit_ABGR8888_BGR888_Modulate_Blend(SDL_BlitInfo *info)
  1.2546 +{
  1.2547 +    const int flags = info->flags;
  1.2548 +    const Uint32 modulateR = info->r;
  1.2549 +    const Uint32 modulateG = info->g;
  1.2550 +    const Uint32 modulateB = info->b;
  1.2551 +    const Uint32 modulateA = info->a;
  1.2552 +    Uint32 srcpixel;
  1.2553 +    Uint32 srcR, srcG, srcB, srcA;
  1.2554 +    Uint32 dstpixel;
  1.2555 +    Uint32 dstR, dstG, dstB, dstA;
  1.2556 +
  1.2557 +    while (info->dst_h--) {
  1.2558 +        Uint32 *src = (Uint32 *)info->src;
  1.2559 +        Uint32 *dst = (Uint32 *)info->dst;
  1.2560 +        int n = info->dst_w;
  1.2561 +        while (n--) {
  1.2562 +            srcpixel = *src;
  1.2563 +            srcA = (Uint8)(srcpixel >> 24); srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel;
  1.2564 +            dstpixel = *dst;
  1.2565 +            dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
  1.2566 +            if (flags & SDL_COPY_MODULATE_COLOR) {
  1.2567 +                srcR = (srcR * modulateR) / 255;
  1.2568 +                srcG = (srcG * modulateG) / 255;
  1.2569 +                srcB = (srcB * modulateB) / 255;
  1.2570 +            }
  1.2571 +            if (flags & SDL_COPY_MODULATE_ALPHA) {
  1.2572 +                srcA = (srcA * modulateA) / 255;
  1.2573 +            }
  1.2574 +            if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  1.2575 +                /* This goes away if we ever use premultiplied alpha */
  1.2576 +                if (srcA < 255) {
  1.2577 +                    srcR = (srcR * srcA) / 255;
  1.2578 +                    srcG = (srcG * srcA) / 255;
  1.2579 +                    srcB = (srcB * srcA) / 255;
  1.2580 +                }
  1.2581 +            }
  1.2582 +            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
  1.2583 +            case SDL_COPY_MASK:
  1.2584 +                if (srcA) {
  1.2585 +                    dstR = srcR;
  1.2586 +                    dstG = srcG;
  1.2587 +                    dstB = srcB;
  1.2588 +                }
  1.2589 +                break;
  1.2590 +            case SDL_COPY_BLEND:
  1.2591 +                dstR = srcR + ((255 - srcA) * dstR) / 255;
  1.2592 +                dstG = srcG + ((255 - srcA) * dstG) / 255;
  1.2593 +                dstB = srcB + ((255 - srcA) * dstB) / 255;
  1.2594 +                break;
  1.2595 +            case SDL_COPY_ADD:
  1.2596 +                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  1.2597 +                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  1.2598 +                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  1.2599 +                break;
  1.2600 +            case SDL_COPY_MOD:
  1.2601 +                dstR = (srcR * dstR) / 255;
  1.2602 +                dstG = (srcG * dstG) / 255;
  1.2603 +                dstB = (srcB * dstB) / 255;
  1.2604 +                break;
  1.2605 +            }
  1.2606 +            dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
  1.2607 +            *dst = dstpixel;
  1.2608 +            ++src;
  1.2609 +            ++dst;
  1.2610 +        }
  1.2611 +        info->src += info->src_pitch;
  1.2612 +        info->dst += info->dst_pitch;
  1.2613 +    }
  1.2614 +}
  1.2615 +
  1.2616 +static void SDL_Blit_ABGR8888_BGR888_Modulate_Blend_Scale(SDL_BlitInfo *info)
  1.2617 +{
  1.2618 +    const int flags = info->flags;
  1.2619 +    const Uint32 modulateR = info->r;
  1.2620 +    const Uint32 modulateG = info->g;
  1.2621 +    const Uint32 modulateB = info->b;
  1.2622 +    const Uint32 modulateA = info->a;
  1.2623 +    Uint32 srcpixel;
  1.2624 +    Uint32 srcR, srcG, srcB, srcA;
  1.2625 +    Uint32 dstpixel;
  1.2626 +    Uint32 dstR, dstG, dstB, dstA;
  1.2627 +    int srcy, srcx;
  1.2628 +    int posy, posx;
  1.2629 +    int incy, incx;
  1.2630 +
  1.2631 +    srcy = 0;
  1.2632 +    posy = 0;
  1.2633 +    incy = (info->src_h << 16) / info->dst_h;
  1.2634 +    incx = (info->src_w << 16) / info->dst_w;
  1.2635 +
  1.2636 +    while (info->dst_h--) {
  1.2637 +        Uint32 *src;
  1.2638 +        Uint32 *dst = (Uint32 *)info->dst;
  1.2639 +        int n = info->dst_w;
  1.2640 +        srcx = -1;
  1.2641 +        posx = 0x10000L;
  1.2642 +        while (posy >= 0x10000L) {
  1.2643 +            ++srcy;
  1.2644 +            posy -= 0x10000L;
  1.2645 +        }
  1.2646 +        while (n--) {
  1.2647 +            if (posx >= 0x10000L) {
  1.2648 +                while (posx >= 0x10000L) {
  1.2649 +                    ++srcx;
  1.2650 +                    posx -= 0x10000L;
  1.2651 +                }
  1.2652 +                src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  1.2653 +            }
  1.2654 +            srcpixel = *src;
  1.2655 +            srcA = (Uint8)(srcpixel >> 24); srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel;
  1.2656 +            dstpixel = *dst;
  1.2657 +            dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
  1.2658 +            if (flags & SDL_COPY_MODULATE_COLOR) {
  1.2659 +                srcR = (srcR * modulateR) / 255;
  1.2660 +                srcG = (srcG * modulateG) / 255;
  1.2661 +                srcB = (srcB * modulateB) / 255;
  1.2662 +            }
  1.2663 +            if (flags & SDL_COPY_MODULATE_ALPHA) {
  1.2664 +                srcA = (srcA * modulateA) / 255;
  1.2665 +            }
  1.2666 +            if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  1.2667 +                /* This goes away if we ever use premultiplied alpha */
  1.2668 +                if (srcA < 255) {
  1.2669 +                    srcR = (srcR * srcA) / 255;
  1.2670 +                    srcG = (srcG * srcA) / 255;
  1.2671 +                    srcB = (srcB * srcA) / 255;
  1.2672 +                }
  1.2673 +            }
  1.2674 +            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
  1.2675 +            case SDL_COPY_MASK:
  1.2676 +                if (srcA) {
  1.2677 +                    dstR = srcR;
  1.2678 +                    dstG = srcG;
  1.2679 +                    dstB = srcB;
  1.2680 +                }
  1.2681 +                break;
  1.2682 +            case SDL_COPY_BLEND:
  1.2683 +                dstR = srcR + ((255 - srcA) * dstR) / 255;
  1.2684 +                dstG = srcG + ((255 - srcA) * dstG) / 255;
  1.2685 +                dstB = srcB + ((255 - srcA) * dstB) / 255;
  1.2686 +                break;
  1.2687 +            case SDL_COPY_ADD:
  1.2688 +                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  1.2689 +                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  1.2690 +                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  1.2691 +                break;
  1.2692 +            case SDL_COPY_MOD:
  1.2693 +                dstR = (srcR * dstR) / 255;
  1.2694 +                dstG = (srcG * dstG) / 255;
  1.2695 +                dstB = (srcB * dstB) / 255;
  1.2696 +                break;
  1.2697 +            }
  1.2698 +            dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
  1.2699 +            *dst = dstpixel;
  1.2700 +            posx += incx;
  1.2701 +            ++dst;
  1.2702 +        }
  1.2703 +        posy += incy;
  1.2704 +        info->dst += info->dst_pitch;
  1.2705 +    }
  1.2706 +}
  1.2707 +
  1.2708 +static void SDL_Blit_ABGR8888_ARGB8888_Scale(SDL_BlitInfo *info)
  1.2709 +{
  1.2710 +    const int flags = info->flags;
  1.2711 +    Uint32 pixel;
  1.2712 +    Uint32 R, G, B, A;
  1.2713 +    int srcy, srcx;
  1.2714 +    int posy, posx;
  1.2715 +    int incy, incx;
  1.2716 +
  1.2717 +    srcy = 0;
  1.2718 +    posy = 0;
  1.2719 +    incy = (info->src_h << 16) / info->dst_h;
  1.2720 +    incx = (info->src_w << 16) / info->dst_w;
  1.2721 +
  1.2722 +    while (info->dst_h--) {
  1.2723 +        Uint32 *src;
  1.2724 +        Uint32 *dst = (Uint32 *)info->dst;
  1.2725 +        int n = info->dst_w;
  1.2726 +        srcx = -1;
  1.2727 +        posx = 0x10000L;
  1.2728 +        while (posy >= 0x10000L) {
  1.2729 +            ++srcy;
  1.2730 +            posy -= 0x10000L;
  1.2731 +        }
  1.2732 +        while (n--) {
  1.2733 +            if (posx >= 0x10000L) {
  1.2734 +                while (posx >= 0x10000L) {
  1.2735 +                    ++srcx;
  1.2736 +                    posx -= 0x10000L;
  1.2737 +                }
  1.2738 +                src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  1.2739 +            }
  1.2740 +            pixel = *src;
  1.2741 +            A = (Uint8)(pixel >> 24); B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel;
  1.2742 +            pixel = ((Uint32)A << 24) | ((Uint32)R << 16) | ((Uint32)G << 8) | B;
  1.2743 +            *dst = pixel;
  1.2744 +            posx += incx;
  1.2745 +            ++dst;
  1.2746 +        }
  1.2747 +        posy += incy;
  1.2748 +        info->dst += info->dst_pitch;
  1.2749 +    }
  1.2750 +}
  1.2751 +
  1.2752 +static void SDL_Blit_ABGR8888_ARGB8888_Blend(SDL_BlitInfo *info)
  1.2753 +{
  1.2754 +    const int flags = info->flags;
  1.2755 +    Uint32 srcpixel;
  1.2756 +    Uint32 srcR, srcG, srcB, srcA;
  1.2757 +    Uint32 dstpixel;
  1.2758 +    Uint32 dstR, dstG, dstB, dstA;
  1.2759 +
  1.2760 +    while (info->dst_h--) {
  1.2761 +        Uint32 *src = (Uint32 *)info->src;
  1.2762 +        Uint32 *dst = (Uint32 *)info->dst;
  1.2763 +        int n = info->dst_w;
  1.2764 +        while (n--) {
  1.2765 +            srcpixel = *src;
  1.2766 +            srcA = (Uint8)(srcpixel >> 24); srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel;
  1.2767 +            dstpixel = *dst;
  1.2768 +            dstA = (Uint8)(dstpixel >> 24); dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
  1.2769 +            if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  1.2770 +                /* This goes away if we ever use premultiplied alpha */
  1.2771 +                if (srcA < 255) {
  1.2772 +                    srcR = (srcR * srcA) / 255;
  1.2773 +                    srcG = (srcG * srcA) / 255;
  1.2774 +                    srcB = (srcB * srcA) / 255;
  1.2775 +                }
  1.2776 +            }
  1.2777 +            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
  1.2778 +            case SDL_COPY_MASK:
  1.2779 +                if (srcA) {
  1.2780 +                    dstR = srcR;
  1.2781 +                    dstG = srcG;
  1.2782 +                    dstB = srcB;
  1.2783 +                }
  1.2784 +                break;
  1.2785 +            case SDL_COPY_BLEND:
  1.2786 +                dstR = srcR + ((255 - srcA) * dstR) / 255;
  1.2787 +                dstG = srcG + ((255 - srcA) * dstG) / 255;
  1.2788 +                dstB = srcB + ((255 - srcA) * dstB) / 255;
  1.2789 +                break;
  1.2790 +            case SDL_COPY_ADD:
  1.2791 +                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  1.2792 +                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  1.2793 +                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  1.2794 +                break;
  1.2795 +            case SDL_COPY_MOD:
  1.2796 +                dstR = (srcR * dstR) / 255;
  1.2797 +                dstG = (srcG * dstG) / 255;
  1.2798 +                dstB = (srcB * dstB) / 255;
  1.2799 +                break;
  1.2800 +            }
  1.2801 +            dstpixel = ((Uint32)dstA << 24) | ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
  1.2802 +            *dst = dstpixel;
  1.2803 +            ++src;
  1.2804 +            ++dst;
  1.2805 +        }
  1.2806 +        info->src += info->src_pitch;
  1.2807 +        info->dst += info->dst_pitch;
  1.2808 +    }
  1.2809 +}
  1.2810 +
  1.2811 +static void SDL_Blit_ABGR8888_ARGB8888_Blend_Scale(SDL_BlitInfo *info)
  1.2812 +{
  1.2813 +    const int flags = info->flags;
  1.2814 +    Uint32 srcpixel;
  1.2815 +    Uint32 srcR, srcG, srcB, srcA;
  1.2816 +    Uint32 dstpixel;
  1.2817 +    Uint32 dstR, dstG, dstB, dstA;
  1.2818 +    int srcy, srcx;
  1.2819 +    int posy, posx;
  1.2820 +    int incy, incx;
  1.2821 +
  1.2822 +    srcy = 0;
  1.2823 +    posy = 0;
  1.2824 +    incy = (info->src_h << 16) / info->dst_h;
  1.2825 +    incx = (info->src_w << 16) / info->dst_w;
  1.2826 +
  1.2827 +    while (info->dst_h--) {
  1.2828 +        Uint32 *src;
  1.2829 +        Uint32 *dst = (Uint32 *)info->dst;
  1.2830 +        int n = info->dst_w;
  1.2831 +        srcx = -1;
  1.2832 +        posx = 0x10000L;
  1.2833 +        while (posy >= 0x10000L) {
  1.2834 +            ++srcy;
  1.2835 +            posy -= 0x10000L;
  1.2836 +        }
  1.2837 +        while (n--) {
  1.2838 +            if (posx >= 0x10000L) {
  1.2839 +                while (posx >= 0x10000L) {
  1.2840 +                    ++srcx;
  1.2841 +                    posx -= 0x10000L;
  1.2842 +                }
  1.2843 +                src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  1.2844 +            }
  1.2845 +            srcpixel = *src;
  1.2846 +            srcA = (Uint8)(srcpixel >> 24); srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel;
  1.2847 +            dstpixel = *dst;
  1.2848 +            dstA = (Uint8)(dstpixel >> 24); dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
  1.2849 +            if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  1.2850 +                /* This goes away if we ever use premultiplied alpha */
  1.2851 +                if (srcA < 255) {
  1.2852 +                    srcR = (srcR * srcA) / 255;
  1.2853 +                    srcG = (srcG * srcA) / 255;
  1.2854 +                    srcB = (srcB * srcA) / 255;
  1.2855 +                }
  1.2856 +            }
  1.2857 +            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
  1.2858 +            case SDL_COPY_MASK:
  1.2859 +                if (srcA) {
  1.2860 +                    dstR = srcR;
  1.2861 +                    dstG = srcG;
  1.2862 +                    dstB = srcB;
  1.2863 +                }
  1.2864 +                break;
  1.2865 +            case SDL_COPY_BLEND:
  1.2866 +                dstR = srcR + ((255 - srcA) * dstR) / 255;
  1.2867 +                dstG = srcG + ((255 - srcA) * dstG) / 255;
  1.2868 +                dstB = srcB + ((255 - srcA) * dstB) / 255;
  1.2869 +                break;
  1.2870 +            case SDL_COPY_ADD:
  1.2871 +                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  1.2872 +                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  1.2873 +                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  1.2874 +                break;
  1.2875 +            case SDL_COPY_MOD:
  1.2876 +                dstR = (srcR * dstR) / 255;
  1.2877 +                dstG = (srcG * dstG) / 255;
  1.2878 +                dstB = (srcB * dstB) / 255;
  1.2879 +                break;
  1.2880 +            }
  1.2881 +            dstpixel = ((Uint32)dstA << 24) | ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
  1.2882 +            *dst = dstpixel;
  1.2883 +            posx += incx;
  1.2884 +            ++dst;
  1.2885 +        }
  1.2886 +        posy += incy;
  1.2887 +        info->dst += info->dst_pitch;
  1.2888 +    }
  1.2889 +}
  1.2890 +
  1.2891 +static void SDL_Blit_ABGR8888_ARGB8888_Modulate(SDL_BlitInfo *info)
  1.2892 +{
  1.2893 +    const int flags = info->flags;
  1.2894 +    const Uint32 modulateR = info->r;
  1.2895 +    const Uint32 modulateG = info->g;
  1.2896 +    const Uint32 modulateB = info->b;
  1.2897 +    const Uint32 modulateA = info->a;
  1.2898 +    Uint32 pixel;
  1.2899 +    Uint32 R, G, B, A;
  1.2900 +
  1.2901 +    while (info->dst_h--) {
  1.2902 +        Uint32 *src = (Uint32 *)info->src;
  1.2903 +        Uint32 *dst = (Uint32 *)info->dst;
  1.2904 +        int n = info->dst_w;
  1.2905 +        while (n--) {
  1.2906 +            pixel = *src;
  1.2907 +            A = (Uint8)(pixel >> 24); B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel;
  1.2908 +            if (flags & SDL_COPY_MODULATE_COLOR) {
  1.2909 +                R = (R * modulateR) / 255;
  1.2910 +                G = (G * modulateG) / 255;
  1.2911 +                B = (B * modulateB) / 255;
  1.2912 +            }
  1.2913 +            if (flags & SDL_COPY_MODULATE_ALPHA) {
  1.2914 +                A = (A * modulateA) / 255;
  1.2915 +            }
  1.2916 +            pixel = ((Uint32)A << 24) | ((Uint32)R << 16) | ((Uint32)G << 8) | B;
  1.2917 +            *dst = pixel;
  1.2918 +            ++src;
  1.2919 +            ++dst;
  1.2920 +        }
  1.2921 +        info->src += info->src_pitch;
  1.2922 +        info->dst += info->dst_pitch;
  1.2923 +    }
  1.2924 +}
  1.2925 +
  1.2926 +static void SDL_Blit_ABGR8888_ARGB8888_Modulate_Scale(SDL_BlitInfo *info)
  1.2927 +{
  1.2928 +    const int flags = info->flags;
  1.2929 +    const Uint32 modulateR = info->r;
  1.2930 +    const Uint32 modulateG = info->g;
  1.2931 +    const Uint32 modulateB = info->b;
  1.2932 +    const Uint32 modulateA = info->a;
  1.2933 +    Uint32 pixel;
  1.2934 +    Uint32 R, G, B, A;
  1.2935 +    int srcy, srcx;
  1.2936 +    int posy, posx;
  1.2937 +    int incy, incx;
  1.2938 +
  1.2939 +    srcy = 0;
  1.2940 +    posy = 0;
  1.2941 +    incy = (info->src_h << 16) / info->dst_h;
  1.2942 +    incx = (info->src_w << 16) / info->dst_w;
  1.2943 +
  1.2944 +    while (info->dst_h--) {
  1.2945 +        Uint32 *src;
  1.2946 +        Uint32 *dst = (Uint32 *)info->dst;
  1.2947 +        int n = info->dst_w;
  1.2948 +        srcx = -1;
  1.2949 +        posx = 0x10000L;
  1.2950 +        while (posy >= 0x10000L) {
  1.2951 +            ++srcy;
  1.2952 +            posy -= 0x10000L;
  1.2953 +        }
  1.2954 +        while (n--) {
  1.2955 +            if (posx >= 0x10000L) {
  1.2956 +                while (posx >= 0x10000L) {
  1.2957 +                    ++srcx;
  1.2958 +                    posx -= 0x10000L;
  1.2959 +                }
  1.2960 +                src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  1.2961 +            }
  1.2962 +            pixel = *src;
  1.2963 +            A = (Uint8)(pixel >> 24); B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel;
  1.2964 +            if (flags & SDL_COPY_MODULATE_COLOR) {
  1.2965 +                R = (R * modulateR) / 255;
  1.2966 +                G = (G * modulateG) / 255;
  1.2967 +                B = (B * modulateB) / 255;
  1.2968 +            }
  1.2969 +            if (flags & SDL_COPY_MODULATE_ALPHA) {
  1.2970 +                A = (A * modulateA) / 255;
  1.2971 +            }
  1.2972 +            pixel = ((Uint32)A << 24) | ((Uint32)R << 16) | ((Uint32)G << 8) | B;
  1.2973 +            *dst = pixel;
  1.2974 +            posx += incx;
  1.2975 +            ++dst;
  1.2976 +        }
  1.2977 +        posy += incy;
  1.2978 +        info->dst += info->dst_pitch;
  1.2979 +    }
  1.2980 +}
  1.2981 +
  1.2982 +static void SDL_Blit_ABGR8888_ARGB8888_Modulate_Blend(SDL_BlitInfo *info)
  1.2983 +{
  1.2984 +    const int flags = info->flags;
  1.2985 +    const Uint32 modulateR = info->r;
  1.2986 +    const Uint32 modulateG = info->g;
  1.2987 +    const Uint32 modulateB = info->b;
  1.2988 +    const Uint32 modulateA = info->a;
  1.2989 +    Uint32 srcpixel;
  1.2990 +    Uint32 srcR, srcG, srcB, srcA;
  1.2991 +    Uint32 dstpixel;
  1.2992 +    Uint32 dstR, dstG, dstB, dstA;
  1.2993 +
  1.2994 +    while (info->dst_h--) {
  1.2995 +        Uint32 *src = (Uint32 *)info->src;
  1.2996 +        Uint32 *dst = (Uint32 *)info->dst;
  1.2997 +        int n = info->dst_w;
  1.2998 +        while (n--) {
  1.2999 +            srcpixel = *src;
  1.3000 +            srcA = (Uint8)(srcpixel >> 24); srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel;
  1.3001 +            dstpixel = *dst;
  1.3002 +            dstA = (Uint8)(dstpixel >> 24); dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
  1.3003 +            if (flags & SDL_COPY_MODULATE_COLOR) {
  1.3004 +                srcR = (srcR * modulateR) / 255;
  1.3005 +                srcG = (srcG * modulateG) / 255;
  1.3006 +                srcB = (srcB * modulateB) / 255;
  1.3007 +            }
  1.3008 +            if (flags & SDL_COPY_MODULATE_ALPHA) {
  1.3009 +                srcA = (srcA * modulateA) / 255;
  1.3010 +            }
  1.3011 +            if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  1.3012 +                /* This goes away if we ever use premultiplied alpha */
  1.3013 +                if (srcA < 255) {
  1.3014 +                    srcR = (srcR * srcA) / 255;
  1.3015 +                    srcG = (srcG * srcA) / 255;
  1.3016 +                    srcB = (srcB * srcA) / 255;
  1.3017 +                }
  1.3018 +            }
  1.3019 +            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
  1.3020 +            case SDL_COPY_MASK:
  1.3021 +                if (srcA) {
  1.3022 +                    dstR = srcR;
  1.3023 +                    dstG = srcG;
  1.3024 +                    dstB = srcB;
  1.3025 +                }
  1.3026 +                break;
  1.3027 +            case SDL_COPY_BLEND:
  1.3028 +                dstR = srcR + ((255 - srcA) * dstR) / 255;
  1.3029 +                dstG = srcG + ((255 - srcA) * dstG) / 255;
  1.3030 +                dstB = srcB + ((255 - srcA) * dstB) / 255;
  1.3031 +                break;
  1.3032 +            case SDL_COPY_ADD:
  1.3033 +                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  1.3034 +                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  1.3035 +                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  1.3036 +                break;
  1.3037 +            case SDL_COPY_MOD:
  1.3038 +                dstR = (srcR * dstR) / 255;
  1.3039 +                dstG = (srcG * dstG) / 255;
  1.3040 +                dstB = (srcB * dstB) / 255;
  1.3041 +                break;
  1.3042 +            }
  1.3043 +            dstpixel = ((Uint32)dstA << 24) | ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
  1.3044 +            *dst = dstpixel;
  1.3045 +            ++src;
  1.3046 +            ++dst;
  1.3047 +        }
  1.3048 +        info->src += info->src_pitch;
  1.3049 +        info->dst += info->dst_pitch;
  1.3050 +    }
  1.3051 +}
  1.3052 +
  1.3053 +static void SDL_Blit_ABGR8888_ARGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
  1.3054 +{
  1.3055 +    const int flags = info->flags;
  1.3056 +    const Uint32 modulateR = info->r;
  1.3057 +    const Uint32 modulateG = info->g;
  1.3058 +    const Uint32 modulateB = info->b;
  1.3059 +    const Uint32 modulateA = info->a;
  1.3060 +    Uint32 srcpixel;
  1.3061 +    Uint32 srcR, srcG, srcB, srcA;
  1.3062 +    Uint32 dstpixel;
  1.3063 +    Uint32 dstR, dstG, dstB, dstA;
  1.3064 +    int srcy, srcx;
  1.3065 +    int posy, posx;
  1.3066 +    int incy, incx;
  1.3067 +
  1.3068 +    srcy = 0;
  1.3069 +    posy = 0;
  1.3070 +    incy = (info->src_h << 16) / info->dst_h;
  1.3071 +    incx = (info->src_w << 16) / info->dst_w;
  1.3072 +
  1.3073 +    while (info->dst_h--) {
  1.3074 +        Uint32 *src;
  1.3075 +        Uint32 *dst = (Uint32 *)info->dst;
  1.3076 +        int n = info->dst_w;
  1.3077 +        srcx = -1;
  1.3078 +        posx = 0x10000L;
  1.3079 +        while (posy >= 0x10000L) {
  1.3080 +            ++srcy;
  1.3081 +            posy -= 0x10000L;
  1.3082 +        }
  1.3083 +        while (n--) {
  1.3084 +            if (posx >= 0x10000L) {
  1.3085 +                while (posx >= 0x10000L) {
  1.3086 +                    ++srcx;
  1.3087 +                    posx -= 0x10000L;
  1.3088 +                }
  1.3089 +                src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  1.3090 +            }
  1.3091 +            srcpixel = *src;
  1.3092 +            srcA = (Uint8)(srcpixel >> 24); srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel;
  1.3093 +            dstpixel = *dst;
  1.3094 +            dstA = (Uint8)(dstpixel >> 24); dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
  1.3095 +            if (flags & SDL_COPY_MODULATE_COLOR) {
  1.3096 +                srcR = (srcR * modulateR) / 255;
  1.3097 +                srcG = (srcG * modulateG) / 255;
  1.3098 +                srcB = (srcB * modulateB) / 255;
  1.3099 +            }
  1.3100 +            if (flags & SDL_COPY_MODULATE_ALPHA) {
  1.3101 +                srcA = (srcA * modulateA) / 255;
  1.3102 +            }
  1.3103 +            if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  1.3104 +                /* This goes away if we ever use premultiplied alpha */
  1.3105 +                if (srcA < 255) {
  1.3106 +                    srcR = (srcR * srcA) / 255;
  1.3107 +                    srcG = (srcG * srcA) / 255;
  1.3108 +                    srcB = (srcB * srcA) / 255;
  1.3109 +                }
  1.3110 +            }
  1.3111 +            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
  1.3112 +            case SDL_COPY_MASK:
  1.3113 +                if (srcA) {
  1.3114 +                    dstR = srcR;
  1.3115 +                    dstG = srcG;
  1.3116 +                    dstB = srcB;
  1.3117 +                }
  1.3118 +                break;
  1.3119 +            case SDL_COPY_BLEND:
  1.3120 +                dstR = srcR + ((255 - srcA) * dstR) / 255;
  1.3121 +                dstG = srcG + ((255 - srcA) * dstG) / 255;
  1.3122 +                dstB = srcB + ((255 - srcA) * dstB) / 255;
  1.3123 +                break;
  1.3124 +            case SDL_COPY_ADD:
  1.3125 +                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  1.3126 +                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  1.3127 +                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  1.3128 +                break;
  1.3129 +            case SDL_COPY_MOD:
  1.3130 +                dstR = (srcR * dstR) / 255;
  1.3131 +                dstG = (srcG * dstG) / 255;
  1.3132 +                dstB = (srcB * dstB) / 255;
  1.3133 +                break;
  1.3134 +            }
  1.3135 +            dstpixel = ((Uint32)dstA << 24) | ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
  1.3136 +            *dst = dstpixel;
  1.3137 +            posx += incx;
  1.3138 +            ++dst;
  1.3139 +        }
  1.3140 +        posy += incy;
  1.3141 +        info->dst += info->dst_pitch;
  1.3142 +    }
  1.3143 +}
  1.3144 +
  1.3145 +static void SDL_Blit_BGRA8888_RGB888_Scale(SDL_BlitInfo *info)
  1.3146 +{
  1.3147 +    const int flags = info->flags;
  1.3148 +    Uint32 pixel;
  1.3149 +    Uint32 R, G, B, A;
  1.3150 +    int srcy, srcx;
  1.3151 +    int posy, posx;
  1.3152 +    int incy, incx;
  1.3153 +
  1.3154 +    srcy = 0;
  1.3155 +    posy = 0;
  1.3156 +    incy = (info->src_h << 16) / info->dst_h;
  1.3157 +    incx = (info->src_w << 16) / info->dst_w;
  1.3158 +
  1.3159 +    while (info->dst_h--) {
  1.3160 +        Uint32 *src;
  1.3161 +        Uint32 *dst = (Uint32 *)info->dst;
  1.3162 +        int n = info->dst_w;
  1.3163 +        srcx = -1;
  1.3164 +        posx = 0x10000L;
  1.3165 +        while (posy >= 0x10000L) {
  1.3166 +            ++srcy;
  1.3167 +            posy -= 0x10000L;
  1.3168 +        }
  1.3169 +        while (n--) {
  1.3170 +            if (posx >= 0x10000L) {
  1.3171 +                while (posx >= 0x10000L) {
  1.3172 +                    ++srcx;
  1.3173 +                    posx -= 0x10000L;
  1.3174 +                }
  1.3175 +                src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  1.3176 +            }
  1.3177 +            pixel = *src;
  1.3178 +            B = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); R = (Uint8)(pixel >> 8); A = (Uint8)pixel;
  1.3179 +            pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B;
  1.3180 +            *dst = pixel;
  1.3181 +            posx += incx;
  1.3182 +            ++dst;
  1.3183 +        }
  1.3184 +        posy += incy;
  1.3185 +        info->dst += info->dst_pitch;
  1.3186 +    }
  1.3187 +}
  1.3188 +
  1.3189 +static void SDL_Blit_BGRA8888_RGB888_Blend(SDL_BlitInfo *info)
  1.3190 +{
  1.3191 +    const int flags = info->flags;
  1.3192 +    Uint32 srcpixel;
  1.3193 +    Uint32 srcR, srcG, srcB, srcA;
  1.3194 +    Uint32 dstpixel;
  1.3195 +    Uint32 dstR, dstG, dstB, dstA;
  1.3196 +
  1.3197 +    while (info->dst_h--) {
  1.3198 +        Uint32 *src = (Uint32 *)info->src;
  1.3199 +        Uint32 *dst = (Uint32 *)info->dst;
  1.3200 +        int n = info->dst_w;
  1.3201 +        while (n--) {
  1.3202 +            srcpixel = *src;
  1.3203 +            srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
  1.3204 +            dstpixel = *dst;
  1.3205 +            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
  1.3206 +            if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  1.3207 +                /* This goes away if we ever use premultiplied alpha */
  1.3208 +                if (srcA < 255) {
  1.3209 +                    srcR = (srcR * srcA) / 255;
  1.3210 +                    srcG = (srcG * srcA) / 255;
  1.3211 +                    srcB = (srcB * srcA) / 255;
  1.3212 +                }
  1.3213 +            }
  1.3214 +            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
  1.3215 +            case SDL_COPY_MASK:
  1.3216 +                if (srcA) {
  1.3217 +                    dstR = srcR;
  1.3218 +                    dstG = srcG;
  1.3219 +                    dstB = srcB;
  1.3220 +                }
  1.3221 +                break;
  1.3222 +            case SDL_COPY_BLEND:
  1.3223 +                dstR = srcR + ((255 - srcA) * dstR) / 255;
  1.3224 +                dstG = srcG + ((255 - srcA) * dstG) / 255;
  1.3225 +                dstB = srcB + ((255 - srcA) * dstB) / 255;
  1.3226 +                break;
  1.3227 +            case SDL_COPY_ADD:
  1.3228 +                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  1.3229 +                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  1.3230 +                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  1.3231 +                break;
  1.3232 +            case SDL_COPY_MOD:
  1.3233 +                dstR = (srcR * dstR) / 255;
  1.3234 +                dstG = (srcG * dstG) / 255;
  1.3235 +                dstB = (srcB * dstB) / 255;
  1.3236 +                break;
  1.3237 +            }
  1.3238 +            dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
  1.3239 +            *dst = dstpixel;
  1.3240 +            ++src;
  1.3241 +            ++dst;
  1.3242 +        }
  1.3243 +        info->src += info->src_pitch;
  1.3244 +        info->dst += info->dst_pitch;
  1.3245 +    }
  1.3246 +}
  1.3247 +
  1.3248 +static void SDL_Blit_BGRA8888_RGB888_Blend_Scale(SDL_BlitInfo *info)
  1.3249 +{
  1.3250 +    const int flags = info->flags;
  1.3251 +    Uint32 srcpixel;
  1.3252 +    Uint32 srcR, srcG, srcB, srcA;
  1.3253 +    Uint32 dstpixel;
  1.3254 +    Uint32 dstR, dstG, dstB, dstA;
  1.3255 +    int srcy, srcx;
  1.3256 +    int posy, posx;
  1.3257 +    int incy, incx;
  1.3258 +
  1.3259 +    srcy = 0;
  1.3260 +    posy = 0;
  1.3261 +    incy = (info->src_h << 16) / info->dst_h;
  1.3262 +    incx = (info->src_w << 16) / info->dst_w;
  1.3263 +
  1.3264 +    while (info->dst_h--) {
  1.3265 +        Uint32 *src;
  1.3266 +        Uint32 *dst = (Uint32 *)info->dst;
  1.3267 +        int n = info->dst_w;
  1.3268 +        srcx = -1;
  1.3269 +        posx = 0x10000L;
  1.3270 +        while (posy >= 0x10000L) {
  1.3271 +            ++srcy;
  1.3272 +            posy -= 0x10000L;
  1.3273 +        }
  1.3274 +        while (n--) {
  1.3275 +            if (posx >= 0x10000L) {
  1.3276 +                while (posx >= 0x10000L) {
  1.3277 +                    ++srcx;
  1.3278 +                    posx -= 0x10000L;
  1.3279 +                }
  1.3280 +                src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  1.3281 +            }
  1.3282 +            srcpixel = *src;
  1.3283 +            srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
  1.3284 +            dstpixel = *dst;
  1.3285 +            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
  1.3286 +            if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  1.3287 +                /* This goes away if we ever use premultiplied alpha */
  1.3288 +                if (srcA < 255) {
  1.3289 +                    srcR = (srcR * srcA) / 255;
  1.3290 +                    srcG = (srcG * srcA) / 255;
  1.3291 +                    srcB = (srcB * srcA) / 255;
  1.3292 +                }
  1.3293 +            }
  1.3294 +            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
  1.3295 +            case SDL_COPY_MASK:
  1.3296 +                if (srcA) {
  1.3297 +                    dstR = srcR;
  1.3298 +                    dstG = srcG;
  1.3299 +                    dstB = srcB;
  1.3300 +                }
  1.3301 +                break;
  1.3302 +            case SDL_COPY_BLEND:
  1.3303 +                dstR = srcR + ((255 - srcA) * dstR) / 255;
  1.3304 +                dstG = srcG + ((255 - srcA) * dstG) / 255;
  1.3305 +                dstB = srcB + ((255 - srcA) * dstB) / 255;
  1.3306 +                break;
  1.3307 +            case SDL_COPY_ADD:
  1.3308 +                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  1.3309 +                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  1.3310 +                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  1.3311 +                break;
  1.3312 +            case SDL_COPY_MOD:
  1.3313 +                dstR = (srcR * dstR) / 255;
  1.3314 +                dstG = (srcG * dstG) / 255;
  1.3315 +                dstB = (srcB * dstB) / 255;
  1.3316 +                break;
  1.3317 +            }
  1.3318 +            dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
  1.3319 +            *dst = dstpixel;
  1.3320 +            posx += incx;
  1.3321 +            ++dst;
  1.3322 +        }
  1.3323 +        posy += incy;
  1.3324 +        info->dst += info->dst_pitch;
  1.3325 +    }
  1.3326 +}
  1.3327 +
  1.3328 +static void SDL_Blit_BGRA8888_RGB888_Modulate(SDL_BlitInfo *info)
  1.3329 +{
  1.3330 +    const int flags = info->flags;
  1.3331 +    const Uint32 modulateR = info->r;
  1.3332 +    const Uint32 modulateG = info->g;
  1.3333 +    const Uint32 modulateB = info->b;
  1.3334 +    const Uint32 modulateA = info->a;
  1.3335 +    Uint32 pixel;
  1.3336 +    Uint32 R, G, B, A;
  1.3337 +
  1.3338 +    while (info->dst_h--) {
  1.3339 +        Uint32 *src = (Uint32 *)info->src;
  1.3340 +        Uint32 *dst = (Uint32 *)info->dst;
  1.3341 +        int n = info->dst_w;
  1.3342 +        while (n--) {
  1.3343 +            pixel = *src;
  1.3344 +            B = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); R = (Uint8)(pixel >> 8); A = (Uint8)pixel;
  1.3345 +            if (flags & SDL_COPY_MODULATE_COLOR) {
  1.3346 +                R = (R * modulateR) / 255;
  1.3347 +                G = (G * modulateG) / 255;
  1.3348 +                B = (B * modulateB) / 255;
  1.3349 +            }
  1.3350 +            if (flags & SDL_COPY_MODULATE_ALPHA) {
  1.3351 +                A = (A * modulateA) / 255;
  1.3352 +            }
  1.3353 +            pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B;
  1.3354 +            *dst = pixel;
  1.3355 +            ++src;
  1.3356 +            ++dst;
  1.3357 +        }
  1.3358 +        info->src += info->src_pitch;
  1.3359 +        info->dst += info->dst_pitch;
  1.3360 +    }
  1.3361 +}
  1.3362 +
  1.3363 +static void SDL_Blit_BGRA8888_RGB888_Modulate_Scale(SDL_BlitInfo *info)
  1.3364 +{
  1.3365 +    const int flags = info->flags;
  1.3366 +    const Uint32 modulateR = info->r;
  1.3367 +    const Uint32 modulateG = info->g;
  1.3368 +    const Uint32 modulateB = info->b;
  1.3369 +    const Uint32 modulateA = info->a;
  1.3370 +    Uint32 pixel;
  1.3371 +    Uint32 R, G, B, A;
  1.3372 +    int srcy, srcx;
  1.3373 +    int posy, posx;
  1.3374 +    int incy, incx;
  1.3375 +
  1.3376 +    srcy = 0;
  1.3377 +    posy = 0;
  1.3378 +    incy = (info->src_h << 16) / info->dst_h;
  1.3379 +    incx = (info->src_w << 16) / info->dst_w;
  1.3380 +
  1.3381 +    while (info->dst_h--) {
  1.3382 +        Uint32 *src;
  1.3383 +        Uint32 *dst = (Uint32 *)info->dst;
  1.3384 +        int n = info->dst_w;
  1.3385 +        srcx = -1;
  1.3386 +        posx = 0x10000L;
  1.3387 +        while (posy >= 0x10000L) {
  1.3388 +            ++srcy;
  1.3389 +            posy -= 0x10000L;
  1.3390 +        }
  1.3391 +        while (n--) {
  1.3392 +            if (posx >= 0x10000L) {
  1.3393 +                while (posx >= 0x10000L) {
  1.3394 +                    ++srcx;
  1.3395 +                    posx -= 0x10000L;
  1.3396 +                }
  1.3397 +                src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  1.3398 +            }
  1.3399 +            pixel = *src;
  1.3400 +            B = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); R = (Uint8)(pixel >> 8); A = (Uint8)pixel;
  1.3401 +            if (flags & SDL_COPY_MODULATE_COLOR) {
  1.3402 +                R = (R * modulateR) / 255;
  1.3403 +                G = (G * modulateG) / 255;
  1.3404 +                B = (B * modulateB) / 255;
  1.3405 +            }
  1.3406 +            if (flags & SDL_COPY_MODULATE_ALPHA) {
  1.3407 +                A = (A * modulateA) / 255;
  1.3408 +            }
  1.3409 +            pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B;
  1.3410 +            *dst = pixel;
  1.3411 +            posx += incx;
  1.3412 +            ++dst;
  1.3413 +        }
  1.3414 +        posy += incy;
  1.3415 +        info->dst += info->dst_pitch;
  1.3416 +    }
  1.3417 +}
  1.3418 +
  1.3419 +static void SDL_Blit_BGRA8888_RGB888_Modulate_Blend(SDL_BlitInfo *info)
  1.3420 +{
  1.3421 +    const int flags = info->flags;
  1.3422 +    const Uint32 modulateR = info->r;
  1.3423 +    const Uint32 modulateG = info->g;
  1.3424 +    const Uint32 modulateB = info->b;
  1.3425 +    const Uint32 modulateA = info->a;
  1.3426 +    Uint32 srcpixel;
  1.3427 +    Uint32 srcR, srcG, srcB, srcA;
  1.3428 +    Uint32 dstpixel;
  1.3429 +    Uint32 dstR, dstG, dstB, dstA;
  1.3430 +
  1.3431 +    while (info->dst_h--) {
  1.3432 +        Uint32 *src = (Uint32 *)info->src;
  1.3433 +        Uint32 *dst = (Uint32 *)info->dst;
  1.3434 +        int n = info->dst_w;
  1.3435 +        while (n--) {
  1.3436 +            srcpixel = *src;
  1.3437 +            srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
  1.3438 +            dstpixel = *dst;
  1.3439 +            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
  1.3440 +            if (flags & SDL_COPY_MODULATE_COLOR) {
  1.3441 +                srcR = (srcR * modulateR) / 255;
  1.3442 +                srcG = (srcG * modulateG) / 255;
  1.3443 +                srcB = (srcB * modulateB) / 255;
  1.3444 +            }
  1.3445 +            if (flags & SDL_COPY_MODULATE_ALPHA) {
  1.3446 +                srcA = (srcA * modulateA) / 255;
  1.3447 +            }
  1.3448 +            if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  1.3449 +                /* This goes away if we ever use premultiplied alpha */
  1.3450 +                if (srcA < 255) {
  1.3451 +                    srcR = (srcR * srcA) / 255;
  1.3452 +                    srcG = (srcG * srcA) / 255;
  1.3453 +                    srcB = (srcB * srcA) / 255;
  1.3454 +                }
  1.3455 +            }
  1.3456 +            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
  1.3457 +            case SDL_COPY_MASK:
  1.3458 +                if (srcA) {
  1.3459 +                    dstR = srcR;
  1.3460 +                    dstG = srcG;
  1.3461 +                    dstB = srcB;
  1.3462 +                }
  1.3463 +                break;
  1.3464 +            case SDL_COPY_BLEND:
  1.3465 +                dstR = srcR + ((255 - srcA) * dstR) / 255;
  1.3466 +                dstG = srcG + ((255 - srcA) * dstG) / 255;
  1.3467 +                dstB = srcB + ((255 - srcA) * dstB) / 255;
  1.3468 +                break;
  1.3469 +            case SDL_COPY_ADD:
  1.3470 +                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  1.3471 +                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  1.3472 +                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  1.3473 +                break;
  1.3474 +            case SDL_COPY_MOD:
  1.3475 +                dstR = (srcR * dstR) / 255;
  1.3476 +                dstG = (srcG * dstG) / 255;
  1.3477 +                dstB = (srcB * dstB) / 255;
  1.3478 +                break;
  1.3479 +            }
  1.3480 +            dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
  1.3481 +            *dst = dstpixel;
  1.3482 +            ++src;
  1.3483 +            ++dst;
  1.3484 +        }
  1.3485 +        info->src += info->src_pitch;
  1.3486 +        info->dst += info->dst_pitch;
  1.3487 +    }
  1.3488 +}
  1.3489 +
  1.3490 +static void SDL_Blit_BGRA8888_RGB888_Modulate_Blend_Scale(SDL_BlitInfo *info)
  1.3491 +{
  1.3492 +    const int flags = info->flags;
  1.3493 +    const Uint32 modulateR = info->r;
  1.3494 +    const Uint32 modulateG = info->g;
  1.3495 +    const Uint32 modulateB = info->b;
  1.3496 +    const Uint32 modulateA = info->a;
  1.3497 +    Uint32 srcpixel;
  1.3498 +    Uint32 srcR, srcG, srcB, srcA;
  1.3499 +    Uint32 dstpixel;
  1.3500 +    Uint32 dstR, dstG, dstB, dstA;
  1.3501 +    int srcy, srcx;
  1.3502 +    int posy, posx;
  1.3503 +    int incy, incx;
  1.3504 +
  1.3505 +    srcy = 0;
  1.3506 +    posy = 0;
  1.3507 +    incy = (info->src_h << 16) / info->dst_h;
  1.3508 +    incx = (info->src_w << 16) / info->dst_w;
  1.3509 +
  1.3510 +    while (info->dst_h--) {
  1.3511 +        Uint32 *src;
  1.3512 +        Uint32 *dst = (Uint32 *)info->dst;
  1.3513 +        int n = info->dst_w;
  1.3514 +        srcx = -1;
  1.3515 +        posx = 0x10000L;
  1.3516 +        while (posy >= 0x10000L) {
  1.3517 +            ++srcy;
  1.3518 +            posy -= 0x10000L;
  1.3519 +        }
  1.3520 +        while (n--) {
  1.3521 +            if (posx >= 0x10000L) {
  1.3522 +                while (posx >= 0x10000L) {
  1.3523 +                    ++srcx;
  1.3524 +                    posx -= 0x10000L;
  1.3525 +                }
  1.3526 +                src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  1.3527 +            }
  1.3528 +            srcpixel = *src;
  1.3529 +            srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
  1.3530 +            dstpixel = *dst;
  1.3531 +            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
  1.3532 +            if (flags & SDL_COPY_MODULATE_COLOR) {
  1.3533 +                srcR = (srcR * modulateR) / 255;
  1.3534 +                srcG = (srcG * modulateG) / 255;
  1.3535 +                srcB = (srcB * modulateB) / 255;
  1.3536 +            }
  1.3537 +            if (flags & SDL_COPY_MODULATE_ALPHA) {
  1.3538 +                srcA = (srcA * modulateA) / 255;
  1.3539 +            }
  1.3540 +            if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  1.3541 +                /* This goes away if we ever use premultiplied alpha */
  1.3542 +                if (srcA < 255) {
  1.3543 +                    srcR = (srcR * srcA) / 255;
  1.3544 +                    srcG = (srcG * srcA) / 255;
  1.3545 +                    srcB = (srcB * srcA) / 255;
  1.3546 +                }
  1.3547 +            }
  1.3548 +            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
  1.3549 +            case SDL_COPY_MASK:
  1.3550 +                if (srcA) {
  1.3551 +                    dstR = srcR;
  1.3552 +                    dstG = srcG;
  1.3553 +                    dstB = srcB;
  1.3554 +                }
  1.3555 +                break;
  1.3556 +            case SDL_COPY_BLEND:
  1.3557 +                dstR = srcR + ((255 - srcA) * dstR) / 255;
  1.3558 +                dstG = srcG + ((255 - srcA) * dstG) / 255;
  1.3559 +                dstB = srcB + ((255 - srcA) * dstB) / 255;
  1.3560 +                break;
  1.3561 +            case SDL_COPY_ADD:
  1.3562 +                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  1.3563 +                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  1.3564 +                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  1.3565 +                break;
  1.3566 +            case SDL_COPY_MOD:
  1.3567 +                dstR = (srcR * dstR) / 255;
  1.3568 +                dstG = (srcG * dstG) / 255;
  1.3569 +                dstB = (srcB * dstB) / 255;
  1.3570 +                break;
  1.3571 +            }
  1.3572 +            dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
  1.3573 +            *dst = dstpixel;
  1.3574 +            posx += incx;
  1.3575 +            ++dst;
  1.3576 +        }
  1.3577 +        posy += incy;
  1.3578 +        info->dst += info->dst_pitch;
  1.3579 +    }
  1.3580 +}
  1.3581 +
  1.3582 +static void SDL_Blit_BGRA8888_BGR888_Scale(SDL_BlitInfo *info)
  1.3583 +{
  1.3584 +    const int flags = info->flags;
  1.3585 +    Uint32 pixel;
  1.3586 +    Uint32 R, G, B, A;
  1.3587 +    int srcy, srcx;
  1.3588 +    int posy, posx;
  1.3589 +    int incy, incx;
  1.3590 +
  1.3591 +    srcy = 0;
  1.3592 +    posy = 0;
  1.3593 +    incy = (info->src_h << 16) / info->dst_h;
  1.3594 +    incx = (info->src_w << 16) / info->dst_w;
  1.3595 +
  1.3596 +    while (info->dst_h--) {
  1.3597 +        Uint32 *src;
  1.3598 +        Uint32 *dst = (Uint32 *)info->dst;
  1.3599 +        int n = info->dst_w;
  1.3600 +        srcx = -1;
  1.3601 +        posx = 0x10000L;
  1.3602 +        while (posy >= 0x10000L) {
  1.3603 +            ++srcy;
  1.3604 +            posy -= 0x10000L;
  1.3605 +        }
  1.3606 +        while (n--) {
  1.3607 +            if (posx >= 0x10000L) {
  1.3608 +                while (posx >= 0x10000L) {
  1.3609 +                    ++srcx;
  1.3610 +                    posx -= 0x10000L;
  1.3611 +                }
  1.3612 +                src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  1.3613 +            }
  1.3614 +            pixel = *src;
  1.3615 +            B = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); R = (Uint8)(pixel >> 8); A = (Uint8)pixel;
  1.3616 +            pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R;
  1.3617 +            *dst = pixel;
  1.3618 +            posx += incx;
  1.3619 +            ++dst;
  1.3620 +        }
  1.3621 +        posy += incy;
  1.3622 +        info->dst += info->dst_pitch;
  1.3623 +    }
  1.3624 +}
  1.3625 +
  1.3626 +static void SDL_Blit_BGRA8888_BGR888_Blend(SDL_BlitInfo *info)
  1.3627 +{
  1.3628 +    const int flags = info->flags;
  1.3629 +    Uint32 srcpixel;
  1.3630 +    Uint32 srcR, srcG, srcB, srcA;
  1.3631 +    Uint32 dstpixel;
  1.3632 +    Uint32 dstR, dstG, dstB, dstA;
  1.3633 +
  1.3634 +    while (info->dst_h--) {
  1.3635 +        Uint32 *src = (Uint32 *)info->src;
  1.3636 +        Uint32 *dst = (Uint32 *)info->dst;
  1.3637 +        int n = info->dst_w;
  1.3638 +        while (n--) {
  1.3639 +            srcpixel = *src;
  1.3640 +            srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
  1.3641 +            dstpixel = *dst;
  1.3642 +            dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
  1.3643 +            if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  1.3644 +                /* This goes away if we ever use premultiplied alpha */
  1.3645 +                if (srcA < 255) {
  1.3646 +                    srcR = (srcR * srcA) / 255;
  1.3647 +                    srcG = (srcG * srcA) / 255;
  1.3648 +                    srcB = (srcB * srcA) / 255;
  1.3649 +                }
  1.3650 +            }
  1.3651 +            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
  1.3652 +            case SDL_COPY_MASK:
  1.3653 +                if (srcA) {
  1.3654 +                    dstR = srcR;
  1.3655 +                    dstG = srcG;
  1.3656 +                    dstB = srcB;
  1.3657 +                }
  1.3658 +                break;
  1.3659 +            case SDL_COPY_BLEND:
  1.3660 +                dstR = srcR + ((255 - srcA) * dstR) / 255;
  1.3661 +                dstG = srcG + ((255 - srcA) * dstG) / 255;
  1.3662 +                dstB = srcB + ((255 - srcA) * dstB) / 255;
  1.3663 +                break;
  1.3664 +            case SDL_COPY_ADD:
  1.3665 +                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  1.3666 +                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  1.3667 +                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  1.3668 +                break;
  1.3669 +            case SDL_COPY_MOD:
  1.3670 +                dstR = (srcR * dstR) / 255;
  1.3671 +                dstG = (srcG * dstG) / 255;
  1.3672 +                dstB = (srcB * dstB) / 255;
  1.3673 +                break;
  1.3674 +            }
  1.3675 +            dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
  1.3676 +            *dst = dstpixel;
  1.3677 +            ++src;
  1.3678 +            ++dst;
  1.3679 +        }
  1.3680 +        info->src += info->src_pitch;
  1.3681 +        info->dst += info->dst_pitch;
  1.3682 +    }
  1.3683 +}
  1.3684 +
  1.3685 +static void SDL_Blit_BGRA8888_BGR888_Blend_Scale(SDL_BlitInfo *info)
  1.3686 +{
  1.3687 +    const int flags = info->flags;
  1.3688 +    Uint32 srcpixel;
  1.3689 +    Uint32 srcR, srcG, srcB, srcA;
  1.3690 +    Uint32 dstpixel;
  1.3691 +    Uint32 dstR, dstG, dstB, dstA;
  1.3692 +    int srcy, srcx;
  1.3693 +    int posy, posx;
  1.3694 +    int incy, incx;
  1.3695 +
  1.3696 +    srcy = 0;
  1.3697 +    posy = 0;
  1.3698 +    incy = (info->src_h << 16) / info->dst_h;
  1.3699 +    incx = (info->src_w << 16) / info->dst_w;
  1.3700 +
  1.3701 +    while (info->dst_h--) {
  1.3702 +        Uint32 *src;
  1.3703 +        Uint32 *dst = (Uint32 *)info->dst;
  1.3704 +        int n = info->dst_w;
  1.3705 +        srcx = -1;
  1.3706 +        posx = 0x10000L;
  1.3707 +        while (posy >= 0x10000L) {
  1.3708 +            ++srcy;
  1.3709 +            posy -= 0x10000L;
  1.3710 +        }
  1.3711 +        while (n--) {
  1.3712 +            if (posx >= 0x10000L) {
  1.3713 +                while (posx >= 0x10000L) {
  1.3714 +                    ++srcx;
  1.3715 +                    posx -= 0x10000L;
  1.3716 +                }
  1.3717 +                src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  1.3718 +            }
  1.3719 +            srcpixel = *src;
  1.3720 +            srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
  1.3721 +            dstpixel = *dst;
  1.3722 +            dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
  1.3723 +            if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  1.3724 +                /* This goes away if we ever use premultiplied alpha */
  1.3725 +                if (srcA < 255) {
  1.3726 +                    srcR = (srcR * srcA) / 255;
  1.3727 +                    srcG = (srcG * srcA) / 255;
  1.3728 +                    srcB = (srcB * srcA) / 255;
  1.3729 +                }
  1.3730 +            }
  1.3731 +            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
  1.3732 +            case SDL_COPY_MASK:
  1.3733 +                if (srcA) {
  1.3734 +                    dstR = srcR;
  1.3735 +                    dstG = srcG;
  1.3736 +                    dstB = srcB;
  1.3737 +                }
  1.3738 +                break;
  1.3739 +            case SDL_COPY_BLEND:
  1.3740 +                dstR = srcR + ((255 - srcA) * dstR) / 255;
  1.3741 +                dstG = srcG + ((255 - srcA) * dstG) / 255;
  1.3742 +                dstB = srcB + ((255 - srcA) * dstB) / 255;
  1.3743 +                break;
  1.3744 +            case SDL_COPY_ADD:
  1.3745 +                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  1.3746 +                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  1.3747 +                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  1.3748 +                break;
  1.3749 +            case SDL_COPY_MOD:
  1.3750 +                dstR = (srcR * dstR) / 255;
  1.3751 +                dstG = (srcG * dstG) / 255;
  1.3752 +                dstB = (srcB * dstB) / 255;
  1.3753 +                break;
  1.3754 +            }
  1.3755 +            dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
  1.3756 +            *dst = dstpixel;
  1.3757 +            posx += incx;
  1.3758 +            ++dst;
  1.3759 +        }
  1.3760 +        posy += incy;
  1.3761 +        info->dst += info->dst_pitch;
  1.3762 +    }
  1.3763 +}
  1.3764 +
  1.3765 +static void SDL_Blit_BGRA8888_BGR888_Modulate(SDL_BlitInfo *info)
  1.3766 +{
  1.3767 +    const int flags = info->flags;
  1.3768 +    const Uint32 modulateR = info->r;
  1.3769 +    const Uint32 modulateG = info->g;
  1.3770 +    const Uint32 modulateB = info->b;
  1.3771 +    const Uint32 modulateA = info->a;
  1.3772 +    Uint32 pixel;
  1.3773 +    Uint32 R, G, B, A;
  1.3774 +
  1.3775 +    while (info->dst_h--) {
  1.3776 +        Uint32 *src = (Uint32 *)info->src;
  1.3777 +        Uint32 *dst = (Uint32 *)info->dst;
  1.3778 +        int n = info->dst_w;
  1.3779 +        while (n--) {
  1.3780 +            pixel = *src;
  1.3781 +            B = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); R = (Uint8)(pixel >> 8); A = (Uint8)pixel;
  1.3782 +            if (flags & SDL_COPY_MODULATE_COLOR) {
  1.3783 +                R = (R * modulateR) / 255;
  1.3784 +                G = (G * modulateG) / 255;
  1.3785 +                B = (B * modulateB) / 255;
  1.3786 +            }
  1.3787 +            if (flags & SDL_COPY_MODULATE_ALPHA) {
  1.3788 +                A = (A * modulateA) / 255;
  1.3789 +            }
  1.3790 +            pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R;
  1.3791 +            *dst = pixel;
  1.3792 +            ++src;
  1.3793 +            ++dst;
  1.3794 +        }
  1.3795 +        info->src += info->src_pitch;
  1.3796 +        info->dst += info->dst_pitch;
  1.3797 +    }
  1.3798 +}
  1.3799 +
  1.3800 +static void SDL_Blit_BGRA8888_BGR888_Modulate_Scale(SDL_BlitInfo *info)
  1.3801 +{
  1.3802 +    const int flags = info->flags;
  1.3803 +    const Uint32 modulateR = info->r;
  1.3804 +    const Uint32 modulateG = info->g;
  1.3805 +    const Uint32 modulateB = info->b;
  1.3806 +    const Uint32 modulateA = info->a;
  1.3807 +    Uint32 pixel;
  1.3808 +    Uint32 R, G, B, A;
  1.3809 +    int srcy, srcx;
  1.3810 +    int posy, posx;
  1.3811 +    int incy, incx;
  1.3812 +
  1.3813 +    srcy = 0;
  1.3814 +    posy = 0;
  1.3815 +    incy = (info->src_h << 16) / info->dst_h;
  1.3816 +    incx = (info->src_w << 16) / info->dst_w;
  1.3817 +
  1.3818 +    while (info->dst_h--) {
  1.3819 +        Uint32 *src;
  1.3820 +        Uint32 *dst = (Uint32 *)info->dst;
  1.3821 +        int n = info->dst_w;
  1.3822 +        srcx = -1;
  1.3823 +        posx = 0x10000L;
  1.3824 +        while (posy >= 0x10000L) {
  1.3825 +            ++srcy;
  1.3826 +            posy -= 0x10000L;
  1.3827 +        }
  1.3828 +        while (n--) {
  1.3829 +            if (posx >= 0x10000L) {
  1.3830 +                while (posx >= 0x10000L) {
  1.3831 +                    ++srcx;
  1.3832 +                    posx -= 0x10000L;
  1.3833 +                }
  1.3834 +                src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  1.3835 +            }
  1.3836 +            pixel = *src;
  1.3837 +            B = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); R = (Uint8)(pixel >> 8); A = (Uint8)pixel;
  1.3838 +            if (flags & SDL_COPY_MODULATE_COLOR) {
  1.3839 +                R = (R * modulateR) / 255;
  1.3840 +                G = (G * modulateG) / 255;
  1.3841 +                B = (B * modulateB) / 255;
  1.3842 +            }
  1.3843 +            if (flags & SDL_COPY_MODULATE_ALPHA) {
  1.3844 +                A = (A * modulateA) / 255;
  1.3845 +            }
  1.3846 +            pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R;
  1.3847 +            *dst = pixel;
  1.3848 +            posx += incx;
  1.3849 +            ++dst;
  1.3850 +        }
  1.3851 +        posy += incy;
  1.3852 +        info->dst += info->dst_pitch;
  1.3853 +    }
  1.3854 +}
  1.3855 +
  1.3856 +static void SDL_Blit_BGRA8888_BGR888_Modulate_Blend(SDL_BlitInfo *info)
  1.3857 +{
  1.3858 +    const int flags = info->flags;
  1.3859 +    const Uint32 modulateR = info->r;
  1.3860 +    const Uint32 modulateG = info->g;
  1.3861 +    const Uint32 modulateB = info->b;
  1.3862 +    const Uint32 modulateA = info->a;
  1.3863 +    Uint32 srcpixel;
  1.3864 +    Uint32 srcR, srcG, srcB, srcA;
  1.3865 +    Uint32 dstpixel;
  1.3866 +    Uint32 dstR, dstG, dstB, dstA;
  1.3867 +
  1.3868 +    while (info->dst_h--) {
  1.3869 +        Uint32 *src = (Uint32 *)info->src;
  1.3870 +        Uint32 *dst = (Uint32 *)info->dst;
  1.3871 +        int n = info->dst_w;
  1.3872 +        while (n--) {
  1.3873 +            srcpixel = *src;
  1.3874              srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
  1.3875              dstpixel = *dst;
  1.3876              dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
  1.3877 @@ -5254,6 +7342,535 @@
  1.3878              }
  1.3879              dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
  1.3880              *dst = dstpixel;
  1.3881 +            ++src;
  1.3882 +            ++dst;
  1.3883 +        }
  1.3884 +        info->src += info->src_pitch;
  1.3885 +        info->dst += info->dst_pitch;
  1.3886 +    }
  1.3887 +}
  1.3888 +
  1.3889 +static void SDL_Blit_BGRA8888_BGR888_Modulate_Blend_Scale(SDL_BlitInfo *info)
  1.3890 +{
  1.3891 +    const int flags = info->flags;
  1.3892 +    const Uint32 modulateR = info->r;
  1.3893 +    const Uint32 modulateG = info->g;
  1.3894 +    const Uint32 modulateB = info->b;
  1.3895 +    const Uint32 modulateA = info->a;
  1.3896 +    Uint32 srcpixel;
  1.3897 +    Uint32 srcR, srcG, srcB, srcA;
  1.3898 +    Uint32 dstpixel;
  1.3899 +    Uint32 dstR, dstG, dstB, dstA;
  1.3900 +    int srcy, srcx;
  1.3901 +    int posy, posx;
  1.3902 +    int incy, incx;
  1.3903 +
  1.3904 +    srcy = 0;
  1.3905 +    posy = 0;
  1.3906 +    incy = (info->src_h << 16) / info->dst_h;
  1.3907 +    incx = (info->src_w << 16) / info->dst_w;
  1.3908 +
  1.3909 +    while (info->dst_h--) {
  1.3910 +        Uint32 *src;
  1.3911 +        Uint32 *dst = (Uint32 *)info->dst;
  1.3912 +        int n = info->dst_w;
  1.3913 +        srcx = -1;
  1.3914 +        posx = 0x10000L;
  1.3915 +        while (posy >= 0x10000L) {
  1.3916 +            ++srcy;
  1.3917 +            posy -= 0x10000L;
  1.3918 +        }
  1.3919 +        while (n--) {
  1.3920 +            if (posx >= 0x10000L) {
  1.3921 +                while (posx >= 0x10000L) {
  1.3922 +                    ++srcx;
  1.3923 +                    posx -= 0x10000L;
  1.3924 +                }
  1.3925 +                src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  1.3926 +            }
  1.3927 +            srcpixel = *src;
  1.3928 +            srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
  1.3929 +            dstpixel = *dst;
  1.3930 +            dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
  1.3931 +            if (flags & SDL_COPY_MODULATE_COLOR) {
  1.3932 +                srcR = (srcR * modulateR) / 255;
  1.3933 +                srcG = (srcG * modulateG) / 255;
  1.3934 +                srcB = (srcB * modulateB) / 255;
  1.3935 +            }
  1.3936 +            if (flags & SDL_COPY_MODULATE_ALPHA) {
  1.3937 +                srcA = (srcA * modulateA) / 255;
  1.3938 +            }
  1.3939 +            if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  1.3940 +                /* This goes away if we ever use premultiplied alpha */
  1.3941 +                if (srcA < 255) {
  1.3942 +                    srcR = (srcR * srcA) / 255;
  1.3943 +                    srcG = (srcG * srcA) / 255;
  1.3944 +                    srcB = (srcB * srcA) / 255;
  1.3945 +                }
  1.3946 +            }
  1.3947 +            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
  1.3948 +            case SDL_COPY_MASK:
  1.3949 +                if (srcA) {
  1.3950 +                    dstR = srcR;
  1.3951 +                    dstG = srcG;
  1.3952 +                    dstB = srcB;
  1.3953 +                }
  1.3954 +                break;
  1.3955 +            case SDL_COPY_BLEND:
  1.3956 +                dstR = srcR + ((255 - srcA) * dstR) / 255;
  1.3957 +                dstG = srcG + ((255 - srcA) * dstG) / 255;
  1.3958 +                dstB = srcB + ((255 - srcA) * dstB) / 255;
  1.3959 +                break;
  1.3960 +            case SDL_COPY_ADD:
  1.3961 +                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  1.3962 +                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  1.3963 +                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  1.3964 +                break;
  1.3965 +            case SDL_COPY_MOD:
  1.3966 +                dstR = (srcR * dstR) / 255;
  1.3967 +                dstG = (srcG * dstG) / 255;
  1.3968 +                dstB = (srcB * dstB) / 255;
  1.3969 +                break;
  1.3970 +            }
  1.3971 +            dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
  1.3972 +            *dst = dstpixel;
  1.3973 +            posx += incx;
  1.3974 +            ++dst;
  1.3975 +        }
  1.3976 +        posy += incy;
  1.3977 +        info->dst += info->dst_pitch;
  1.3978 +    }
  1.3979 +}
  1.3980 +
  1.3981 +static void SDL_Blit_BGRA8888_ARGB8888_Scale(SDL_BlitInfo *info)
  1.3982 +{
  1.3983 +    const int flags = info->flags;
  1.3984 +    Uint32 pixel;
  1.3985 +    Uint32 R, G, B, A;
  1.3986 +    int srcy, srcx;
  1.3987 +    int posy, posx;
  1.3988 +    int incy, incx;
  1.3989 +
  1.3990 +    srcy = 0;
  1.3991 +    posy = 0;
  1.3992 +    incy = (info->src_h << 16) / info->dst_h;
  1.3993 +    incx = (info->src_w << 16) / info->dst_w;
  1.3994 +
  1.3995 +    while (info->dst_h--) {
  1.3996 +        Uint32 *src;
  1.3997 +        Uint32 *dst = (Uint32 *)info->dst;
  1.3998 +        int n = info->dst_w;
  1.3999 +        srcx = -1;
  1.4000 +        posx = 0x10000L;
  1.4001 +        while (posy >= 0x10000L) {
  1.4002 +            ++srcy;
  1.4003 +            posy -= 0x10000L;
  1.4004 +        }
  1.4005 +        while (n--) {
  1.4006 +            if (posx >= 0x10000L) {
  1.4007 +                while (posx >= 0x10000L) {
  1.4008 +                    ++srcx;
  1.4009 +                    posx -= 0x10000L;
  1.4010 +                }
  1.4011 +                src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  1.4012 +            }
  1.4013 +            pixel = *src;
  1.4014 +            B = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); R = (Uint8)(pixel >> 8); A = (Uint8)pixel;
  1.4015 +            pixel = ((Uint32)A << 24) | ((Uint32)R << 16) | ((Uint32)G << 8) | B;
  1.4016 +            *dst = pixel;
  1.4017 +            posx += incx;
  1.4018 +            ++dst;
  1.4019 +        }
  1.4020 +        posy += incy;
  1.4021 +        info->dst += info->dst_pitch;
  1.4022 +    }
  1.4023 +}
  1.4024 +
  1.4025 +static void SDL_Blit_BGRA8888_ARGB8888_Blend(SDL_BlitInfo *info)
  1.4026 +{
  1.4027 +    const int flags = info->flags;
  1.4028 +    Uint32 srcpixel;
  1.4029 +    Uint32 srcR, srcG, srcB, srcA;
  1.4030 +    Uint32 dstpixel;
  1.4031 +    Uint32 dstR, dstG, dstB, dstA;
  1.4032 +
  1.4033 +    while (info->dst_h--) {
  1.4034 +        Uint32 *src = (Uint32 *)info->src;
  1.4035 +        Uint32 *dst = (Uint32 *)info->dst;
  1.4036 +        int n = info->dst_w;
  1.4037 +        while (n--) {
  1.4038 +            srcpixel = *src;
  1.4039 +            srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
  1.4040 +            dstpixel = *dst;
  1.4041 +            dstA = (Uint8)(dstpixel >> 24); dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
  1.4042 +            if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  1.4043 +                /* This goes away if we ever use premultiplied alpha */
  1.4044 +                if (srcA < 255) {
  1.4045 +                    srcR = (srcR * srcA) / 255;
  1.4046 +                    srcG = (srcG * srcA) / 255;
  1.4047 +                    srcB = (srcB * srcA) / 255;
  1.4048 +                }
  1.4049 +            }
  1.4050 +            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
  1.4051 +            case SDL_COPY_MASK:
  1.4052 +                if (srcA) {
  1.4053 +                    dstR = srcR;
  1.4054 +                    dstG = srcG;
  1.4055 +                    dstB = srcB;
  1.4056 +                }
  1.4057 +                break;
  1.4058 +            case SDL_COPY_BLEND:
  1.4059 +                dstR = srcR + ((255 - srcA) * dstR) / 255;
  1.4060 +                dstG = srcG + ((255 - srcA) * dstG) / 255;
  1.4061 +                dstB = srcB + ((255 - srcA) * dstB) / 255;
  1.4062 +                break;
  1.4063 +            case SDL_COPY_ADD:
  1.4064 +                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  1.4065 +                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  1.4066 +                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  1.4067 +                break;
  1.4068 +            case SDL_COPY_MOD:
  1.4069 +                dstR = (srcR * dstR) / 255;
  1.4070 +                dstG = (srcG * dstG) / 255;
  1.4071 +                dstB = (srcB * dstB) / 255;
  1.4072 +                break;
  1.4073 +            }
  1.4074 +            dstpixel = ((Uint32)dstA << 24) | ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
  1.4075 +            *dst = dstpixel;
  1.4076 +            ++src;
  1.4077 +            ++dst;
  1.4078 +        }
  1.4079 +        info->src += info->src_pitch;
  1.4080 +        info->dst += info->dst_pitch;
  1.4081 +    }
  1.4082 +}
  1.4083 +
  1.4084 +static void SDL_Blit_BGRA8888_ARGB8888_Blend_Scale(SDL_BlitInfo *info)
  1.4085 +{
  1.4086 +    const int flags = info->flags;
  1.4087 +    Uint32 srcpixel;
  1.4088 +    Uint32 srcR, srcG, srcB, srcA;
  1.4089 +    Uint32 dstpixel;
  1.4090 +    Uint32 dstR, dstG, dstB, dstA;
  1.4091 +    int srcy, srcx;
  1.4092 +    int posy, posx;
  1.4093 +    int incy, incx;
  1.4094 +
  1.4095 +    srcy = 0;
  1.4096 +    posy = 0;
  1.4097 +    incy = (info->src_h << 16) / info->dst_h;
  1.4098 +    incx = (info->src_w << 16) / info->dst_w;
  1.4099 +
  1.4100 +    while (info->dst_h--) {
  1.4101 +        Uint32 *src;
  1.4102 +        Uint32 *dst = (Uint32 *)info->dst;
  1.4103 +        int n = info->dst_w;
  1.4104 +        srcx = -1;
  1.4105 +        posx = 0x10000L;
  1.4106 +        while (posy >= 0x10000L) {
  1.4107 +            ++srcy;
  1.4108 +            posy -= 0x10000L;
  1.4109 +        }
  1.4110 +        while (n--) {
  1.4111 +            if (posx >= 0x10000L) {
  1.4112 +                while (posx >= 0x10000L) {
  1.4113 +                    ++srcx;
  1.4114 +                    posx -= 0x10000L;
  1.4115 +                }
  1.4116 +                src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  1.4117 +            }
  1.4118 +            srcpixel = *src;
  1.4119 +            srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
  1.4120 +            dstpixel = *dst;
  1.4121 +            dstA = (Uint8)(dstpixel >> 24); dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
  1.4122 +            if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  1.4123 +                /* This goes away if we ever use premultiplied alpha */
  1.4124 +                if (srcA < 255) {
  1.4125 +                    srcR = (srcR * srcA) / 255;
  1.4126 +                    srcG = (srcG * srcA) / 255;
  1.4127 +                    srcB = (srcB * srcA) / 255;
  1.4128 +                }
  1.4129 +            }
  1.4130 +            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
  1.4131 +            case SDL_COPY_MASK:
  1.4132 +                if (srcA) {
  1.4133 +                    dstR = srcR;
  1.4134 +                    dstG = srcG;
  1.4135 +                    dstB = srcB;
  1.4136 +                }
  1.4137 +                break;
  1.4138 +            case SDL_COPY_BLEND:
  1.4139 +                dstR = srcR + ((255 - srcA) * dstR) / 255;
  1.4140 +                dstG = srcG + ((255 - srcA) * dstG) / 255;
  1.4141 +                dstB = srcB + ((255 - srcA) * dstB) / 255;
  1.4142 +                break;
  1.4143 +            case SDL_COPY_ADD:
  1.4144 +                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  1.4145 +                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  1.4146 +                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  1.4147 +                break;
  1.4148 +            case SDL_COPY_MOD:
  1.4149 +                dstR = (srcR * dstR) / 255;
  1.4150 +                dstG = (srcG * dstG) / 255;
  1.4151 +                dstB = (srcB * dstB) / 255;
  1.4152 +                break;
  1.4153 +            }
  1.4154 +            dstpixel = ((Uint32)dstA << 24) | ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
  1.4155 +            *dst = dstpixel;
  1.4156 +            posx += incx;
  1.4157 +            ++dst;
  1.4158 +        }
  1.4159 +        posy += incy;
  1.4160 +        info->dst += info->dst_pitch;
  1.4161 +    }
  1.4162 +}
  1.4163 +
  1.4164 +static void SDL_Blit_BGRA8888_ARGB8888_Modulate(SDL_BlitInfo *info)
  1.4165 +{
  1.4166 +    const int flags = info->flags;
  1.4167 +    const Uint32 modulateR = info->r;
  1.4168 +    const Uint32 modulateG = info->g;
  1.4169 +    const Uint32 modulateB = info->b;
  1.4170 +    const Uint32 modulateA = info->a;
  1.4171 +    Uint32 pixel;
  1.4172 +    Uint32 R, G, B, A;
  1.4173 +
  1.4174 +    while (info->dst_h--) {
  1.4175 +        Uint32 *src = (Uint32 *)info->src;
  1.4176 +        Uint32 *dst = (Uint32 *)info->dst;
  1.4177 +        int n = info->dst_w;
  1.4178 +        while (n--) {
  1.4179 +            pixel = *src;
  1.4180 +            B = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); R = (Uint8)(pixel >> 8); A = (Uint8)pixel;
  1.4181 +            if (flags & SDL_COPY_MODULATE_COLOR) {
  1.4182 +                R = (R * modulateR) / 255;
  1.4183 +                G = (G * modulateG) / 255;
  1.4184 +                B = (B * modulateB) / 255;
  1.4185 +            }
  1.4186 +            if (flags & SDL_COPY_MODULATE_ALPHA) {
  1.4187 +                A = (A * modulateA) / 255;
  1.4188 +            }
  1.4189 +            pixel = ((Uint32)A << 24) | ((Uint32)R << 16) | ((Uint32)G << 8) | B;
  1.4190 +            *dst = pixel;
  1.4191 +            ++src;
  1.4192 +            ++dst;
  1.4193 +        }
  1.4194 +        info->src += info->src_pitch;
  1.4195 +        info->dst += info->dst_pitch;
  1.4196 +    }
  1.4197 +}
  1.4198 +
  1.4199 +static void SDL_Blit_BGRA8888_ARGB8888_Modulate_Scale(SDL_BlitInfo *info)
  1.4200 +{
  1.4201 +    const int flags = info->flags;
  1.4202 +    const Uint32 modulateR = info->r;
  1.4203 +    const Uint32 modulateG = info->g;
  1.4204 +    const Uint32 modulateB = info->b;
  1.4205 +    const Uint32 modulateA = info->a;
  1.4206 +    Uint32 pixel;
  1.4207 +    Uint32 R, G, B, A;
  1.4208 +    int srcy, srcx;
  1.4209 +    int posy, posx;
  1.4210 +    int incy, incx;
  1.4211 +
  1.4212 +    srcy = 0;
  1.4213 +    posy = 0;
  1.4214 +    incy = (info->src_h << 16) / info->dst_h;
  1.4215 +    incx = (info->src_w << 16) / info->dst_w;
  1.4216 +
  1.4217 +    while (info->dst_h--) {
  1.4218 +        Uint32 *src;
  1.4219 +        Uint32 *dst = (Uint32 *)info->dst;
  1.4220 +        int n = info->dst_w;
  1.4221 +        srcx = -1;
  1.4222 +        posx = 0x10000L;
  1.4223 +        while (posy >= 0x10000L) {
  1.4224 +            ++srcy;
  1.4225 +            posy -= 0x10000L;
  1.4226 +        }
  1.4227 +        while (n--) {
  1.4228 +            if (posx >= 0x10000L) {
  1.4229 +                while (posx >= 0x10000L) {
  1.4230 +                    ++srcx;
  1.4231 +                    posx -= 0x10000L;
  1.4232 +                }
  1.4233 +                src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  1.4234 +            }
  1.4235 +            pixel = *src;
  1.4236 +            B = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); R = (Uint8)(pixel >> 8); A = (Uint8)pixel;
  1.4237 +            if (flags & SDL_COPY_MODULATE_COLOR) {
  1.4238 +                R = (R * modulateR) / 255;
  1.4239 +                G = (G * modulateG) / 255;
  1.4240 +                B = (B * modulateB) / 255;
  1.4241 +            }
  1.4242 +            if (flags & SDL_COPY_MODULATE_ALPHA) {
  1.4243 +                A = (A * modulateA) / 255;
  1.4244 +            }
  1.4245 +            pixel = ((Uint32)A << 24) | ((Uint32)R << 16) | ((Uint32)G << 8) | B;
  1.4246 +            *dst = pixel;
  1.4247 +            posx += incx;
  1.4248 +            ++dst;
  1.4249 +        }
  1.4250 +        posy += incy;
  1.4251 +        info->dst += info->dst_pitch;
  1.4252 +    }
  1.4253 +}
  1.4254 +
  1.4255 +static void SDL_Blit_BGRA8888_ARGB8888_Modulate_Blend(SDL_BlitInfo *info)
  1.4256 +{
  1.4257 +    const int flags = info->flags;
  1.4258 +    const Uint32 modulateR = info->r;
  1.4259 +    const Uint32 modulateG = info->g;
  1.4260 +    const Uint32 modulateB = info->b;
  1.4261 +    const Uint32 modulateA = info->a;
  1.4262 +    Uint32 srcpixel;
  1.4263 +    Uint32 srcR, srcG, srcB, srcA;
  1.4264 +    Uint32 dstpixel;
  1.4265 +    Uint32 dstR, dstG, dstB, dstA;
  1.4266 +
  1.4267 +    while (info->dst_h--) {
  1.4268 +        Uint32 *src = (Uint32 *)info->src;
  1.4269 +        Uint32 *dst = (Uint32 *)info->dst;
  1.4270 +        int n = info->dst_w;
  1.4271 +        while (n--) {
  1.4272 +            srcpixel = *src;
  1.4273 +            srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
  1.4274 +            dstpixel = *dst;
  1.4275 +            dstA = (Uint8)(dstpixel >> 24); dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
  1.4276 +            if (flags & SDL_COPY_MODULATE_COLOR) {
  1.4277 +                srcR = (srcR * modulateR) / 255;
  1.4278 +                srcG = (srcG * modulateG) / 255;
  1.4279 +                srcB = (srcB * modulateB) / 255;
  1.4280 +            }
  1.4281 +            if (flags & SDL_COPY_MODULATE_ALPHA) {
  1.4282 +                srcA = (srcA * modulateA) / 255;
  1.4283 +            }
  1.4284 +            if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  1.4285 +                /* This goes away if we ever use premultiplied alpha */
  1.4286 +                if (srcA < 255) {
  1.4287 +                    srcR = (srcR * srcA) / 255;
  1.4288 +                    srcG = (srcG * srcA) / 255;
  1.4289 +                    srcB = (srcB * srcA) / 255;
  1.4290 +                }
  1.4291 +            }
  1.4292 +            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
  1.4293 +            case SDL_COPY_MASK:
  1.4294 +                if (srcA) {
  1.4295 +                    dstR = srcR;
  1.4296 +                    dstG = srcG;
  1.4297 +                    dstB = srcB;
  1.4298 +                }
  1.4299 +                break;
  1.4300 +            case SDL_COPY_BLEND:
  1.4301 +                dstR = srcR + ((255 - srcA) * dstR) / 255;
  1.4302 +                dstG = srcG + ((255 - srcA) * dstG) / 255;
  1.4303 +                dstB = srcB + ((255 - srcA) * dstB) / 255;
  1.4304 +                break;
  1.4305 +            case SDL_COPY_ADD:
  1.4306 +                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  1.4307 +                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  1.4308 +                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  1.4309 +                break;
  1.4310 +            case SDL_COPY_MOD:
  1.4311 +                dstR = (srcR * dstR) / 255;
  1.4312 +                dstG = (srcG * dstG) / 255;
  1.4313 +                dstB = (srcB * dstB) / 255;
  1.4314 +                break;
  1.4315 +            }
  1.4316 +            dstpixel = ((Uint32)dstA << 24) | ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
  1.4317 +            *dst = dstpixel;
  1.4318 +            ++src;
  1.4319 +            ++dst;
  1.4320 +        }
  1.4321 +        info->src += info->src_pitch;
  1.4322 +        info->dst += info->dst_pitch;
  1.4323 +    }
  1.4324 +}
  1.4325 +
  1.4326 +static void SDL_Blit_BGRA8888_ARGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info)
  1.4327 +{
  1.4328 +    const int flags = info->flags;
  1.4329 +    const Uint32 modulateR = info->r;
  1.4330 +    const Uint32 modulateG = info->g;
  1.4331 +    const Uint32 modulateB = info->b;
  1.4332 +    const Uint32 modulateA = info->a;
  1.4333 +    Uint32 srcpixel;
  1.4334 +    Uint32 srcR, srcG, srcB, srcA;
  1.4335 +    Uint32 dstpixel;
  1.4336 +    Uint32 dstR, dstG, dstB, dstA;
  1.4337 +    int srcy, srcx;
  1.4338 +    int posy, posx;
  1.4339 +    int incy, incx;
  1.4340 +
  1.4341 +    srcy = 0;
  1.4342 +    posy = 0;
  1.4343 +    incy = (info->src_h << 16) / info->dst_h;
  1.4344 +    incx = (info->src_w << 16) / info->dst_w;
  1.4345 +
  1.4346 +    while (info->dst_h--) {
  1.4347 +        Uint32 *src;
  1.4348 +        Uint32 *dst = (Uint32 *)info->dst;
  1.4349 +        int n = info->dst_w;
  1.4350 +        srcx = -1;
  1.4351 +        posx = 0x10000L;
  1.4352 +        while (posy >= 0x10000L) {
  1.4353 +            ++srcy;
  1.4354 +            posy -= 0x10000L;
  1.4355 +        }
  1.4356 +        while (n--) {
  1.4357 +            if (posx >= 0x10000L) {
  1.4358 +                while (posx >= 0x10000L) {
  1.4359 +                    ++srcx;
  1.4360 +                    posx -= 0x10000L;
  1.4361 +                }
  1.4362 +                src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
  1.4363 +            }
  1.4364 +            srcpixel = *src;
  1.4365 +            srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
  1.4366 +            dstpixel = *dst;
  1.4367 +            dstA = (Uint8)(dstpixel >> 24); dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel;
  1.4368 +            if (flags & SDL_COPY_MODULATE_COLOR) {
  1.4369 +                srcR = (srcR * modulateR) / 255;
  1.4370 +                srcG = (srcG * modulateG) / 255;
  1.4371 +                srcB = (srcB * modulateB) / 255;
  1.4372 +            }
  1.4373 +            if (flags & SDL_COPY_MODULATE_ALPHA) {
  1.4374 +                srcA = (srcA * modulateA) / 255;
  1.4375 +            }
  1.4376 +            if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
  1.4377 +                /* This goes away if we ever use premultiplied alpha */
  1.4378 +                if (srcA < 255) {
  1.4379 +                    srcR = (srcR * srcA) / 255;
  1.4380 +                    srcG = (srcG * srcA) / 255;
  1.4381 +                    srcB = (srcB * srcA) / 255;
  1.4382 +                }
  1.4383 +            }
  1.4384 +            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
  1.4385 +            case SDL_COPY_MASK:
  1.4386 +                if (srcA) {
  1.4387 +                    dstR = srcR;
  1.4388 +                    dstG = srcG;
  1.4389 +                    dstB = srcB;
  1.4390 +                }
  1.4391 +                break;
  1.4392 +            case SDL_COPY_BLEND:
  1.4393 +                dstR = srcR + ((255 - srcA) * dstR) / 255;
  1.4394 +                dstG = srcG + ((255 - srcA) * dstG) / 255;
  1.4395 +                dstB = srcB + ((255 - srcA) * dstB) / 255;
  1.4396 +                break;
  1.4397 +            case SDL_COPY_ADD:
  1.4398 +                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  1.4399 +                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  1.4400 +                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  1.4401 +                break;
  1.4402 +            case SDL_COPY_MOD:
  1.4403 +                dstR = (srcR * dstR) / 255;
  1.4404 +                dstG = (srcG * dstG) / 255;
  1.4405 +                dstB = (srcB * dstB) / 255;
  1.4406 +                break;
  1.4407 +            }
  1.4408 +            dstpixel = ((Uint32)dstA << 24) | ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
  1.4409 +            *dst = dstpixel;
  1.4410              posx += incx;
  1.4411              ++dst;
  1.4412          }
  1.4413 @@ -5277,6 +7894,13 @@
  1.4414      { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGB888_BGR888_Modulate_Scale },
  1.4415      { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_RGB888_BGR888_Modulate_Blend },
  1.4416      { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGB888_BGR888_Modulate_Blend_Scale },
  1.4417 +    { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGB888_ARGB8888_Scale },
  1.4418 +    { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_RGB888_ARGB8888_Blend },
  1.4419 +    { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGB888_ARGB8888_Blend_Scale },
  1.4420 +    { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA), SDL_CPU_ANY, SDL_Blit_RGB888_ARGB8888_Modulate },
  1.4421 +    { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGB888_ARGB8888_Modulate_Scale },
  1.4422 +    { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_RGB888_ARGB8888_Modulate_Blend },
  1.4423 +    { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGB888_ARGB8888_Modulate_Blend_Scale },
  1.4424      { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGR888_RGB888_Scale },
  1.4425      { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_BGR888_RGB888_Blend },
  1.4426      { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGR888_RGB888_Blend_Scale },
  1.4427 @@ -5291,6 +7915,13 @@
  1.4428      { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGR888_BGR888_Modulate_Scale },
  1.4429      { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_BGR888_BGR888_Modulate_Blend },
  1.4430      { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGR888_BGR888_Modulate_Blend_Scale },
  1.4431 +    { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGR888_ARGB8888_Scale },
  1.4432 +    { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_BGR888_ARGB8888_Blend },
  1.4433 +    { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGR888_ARGB8888_Blend_Scale },
  1.4434 +    { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA), SDL_CPU_ANY, SDL_Blit_BGR888_ARGB8888_Modulate },
  1.4435 +    { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGR888_ARGB8888_Modulate_Scale },
  1.4436 +    { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_BGR888_ARGB8888_Modulate_Blend },
  1.4437 +    { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGR888_ARGB8888_Modulate_Blend_Scale },
  1.4438      { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_RGB888_Scale },
  1.4439      { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_ARGB8888_RGB888_Blend },
  1.4440      { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_RGB888_Blend_Scale },
  1.4441 @@ -5305,6 +7936,13 @@
  1.4442      { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_BGR888_Modulate_Scale },
  1.4443      { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_ARGB8888_BGR888_Modulate_Blend },
  1.4444      { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_BGR888_Modulate_Blend_Scale },
  1.4445 +    { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_ARGB8888_Scale },
  1.4446 +    { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_ARGB8888_ARGB8888_Blend },
  1.4447 +    { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_ARGB8888_Blend_Scale },
  1.4448 +    { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA), SDL_CPU_ANY, SDL_Blit_ARGB8888_ARGB8888_Modulate },
  1.4449 +    { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_ARGB8888_Modulate_Scale },
  1.4450 +    { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_ARGB8888_ARGB8888_Modulate_Blend },
  1.4451 +    { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_ARGB8888_Modulate_Blend_Scale },
  1.4452      { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_RGB888_Scale },
  1.4453      { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_RGBA8888_RGB888_Blend },
  1.4454      { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_RGB888_Blend_Scale },
  1.4455 @@ -5319,6 +7957,13 @@
  1.4456      { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_BGR888_Modulate_Scale },
  1.4457      { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_RGBA8888_BGR888_Modulate_Blend },
  1.4458      { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_BGR888_Modulate_Blend_Scale },
  1.4459 +    { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_ARGB8888_Scale },
  1.4460 +    { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_RGBA8888_ARGB8888_Blend },
  1.4461 +    { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_ARGB8888_Blend_Scale },
  1.4462 +    { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA), SDL_CPU_ANY, SDL_Blit_RGBA8888_ARGB8888_Modulate },
  1.4463 +    { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_ARGB8888_Modulate_Scale },
  1.4464 +    { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_RGBA8888_ARGB8888_Modulate_Blend },
  1.4465 +    { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_ARGB8888_Modulate_Blend_Scale },
  1.4466      { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_RGB888_Scale },
  1.4467      { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_ABGR8888_RGB888_Blend },
  1.4468      { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_RGB888_Blend_Scale },
  1.4469 @@ -5333,6 +7978,13 @@
  1.4470      { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_BGR888_Modulate_Scale },
  1.4471      { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_ABGR8888_BGR888_Modulate_Blend },
  1.4472      { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_BGR888_Modulate_Blend_Scale },
  1.4473 +    { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_ARGB8888_Scale },
  1.4474 +    { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_ABGR8888_ARGB8888_Blend },
  1.4475 +    { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_ARGB8888_Blend_Scale },
  1.4476 +    { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA), SDL_CPU_ANY, SDL_Blit_ABGR8888_ARGB8888_Modulate },
  1.4477 +    { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_ARGB8888_Modulate_Scale },
  1.4478 +    { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_ABGR8888_ARGB8888_Modulate_Blend },
  1.4479 +    { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_ARGB8888_Modulate_Blend_Scale },
  1.4480      { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_RGB888_Scale },
  1.4481      { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_BGRA8888_RGB888_Blend },
  1.4482      { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_RGB888_Blend_Scale },
  1.4483 @@ -5347,6 +7999,13 @@
  1.4484      { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_BGR888_Modulate_Scale },
  1.4485      { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_BGRA8888_BGR888_Modulate_Blend },
  1.4486      { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_BGR888_Modulate_Blend_Scale },
  1.4487 +    { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_ARGB8888_Scale },
  1.4488 +    { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_BGRA8888_ARGB8888_Blend },
  1.4489 +    { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_ARGB8888_Blend_Scale },
  1.4490 +    { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA), SDL_CPU_ANY, SDL_Blit_BGRA8888_ARGB8888_Modulate },
  1.4491 +    { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_ARGB8888_Modulate_Scale },
  1.4492 +    { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_BGRA8888_ARGB8888_Modulate_Blend },
  1.4493 +    { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_ARGB8888_Modulate_Blend_Scale },
  1.4494      { 0, 0, 0, 0, NULL }
  1.4495  };
  1.4496  
     2.1 --- a/src/video/sdlgenblit.pl	Fri Nov 28 20:09:32 2008 +0000
     2.2 +++ b/src/video/sdlgenblit.pl	Sat Nov 29 00:08:29 2008 +0000
     2.3 @@ -38,6 +38,7 @@
     2.4  my @dst_formats = (
     2.5      "RGB888",
     2.6      "BGR888",
     2.7 +    "ARGB8888",
     2.8  );
     2.9  
    2.10  my %format_size = (
    2.11 @@ -60,8 +61,7 @@
    2.12  
    2.13  my %get_rgba_string = (
    2.14      "RGB888" => "_R = (Uint8)(_pixel >> 16); _G = (Uint8)(_pixel >> 8); _B = (Uint8)_pixel; _A = 0xFF;",
    2.15 -    "BGR888" => "_B = (Uint8)(_pixel >> 16); _G = (Uint8)(_pixel >> 8); _R = (Uint8)_pixel; _A = 0xFF;",
    2.16 -    "ARGB8888" => "_A = (Uint8)(_pixel >> 24); _R = (Uint8)(_pixel >> 16); _G = (Uint8)(_pixel >> 8); _B = (Uint8)_pixel;",
    2.17 +    "BGR888" => "_B = (Uint8)(_pixel >> 16); _G = (Uint8)(_pixel >> 8); _R = (Uint8)_pixel; _A = 0xFF;", "ARGB8888" => "_A = (Uint8)(_pixel >> 24); _R = (Uint8)(_pixel >> 16); _G = (Uint8)(_pixel >> 8); _B = (Uint8)_pixel;",
    2.18      "RGBA8888" => "_R = (Uint8)(_pixel >> 24); _G = (Uint8)(_pixel >> 16); _B = (Uint8)(_pixel >> 8); _A = (Uint8)_pixel;",
    2.19      "ABGR8888" => "_A = (Uint8)(_pixel >> 24); _B = (Uint8)(_pixel >> 16); _G = (Uint8)(_pixel >> 8); _R = (Uint8)_pixel;",
    2.20      "BGRA8888" => "_B = (Uint8)(_pixel >> 24); _G = (Uint8)(_pixel >> 16); _R = (Uint8)(_pixel >> 8); _A = (Uint8)_pixel;",
    2.21 @@ -70,6 +70,10 @@
    2.22  my %set_rgba_string = (
    2.23      "RGB888" => "_pixel = ((Uint32)_R << 16) | ((Uint32)_G << 8) | _B;",
    2.24      "BGR888" => "_pixel = ((Uint32)_B << 16) | ((Uint32)_G << 8) | _R;",
    2.25 +    "ARGB8888" => "_pixel = ((Uint32)_A << 24) | ((Uint32)_R << 16) | ((Uint32)_G << 8) | _B;",
    2.26 +    "RGBA8888" => "_pixel = ((Uint32)_R << 24) | ((Uint32)_G << 16) | ((Uint32)_B << 8) | _A;",
    2.27 +    "ABGR8888" => "_pixel = ((Uint32)_A << 24) | ((Uint32)_B << 16) | ((Uint32)_G << 8) | _R;",
    2.28 +    "BGRA8888" => "_pixel = ((Uint32)_B << 24) | ((Uint32)_G << 16) | ((Uint32)_R << 8) | _A;",
    2.29  );
    2.30  
    2.31  sub open_file {