Added source color and alpha modulation support.
authorSam Lantinga <slouken@libsdl.org>
Mon, 28 Aug 2006 03:17:39 +0000
changeset 19858055185ae4ed
parent 1984 b910bcabec26
child 1986 f4c65e3bfaed
Added source color and alpha modulation support.
Added perl script to generate optimized render copy functions.
include/SDL_audio.h
include/SDL_endian.h
include/SDL_video.h
src/SDL_compat.c
src/audio/SDL_audiocvt.c
src/audio/SDL_audiotypecvt.c
src/audio/SDL_mixer.c
src/audio/sdlgenaudiocvt.pl
src/hermes/HeadX86.h
src/video/SDL_blit_N.c
src/video/SDL_glfuncs.h
src/video/SDL_rendercopy.c
src/video/SDL_rendercopy.h
src/video/SDL_renderer_gl.c
src/video/SDL_renderer_sw.c
src/video/SDL_stretch.c
src/video/SDL_sysvideo.h
src/video/SDL_video.c
src/video/dummy/SDL_nullrender.c
src/video/sdlgenblit.pl
src/video/win32/SDL_d3drender.c
src/video/win32/SDL_gdirender.c
test/testgl2.c
test/testsprite2.c
test/testwm2.c
     1.1 --- a/include/SDL_audio.h	Thu Aug 24 12:49:59 2006 +0000
     1.2 +++ b/include/SDL_audio.h	Mon Aug 28 03:17:39 2006 +0000
     1.3 @@ -132,22 +132,22 @@
     1.4  
     1.5  /* A structure to hold a set of audio conversion filters and buffers */
     1.6  struct SDL_AudioCVT;
     1.7 -typedef void (SDLCALL * SDL_AudioFilter)(struct SDL_AudioCVT *cvt,
     1.8 -                                         SDL_AudioFormat format);
     1.9 +typedef void (SDLCALL * SDL_AudioFilter) (struct SDL_AudioCVT * cvt,
    1.10 +                                          SDL_AudioFormat format);
    1.11  
    1.12  typedef struct SDL_AudioCVT
    1.13  {
    1.14 -    int needed;                  /* Set to 1 if conversion possible */
    1.15 -    SDL_AudioFormat src_format;  /* Source audio format */
    1.16 -    SDL_AudioFormat dst_format;  /* Target audio format */
    1.17 -    double rate_incr;            /* Rate conversion increment */
    1.18 -    Uint8 *buf;                  /* Buffer to hold entire audio data */
    1.19 -    int len;                     /* Length of original audio buffer */
    1.20 -    int len_cvt;                 /* Length of converted audio buffer */
    1.21 -    int len_mult;                /* buffer must be len*len_mult big */
    1.22 -    double len_ratio;            /* Given len, final size is len*len_ratio */
    1.23 -    SDL_AudioFilter filters[10]; /* Filter list */
    1.24 -    int filter_index;            /* Current audio conversion function */
    1.25 +    int needed;                 /* Set to 1 if conversion possible */
    1.26 +    SDL_AudioFormat src_format; /* Source audio format */
    1.27 +    SDL_AudioFormat dst_format; /* Target audio format */
    1.28 +    double rate_incr;           /* Rate conversion increment */
    1.29 +    Uint8 *buf;                 /* Buffer to hold entire audio data */
    1.30 +    int len;                    /* Length of original audio buffer */
    1.31 +    int len_cvt;                /* Length of converted audio buffer */
    1.32 +    int len_mult;               /* buffer must be len*len_mult big */
    1.33 +    double len_ratio;           /* Given len, final size is len*len_ratio */
    1.34 +    SDL_AudioFilter filters[10];        /* Filter list */
    1.35 +    int filter_index;           /* Current audio conversion function */
    1.36  } SDL_AudioCVT;
    1.37  
    1.38  
     2.1 --- a/include/SDL_endian.h	Thu Aug 24 12:49:59 2006 +0000
     2.2 +++ b/include/SDL_endian.h	Mon Aug 28 03:17:39 2006 +0000
     2.3 @@ -195,7 +195,11 @@
     2.4  static __inline__ float
     2.5  SDL_SwapFloat(float x)
     2.6  {
     2.7 -    union { float f; Uint32 ui32; } swapper;
     2.8 +    union
     2.9 +    {
    2.10 +        float f;
    2.11 +        Uint32 ui32;
    2.12 +    } swapper;
    2.13      swapper.f = x;
    2.14      swapper.ui32 = SDL_Swap32(swapper.ui32);
    2.15      return swapper.f;
     3.1 --- a/include/SDL_video.h	Thu Aug 24 12:49:59 2006 +0000
     3.2 +++ b/include/SDL_video.h	Mon Aug 28 03:17:39 2006 +0000
     3.3 @@ -176,7 +176,7 @@
     3.4      SDL_RENDERER_PRESENTFLIP3 = 0x00000008,     /**< Present uses a flip, rotating between two back buffers and a front buffer */
     3.5      SDL_RENDERER_PRESENTDISCARD = 0x00000010,   /**< Present leaves the contents of the backbuffer undefined */
     3.6      SDL_RENDERER_PRESENTVSYNC = 0x00000020,     /**< Present is synchronized with the refresh rate */
     3.7 -    SDL_RENDERER_ACCELERATED = 0x00000040,      /**< The renderer uses hardware acceleration */
     3.8 +    SDL_RENDERER_ACCELERATED = 0x0000040,       /**< The renderer uses hardware acceleration */
     3.9  } SDL_RendererFlags;
    3.10  
    3.11  /**
    3.12 @@ -188,6 +188,7 @@
    3.13  {
    3.14      const char *name;           /**< The name of the renderer */
    3.15      Uint32 flags;               /**< Supported SDL_RendererFlags */
    3.16 +    Uint32 mod_modes;           /**< A mask of supported channel modulation */
    3.17      Uint32 blend_modes;         /**< A mask of supported blend modes */
    3.18      Uint32 scale_modes;         /**< A mask of supported scale modes */
    3.19      Uint32 num_texture_formats; /**< The number of available texture formats */
    3.20 @@ -208,9 +209,21 @@
    3.21  } SDL_TextureAccess;
    3.22  
    3.23  /**
    3.24 + * \enum SDL_TextureModulate
    3.25 + *
    3.26 + * \brief The texture channel modulation used in SDL_RenderCopy()
    3.27 + */
    3.28 +typedef enum
    3.29 +{
    3.30 +    SDL_TEXTUREMODULATE_NONE = 0x00000000,     /**< No modulation */
    3.31 +    SDL_TEXTUREMODULATE_COLOR = 0x00000001,    /**< srcC = srcC * color */
    3.32 +    SDL_TEXTUREMODULATE_ALPHA = 0x00000002,    /**< srcA = srcA * alpha */
    3.33 +} SDL_TextureModulate;
    3.34 +
    3.35 +/**
    3.36   * \enum SDL_TextureBlendMode
    3.37   *
    3.38 - * \brief The blend mode used in SDL_RenderCopy()
    3.39 + * \brief The texture blend mode used in SDL_RenderCopy()
    3.40   */
    3.41  typedef enum
    3.42  {
    3.43 @@ -224,7 +237,7 @@
    3.44  /**
    3.45   * \enum SDL_TextureScaleMode
    3.46   *
    3.47 - * \brief The scale mode used in SDL_RenderCopy()
    3.48 + * \brief The texture scale mode used in SDL_RenderCopy()
    3.49   */
    3.50  typedef enum
    3.51  {
    3.52 @@ -272,12 +285,15 @@
    3.53      int pitch;                  /* Read-only */
    3.54      void *pixels;               /* Read-write */
    3.55  
    3.56 +    /* Application data associated with the surfade */
    3.57 +    void *userdata;             /* Read-write */
    3.58 +
    3.59      /* texture associated with the surface, if any */
    3.60 -    SDL_TextureID textureID;
    3.61 +    SDL_TextureID textureID;    /* Read-only */
    3.62  
    3.63      /* information needed for surfaces requiring locks */
    3.64 -    int locked;
    3.65 -    void *lock_data;
    3.66 +    int locked;                 /* Read-only */
    3.67 +    void *lock_data;            /* Read-only */
    3.68  
    3.69      /* clipping information */
    3.70      SDL_Rect clip_rect;         /* Read-only */
    3.71 @@ -998,6 +1014,136 @@
    3.72                                                    int ncolors);
    3.73  
    3.74  /**
    3.75 + * \fn int SDL_SetTextureColorMod(SDL_TextureID textureID, Uint8 r, Uint8 g, Uint8 b)
    3.76 + *
    3.77 + * \brief Set an additional color value used in render copy operations
    3.78 + *
    3.79 + * \param texture The texture to update
    3.80 + * \param r The red source color value multiplied into copy operations
    3.81 + * \param g The green source color value multiplied into copy operations
    3.82 + * \param b The blue source color value multiplied into copy operations
    3.83 + *
    3.84 + * \return 0 on success, or -1 if the texture is not valid or color modulation is not supported
    3.85 + *
    3.86 + * \sa SDL_GetTextureColorMod()
    3.87 + */
    3.88 +extern DECLSPEC int SDLCALL SDL_SetTextureColorMod(SDL_TextureID textureID,
    3.89 +                                                   Uint8 r, Uint8 g, Uint8 b);
    3.90 +
    3.91 +
    3.92 +/**
    3.93 + * \fn int SDL_GetTextureColorMod(SDL_TextureID textureID, Uint8 *r, Uint8 *g, Uint8 *b)
    3.94 + *
    3.95 + * \brief Get the additional color value used in render copy operations
    3.96 + *
    3.97 + * \param texture The texture to query
    3.98 + * \param r A pointer filled in with the source red color value
    3.99 + * \param g A pointer filled in with the source green color value
   3.100 + * \param b A pointer filled in with the source blue color value
   3.101 + *
   3.102 + * \return 0 on success, or -1 if the texture is not valid
   3.103 + *
   3.104 + * \sa SDL_SetTextureColorMod()
   3.105 + */
   3.106 +extern DECLSPEC int SDLCALL SDL_GetTextureColorMod(SDL_TextureID textureID,
   3.107 +                                                   Uint8 * r, Uint8 * g,
   3.108 +                                                   Uint8 * b);
   3.109 +
   3.110 +/**
   3.111 + * \fn int SDL_SetTextureAlphaMod(SDL_TextureID textureID, Uint8 alpha)
   3.112 + *
   3.113 + * \brief Set an additional alpha value used in render copy operations
   3.114 + *
   3.115 + * \param texture The texture to update
   3.116 + * \param alpha The source alpha value multiplied into copy operations.
   3.117 + *
   3.118 + * \return 0 on success, or -1 if the texture is not valid or alpha modulation is not supported
   3.119 + *
   3.120 + * \sa SDL_GetTextureAlphaMod()
   3.121 + */
   3.122 +extern DECLSPEC int SDLCALL SDL_SetTextureAlphaMod(SDL_TextureID textureID,
   3.123 +                                                   Uint8 alpha);
   3.124 +
   3.125 +/**
   3.126 + * \fn int SDL_GetTextureAlphaMod(SDL_TextureID textureID, Uint8 *alpha)
   3.127 + *
   3.128 + * \brief Get the additional alpha value used in render copy operations
   3.129 + *
   3.130 + * \param texture The texture to query
   3.131 + * \param alpha A pointer filled in with the source alpha value
   3.132 + *
   3.133 + * \return 0 on success, or -1 if the texture is not valid
   3.134 + *
   3.135 + * \sa SDL_SetTextureAlphaMod()
   3.136 + */
   3.137 +extern DECLSPEC int SDLCALL SDL_GetTextureAlphaMod(SDL_TextureID textureID,
   3.138 +                                                   Uint8 * alpha);
   3.139 +
   3.140 +/**
   3.141 + * \fn int SDL_SetTextureBlendMode(SDL_TextureID textureID, int blendMode)
   3.142 + *
   3.143 + * \brief Set the blend mode used for texture copy operations
   3.144 + *
   3.145 + * \param texture The texture to update
   3.146 + * \param blendMode SDL_TextureBlendMode to use for texture blending
   3.147 + *
   3.148 + * \return 0 on success, or -1 if the texture is not valid or the blend mode is not supported
   3.149 + *
   3.150 + * \note If the blend mode is not supported, the closest supported mode is chosen.
   3.151 + *
   3.152 + * \sa SDL_GetTextureBlendMode()
   3.153 + */
   3.154 +extern DECLSPEC int SDLCALL SDL_SetTextureBlendMode(SDL_TextureID textureID,
   3.155 +                                                    int blendMode);
   3.156 +
   3.157 +/**
   3.158 + * \fn int SDL_GetTextureBlendMode(SDL_TextureID textureID, int *blendMode)
   3.159 + *
   3.160 + * \brief Get the blend mode used for texture copy operations
   3.161 + *
   3.162 + * \param texture The texture to query
   3.163 + * \param blendMode A pointer filled in with the current blend mode
   3.164 + *
   3.165 + * \return 0 on success, or -1 if the texture is not valid
   3.166 + *
   3.167 + * \sa SDL_SetTextureBlendMode()
   3.168 + */
   3.169 +extern DECLSPEC int SDLCALL SDL_GetTextureBlendMode(SDL_TextureID textureID,
   3.170 +                                                    int *blendMode);
   3.171 +
   3.172 +/**
   3.173 + * \fn int SDL_SetTextureScaleMode(SDL_TextureID textureID, int scaleMode)
   3.174 + *
   3.175 + * \brief Set the scale mode used for texture copy operations
   3.176 + *
   3.177 + * \param texture The texture to update
   3.178 + * \param scaleMode SDL_TextureScaleMode to use for texture scaling
   3.179 + *
   3.180 + * \return 0 on success, or -1 if the texture is not valid or the scale mode is not supported
   3.181 + *
   3.182 + * \note If the scale mode is not supported, the closest supported mode is chosen.
   3.183 + *
   3.184 + * \sa SDL_GetTextureScaleMode()
   3.185 + */
   3.186 +extern DECLSPEC int SDLCALL SDL_SetTextureScaleMode(SDL_TextureID textureID,
   3.187 +                                                    int scaleMode);
   3.188 +
   3.189 +/**
   3.190 + * \fn int SDL_GetTextureScaleMode(SDL_TextureID textureID, int *scaleMode)
   3.191 + *
   3.192 + * \brief Get the scale mode used for texture copy operations
   3.193 + *
   3.194 + * \param texture The texture to query
   3.195 + * \param scaleMode A pointer filled in with the current scale mode
   3.196 + *
   3.197 + * \return 0 on success, or -1 if the texture is not valid
   3.198 + *
   3.199 + * \sa SDL_SetTextureScaleMode()
   3.200 + */
   3.201 +extern DECLSPEC int SDLCALL SDL_GetTextureScaleMode(SDL_TextureID textureID,
   3.202 +                                                    int *scaleMode);
   3.203 +
   3.204 +/**
   3.205   * \fn int SDL_UpdateTexture(SDL_TextureID textureID, const SDL_Rect *rect, const void *pixels, int pitch)
   3.206   *
   3.207   * \brief Update the given texture rectangle with new pixel data.
   3.208 @@ -1061,37 +1207,35 @@
   3.209                                                const SDL_Rect * rects);
   3.210  
   3.211  /**
   3.212 - * \fn void SDL_RenderFill(const SDL_Rect *rect, Uint32 color)
   3.213 + * \fn void SDL_RenderFill(Uint8 r, Uint8 g, Uint8 b, Uint8 a, const SDL_Rect *rect)
   3.214   *
   3.215   * \brief Fill the current rendering target with the specified color.
   3.216   *
   3.217 + * \param r The red value used to fill the rendering target
   3.218 + * \param g The green value used to fill the rendering target
   3.219 + * \param b The blue value used to fill the rendering target
   3.220 + * \param a The alpha value used to fill the rendering target, usually SDL_ALPHA_OPAQUE (255)
   3.221   * \param rect A pointer to the destination rectangle, or NULL for the entire rendering target.
   3.222 - * \param color An ARGB color value.
   3.223   *
   3.224   * \return 0 on success, or -1 if there is no rendering context current
   3.225   */
   3.226 -extern DECLSPEC int SDLCALL SDL_RenderFill(const SDL_Rect * rect,
   3.227 -                                           Uint32 color);
   3.228 +extern DECLSPEC int SDLCALL SDL_RenderFill(Uint8 r, Uint8 g, Uint8 b, Uint8 a,
   3.229 +                                           const SDL_Rect * rect);
   3.230  
   3.231  /**
   3.232 - * \fn int SDL_RenderCopy(SDL_TextureID textureID, const SDL_Rect *srcrect, const SDL_Rect *dstrect, Uint32 blendMode, Uint32 scaleMode)
   3.233 + * \fn int SDL_RenderCopy(SDL_TextureID textureID, const SDL_Rect *srcrect, const SDL_Rect *dstrect)
   3.234   *
   3.235   * \brief Copy a portion of the texture to the current rendering target.
   3.236   *
   3.237   * \param texture The source texture.
   3.238   * \param srcrect A pointer to the source rectangle, or NULL for the entire texture.
   3.239   * \param dstrect A pointer to the destination rectangle, or NULL for the entire rendering target.
   3.240 - * \param blendMode SDL_TextureBlendMode to be used if the source texture has an alpha channel.
   3.241 - * \param scaleMode SDL_TextureScaleMode to be used if the source and destination rectangles don't have the same width and height.
   3.242   *
   3.243   * \return 0 on success, or -1 if there is no rendering context current, or the driver doesn't support the requested operation.
   3.244 - *
   3.245 - * \note You can check the video driver info to see what operations are supported.
   3.246   */
   3.247  extern DECLSPEC int SDLCALL SDL_RenderCopy(SDL_TextureID textureID,
   3.248                                             const SDL_Rect * srcrect,
   3.249 -                                           const SDL_Rect * dstrect,
   3.250 -                                           int blendMode, int scaleMode);
   3.251 +                                           const SDL_Rect * dstrect);
   3.252  
   3.253  /**
   3.254   * \fn int SDL_RenderReadPixels(const SDL_Rect *rect, void *pixels, int pitch)
     4.1 --- a/src/SDL_compat.c	Thu Aug 24 12:49:59 2006 +0000
     4.2 +++ b/src/SDL_compat.c	Mon Aug 28 03:17:39 2006 +0000
     4.3 @@ -673,9 +673,7 @@
     4.4      if (screen == SDL_VideoSurface) {
     4.5          if (SDL_VideoRendererInfo.flags & SDL_RENDERER_PRESENTCOPY) {
     4.6              for (i = 0; i < numrects; ++i) {
     4.7 -                SDL_RenderCopy(SDL_VideoTexture, &rects[i], &rects[i],
     4.8 -                               SDL_TEXTUREBLENDMODE_NONE,
     4.9 -                               SDL_TEXTURESCALEMODE_NONE);
    4.10 +                SDL_RenderCopy(SDL_VideoTexture, &rects[i], &rects[i]);
    4.11              }
    4.12          } else {
    4.13              SDL_Rect rect;
    4.14 @@ -683,9 +681,7 @@
    4.15              rect.y = 0;
    4.16              rect.w = screen->w;
    4.17              rect.h = screen->h;
    4.18 -            SDL_RenderCopy(SDL_VideoTexture, &rect, &rect,
    4.19 -                           SDL_TEXTUREBLENDMODE_NONE,
    4.20 -                           SDL_TEXTURESCALEMODE_NONE);
    4.21 +            SDL_RenderCopy(SDL_VideoTexture, &rect, &rect);
    4.22          }
    4.23          SDL_RenderPresent();
    4.24      }
    4.25 @@ -1421,9 +1417,7 @@
    4.26  int
    4.27  SDL_DisplayYUVOverlay(SDL_Overlay * overlay, SDL_Rect * dstrect)
    4.28  {
    4.29 -    if (SDL_RenderCopy(overlay->hwdata->textureID, NULL, dstrect,
    4.30 -                       SDL_TEXTUREBLENDMODE_NONE,
    4.31 -                       SDL_TEXTURESCALEMODE_FAST) < 0) {
    4.32 +    if (SDL_RenderCopy(overlay->hwdata->textureID, NULL, dstrect) < 0) {
    4.33          return -1;
    4.34      }
    4.35      SDL_RenderPresent();
     5.1 --- a/src/audio/SDL_audiocvt.c	Thu Aug 24 12:49:59 2006 +0000
     5.2 +++ b/src/audio/SDL_audiocvt.c	Mon Aug 28 03:17:39 2006 +0000
     5.3 @@ -36,7 +36,7 @@
     5.4  #ifdef DEBUG_CONVERT
     5.5      fprintf(stderr, "Converting to mono\n");
     5.6  #endif
     5.7 -    switch (format & (SDL_AUDIO_MASK_SIGNED|SDL_AUDIO_MASK_BITSIZE)) {
     5.8 +    switch (format & (SDL_AUDIO_MASK_SIGNED | SDL_AUDIO_MASK_BITSIZE)) {
     5.9      case AUDIO_U8:
    5.10          {
    5.11              Uint8 *src, *dst;
    5.12 @@ -170,15 +170,15 @@
    5.13              if (SDL_AUDIO_ISBIGENDIAN(format)) {
    5.14                  for (i = cvt->len_cvt / 8; i; --i, src += 2) {
    5.15                      const Sint64 added =
    5.16 -                                    (((Sint64) (Sint32) SDL_SwapBE32(src[0])) +
    5.17 -                                     ((Sint64) (Sint32) SDL_SwapBE32(src[1])));
    5.18 +                        (((Sint64) (Sint32) SDL_SwapBE32(src[0])) +
    5.19 +                         ((Sint64) (Sint32) SDL_SwapBE32(src[1])));
    5.20                      *(dst++) = SDL_SwapBE32((Uint32) ((Sint32) (added >> 1)));
    5.21                  }
    5.22              } else {
    5.23                  for (i = cvt->len_cvt / 8; i; --i, src += 2) {
    5.24                      const Sint64 added =
    5.25 -                                    (((Sint64) (Sint32) SDL_SwapLE32(src[0])) +
    5.26 -                                     ((Sint64) (Sint32) SDL_SwapLE32(src[1])));
    5.27 +                        (((Sint64) (Sint32) SDL_SwapLE32(src[0])) +
    5.28 +                         ((Sint64) (Sint32) SDL_SwapLE32(src[1])));
    5.29                      *(dst++) = SDL_SwapLE32((Uint32) ((Sint32) (added >> 1)));
    5.30                  }
    5.31              }
    5.32 @@ -188,7 +188,11 @@
    5.33      case AUDIO_F32:
    5.34          {
    5.35              /* !!! FIXME: this convert union is nasty. */
    5.36 -            union { float f; Uint32 ui32; } f2i;
    5.37 +            union
    5.38 +            {
    5.39 +                float f;
    5.40 +                Uint32 ui32;
    5.41 +            } f2i;
    5.42              const Uint32 *src = (const Uint32 *) cvt->buf;
    5.43              Uint32 *dst = (Uint32 *) cvt->buf;
    5.44              if (SDL_AUDIO_ISBIGENDIAN(format)) {
    5.45 @@ -235,7 +239,7 @@
    5.46      fprintf(stderr, "Converting down from 6 channels to stereo\n");
    5.47  #endif
    5.48  
    5.49 -    #define strip_chans_6_to_2(type) \
    5.50 +#define strip_chans_6_to_2(type) \
    5.51      { \
    5.52          const type *src = (const type *) cvt->buf; \
    5.53          type *dst = (type *) cvt->buf; \
    5.54 @@ -249,18 +253,18 @@
    5.55  
    5.56      /* this function only cares about typesize, and data as a block of bits. */
    5.57      switch (SDL_AUDIO_BITSIZE(format)) {
    5.58 -        case 8:
    5.59 -            strip_chans_6_to_2(Uint8);
    5.60 -            break;
    5.61 -        case 16:
    5.62 -            strip_chans_6_to_2(Uint16);
    5.63 -            break;
    5.64 -        case 32:
    5.65 -            strip_chans_6_to_2(Uint32);
    5.66 -            break;
    5.67 +    case 8:
    5.68 +        strip_chans_6_to_2(Uint8);
    5.69 +        break;
    5.70 +    case 16:
    5.71 +        strip_chans_6_to_2(Uint16);
    5.72 +        break;
    5.73 +    case 32:
    5.74 +        strip_chans_6_to_2(Uint32);
    5.75 +        break;
    5.76      }
    5.77  
    5.78 -    #undef strip_chans_6_to_2
    5.79 +#undef strip_chans_6_to_2
    5.80  
    5.81      cvt->len_cvt /= 3;
    5.82      if (cvt->filters[++cvt->filter_index]) {
    5.83 @@ -279,7 +283,7 @@
    5.84      fprintf(stderr, "Converting 6 down to quad\n");
    5.85  #endif
    5.86  
    5.87 -    #define strip_chans_6_to_4(type) \
    5.88 +#define strip_chans_6_to_4(type) \
    5.89      { \
    5.90          const type *src = (const type *) cvt->buf; \
    5.91          type *dst = (type *) cvt->buf; \
    5.92 @@ -295,18 +299,18 @@
    5.93  
    5.94      /* this function only cares about typesize, and data as a block of bits. */
    5.95      switch (SDL_AUDIO_BITSIZE(format)) {
    5.96 -        case 8:
    5.97 -            strip_chans_6_to_4(Uint8);
    5.98 -            break;
    5.99 -        case 16:
   5.100 -            strip_chans_6_to_4(Uint16);
   5.101 -            break;
   5.102 -        case 32:
   5.103 -            strip_chans_6_to_4(Uint32);
   5.104 -            break;
   5.105 +    case 8:
   5.106 +        strip_chans_6_to_4(Uint8);
   5.107 +        break;
   5.108 +    case 16:
   5.109 +        strip_chans_6_to_4(Uint16);
   5.110 +        break;
   5.111 +    case 32:
   5.112 +        strip_chans_6_to_4(Uint32);
   5.113 +        break;
   5.114      }
   5.115  
   5.116 -    #undef strip_chans_6_to_4
   5.117 +#undef strip_chans_6_to_4
   5.118  
   5.119      cvt->len_cvt /= 6;
   5.120      cvt->len_cvt *= 4;
   5.121 @@ -325,7 +329,7 @@
   5.122      fprintf(stderr, "Converting to stereo\n");
   5.123  #endif
   5.124  
   5.125 -    #define dup_chans_1_to_2(type) \
   5.126 +#define dup_chans_1_to_2(type) \
   5.127      { \
   5.128          const type *src = (const type *) (cvt->buf + cvt->len_cvt); \
   5.129          type *dst = (type *) (cvt->buf + cvt->len_cvt * 2); \
   5.130 @@ -338,18 +342,18 @@
   5.131  
   5.132      /* this function only cares about typesize, and data as a block of bits. */
   5.133      switch (SDL_AUDIO_BITSIZE(format)) {
   5.134 -        case 8:
   5.135 -            dup_chans_1_to_2(Uint8);
   5.136 -            break;
   5.137 -        case 16:
   5.138 -            dup_chans_1_to_2(Uint16);
   5.139 -            break;
   5.140 -        case 32:
   5.141 -            dup_chans_1_to_2(Uint32);
   5.142 -            break;
   5.143 +    case 8:
   5.144 +        dup_chans_1_to_2(Uint8);
   5.145 +        break;
   5.146 +    case 16:
   5.147 +        dup_chans_1_to_2(Uint16);
   5.148 +        break;
   5.149 +    case 32:
   5.150 +        dup_chans_1_to_2(Uint32);
   5.151 +        break;
   5.152      }
   5.153  
   5.154 -    #undef dup_chans_1_to_2
   5.155 +#undef dup_chans_1_to_2
   5.156  
   5.157      cvt->len_cvt *= 2;
   5.158      if (cvt->filters[++cvt->filter_index]) {
   5.159 @@ -368,7 +372,7 @@
   5.160      fprintf(stderr, "Converting stereo to surround\n");
   5.161  #endif
   5.162  
   5.163 -    switch (format & (SDL_AUDIO_MASK_SIGNED|SDL_AUDIO_MASK_BITSIZE)) {
   5.164 +    switch (format & (SDL_AUDIO_MASK_SIGNED | SDL_AUDIO_MASK_BITSIZE)) {
   5.165      case AUDIO_U8:
   5.166          {
   5.167              Uint8 *src, *dst, lf, rf, ce;
   5.168 @@ -573,7 +577,11 @@
   5.169  
   5.170      case AUDIO_F32:
   5.171          {
   5.172 -            union { float f; Uint32 ui32; } f2i;  /* !!! FIXME: lame. */
   5.173 +            union
   5.174 +            {
   5.175 +                float f;
   5.176 +                Uint32 ui32;
   5.177 +            } f2i;              /* !!! FIXME: lame. */
   5.178              float lf, rf, ce;
   5.179              const Uint32 *src = (const Uint32 *) cvt->buf + cvt->len_cvt;
   5.180              Uint32 *dst = (Uint32 *) cvt->buf + cvt->len_cvt * 3;
   5.181 @@ -640,7 +648,7 @@
   5.182      fprintf(stderr, "Converting stereo to quad\n");
   5.183  #endif
   5.184  
   5.185 -    switch (format & (SDL_AUDIO_MASK_SIGNED|SDL_AUDIO_MASK_BITSIZE)) {
   5.186 +    switch (format & (SDL_AUDIO_MASK_SIGNED | SDL_AUDIO_MASK_BITSIZE)) {
   5.187      case AUDIO_U8:
   5.188          {
   5.189              Uint8 *src, *dst, lf, rf, ce;
   5.190 @@ -831,7 +839,7 @@
   5.191      fprintf(stderr, "Converting audio rate * 2 (mono)\n");
   5.192  #endif
   5.193  
   5.194 -    #define mul2_mono(type) { \
   5.195 +#define mul2_mono(type) { \
   5.196          const type *src = (const type *) (cvt->buf + cvt->len_cvt); \
   5.197          type *dst = (type *) (cvt->buf + (cvt->len_cvt * 2)); \
   5.198          for (i = cvt->len_cvt / sizeof (type); i; --i) { \
   5.199 @@ -853,7 +861,7 @@
   5.200          break;
   5.201      }
   5.202  
   5.203 -    #undef mul2_mono
   5.204 +#undef mul2_mono
   5.205  
   5.206      cvt->len_cvt *= 2;
   5.207      if (cvt->filters[++cvt->filter_index]) {
   5.208 @@ -872,7 +880,7 @@
   5.209      fprintf(stderr, "Converting audio rate * 2 (stereo)\n");
   5.210  #endif
   5.211  
   5.212 -    #define mul2_stereo(type) { \
   5.213 +#define mul2_stereo(type) { \
   5.214          const type *src = (const type *) (cvt->buf + cvt->len_cvt); \
   5.215          type *dst = (type *) (cvt->buf + (cvt->len_cvt * 2)); \
   5.216          for (i = cvt->len_cvt / (sizeof (type) * 2); i; --i) { \
   5.217 @@ -899,7 +907,7 @@
   5.218          break;
   5.219      }
   5.220  
   5.221 -    #undef mul2_stereo
   5.222 +#undef mul2_stereo
   5.223  
   5.224      cvt->len_cvt *= 2;
   5.225      if (cvt->filters[++cvt->filter_index]) {
   5.226 @@ -917,7 +925,7 @@
   5.227      fprintf(stderr, "Converting audio rate * 2 (quad)\n");
   5.228  #endif
   5.229  
   5.230 -    #define mul2_quad(type) { \
   5.231 +#define mul2_quad(type) { \
   5.232          const type *src = (const type *) (cvt->buf + cvt->len_cvt); \
   5.233          type *dst = (type *) (cvt->buf + (cvt->len_cvt * 2)); \
   5.234          for (i = cvt->len_cvt / (sizeof (type) * 4); i; --i) { \
   5.235 @@ -950,7 +958,7 @@
   5.236          break;
   5.237      }
   5.238  
   5.239 -    #undef mul2_quad
   5.240 +#undef mul2_quad
   5.241  
   5.242      cvt->len_cvt *= 2;
   5.243      if (cvt->filters[++cvt->filter_index]) {
   5.244 @@ -969,7 +977,7 @@
   5.245      fprintf(stderr, "Converting audio rate * 2 (six channels)\n");
   5.246  #endif
   5.247  
   5.248 -    #define mul2_chansix(type) { \
   5.249 +#define mul2_chansix(type) { \
   5.250          const type *src = (const type *) (cvt->buf + cvt->len_cvt); \
   5.251          type *dst = (type *) (cvt->buf + (cvt->len_cvt * 2)); \
   5.252          for (i = cvt->len_cvt / (sizeof (type) * 6); i; --i) { \
   5.253 @@ -1008,7 +1016,7 @@
   5.254          break;
   5.255      }
   5.256  
   5.257 -    #undef mul2_chansix
   5.258 +#undef mul2_chansix
   5.259  
   5.260      cvt->len_cvt *= 2;
   5.261      if (cvt->filters[++cvt->filter_index]) {
   5.262 @@ -1026,7 +1034,7 @@
   5.263      fprintf(stderr, "Converting audio rate / 2 (mono)\n");
   5.264  #endif
   5.265  
   5.266 -    #define div2_mono(type) { \
   5.267 +#define div2_mono(type) { \
   5.268          const type *src = (const type *) cvt->buf; \
   5.269          type *dst = (type *) cvt->buf; \
   5.270          for (i = cvt->len_cvt / (sizeof (type) * 2); i; --i) { \
   5.271 @@ -1048,7 +1056,7 @@
   5.272          break;
   5.273      }
   5.274  
   5.275 -    #undef div2_mono
   5.276 +#undef div2_mono
   5.277  
   5.278      cvt->len_cvt /= 2;
   5.279      if (cvt->filters[++cvt->filter_index]) {
   5.280 @@ -1067,7 +1075,7 @@
   5.281      fprintf(stderr, "Converting audio rate / 2 (stereo)\n");
   5.282  #endif
   5.283  
   5.284 -    #define div2_stereo(type) { \
   5.285 +#define div2_stereo(type) { \
   5.286          const type *src = (const type *) cvt->buf; \
   5.287          type *dst = (type *) cvt->buf; \
   5.288          for (i = cvt->len_cvt / (sizeof (type) * 4); i; --i) { \
   5.289 @@ -1090,7 +1098,7 @@
   5.290          break;
   5.291      }
   5.292  
   5.293 -    #undef div2_stereo
   5.294 +#undef div2_stereo
   5.295  
   5.296      cvt->len_cvt /= 2;
   5.297      if (cvt->filters[++cvt->filter_index]) {
   5.298 @@ -1109,7 +1117,7 @@
   5.299      fprintf(stderr, "Converting audio rate / 2 (quad)\n");
   5.300  #endif
   5.301  
   5.302 -    #define div2_quad(type) { \
   5.303 +#define div2_quad(type) { \
   5.304          const type *src = (const type *) cvt->buf; \
   5.305          type *dst = (type *) cvt->buf; \
   5.306          for (i = cvt->len_cvt / (sizeof (type) * 8); i; --i) { \
   5.307 @@ -1134,7 +1142,7 @@
   5.308          break;
   5.309      }
   5.310  
   5.311 -    #undef div2_quad
   5.312 +#undef div2_quad
   5.313  
   5.314      cvt->len_cvt /= 2;
   5.315      if (cvt->filters[++cvt->filter_index]) {
   5.316 @@ -1152,7 +1160,7 @@
   5.317      fprintf(stderr, "Converting audio rate / 2 (six channels)\n");
   5.318  #endif
   5.319  
   5.320 -    #define div2_chansix(type) { \
   5.321 +#define div2_chansix(type) { \
   5.322          const type *src = (const type *) cvt->buf; \
   5.323          type *dst = (type *) cvt->buf; \
   5.324          for (i = cvt->len_cvt / (sizeof (type) * 12); i; --i) { \
   5.325 @@ -1179,7 +1187,7 @@
   5.326          break;
   5.327      }
   5.328  
   5.329 -    #undef div_chansix
   5.330 +#undef div_chansix
   5.331  
   5.332      cvt->len_cvt /= 2;
   5.333      if (cvt->filters[++cvt->filter_index]) {
   5.334 @@ -1309,7 +1317,7 @@
   5.335       *  processor, platform, compiler, or library here.
   5.336       */
   5.337  
   5.338 -    return NULL;  /* no specialized converter code available. */
   5.339 +    return NULL;                /* no specialized converter code available. */
   5.340  }
   5.341  
   5.342  
   5.343 @@ -1340,7 +1348,7 @@
   5.344              }
   5.345  
   5.346              if (filter == NULL) {
   5.347 -                return -1;  /* Still no matching converter?! */
   5.348 +                return -1;      /* Still no matching converter?! */
   5.349              }
   5.350          }
   5.351  
   5.352 @@ -1354,10 +1362,10 @@
   5.353              cvt->len_ratio /= (src_bitsize / dst_bitsize);
   5.354          }
   5.355  
   5.356 -        return 1;  /* added a converter. */
   5.357 +        return 1;               /* added a converter. */
   5.358      }
   5.359  
   5.360 -    return 0;  /* no conversion necessary. */
   5.361 +    return 0;                   /* no conversion necessary. */
   5.362  }
   5.363  
   5.364  
   5.365 @@ -1379,11 +1387,10 @@
   5.366      if ((SDL_AUDIO_BITSIZE(dst_fmt) > 16) && (!SDL_AUDIO_ISSIGNED(dst_fmt))) {
   5.367          return -1;
   5.368      }
   5.369 -
   5.370 -    #ifdef DEBUG_CONVERT
   5.371 +#ifdef DEBUG_CONVERT
   5.372      printf("Build format %04x->%04x, channels %u->%u, rate %d->%d\n",
   5.373 -		    src_fmt, dst_fmt, src_channels, dst_channels, src_rate, dst_rate);
   5.374 -    #endif
   5.375 +           src_fmt, dst_fmt, src_channels, dst_channels, src_rate, dst_rate);
   5.376 +#endif
   5.377  
   5.378      /* Start off with no conversion necessary */
   5.379  
   5.380 @@ -1397,7 +1404,7 @@
   5.381  
   5.382      /* Convert data types, if necessary. Updates (cvt). */
   5.383      if (SDL_BuildAudioTypeCVT(cvt, src_fmt, dst_fmt) == -1)
   5.384 -        return -1;  /* shouldn't happen, but just in case... */
   5.385 +        return -1;              /* shouldn't happen, but just in case... */
   5.386  
   5.387      /* Channel conversion */
   5.388      if (src_channels != dst_channels) {
     6.1 --- a/src/audio/SDL_audiotypecvt.c	Thu Aug 24 12:49:59 2006 +0000
     6.2 +++ b/src/audio/SDL_audiotypecvt.c	Mon Aug 28 03:17:39 2006 +0000
     6.3 @@ -1,6 +1,4 @@
     6.4 -/* DO NOT EDIT THIS FILE! It is generated code. */
     6.5 -/* Please modify SDL/src/audio/sdlgenaudiocvt.pl instead. */
     6.6 -
     6.7 +/* DO NOT EDIT!  This file is generated by sdlgenaudiocvt.pl */
     6.8  /*
     6.9      SDL - Simple DirectMedia Layer
    6.10      Copyright (C) 1997-2006 Sam Lantinga
    6.11 @@ -27,7 +25,7 @@
    6.12  #include "SDL_audio.h"
    6.13  #include "SDL_audio_c.h"
    6.14  
    6.15 -/* Now the generated code... */
    6.16 +/* *INDENT-OFF* */
    6.17  
    6.18  #define DIVBY127 0.0078740157480315f
    6.19  #define DIVBY255 0.00392156862745098f
    6.20 @@ -2354,3 +2352,6 @@
    6.21  };
    6.22  
    6.23  
    6.24 +/* *INDENT-ON* */
    6.25 +
    6.26 +/* vi: set ts=4 sw=4 expandtab: */
     7.1 --- a/src/audio/SDL_mixer.c	Thu Aug 24 12:49:59 2006 +0000
     7.2 +++ b/src/audio/SDL_mixer.c	Mon Aug 28 03:17:39 2006 +0000
     7.3 @@ -263,8 +263,8 @@
     7.4              Uint32 *dst32 = (Uint32 *) dst;
     7.5              Sint32 src1, src2;
     7.6              Sint64 dst_sample;
     7.7 -            const Sint64 max_audioval = ((((Sint64)1) << (32 - 1)) - 1);
     7.8 -            const Sint64 min_audioval = -(((Sint64)1) << (32 - 1));
     7.9 +            const Sint64 max_audioval = ((((Sint64) 1) << (32 - 1)) - 1);
    7.10 +            const Sint64 min_audioval = -(((Sint64) 1) << (32 - 1));
    7.11  
    7.12              len /= 4;
    7.13              while (len--) {
    7.14 @@ -289,8 +289,8 @@
    7.15              Uint32 *dst32 = (Uint32 *) dst;
    7.16              Sint32 src1, src2;
    7.17              Sint64 dst_sample;
    7.18 -            const Sint64 max_audioval = ((((Sint64)1) << (32 - 1)) - 1);
    7.19 -            const Sint64 min_audioval = -(((Sint64)1) << (32 - 1));
    7.20 +            const Sint64 max_audioval = ((((Sint64) 1) << (32 - 1)) - 1);
    7.21 +            const Sint64 min_audioval = -(((Sint64) 1) << (32 - 1));
    7.22  
    7.23              len /= 4;
    7.24              while (len--) {
    7.25 @@ -322,7 +322,11 @@
    7.26              const double min_audioval = -3.40282347e+38F;
    7.27  
    7.28              /* !!! FIXME: this is a little nasty. */
    7.29 -            union { float f; Uint32 ui32; } cvt;
    7.30 +            union
    7.31 +            {
    7.32 +                float f;
    7.33 +                Uint32 ui32;
    7.34 +            } cvt;
    7.35  
    7.36              len /= 4;
    7.37              while (len--) {
    7.38 @@ -360,7 +364,11 @@
    7.39              const double min_audioval = -3.40282347e+38F;
    7.40  
    7.41              /* !!! FIXME: this is a little nasty. */
    7.42 -            union { float f; Uint32 ui32; } cvt;
    7.43 +            union
    7.44 +            {
    7.45 +                float f;
    7.46 +                Uint32 ui32;
    7.47 +            } cvt;
    7.48  
    7.49              len /= 4;
    7.50              while (len--) {
     8.1 --- a/src/audio/sdlgenaudiocvt.pl	Thu Aug 24 12:49:59 2006 +0000
     8.2 +++ b/src/audio/sdlgenaudiocvt.pl	Mon Aug 28 03:17:39 2006 +0000
     8.3 @@ -23,9 +23,7 @@
     8.4  
     8.5  sub outputHeader {
     8.6      print <<EOF;
     8.7 -/* DO NOT EDIT THIS FILE! It is generated code. */
     8.8 -/* Please modify SDL/src/audio/sdlgenaudiocvt.pl instead. */
     8.9 -
    8.10 +/* DO NOT EDIT!  This file is generated by sdlgenaudiocvt.pl */
    8.11  /*
    8.12      SDL - Simple DirectMedia Layer
    8.13      Copyright (C) 1997-2006 Sam Lantinga
    8.14 @@ -52,7 +50,7 @@
    8.15  #include "SDL_audio.h"
    8.16  #include "SDL_audio_c.h"
    8.17  
    8.18 -/* Now the generated code... */
    8.19 +/* *INDENT-OFF* */
    8.20  
    8.21  EOF
    8.22  
    8.23 @@ -66,6 +64,13 @@
    8.24      print("\n");
    8.25  }
    8.26  
    8.27 +sub outputFooter {
    8.28 +    print <<EOF;
    8.29 +/* *INDENT-ON* */
    8.30 +
    8.31 +/* vi: set ts=4 sw=4 expandtab: */
    8.32 +EOF
    8.33 +}
    8.34  
    8.35  sub splittype {
    8.36      my $t = shift;
    8.37 @@ -307,7 +312,9 @@
    8.38  
    8.39  EOF
    8.40  
    8.41 +outputFooter();
    8.42 +
    8.43  exit 0;
    8.44  
    8.45 -# end of sdlaudiocvt.pl ...
    8.46 +# end of sdlgenaudiocvt.pl ...
    8.47  
     9.1 --- a/src/hermes/HeadX86.h	Thu Aug 24 12:49:59 2006 +0000
     9.2 +++ b/src/hermes/HeadX86.h	Mon Aug 28 03:17:39 2006 +0000
     9.3 @@ -186,4 +186,5 @@
     9.4  
     9.5  
     9.6  #endif
     9.7 +
     9.8  /* vi: set ts=4 sw=4 expandtab: */
    10.1 --- a/src/video/SDL_blit_N.c	Thu Aug 24 12:49:59 2006 +0000
    10.2 +++ b/src/video/SDL_blit_N.c	Mon Aug 28 03:17:39 2006 +0000
    10.3 @@ -2108,7 +2108,7 @@
    10.4  		/* *INDENT-OFF* */
    10.5  		DUFFS_LOOP(
    10.6  		{
    10.7 -		        Uint32 Pixel;
    10.8 +            Uint32 Pixel;
    10.9  			unsigned sR;
   10.10  			unsigned sG;
   10.11  			unsigned sB;
   10.12 @@ -2278,15 +2278,14 @@
   10.13  		/* *INDENT-OFF* */
   10.14  		DUFFS_LOOP(
   10.15  		{
   10.16 -		        Uint32 Pixel;
   10.17 +            Uint32 Pixel;
   10.18  			unsigned sR;
   10.19  			unsigned sG;
   10.20  			unsigned sB;
   10.21  			RETRIEVE_RGB_PIXEL(src, srcbpp, Pixel);
   10.22  			if ( (Pixel & rgbmask) != ckey ) {
   10.23 -			        RGB_FROM_PIXEL(Pixel, srcfmt, sR, sG, sB);
   10.24 -				ASSEMBLE_RGBA(dst, dstbpp, dstfmt,
   10.25 -					      sR, sG, sB, alpha);
   10.26 +                RGB_FROM_PIXEL(Pixel, srcfmt, sR, sG, sB);
   10.27 +				ASSEMBLE_RGBA(dst, dstbpp, dstfmt, sR, sG, sB, alpha);
   10.28  			}
   10.29  			dst += dstbpp;
   10.30  			src += srcbpp;
   10.31 @@ -2327,11 +2326,9 @@
   10.32  		/* *INDENT-OFF* */
   10.33  		DUFFS_LOOP(
   10.34  		{
   10.35 -			DISEMBLE_RGBA(src, srcbpp, srcfmt, Pixel,
   10.36 -				      sR, sG, sB, sA);
   10.37 +			DISEMBLE_RGBA(src, srcbpp, srcfmt, Pixel, sR, sG, sB, sA);
   10.38  			if ( (Pixel & rgbmask) != ckey ) {
   10.39 -				  ASSEMBLE_RGBA(dst, dstbpp, dstfmt,
   10.40 -						sR, sG, sB, sA);
   10.41 +				  ASSEMBLE_RGBA(dst, dstbpp, dstfmt, sR, sG, sB, sA);
   10.42  			}
   10.43  			dst += dstbpp;
   10.44  			src += srcbpp;
    11.1 --- a/src/video/SDL_glfuncs.h	Thu Aug 24 12:49:59 2006 +0000
    11.2 +++ b/src/video/SDL_glfuncs.h	Mon Aug 28 03:17:39 2006 +0000
    11.3 @@ -43,7 +43,7 @@
    11.4  SDL_PROC_UNUSED(void, glColor4bv, (const GLbyte *))
    11.5  SDL_PROC_UNUSED(void, glColor4d, (GLdouble, GLdouble, GLdouble, GLdouble))
    11.6  SDL_PROC_UNUSED(void, glColor4dv, (const GLdouble *))
    11.7 -SDL_PROC_UNUSED(void, glColor4f, (GLfloat, GLfloat, GLfloat, GLfloat))
    11.8 +SDL_PROC(void, glColor4f, (GLfloat, GLfloat, GLfloat, GLfloat))
    11.9  SDL_PROC_UNUSED(void, glColor4fv, (const GLfloat *))
   11.10  SDL_PROC_UNUSED(void, glColor4i, (GLint, GLint, GLint, GLint))
   11.11  SDL_PROC_UNUSED(void, glColor4iv, (const GLint *))
    12.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    12.2 +++ b/src/video/SDL_rendercopy.c	Mon Aug 28 03:17:39 2006 +0000
    12.3 @@ -0,0 +1,5215 @@
    12.4 +/* DO NOT EDIT!  This file is generated by sdlgenblit.pl */
    12.5 +/*
    12.6 +    SDL - Simple DirectMedia Layer
    12.7 +    Copyright (C) 1997-2006 Sam Lantinga
    12.8 +
    12.9 +    This library is free software; you can redistribute it and/or
   12.10 +    modify it under the terms of the GNU Lesser General Public
   12.11 +    License as published by the Free Software Foundation; either
   12.12 +    version 2.1 of the License, or (at your option) any later version.
   12.13 +
   12.14 +    This library is distributed in the hope that it will be useful,
   12.15 +    but WITHOUT ANY WARRANTY; without even the implied warranty of
   12.16 +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   12.17 +    Lesser General Public License for more details.
   12.18 +
   12.19 +    You should have received a copy of the GNU Lesser General Public
   12.20 +    License along with this library; if not, write to the Free Software
   12.21 +    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
   12.22 +
   12.23 +    Sam Lantinga
   12.24 +    slouken@libsdl.org
   12.25 +*/
   12.26 +#include "SDL_config.h"
   12.27 +
   12.28 +/* *INDENT-OFF* */
   12.29 +
   12.30 +#include "SDL_video.h"
   12.31 +#include "SDL_rendercopy.h"
   12.32 +
   12.33 +static struct {
   12.34 +    Uint32 src_format;
   12.35 +    Uint32 dst_format;
   12.36 +    int modMode;
   12.37 +    int blendMode;
   12.38 +    int scaleMode;
   12.39 +    SDL_RenderCopyFunc func;
   12.40 +} SDL_RenderCopyFuncTable[] = {
   12.41 +    { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_RGB888, 0, 0, SDL_TEXTURESCALEMODE_FAST,  SDL_RenderCopy_RGB888_RGB888_Scale },
   12.42 +    { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_RGB888, 0, (SDL_TEXTUREBLENDMODE_MASK | SDL_TEXTUREBLENDMODE_BLEND | SDL_TEXTUREBLENDMODE_ADD | SDL_TEXTUREBLENDMODE_MOD), 0,  SDL_RenderCopy_RGB888_RGB888_Blend },
   12.43 +    { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_RGB888, 0, (SDL_TEXTUREBLENDMODE_MASK | SDL_TEXTUREBLENDMODE_BLEND | SDL_TEXTUREBLENDMODE_ADD | SDL_TEXTUREBLENDMODE_MOD), SDL_TEXTURESCALEMODE_FAST,  SDL_RenderCopy_RGB888_RGB888_Blend_Scale },
   12.44 +    { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_RGB888, (SDL_TEXTUREMODULATE_COLOR | SDL_TEXTUREMODULATE_ALPHA), 0, 0,  SDL_RenderCopy_RGB888_RGB888_Modulate },
   12.45 +    { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_RGB888, (SDL_TEXTUREMODULATE_COLOR | SDL_TEXTUREMODULATE_ALPHA), 0, SDL_TEXTURESCALEMODE_FAST,  SDL_RenderCopy_RGB888_RGB888_Modulate_Scale },
   12.46 +    { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_RGB888, (SDL_TEXTUREMODULATE_COLOR | SDL_TEXTUREMODULATE_ALPHA), (SDL_TEXTUREBLENDMODE_MASK | SDL_TEXTUREBLENDMODE_BLEND | SDL_TEXTUREBLENDMODE_ADD | SDL_TEXTUREBLENDMODE_MOD), 0,  SDL_RenderCopy_RGB888_RGB888_Modulate_Blend },
   12.47 +    { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_RGB888, (SDL_TEXTUREMODULATE_COLOR | SDL_TEXTUREMODULATE_ALPHA), (SDL_TEXTUREBLENDMODE_MASK | SDL_TEXTUREBLENDMODE_BLEND | SDL_TEXTUREBLENDMODE_ADD | SDL_TEXTUREBLENDMODE_MOD), SDL_TEXTURESCALEMODE_FAST,  SDL_RenderCopy_RGB888_RGB888_Modulate_Blend_Scale },
   12.48 +    { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_BGR888, 0, 0, 0,  SDL_RenderCopy_RGB888_BGR888 },
   12.49 +    { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_BGR888, 0, 0, SDL_TEXTURESCALEMODE_FAST,  SDL_RenderCopy_RGB888_BGR888_Scale },
   12.50 +    { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_BGR888, 0, (SDL_TEXTUREBLENDMODE_MASK | SDL_TEXTUREBLENDMODE_BLEND | SDL_TEXTUREBLENDMODE_ADD | SDL_TEXTUREBLENDMODE_MOD), 0,  SDL_RenderCopy_RGB888_BGR888_Blend },
   12.51 +    { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_BGR888, 0, (SDL_TEXTUREBLENDMODE_MASK | SDL_TEXTUREBLENDMODE_BLEND | SDL_TEXTUREBLENDMODE_ADD | SDL_TEXTUREBLENDMODE_MOD), SDL_TEXTURESCALEMODE_FAST,  SDL_RenderCopy_RGB888_BGR888_Blend_Scale },
   12.52 +    { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_BGR888, (SDL_TEXTUREMODULATE_COLOR | SDL_TEXTUREMODULATE_ALPHA), 0, 0,  SDL_RenderCopy_RGB888_BGR888_Modulate },
   12.53 +    { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_BGR888, (SDL_TEXTUREMODULATE_COLOR | SDL_TEXTUREMODULATE_ALPHA), 0, SDL_TEXTURESCALEMODE_FAST,  SDL_RenderCopy_RGB888_BGR888_Modulate_Scale },
   12.54 +    { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_BGR888, (SDL_TEXTUREMODULATE_COLOR | SDL_TEXTUREMODULATE_ALPHA), (SDL_TEXTUREBLENDMODE_MASK | SDL_TEXTUREBLENDMODE_BLEND | SDL_TEXTUREBLENDMODE_ADD | SDL_TEXTUREBLENDMODE_MOD), 0,  SDL_RenderCopy_RGB888_BGR888_Modulate_Blend },
   12.55 +    { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_BGR888, (SDL_TEXTUREMODULATE_COLOR | SDL_TEXTUREMODULATE_ALPHA), (SDL_TEXTUREBLENDMODE_MASK | SDL_TEXTUREBLENDMODE_BLEND | SDL_TEXTUREBLENDMODE_ADD | SDL_TEXTUREBLENDMODE_MOD), SDL_TEXTURESCALEMODE_FAST,  SDL_RenderCopy_RGB888_BGR888_Modulate_Blend_Scale },
   12.56 +    { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_RGB888, 0, 0, 0,  SDL_RenderCopy_BGR888_RGB888 },
   12.57 +    { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_RGB888, 0, 0, SDL_TEXTURESCALEMODE_FAST,  SDL_RenderCopy_BGR888_RGB888_Scale },
   12.58 +    { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_RGB888, 0, (SDL_TEXTUREBLENDMODE_MASK | SDL_TEXTUREBLENDMODE_BLEND | SDL_TEXTUREBLENDMODE_ADD | SDL_TEXTUREBLENDMODE_MOD), 0,  SDL_RenderCopy_BGR888_RGB888_Blend },
   12.59 +    { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_RGB888, 0, (SDL_TEXTUREBLENDMODE_MASK | SDL_TEXTUREBLENDMODE_BLEND | SDL_TEXTUREBLENDMODE_ADD | SDL_TEXTUREBLENDMODE_MOD), SDL_TEXTURESCALEMODE_FAST,  SDL_RenderCopy_BGR888_RGB888_Blend_Scale },
   12.60 +    { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_RGB888, (SDL_TEXTUREMODULATE_COLOR | SDL_TEXTUREMODULATE_ALPHA), 0, 0,  SDL_RenderCopy_BGR888_RGB888_Modulate },
   12.61 +    { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_RGB888, (SDL_TEXTUREMODULATE_COLOR | SDL_TEXTUREMODULATE_ALPHA), 0, SDL_TEXTURESCALEMODE_FAST,  SDL_RenderCopy_BGR888_RGB888_Modulate_Scale },
   12.62 +    { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_RGB888, (SDL_TEXTUREMODULATE_COLOR | SDL_TEXTUREMODULATE_ALPHA), (SDL_TEXTUREBLENDMODE_MASK | SDL_TEXTUREBLENDMODE_BLEND | SDL_TEXTUREBLENDMODE_ADD | SDL_TEXTUREBLENDMODE_MOD), 0,  SDL_RenderCopy_BGR888_RGB888_Modulate_Blend },
   12.63 +    { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_RGB888, (SDL_TEXTUREMODULATE_COLOR | SDL_TEXTUREMODULATE_ALPHA), (SDL_TEXTUREBLENDMODE_MASK | SDL_TEXTUREBLENDMODE_BLEND | SDL_TEXTUREBLENDMODE_ADD | SDL_TEXTUREBLENDMODE_MOD), SDL_TEXTURESCALEMODE_FAST,  SDL_RenderCopy_BGR888_RGB888_Modulate_Blend_Scale },
   12.64 +    { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_BGR888, 0, 0, SDL_TEXTURESCALEMODE_FAST,  SDL_RenderCopy_BGR888_BGR888_Scale },
   12.65 +    { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_BGR888, 0, (SDL_TEXTUREBLENDMODE_MASK | SDL_TEXTUREBLENDMODE_BLEND | SDL_TEXTUREBLENDMODE_ADD | SDL_TEXTUREBLENDMODE_MOD), 0,  SDL_RenderCopy_BGR888_BGR888_Blend },
   12.66 +    { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_BGR888, 0, (SDL_TEXTUREBLENDMODE_MASK | SDL_TEXTUREBLENDMODE_BLEND | SDL_TEXTUREBLENDMODE_ADD | SDL_TEXTUREBLENDMODE_MOD), SDL_TEXTURESCALEMODE_FAST,  SDL_RenderCopy_BGR888_BGR888_Blend_Scale },
   12.67 +    { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_BGR888, (SDL_TEXTUREMODULATE_COLOR | SDL_TEXTUREMODULATE_ALPHA), 0, 0,  SDL_RenderCopy_BGR888_BGR888_Modulate },
   12.68 +    { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_BGR888, (SDL_TEXTUREMODULATE_COLOR | SDL_TEXTUREMODULATE_ALPHA), 0, SDL_TEXTURESCALEMODE_FAST,  SDL_RenderCopy_BGR888_BGR888_Modulate_Scale },
   12.69 +    { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_BGR888, (SDL_TEXTUREMODULATE_COLOR | SDL_TEXTUREMODULATE_ALPHA), (SDL_TEXTUREBLENDMODE_MASK | SDL_TEXTUREBLENDMODE_BLEND | SDL_TEXTUREBLENDMODE_ADD | SDL_TEXTUREBLENDMODE_MOD), 0,  SDL_RenderCopy_BGR888_BGR888_Modulate_Blend },
   12.70 +    { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_BGR888, (SDL_TEXTUREMODULATE_COLOR | SDL_TEXTUREMODULATE_ALPHA), (SDL_TEXTUREBLENDMODE_MASK | SDL_TEXTUREBLENDMODE_BLEND | SDL_TEXTUREBLENDMODE_ADD | SDL_TEXTUREBLENDMODE_MOD), SDL_TEXTURESCALEMODE_FAST,  SDL_RenderCopy_BGR888_BGR888_Modulate_Blend_Scale },
   12.71 +    { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_RGB888, 0, 0, 0,  SDL_RenderCopy_ARGB8888_RGB888 },
   12.72 +    { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_RGB888, 0, 0, SDL_TEXTURESCALEMODE_FAST,  SDL_RenderCopy_ARGB8888_RGB888_Scale },
   12.73 +    { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_RGB888, 0, (SDL_TEXTUREBLENDMODE_MASK | SDL_TEXTUREBLENDMODE_BLEND | SDL_TEXTUREBLENDMODE_ADD | SDL_TEXTUREBLENDMODE_MOD), 0,  SDL_RenderCopy_ARGB8888_RGB888_Blend },
   12.74 +    { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_RGB888, 0, (SDL_TEXTUREBLENDMODE_MASK | SDL_TEXTUREBLENDMODE_BLEND | SDL_TEXTUREBLENDMODE_ADD | SDL_TEXTUREBLENDMODE_MOD), SDL_TEXTURESCALEMODE_FAST,  SDL_RenderCopy_ARGB8888_RGB888_Blend_Scale },
   12.75 +    { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_RGB888, (SDL_TEXTUREMODULATE_COLOR | SDL_TEXTUREMODULATE_ALPHA), 0, 0,  SDL_RenderCopy_ARGB8888_RGB888_Modulate },
   12.76 +    { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_RGB888, (SDL_TEXTUREMODULATE_COLOR | SDL_TEXTUREMODULATE_ALPHA), 0, SDL_TEXTURESCALEMODE_FAST,  SDL_RenderCopy_ARGB8888_RGB888_Modulate_Scale },
   12.77 +    { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_RGB888, (SDL_TEXTUREMODULATE_COLOR | SDL_TEXTUREMODULATE_ALPHA), (SDL_TEXTUREBLENDMODE_MASK | SDL_TEXTUREBLENDMODE_BLEND | SDL_TEXTUREBLENDMODE_ADD | SDL_TEXTUREBLENDMODE_MOD), 0,  SDL_RenderCopy_ARGB8888_RGB888_Modulate_Blend },
   12.78 +    { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_RGB888, (SDL_TEXTUREMODULATE_COLOR | SDL_TEXTUREMODULATE_ALPHA), (SDL_TEXTUREBLENDMODE_MASK | SDL_TEXTUREBLENDMODE_BLEND | SDL_TEXTUREBLENDMODE_ADD | SDL_TEXTUREBLENDMODE_MOD), SDL_TEXTURESCALEMODE_FAST,  SDL_RenderCopy_ARGB8888_RGB888_Modulate_Blend_Scale },
   12.79 +    { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_BGR888, 0, 0, 0,  SDL_RenderCopy_ARGB8888_BGR888 },
   12.80 +    { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_BGR888, 0, 0, SDL_TEXTURESCALEMODE_FAST,  SDL_RenderCopy_ARGB8888_BGR888_Scale },
   12.81 +    { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_BGR888, 0, (SDL_TEXTUREBLENDMODE_MASK | SDL_TEXTUREBLENDMODE_BLEND | SDL_TEXTUREBLENDMODE_ADD | SDL_TEXTUREBLENDMODE_MOD), 0,  SDL_RenderCopy_ARGB8888_BGR888_Blend },
   12.82 +    { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_BGR888, 0, (SDL_TEXTUREBLENDMODE_MASK | SDL_TEXTUREBLENDMODE_BLEND | SDL_TEXTUREBLENDMODE_ADD | SDL_TEXTUREBLENDMODE_MOD), SDL_TEXTURESCALEMODE_FAST,  SDL_RenderCopy_ARGB8888_BGR888_Blend_Scale },
   12.83 +    { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_BGR888, (SDL_TEXTUREMODULATE_COLOR | SDL_TEXTUREMODULATE_ALPHA), 0, 0,  SDL_RenderCopy_ARGB8888_BGR888_Modulate },
   12.84 +    { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_BGR888, (SDL_TEXTUREMODULATE_COLOR | SDL_TEXTUREMODULATE_ALPHA), 0, SDL_TEXTURESCALEMODE_FAST,  SDL_RenderCopy_ARGB8888_BGR888_Modulate_Scale },
   12.85 +    { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_BGR888, (SDL_TEXTUREMODULATE_COLOR | SDL_TEXTUREMODULATE_ALPHA), (SDL_TEXTUREBLENDMODE_MASK | SDL_TEXTUREBLENDMODE_BLEND | SDL_TEXTUREBLENDMODE_ADD | SDL_TEXTUREBLENDMODE_MOD), 0,  SDL_RenderCopy_ARGB8888_BGR888_Modulate_Blend },
   12.86 +    { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_BGR888, (SDL_TEXTUREMODULATE_COLOR | SDL_TEXTUREMODULATE_ALPHA), (SDL_TEXTUREBLENDMODE_MASK | SDL_TEXTUREBLENDMODE_BLEND | SDL_TEXTUREBLENDMODE_ADD | SDL_TEXTUREBLENDMODE_MOD), SDL_TEXTURESCALEMODE_FAST,  SDL_RenderCopy_ARGB8888_BGR888_Modulate_Blend_Scale },
   12.87 +    { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_RGB888, 0, 0, 0,  SDL_RenderCopy_RGBA8888_RGB888 },
   12.88 +    { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_RGB888, 0, 0, SDL_TEXTURESCALEMODE_FAST,  SDL_RenderCopy_RGBA8888_RGB888_Scale },
   12.89 +    { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_RGB888, 0, (SDL_TEXTUREBLENDMODE_MASK | SDL_TEXTUREBLENDMODE_BLEND | SDL_TEXTUREBLENDMODE_ADD | SDL_TEXTUREBLENDMODE_MOD), 0,  SDL_RenderCopy_RGBA8888_RGB888_Blend },
   12.90 +    { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_RGB888, 0, (SDL_TEXTUREBLENDMODE_MASK | SDL_TEXTUREBLENDMODE_BLEND | SDL_TEXTUREBLENDMODE_ADD | SDL_TEXTUREBLENDMODE_MOD), SDL_TEXTURESCALEMODE_FAST,  SDL_RenderCopy_RGBA8888_RGB888_Blend_Scale },
   12.91 +    { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_RGB888, (SDL_TEXTUREMODULATE_COLOR | SDL_TEXTUREMODULATE_ALPHA), 0, 0,  SDL_RenderCopy_RGBA8888_RGB888_Modulate },
   12.92 +    { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_RGB888, (SDL_TEXTUREMODULATE_COLOR | SDL_TEXTUREMODULATE_ALPHA), 0, SDL_TEXTURESCALEMODE_FAST,  SDL_RenderCopy_RGBA8888_RGB888_Modulate_Scale },
   12.93 +    { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_RGB888, (SDL_TEXTUREMODULATE_COLOR | SDL_TEXTUREMODULATE_ALPHA), (SDL_TEXTUREBLENDMODE_MASK | SDL_TEXTUREBLENDMODE_BLEND | SDL_TEXTUREBLENDMODE_ADD | SDL_TEXTUREBLENDMODE_MOD), 0,  SDL_RenderCopy_RGBA8888_RGB888_Modulate_Blend },
   12.94 +    { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_RGB888, (SDL_TEXTUREMODULATE_COLOR | SDL_TEXTUREMODULATE_ALPHA), (SDL_TEXTUREBLENDMODE_MASK | SDL_TEXTUREBLENDMODE_BLEND | SDL_TEXTUREBLENDMODE_ADD | SDL_TEXTUREBLENDMODE_MOD), SDL_TEXTURESCALEMODE_FAST,  SDL_RenderCopy_RGBA8888_RGB888_Modulate_Blend_Scale },
   12.95 +    { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_BGR888, 0, 0, 0,  SDL_RenderCopy_RGBA8888_BGR888 },
   12.96 +    { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_BGR888, 0, 0, SDL_TEXTURESCALEMODE_FAST,  SDL_RenderCopy_RGBA8888_BGR888_Scale },
   12.97 +    { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_BGR888, 0, (SDL_TEXTUREBLENDMODE_MASK | SDL_TEXTUREBLENDMODE_BLEND | SDL_TEXTUREBLENDMODE_ADD | SDL_TEXTUREBLENDMODE_MOD), 0,  SDL_RenderCopy_RGBA8888_BGR888_Blend },
   12.98 +    { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_BGR888, 0, (SDL_TEXTUREBLENDMODE_MASK | SDL_TEXTUREBLENDMODE_BLEND | SDL_TEXTUREBLENDMODE_ADD | SDL_TEXTUREBLENDMODE_MOD), SDL_TEXTURESCALEMODE_FAST,  SDL_RenderCopy_RGBA8888_BGR888_Blend_Scale },
   12.99 +    { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_BGR888, (SDL_TEXTUREMODULATE_COLOR | SDL_TEXTUREMODULATE_ALPHA), 0, 0,  SDL_RenderCopy_RGBA8888_BGR888_Modulate },
  12.100 +    { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_BGR888, (SDL_TEXTUREMODULATE_COLOR | SDL_TEXTUREMODULATE_ALPHA), 0, SDL_TEXTURESCALEMODE_FAST,  SDL_RenderCopy_RGBA8888_BGR888_Modulate_Scale },
  12.101 +    { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_BGR888, (SDL_TEXTUREMODULATE_COLOR | SDL_TEXTUREMODULATE_ALPHA), (SDL_TEXTUREBLENDMODE_MASK | SDL_TEXTUREBLENDMODE_BLEND | SDL_TEXTUREBLENDMODE_ADD | SDL_TEXTUREBLENDMODE_MOD), 0,  SDL_RenderCopy_RGBA8888_BGR888_Modulate_Blend },
  12.102 +    { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_BGR888, (SDL_TEXTUREMODULATE_COLOR | SDL_TEXTUREMODULATE_ALPHA), (SDL_TEXTUREBLENDMODE_MASK | SDL_TEXTUREBLENDMODE_BLEND | SDL_TEXTUREBLENDMODE_ADD | SDL_TEXTUREBLENDMODE_MOD), SDL_TEXTURESCALEMODE_FAST,  SDL_RenderCopy_RGBA8888_BGR888_Modulate_Blend_Scale },
  12.103 +    { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_RGB888, 0, 0, 0,  SDL_RenderCopy_ABGR8888_RGB888 },
  12.104 +    { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_RGB888, 0, 0, SDL_TEXTURESCALEMODE_FAST,  SDL_RenderCopy_ABGR8888_RGB888_Scale },
  12.105 +    { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_RGB888, 0, (SDL_TEXTUREBLENDMODE_MASK | SDL_TEXTUREBLENDMODE_BLEND | SDL_TEXTUREBLENDMODE_ADD | SDL_TEXTUREBLENDMODE_MOD), 0,  SDL_RenderCopy_ABGR8888_RGB888_Blend },
  12.106 +    { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_RGB888, 0, (SDL_TEXTUREBLENDMODE_MASK | SDL_TEXTUREBLENDMODE_BLEND | SDL_TEXTUREBLENDMODE_ADD | SDL_TEXTUREBLENDMODE_MOD), SDL_TEXTURESCALEMODE_FAST,  SDL_RenderCopy_ABGR8888_RGB888_Blend_Scale },
  12.107 +    { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_RGB888, (SDL_TEXTUREMODULATE_COLOR | SDL_TEXTUREMODULATE_ALPHA), 0, 0,  SDL_RenderCopy_ABGR8888_RGB888_Modulate },
  12.108 +    { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_RGB888, (SDL_TEXTUREMODULATE_COLOR | SDL_TEXTUREMODULATE_ALPHA), 0, SDL_TEXTURESCALEMODE_FAST,  SDL_RenderCopy_ABGR8888_RGB888_Modulate_Scale },
  12.109 +    { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_RGB888, (SDL_TEXTUREMODULATE_COLOR | SDL_TEXTUREMODULATE_ALPHA), (SDL_TEXTUREBLENDMODE_MASK | SDL_TEXTUREBLENDMODE_BLEND | SDL_TEXTUREBLENDMODE_ADD | SDL_TEXTUREBLENDMODE_MOD), 0,  SDL_RenderCopy_ABGR8888_RGB888_Modulate_Blend },
  12.110 +    { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_RGB888, (SDL_TEXTUREMODULATE_COLOR | SDL_TEXTUREMODULATE_ALPHA), (SDL_TEXTUREBLENDMODE_MASK | SDL_TEXTUREBLENDMODE_BLEND | SDL_TEXTUREBLENDMODE_ADD | SDL_TEXTUREBLENDMODE_MOD), SDL_TEXTURESCALEMODE_FAST,  SDL_RenderCopy_ABGR8888_RGB888_Modulate_Blend_Scale },
  12.111 +    { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_BGR888, 0, 0, 0,  SDL_RenderCopy_ABGR8888_BGR888 },
  12.112 +    { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_BGR888, 0, 0, SDL_TEXTURESCALEMODE_FAST,  SDL_RenderCopy_ABGR8888_BGR888_Scale },
  12.113 +    { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_BGR888, 0, (SDL_TEXTUREBLENDMODE_MASK | SDL_TEXTUREBLENDMODE_BLEND | SDL_TEXTUREBLENDMODE_ADD | SDL_TEXTUREBLENDMODE_MOD), 0,  SDL_RenderCopy_ABGR8888_BGR888_Blend },
  12.114 +    { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_BGR888, 0, (SDL_TEXTUREBLENDMODE_MASK | SDL_TEXTUREBLENDMODE_BLEND | SDL_TEXTUREBLENDMODE_ADD | SDL_TEXTUREBLENDMODE_MOD), SDL_TEXTURESCALEMODE_FAST,  SDL_RenderCopy_ABGR8888_BGR888_Blend_Scale },
  12.115 +    { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_BGR888, (SDL_TEXTUREMODULATE_COLOR | SDL_TEXTUREMODULATE_ALPHA), 0, 0,  SDL_RenderCopy_ABGR8888_BGR888_Modulate },
  12.116 +    { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_BGR888, (SDL_TEXTUREMODULATE_COLOR | SDL_TEXTUREMODULATE_ALPHA), 0, SDL_TEXTURESCALEMODE_FAST,  SDL_RenderCopy_ABGR8888_BGR888_Modulate_Scale },
  12.117 +    { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_BGR888, (SDL_TEXTUREMODULATE_COLOR | SDL_TEXTUREMODULATE_ALPHA), (SDL_TEXTUREBLENDMODE_MASK | SDL_TEXTUREBLENDMODE_BLEND | SDL_TEXTUREBLENDMODE_ADD | SDL_TEXTUREBLENDMODE_MOD), 0,  SDL_RenderCopy_ABGR8888_BGR888_Modulate_Blend },
  12.118 +    { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_BGR888, (SDL_TEXTUREMODULATE_COLOR | SDL_TEXTUREMODULATE_ALPHA), (SDL_TEXTUREBLENDMODE_MASK | SDL_TEXTUREBLENDMODE_BLEND | SDL_TEXTUREBLENDMODE_ADD | SDL_TEXTUREBLENDMODE_MOD), SDL_TEXTURESCALEMODE_FAST,  SDL_RenderCopy_ABGR8888_BGR888_Modulate_Blend_Scale },
  12.119 +    { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_RGB888, 0, 0, 0,  SDL_RenderCopy_BGRA8888_RGB888 },
  12.120 +    { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_RGB888, 0, 0, SDL_TEXTURESCALEMODE_FAST,  SDL_RenderCopy_BGRA8888_RGB888_Scale },
  12.121 +    { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_RGB888, 0, (SDL_TEXTUREBLENDMODE_MASK | SDL_TEXTUREBLENDMODE_BLEND | SDL_TEXTUREBLENDMODE_ADD | SDL_TEXTUREBLENDMODE_MOD), 0,  SDL_RenderCopy_BGRA8888_RGB888_Blend },
  12.122 +    { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_RGB888, 0, (SDL_TEXTUREBLENDMODE_MASK | SDL_TEXTUREBLENDMODE_BLEND | SDL_TEXTUREBLENDMODE_ADD | SDL_TEXTUREBLENDMODE_MOD), SDL_TEXTURESCALEMODE_FAST,  SDL_RenderCopy_BGRA8888_RGB888_Blend_Scale },
  12.123 +    { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_RGB888, (SDL_TEXTUREMODULATE_COLOR | SDL_TEXTUREMODULATE_ALPHA), 0, 0,  SDL_RenderCopy_BGRA8888_RGB888_Modulate },
  12.124 +    { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_RGB888, (SDL_TEXTUREMODULATE_COLOR | SDL_TEXTUREMODULATE_ALPHA), 0, SDL_TEXTURESCALEMODE_FAST,  SDL_RenderCopy_BGRA8888_RGB888_Modulate_Scale },
  12.125 +    { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_RGB888, (SDL_TEXTUREMODULATE_COLOR | SDL_TEXTUREMODULATE_ALPHA), (SDL_TEXTUREBLENDMODE_MASK | SDL_TEXTUREBLENDMODE_BLEND | SDL_TEXTUREBLENDMODE_ADD | SDL_TEXTUREBLENDMODE_MOD), 0,  SDL_RenderCopy_BGRA8888_RGB888_Modulate_Blend },
  12.126 +    { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_RGB888, (SDL_TEXTUREMODULATE_COLOR | SDL_TEXTUREMODULATE_ALPHA), (SDL_TEXTUREBLENDMODE_MASK | SDL_TEXTUREBLENDMODE_BLEND | SDL_TEXTUREBLENDMODE_ADD | SDL_TEXTUREBLENDMODE_MOD), SDL_TEXTURESCALEMODE_FAST,  SDL_RenderCopy_BGRA8888_RGB888_Modulate_Blend_Scale },
  12.127 +    { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_BGR888, 0, 0, 0,  SDL_RenderCopy_BGRA8888_BGR888 },
  12.128 +    { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_BGR888, 0, 0, SDL_TEXTURESCALEMODE_FAST,  SDL_RenderCopy_BGRA8888_BGR888_Scale },
  12.129 +    { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_BGR888, 0, (SDL_TEXTUREBLENDMODE_MASK | SDL_TEXTUREBLENDMODE_BLEND | SDL_TEXTUREBLENDMODE_ADD | SDL_TEXTUREBLENDMODE_MOD), 0,  SDL_RenderCopy_BGRA8888_BGR888_Blend },
  12.130 +    { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_BGR888, 0, (SDL_TEXTUREBLENDMODE_MASK | SDL_TEXTUREBLENDMODE_BLEND | SDL_TEXTUREBLENDMODE_ADD | SDL_TEXTUREBLENDMODE_MOD), SDL_TEXTURESCALEMODE_FAST,  SDL_RenderCopy_BGRA8888_BGR888_Blend_Scale },
  12.131 +    { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_BGR888, (SDL_TEXTUREMODULATE_COLOR | SDL_TEXTUREMODULATE_ALPHA), 0, 0,  SDL_RenderCopy_BGRA8888_BGR888_Modulate },
  12.132 +    { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_BGR888, (SDL_TEXTUREMODULATE_COLOR | SDL_TEXTUREMODULATE_ALPHA), 0, SDL_TEXTURESCALEMODE_FAST,  SDL_RenderCopy_BGRA8888_BGR888_Modulate_Scale },
  12.133 +    { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_BGR888, (SDL_TEXTUREMODULATE_COLOR | SDL_TEXTUREMODULATE_ALPHA), (SDL_TEXTUREBLENDMODE_MASK | SDL_TEXTUREBLENDMODE_BLEND | SDL_TEXTUREBLENDMODE_ADD | SDL_TEXTUREBLENDMODE_MOD), 0,  SDL_RenderCopy_BGRA8888_BGR888_Modulate_Blend },
  12.134 +    { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_BGR888, (SDL_TEXTUREMODULATE_COLOR | SDL_TEXTUREMODULATE_ALPHA), (SDL_TEXTUREBLENDMODE_MASK | SDL_TEXTUREBLENDMODE_BLEND | SDL_TEXTUREBLENDMODE_ADD | SDL_TEXTUREBLENDMODE_MOD), SDL_TEXTURESCALEMODE_FAST,  SDL_RenderCopy_BGRA8888_BGR888_Modulate_Blend_Scale },
  12.135 +};
  12.136 +
  12.137 +SDL_RenderCopyFunc SDL_GetRenderCopyFunc(Uint32 src_format, Uint32 dst_format, int modMode, int blendMode, int scaleMode)
  12.138 +{
  12.139 +    int i;
  12.140 +
  12.141 +    for (i = 0; i < SDL_arraysize(SDL_RenderCopyFuncTable); ++i) {
  12.142 +        if (src_format != SDL_RenderCopyFuncTable[i].src_format) {
  12.143 +            continue;
  12.144 +        }
  12.145 +        if (dst_format != SDL_RenderCopyFuncTable[i].dst_format) {
  12.146 +            continue;
  12.147 +        }
  12.148 +        if ((modMode & SDL_RenderCopyFuncTable[i].modMode) != modMode) {
  12.149 +            continue;
  12.150 +        }
  12.151 +        if ((blendMode & SDL_RenderCopyFuncTable[i].blendMode) != blendMode) {
  12.152 +            continue;
  12.153 +        }
  12.154 +        if ((scaleMode & SDL_RenderCopyFuncTable[i].scaleMode) != scaleMode) {
  12.155 +            continue;
  12.156 +        }
  12.157 +        return SDL_RenderCopyFuncTable[i].func;
  12.158 +    }
  12.159 +    return NULL;
  12.160 +}
  12.161 +
  12.162 +int SDL_RenderCopy_RGB888_RGB888_Scale(SDL_RenderCopyData *data)
  12.163 +{
  12.164 +    const int flags = data->flags;
  12.165 +    int srcy, srcx;
  12.166 +    int posy, posx;
  12.167 +    int incy, incx;
  12.168 +
  12.169 +    srcy = 0;
  12.170 +    posy = 0;
  12.171 +    incy = (data->src_h << 16) / data->dst_h;
  12.172 +    incx = (data->src_w << 16) / data->dst_w;
  12.173 +
  12.174 +    while (data->dst_h--) {
  12.175 +        Uint32 *src;
  12.176 +        Uint32 *dst = (Uint32 *)data->dst;
  12.177 +        int n = data->dst_w;
  12.178 +        srcx = -1;
  12.179 +        posx = 0x10000L;
  12.180 +        while (posy >= 0x10000L) {
  12.181 +            ++srcy;
  12.182 +            posy -= 0x10000L;
  12.183 +        }
  12.184 +        while (n--) {
  12.185 +            if (posx >= 0x10000L) {
  12.186 +                while (posx >= 0x10000L) {
  12.187 +                    ++srcx;
  12.188 +                    posx -= 0x10000L;
  12.189 +                }
  12.190 +                src = (Uint32 *)(data->src + (srcy * data->src_pitch) + (srcx * 4));
  12.191 +            }
  12.192 +            *dst = *src;
  12.193 +            posx += incx;
  12.194 +            ++dst;
  12.195 +        }
  12.196 +        posy += incy;
  12.197 +        data->dst += data->dst_pitch;
  12.198 +    }
  12.199 +    return 0;
  12.200 +}
  12.201 +
  12.202 +int SDL_RenderCopy_RGB888_RGB888_Blend(SDL_RenderCopyData *data)
  12.203 +{
  12.204 +    const int flags = data->flags;
  12.205 +    Uint32 srcpixel;
  12.206 +    Uint32 srcR, srcG, srcB, srcA;
  12.207 +    Uint32 dstpixel;
  12.208 +    Uint32 dstR, dstG, dstB, dstA;
  12.209 +
  12.210 +    while (data->dst_h--) {
  12.211 +        Uint32 *src = (Uint32 *)data->src;
  12.212 +        Uint32 *dst = (Uint32 *)data->dst;
  12.213 +        int n = data->dst_w;
  12.214 +        while (n--) {
  12.215 +            srcpixel = *src;
  12.216 +            srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = 0xFF;
  12.217 +            dstpixel = *dst;
  12.218 +            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
  12.219 +            if (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD)) {
  12.220 +                /* This goes away if we ever use premultiplied alpha */
  12.221 +                srcR = (srcR * srcA) / 255;
  12.222 +                srcG = (srcG * srcA) / 255;
  12.223 +                srcB = (srcB * srcA) / 255;
  12.224 +            }
  12.225 +            switch (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD|SDL_RENDERCOPY_MOD)) {
  12.226 +            case SDL_RENDERCOPY_BLEND:
  12.227 +                dstR = srcR + ((255 - srcA) * dstR) / 255;
  12.228 +                dstG = srcG + ((255 - srcA) * dstG) / 255;
  12.229 +                dstB = srcB + ((255 - srcA) * dstB) / 255;
  12.230 +                break;
  12.231 +            case SDL_RENDERCOPY_ADD:
  12.232 +                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  12.233 +                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  12.234 +                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  12.235 +                break;
  12.236 +            case SDL_RENDERCOPY_MOD:
  12.237 +                dstR = (srcR * dstR) / 255;
  12.238 +                dstG = (srcG * dstG) / 255;
  12.239 +                dstB = (srcB * dstB) / 255;
  12.240 +                break;
  12.241 +            }
  12.242 +            dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
  12.243 +            *dst = dstpixel;
  12.244 +            ++src;
  12.245 +            ++dst;
  12.246 +        }
  12.247 +        data->src += data->src_pitch;
  12.248 +        data->dst += data->dst_pitch;
  12.249 +    }
  12.250 +    return 0;
  12.251 +}
  12.252 +
  12.253 +int SDL_RenderCopy_RGB888_RGB888_Blend_Scale(SDL_RenderCopyData *data)
  12.254 +{
  12.255 +    const int flags = data->flags;
  12.256 +    Uint32 srcpixel;
  12.257 +    Uint32 srcR, srcG, srcB, srcA;
  12.258 +    Uint32 dstpixel;
  12.259 +    Uint32 dstR, dstG, dstB, dstA;
  12.260 +    int srcy, srcx;
  12.261 +    int posy, posx;
  12.262 +    int incy, incx;
  12.263 +
  12.264 +    srcy = 0;
  12.265 +    posy = 0;
  12.266 +    incy = (data->src_h << 16) / data->dst_h;
  12.267 +    incx = (data->src_w << 16) / data->dst_w;
  12.268 +
  12.269 +    while (data->dst_h--) {
  12.270 +        Uint32 *src;
  12.271 +        Uint32 *dst = (Uint32 *)data->dst;
  12.272 +        int n = data->dst_w;
  12.273 +        srcx = -1;
  12.274 +        posx = 0x10000L;
  12.275 +        while (posy >= 0x10000L) {
  12.276 +            ++srcy;
  12.277 +            posy -= 0x10000L;
  12.278 +        }
  12.279 +        while (n--) {
  12.280 +            if (posx >= 0x10000L) {
  12.281 +                while (posx >= 0x10000L) {
  12.282 +                    ++srcx;
  12.283 +                    posx -= 0x10000L;
  12.284 +                }
  12.285 +                src = (Uint32 *)(data->src + (srcy * data->src_pitch) + (srcx * 4));
  12.286 +            }
  12.287 +            srcpixel = *src;
  12.288 +            srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = 0xFF;
  12.289 +            dstpixel = *dst;
  12.290 +            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
  12.291 +            if (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD)) {
  12.292 +                /* This goes away if we ever use premultiplied alpha */
  12.293 +                srcR = (srcR * srcA) / 255;
  12.294 +                srcG = (srcG * srcA) / 255;
  12.295 +                srcB = (srcB * srcA) / 255;
  12.296 +            }
  12.297 +            switch (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD|SDL_RENDERCOPY_MOD)) {
  12.298 +            case SDL_RENDERCOPY_BLEND:
  12.299 +                dstR = srcR + ((255 - srcA) * dstR) / 255;
  12.300 +                dstG = srcG + ((255 - srcA) * dstG) / 255;
  12.301 +                dstB = srcB + ((255 - srcA) * dstB) / 255;
  12.302 +                break;
  12.303 +            case SDL_RENDERCOPY_ADD:
  12.304 +                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  12.305 +                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  12.306 +                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  12.307 +                break;
  12.308 +            case SDL_RENDERCOPY_MOD:
  12.309 +                dstR = (srcR * dstR) / 255;
  12.310 +                dstG = (srcG * dstG) / 255;
  12.311 +                dstB = (srcB * dstB) / 255;
  12.312 +                break;
  12.313 +            }
  12.314 +            dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
  12.315 +            *dst = dstpixel;
  12.316 +            posx += incx;
  12.317 +            ++dst;
  12.318 +        }
  12.319 +        posy += incy;
  12.320 +        data->dst += data->dst_pitch;
  12.321 +    }
  12.322 +    return 0;
  12.323 +}
  12.324 +
  12.325 +int SDL_RenderCopy_RGB888_RGB888_Modulate(SDL_RenderCopyData *data)
  12.326 +{
  12.327 +    const int flags = data->flags;
  12.328 +    const Uint32 modulateR = data->r;
  12.329 +    const Uint32 modulateG = data->g;
  12.330 +    const Uint32 modulateB = data->b;
  12.331 +    const Uint32 modulateA = data->a;
  12.332 +    Uint32 pixel;
  12.333 +    Uint32 R, G, B, A;
  12.334 +
  12.335 +    while (data->dst_h--) {
  12.336 +        Uint32 *src = (Uint32 *)data->src;
  12.337 +        Uint32 *dst = (Uint32 *)data->dst;
  12.338 +        int n = data->dst_w;
  12.339 +        while (n--) {
  12.340 +            pixel = *src;
  12.341 +            R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; A = 0xFF;
  12.342 +            if (flags & SDL_RENDERCOPY_MODULATE_COLOR) {
  12.343 +                R = (R * modulateR) / 255;
  12.344 +                G = (G * modulateG) / 255;
  12.345 +                B = (B * modulateB) / 255;
  12.346 +            }
  12.347 +            pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B;
  12.348 +            *dst = pixel;
  12.349 +            ++src;
  12.350 +            ++dst;
  12.351 +        }
  12.352 +        data->src += data->src_pitch;
  12.353 +        data->dst += data->dst_pitch;
  12.354 +    }
  12.355 +    return 0;
  12.356 +}
  12.357 +
  12.358 +int SDL_RenderCopy_RGB888_RGB888_Modulate_Scale(SDL_RenderCopyData *data)
  12.359 +{
  12.360 +    const int flags = data->flags;
  12.361 +    const Uint32 modulateR = data->r;
  12.362 +    const Uint32 modulateG = data->g;
  12.363 +    const Uint32 modulateB = data->b;
  12.364 +    const Uint32 modulateA = data->a;
  12.365 +    Uint32 pixel;
  12.366 +    Uint32 R, G, B, A;
  12.367 +    int srcy, srcx;
  12.368 +    int posy, posx;
  12.369 +    int incy, incx;
  12.370 +
  12.371 +    srcy = 0;
  12.372 +    posy = 0;
  12.373 +    incy = (data->src_h << 16) / data->dst_h;
  12.374 +    incx = (data->src_w << 16) / data->dst_w;
  12.375 +
  12.376 +    while (data->dst_h--) {
  12.377 +        Uint32 *src;
  12.378 +        Uint32 *dst = (Uint32 *)data->dst;
  12.379 +        int n = data->dst_w;
  12.380 +        srcx = -1;
  12.381 +        posx = 0x10000L;
  12.382 +        while (posy >= 0x10000L) {
  12.383 +            ++srcy;
  12.384 +            posy -= 0x10000L;
  12.385 +        }
  12.386 +        while (n--) {
  12.387 +            if (posx >= 0x10000L) {
  12.388 +                while (posx >= 0x10000L) {
  12.389 +                    ++srcx;
  12.390 +                    posx -= 0x10000L;
  12.391 +                }
  12.392 +                src = (Uint32 *)(data->src + (srcy * data->src_pitch) + (srcx * 4));
  12.393 +            }
  12.394 +            pixel = *src;
  12.395 +            R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; A = 0xFF;
  12.396 +            if (flags & SDL_RENDERCOPY_MODULATE_COLOR) {
  12.397 +                R = (R * modulateR) / 255;
  12.398 +                G = (G * modulateG) / 255;
  12.399 +                B = (B * modulateB) / 255;
  12.400 +            }
  12.401 +            pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B;
  12.402 +            *dst = pixel;
  12.403 +            posx += incx;
  12.404 +            ++dst;
  12.405 +        }
  12.406 +        posy += incy;
  12.407 +        data->dst += data->dst_pitch;
  12.408 +    }
  12.409 +    return 0;
  12.410 +}
  12.411 +
  12.412 +int SDL_RenderCopy_RGB888_RGB888_Modulate_Blend(SDL_RenderCopyData *data)
  12.413 +{
  12.414 +    const int flags = data->flags;
  12.415 +    const Uint32 modulateR = data->r;
  12.416 +    const Uint32 modulateG = data->g;
  12.417 +    const Uint32 modulateB = data->b;
  12.418 +    const Uint32 modulateA = data->a;
  12.419 +    Uint32 srcpixel;
  12.420 +    Uint32 srcR, srcG, srcB, srcA;
  12.421 +    Uint32 dstpixel;
  12.422 +    Uint32 dstR, dstG, dstB, dstA;
  12.423 +
  12.424 +    while (data->dst_h--) {
  12.425 +        Uint32 *src = (Uint32 *)data->src;
  12.426 +        Uint32 *dst = (Uint32 *)data->dst;
  12.427 +        int n = data->dst_w;
  12.428 +        while (n--) {
  12.429 +            srcpixel = *src;
  12.430 +            srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = 0xFF;
  12.431 +            dstpixel = *dst;
  12.432 +            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
  12.433 +            if (flags & SDL_RENDERCOPY_MODULATE_COLOR) {
  12.434 +                srcR = (srcR * modulateR) / 255;
  12.435 +                srcG = (srcG * modulateG) / 255;
  12.436 +                srcB = (srcB * modulateB) / 255;
  12.437 +            }
  12.438 +            if (flags & SDL_RENDERCOPY_MODULATE_ALPHA) {
  12.439 +                srcA = (srcA * modulateA) / 255;
  12.440 +            }
  12.441 +            if (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD)) {
  12.442 +                /* This goes away if we ever use premultiplied alpha */
  12.443 +                srcR = (srcR * srcA) / 255;
  12.444 +                srcG = (srcG * srcA) / 255;
  12.445 +                srcB = (srcB * srcA) / 255;
  12.446 +            }
  12.447 +            switch (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD|SDL_RENDERCOPY_MOD)) {
  12.448 +            case SDL_RENDERCOPY_BLEND:
  12.449 +                dstR = srcR + ((255 - srcA) * dstR) / 255;
  12.450 +                dstG = srcG + ((255 - srcA) * dstG) / 255;
  12.451 +                dstB = srcB + ((255 - srcA) * dstB) / 255;
  12.452 +                break;
  12.453 +            case SDL_RENDERCOPY_ADD:
  12.454 +                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  12.455 +                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  12.456 +                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  12.457 +                break;
  12.458 +            case SDL_RENDERCOPY_MOD:
  12.459 +                dstR = (srcR * dstR) / 255;
  12.460 +                dstG = (srcG * dstG) / 255;
  12.461 +                dstB = (srcB * dstB) / 255;
  12.462 +                break;
  12.463 +            }
  12.464 +            dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
  12.465 +            *dst = dstpixel;
  12.466 +            ++src;
  12.467 +            ++dst;
  12.468 +        }
  12.469 +        data->src += data->src_pitch;
  12.470 +        data->dst += data->dst_pitch;
  12.471 +    }
  12.472 +    return 0;
  12.473 +}
  12.474 +
  12.475 +int SDL_RenderCopy_RGB888_RGB888_Modulate_Blend_Scale(SDL_RenderCopyData *data)
  12.476 +{
  12.477 +    const int flags = data->flags;
  12.478 +    const Uint32 modulateR = data->r;
  12.479 +    const Uint32 modulateG = data->g;
  12.480 +    const Uint32 modulateB = data->b;
  12.481 +    const Uint32 modulateA = data->a;
  12.482 +    Uint32 srcpixel;
  12.483 +    Uint32 srcR, srcG, srcB, srcA;
  12.484 +    Uint32 dstpixel;
  12.485 +    Uint32 dstR, dstG, dstB, dstA;
  12.486 +    int srcy, srcx;
  12.487 +    int posy, posx;
  12.488 +    int incy, incx;
  12.489 +
  12.490 +    srcy = 0;
  12.491 +    posy = 0;
  12.492 +    incy = (data->src_h << 16) / data->dst_h;
  12.493 +    incx = (data->src_w << 16) / data->dst_w;
  12.494 +
  12.495 +    while (data->dst_h--) {
  12.496 +        Uint32 *src;
  12.497 +        Uint32 *dst = (Uint32 *)data->dst;
  12.498 +        int n = data->dst_w;
  12.499 +        srcx = -1;
  12.500 +        posx = 0x10000L;
  12.501 +        while (posy >= 0x10000L) {
  12.502 +            ++srcy;
  12.503 +            posy -= 0x10000L;
  12.504 +        }
  12.505 +        while (n--) {
  12.506 +            if (posx >= 0x10000L) {
  12.507 +                while (posx >= 0x10000L) {
  12.508 +                    ++srcx;
  12.509 +                    posx -= 0x10000L;
  12.510 +                }
  12.511 +                src = (Uint32 *)(data->src + (srcy * data->src_pitch) + (srcx * 4));
  12.512 +            }
  12.513 +            srcpixel = *src;
  12.514 +            srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = 0xFF;
  12.515 +            dstpixel = *dst;
  12.516 +            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
  12.517 +            if (flags & SDL_RENDERCOPY_MODULATE_COLOR) {
  12.518 +                srcR = (srcR * modulateR) / 255;
  12.519 +                srcG = (srcG * modulateG) / 255;
  12.520 +                srcB = (srcB * modulateB) / 255;
  12.521 +            }
  12.522 +            if (flags & SDL_RENDERCOPY_MODULATE_ALPHA) {
  12.523 +                srcA = (srcA * modulateA) / 255;
  12.524 +            }
  12.525 +            if (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD)) {
  12.526 +                /* This goes away if we ever use premultiplied alpha */
  12.527 +                srcR = (srcR * srcA) / 255;
  12.528 +                srcG = (srcG * srcA) / 255;
  12.529 +                srcB = (srcB * srcA) / 255;
  12.530 +            }
  12.531 +            switch (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD|SDL_RENDERCOPY_MOD)) {
  12.532 +            case SDL_RENDERCOPY_BLEND:
  12.533 +                dstR = srcR + ((255 - srcA) * dstR) / 255;
  12.534 +                dstG = srcG + ((255 - srcA) * dstG) / 255;
  12.535 +                dstB = srcB + ((255 - srcA) * dstB) / 255;
  12.536 +                break;
  12.537 +            case SDL_RENDERCOPY_ADD:
  12.538 +                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  12.539 +                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  12.540 +                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  12.541 +                break;
  12.542 +            case SDL_RENDERCOPY_MOD:
  12.543 +                dstR = (srcR * dstR) / 255;
  12.544 +                dstG = (srcG * dstG) / 255;
  12.545 +                dstB = (srcB * dstB) / 255;
  12.546 +                break;
  12.547 +            }
  12.548 +            dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
  12.549 +            *dst = dstpixel;
  12.550 +            posx += incx;
  12.551 +            ++dst;
  12.552 +        }
  12.553 +        posy += incy;
  12.554 +        data->dst += data->dst_pitch;
  12.555 +    }
  12.556 +    return 0;
  12.557 +}
  12.558 +
  12.559 +int SDL_RenderCopy_RGB888_BGR888(SDL_RenderCopyData *data)
  12.560 +{
  12.561 +    const int flags = data->flags;
  12.562 +    Uint32 pixel;
  12.563 +    Uint32 R, G, B, A;
  12.564 +
  12.565 +    while (data->dst_h--) {
  12.566 +        Uint32 *src = (Uint32 *)data->src;
  12.567 +        Uint32 *dst = (Uint32 *)data->dst;
  12.568 +        int n = data->dst_w;
  12.569 +        while (n--) {
  12.570 +            pixel = *src;
  12.571 +            R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; A = 0xFF;
  12.572 +            pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R;
  12.573 +            *dst = pixel;
  12.574 +            ++src;
  12.575 +            ++dst;
  12.576 +        }
  12.577 +        data->src += data->src_pitch;
  12.578 +        data->dst += data->dst_pitch;
  12.579 +    }
  12.580 +    return 0;
  12.581 +}
  12.582 +
  12.583 +int SDL_RenderCopy_RGB888_BGR888_Scale(SDL_RenderCopyData *data)
  12.584 +{
  12.585 +    const int flags = data->flags;
  12.586 +    Uint32 pixel;
  12.587 +    Uint32 R, G, B, A;
  12.588 +    int srcy, srcx;
  12.589 +    int posy, posx;
  12.590 +    int incy, incx;
  12.591 +
  12.592 +    srcy = 0;
  12.593 +    posy = 0;
  12.594 +    incy = (data->src_h << 16) / data->dst_h;
  12.595 +    incx = (data->src_w << 16) / data->dst_w;
  12.596 +
  12.597 +    while (data->dst_h--) {
  12.598 +        Uint32 *src;
  12.599 +        Uint32 *dst = (Uint32 *)data->dst;
  12.600 +        int n = data->dst_w;
  12.601 +        srcx = -1;
  12.602 +        posx = 0x10000L;
  12.603 +        while (posy >= 0x10000L) {
  12.604 +            ++srcy;
  12.605 +            posy -= 0x10000L;
  12.606 +        }
  12.607 +        while (n--) {
  12.608 +            if (posx >= 0x10000L) {
  12.609 +                while (posx >= 0x10000L) {
  12.610 +                    ++srcx;
  12.611 +                    posx -= 0x10000L;
  12.612 +                }
  12.613 +                src = (Uint32 *)(data->src + (srcy * data->src_pitch) + (srcx * 4));
  12.614 +            }
  12.615 +            pixel = *src;
  12.616 +            R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; A = 0xFF;
  12.617 +            pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R;
  12.618 +            *dst = pixel;
  12.619 +            posx += incx;
  12.620 +            ++dst;
  12.621 +        }
  12.622 +        posy += incy;
  12.623 +        data->dst += data->dst_pitch;
  12.624 +    }
  12.625 +    return 0;
  12.626 +}
  12.627 +
  12.628 +int SDL_RenderCopy_RGB888_BGR888_Blend(SDL_RenderCopyData *data)
  12.629 +{
  12.630 +    const int flags = data->flags;
  12.631 +    Uint32 srcpixel;
  12.632 +    Uint32 srcR, srcG, srcB, srcA;
  12.633 +    Uint32 dstpixel;
  12.634 +    Uint32 dstR, dstG, dstB, dstA;
  12.635 +
  12.636 +    while (data->dst_h--) {
  12.637 +        Uint32 *src = (Uint32 *)data->src;
  12.638 +        Uint32 *dst = (Uint32 *)data->dst;
  12.639 +        int n = data->dst_w;
  12.640 +        while (n--) {
  12.641 +            srcpixel = *src;
  12.642 +            srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = 0xFF;
  12.643 +            dstpixel = *dst;
  12.644 +            dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
  12.645 +            if (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD)) {
  12.646 +                /* This goes away if we ever use premultiplied alpha */
  12.647 +                srcR = (srcR * srcA) / 255;
  12.648 +                srcG = (srcG * srcA) / 255;
  12.649 +                srcB = (srcB * srcA) / 255;
  12.650 +            }
  12.651 +            switch (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD|SDL_RENDERCOPY_MOD)) {
  12.652 +            case SDL_RENDERCOPY_BLEND:
  12.653 +                dstR = srcR + ((255 - srcA) * dstR) / 255;
  12.654 +                dstG = srcG + ((255 - srcA) * dstG) / 255;
  12.655 +                dstB = srcB + ((255 - srcA) * dstB) / 255;
  12.656 +                break;
  12.657 +            case SDL_RENDERCOPY_ADD:
  12.658 +                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  12.659 +                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  12.660 +                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  12.661 +                break;
  12.662 +            case SDL_RENDERCOPY_MOD:
  12.663 +                dstR = (srcR * dstR) / 255;
  12.664 +                dstG = (srcG * dstG) / 255;
  12.665 +                dstB = (srcB * dstB) / 255;
  12.666 +                break;
  12.667 +            }
  12.668 +            dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
  12.669 +            *dst = dstpixel;
  12.670 +            ++src;
  12.671 +            ++dst;
  12.672 +        }
  12.673 +        data->src += data->src_pitch;
  12.674 +        data->dst += data->dst_pitch;
  12.675 +    }
  12.676 +    return 0;
  12.677 +}
  12.678 +
  12.679 +int SDL_RenderCopy_RGB888_BGR888_Blend_Scale(SDL_RenderCopyData *data)
  12.680 +{
  12.681 +    const int flags = data->flags;
  12.682 +    Uint32 srcpixel;
  12.683 +    Uint32 srcR, srcG, srcB, srcA;
  12.684 +    Uint32 dstpixel;
  12.685 +    Uint32 dstR, dstG, dstB, dstA;
  12.686 +    int srcy, srcx;
  12.687 +    int posy, posx;
  12.688 +    int incy, incx;
  12.689 +
  12.690 +    srcy = 0;
  12.691 +    posy = 0;
  12.692 +    incy = (data->src_h << 16) / data->dst_h;
  12.693 +    incx = (data->src_w << 16) / data->dst_w;
  12.694 +
  12.695 +    while (data->dst_h--) {
  12.696 +        Uint32 *src;
  12.697 +        Uint32 *dst = (Uint32 *)data->dst;
  12.698 +        int n = data->dst_w;
  12.699 +        srcx = -1;
  12.700 +        posx = 0x10000L;
  12.701 +        while (posy >= 0x10000L) {
  12.702 +            ++srcy;
  12.703 +            posy -= 0x10000L;
  12.704 +        }
  12.705 +        while (n--) {
  12.706 +            if (posx >= 0x10000L) {
  12.707 +                while (posx >= 0x10000L) {
  12.708 +                    ++srcx;
  12.709 +                    posx -= 0x10000L;
  12.710 +                }
  12.711 +                src = (Uint32 *)(data->src + (srcy * data->src_pitch) + (srcx * 4));
  12.712 +            }
  12.713 +            srcpixel = *src;
  12.714 +            srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = 0xFF;
  12.715 +            dstpixel = *dst;
  12.716 +            dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
  12.717 +            if (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD)) {
  12.718 +                /* This goes away if we ever use premultiplied alpha */
  12.719 +                srcR = (srcR * srcA) / 255;
  12.720 +                srcG = (srcG * srcA) / 255;
  12.721 +                srcB = (srcB * srcA) / 255;
  12.722 +            }
  12.723 +            switch (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD|SDL_RENDERCOPY_MOD)) {
  12.724 +            case SDL_RENDERCOPY_BLEND:
  12.725 +                dstR = srcR + ((255 - srcA) * dstR) / 255;
  12.726 +                dstG = srcG + ((255 - srcA) * dstG) / 255;
  12.727 +                dstB = srcB + ((255 - srcA) * dstB) / 255;
  12.728 +                break;
  12.729 +            case SDL_RENDERCOPY_ADD:
  12.730 +                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  12.731 +                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  12.732 +                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  12.733 +                break;
  12.734 +            case SDL_RENDERCOPY_MOD:
  12.735 +                dstR = (srcR * dstR) / 255;
  12.736 +                dstG = (srcG * dstG) / 255;
  12.737 +                dstB = (srcB * dstB) / 255;
  12.738 +                break;
  12.739 +            }
  12.740 +            dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
  12.741 +            *dst = dstpixel;
  12.742 +            posx += incx;
  12.743 +            ++dst;
  12.744 +        }
  12.745 +        posy += incy;
  12.746 +        data->dst += data->dst_pitch;
  12.747 +    }
  12.748 +    return 0;
  12.749 +}
  12.750 +
  12.751 +int SDL_RenderCopy_RGB888_BGR888_Modulate(SDL_RenderCopyData *data)
  12.752 +{
  12.753 +    const int flags = data->flags;
  12.754 +    const Uint32 modulateR = data->r;
  12.755 +    const Uint32 modulateG = data->g;
  12.756 +    const Uint32 modulateB = data->b;
  12.757 +    const Uint32 modulateA = data->a;
  12.758 +    Uint32 pixel;
  12.759 +    Uint32 R, G, B, A;
  12.760 +
  12.761 +    while (data->dst_h--) {
  12.762 +        Uint32 *src = (Uint32 *)data->src;
  12.763 +        Uint32 *dst = (Uint32 *)data->dst;
  12.764 +        int n = data->dst_w;
  12.765 +        while (n--) {
  12.766 +            pixel = *src;
  12.767 +            R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; A = 0xFF;
  12.768 +            if (flags & SDL_RENDERCOPY_MODULATE_COLOR) {
  12.769 +                R = (R * modulateR) / 255;
  12.770 +                G = (G * modulateG) / 255;
  12.771 +                B = (B * modulateB) / 255;
  12.772 +            }
  12.773 +            pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R;
  12.774 +            *dst = pixel;
  12.775 +            ++src;
  12.776 +            ++dst;
  12.777 +        }
  12.778 +        data->src += data->src_pitch;
  12.779 +        data->dst += data->dst_pitch;
  12.780 +    }
  12.781 +    return 0;
  12.782 +}
  12.783 +
  12.784 +int SDL_RenderCopy_RGB888_BGR888_Modulate_Scale(SDL_RenderCopyData *data)
  12.785 +{
  12.786 +    const int flags = data->flags;
  12.787 +    const Uint32 modulateR = data->r;
  12.788 +    const Uint32 modulateG = data->g;
  12.789 +    const Uint32 modulateB = data->b;
  12.790 +    const Uint32 modulateA = data->a;
  12.791 +    Uint32 pixel;
  12.792 +    Uint32 R, G, B, A;
  12.793 +    int srcy, srcx;
  12.794 +    int posy, posx;
  12.795 +    int incy, incx;
  12.796 +
  12.797 +    srcy = 0;
  12.798 +    posy = 0;
  12.799 +    incy = (data->src_h << 16) / data->dst_h;
  12.800 +    incx = (data->src_w << 16) / data->dst_w;
  12.801 +
  12.802 +    while (data->dst_h--) {
  12.803 +        Uint32 *src;
  12.804 +        Uint32 *dst = (Uint32 *)data->dst;
  12.805 +        int n = data->dst_w;
  12.806 +        srcx = -1;
  12.807 +        posx = 0x10000L;
  12.808 +        while (posy >= 0x10000L) {
  12.809 +            ++srcy;
  12.810 +            posy -= 0x10000L;
  12.811 +        }
  12.812 +        while (n--) {
  12.813 +            if (posx >= 0x10000L) {
  12.814 +                while (posx >= 0x10000L) {
  12.815 +                    ++srcx;
  12.816 +                    posx -= 0x10000L;
  12.817 +                }
  12.818 +                src = (Uint32 *)(data->src + (srcy * data->src_pitch) + (srcx * 4));
  12.819 +            }
  12.820 +            pixel = *src;
  12.821 +            R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; A = 0xFF;
  12.822 +            if (flags & SDL_RENDERCOPY_MODULATE_COLOR) {
  12.823 +                R = (R * modulateR) / 255;
  12.824 +                G = (G * modulateG) / 255;
  12.825 +                B = (B * modulateB) / 255;
  12.826 +            }
  12.827 +            pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R;
  12.828 +            *dst = pixel;
  12.829 +            posx += incx;
  12.830 +            ++dst;
  12.831 +        }
  12.832 +        posy += incy;
  12.833 +        data->dst += data->dst_pitch;
  12.834 +    }
  12.835 +    return 0;
  12.836 +}
  12.837 +
  12.838 +int SDL_RenderCopy_RGB888_BGR888_Modulate_Blend(SDL_RenderCopyData *data)
  12.839 +{
  12.840 +    const int flags = data->flags;
  12.841 +    const Uint32 modulateR = data->r;
  12.842 +    const Uint32 modulateG = data->g;
  12.843 +    const Uint32 modulateB = data->b;
  12.844 +    const Uint32 modulateA = data->a;
  12.845 +    Uint32 srcpixel;
  12.846 +    Uint32 srcR, srcG, srcB, srcA;
  12.847 +    Uint32 dstpixel;
  12.848 +    Uint32 dstR, dstG, dstB, dstA;
  12.849 +
  12.850 +    while (data->dst_h--) {
  12.851 +        Uint32 *src = (Uint32 *)data->src;
  12.852 +        Uint32 *dst = (Uint32 *)data->dst;
  12.853 +        int n = data->dst_w;
  12.854 +        while (n--) {
  12.855 +            srcpixel = *src;
  12.856 +            srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = 0xFF;
  12.857 +            dstpixel = *dst;
  12.858 +            dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
  12.859 +            if (flags & SDL_RENDERCOPY_MODULATE_COLOR) {
  12.860 +                srcR = (srcR * modulateR) / 255;
  12.861 +                srcG = (srcG * modulateG) / 255;
  12.862 +                srcB = (srcB * modulateB) / 255;
  12.863 +            }
  12.864 +            if (flags & SDL_RENDERCOPY_MODULATE_ALPHA) {
  12.865 +                srcA = (srcA * modulateA) / 255;
  12.866 +            }
  12.867 +            if (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD)) {
  12.868 +                /* This goes away if we ever use premultiplied alpha */
  12.869 +                srcR = (srcR * srcA) / 255;
  12.870 +                srcG = (srcG * srcA) / 255;
  12.871 +                srcB = (srcB * srcA) / 255;
  12.872 +            }
  12.873 +            switch (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD|SDL_RENDERCOPY_MOD)) {
  12.874 +            case SDL_RENDERCOPY_BLEND:
  12.875 +                dstR = srcR + ((255 - srcA) * dstR) / 255;
  12.876 +                dstG = srcG + ((255 - srcA) * dstG) / 255;
  12.877 +                dstB = srcB + ((255 - srcA) * dstB) / 255;
  12.878 +                break;
  12.879 +            case SDL_RENDERCOPY_ADD:
  12.880 +                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  12.881 +                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  12.882 +                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  12.883 +                break;
  12.884 +            case SDL_RENDERCOPY_MOD:
  12.885 +                dstR = (srcR * dstR) / 255;
  12.886 +                dstG = (srcG * dstG) / 255;
  12.887 +                dstB = (srcB * dstB) / 255;
  12.888 +                break;
  12.889 +            }
  12.890 +            dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
  12.891 +            *dst = dstpixel;
  12.892 +            ++src;
  12.893 +            ++dst;
  12.894 +        }
  12.895 +        data->src += data->src_pitch;
  12.896 +        data->dst += data->dst_pitch;
  12.897 +    }
  12.898 +    return 0;
  12.899 +}
  12.900 +
  12.901 +int SDL_RenderCopy_RGB888_BGR888_Modulate_Blend_Scale(SDL_RenderCopyData *data)
  12.902 +{
  12.903 +    const int flags = data->flags;
  12.904 +    const Uint32 modulateR = data->r;
  12.905 +    const Uint32 modulateG = data->g;
  12.906 +    const Uint32 modulateB = data->b;
  12.907 +    const Uint32 modulateA = data->a;
  12.908 +    Uint32 srcpixel;
  12.909 +    Uint32 srcR, srcG, srcB, srcA;
  12.910 +    Uint32 dstpixel;
  12.911 +    Uint32 dstR, dstG, dstB, dstA;
  12.912 +    int srcy, srcx;
  12.913 +    int posy, posx;
  12.914 +    int incy, incx;
  12.915 +
  12.916 +    srcy = 0;
  12.917 +    posy = 0;
  12.918 +    incy = (data->src_h << 16) / data->dst_h;
  12.919 +    incx = (data->src_w << 16) / data->dst_w;
  12.920 +
  12.921 +    while (data->dst_h--) {
  12.922 +        Uint32 *src;
  12.923 +        Uint32 *dst = (Uint32 *)data->dst;
  12.924 +        int n = data->dst_w;
  12.925 +        srcx = -1;
  12.926 +        posx = 0x10000L;
  12.927 +        while (posy >= 0x10000L) {
  12.928 +            ++srcy;
  12.929 +            posy -= 0x10000L;
  12.930 +        }
  12.931 +        while (n--) {
  12.932 +            if (posx >= 0x10000L) {
  12.933 +                while (posx >= 0x10000L) {
  12.934 +                    ++srcx;
  12.935 +                    posx -= 0x10000L;
  12.936 +                }
  12.937 +                src = (Uint32 *)(data->src + (srcy * data->src_pitch) + (srcx * 4));
  12.938 +            }
  12.939 +            srcpixel = *src;
  12.940 +            srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = 0xFF;
  12.941 +            dstpixel = *dst;
  12.942 +            dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
  12.943 +            if (flags & SDL_RENDERCOPY_MODULATE_COLOR) {
  12.944 +                srcR = (srcR * modulateR) / 255;
  12.945 +                srcG = (srcG * modulateG) / 255;
  12.946 +                srcB = (srcB * modulateB) / 255;
  12.947 +            }
  12.948 +            if (flags & SDL_RENDERCOPY_MODULATE_ALPHA) {
  12.949 +                srcA = (srcA * modulateA) / 255;
  12.950 +            }
  12.951 +            if (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD)) {
  12.952 +                /* This goes away if we ever use premultiplied alpha */
  12.953 +                srcR = (srcR * srcA) / 255;
  12.954 +                srcG = (srcG * srcA) / 255;
  12.955 +                srcB = (srcB * srcA) / 255;
  12.956 +            }
  12.957 +            switch (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD|SDL_RENDERCOPY_MOD)) {
  12.958 +            case SDL_RENDERCOPY_BLEND:
  12.959 +                dstR = srcR + ((255 - srcA) * dstR) / 255;
  12.960 +                dstG = srcG + ((255 - srcA) * dstG) / 255;
  12.961 +                dstB = srcB + ((255 - srcA) * dstB) / 255;
  12.962 +                break;
  12.963 +            case SDL_RENDERCOPY_ADD:
  12.964 +                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
  12.965 +                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
  12.966 +                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
  12.967 +                break;
  12.968 +            case SDL_RENDERCOPY_MOD:
  12.969 +                dstR = (srcR * dstR) / 255;
  12.970 +                dstG = (srcG * dstG) / 255;
  12.971 +                dstB = (srcB * dstB) / 255;
  12.972 +                break;
  12.973 +            }
  12.974 +            dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
  12.975 +            *dst = dstpixel;
  12.976 +            posx += incx;
  12.977 +            ++dst;
  12.978 +        }
  12.979 +        posy += incy;
  12.980 +        data->dst += data->dst_pitch;
  12.981 +    }
  12.982 +    return 0;
  12.983 +}
  12.984 +
  12.985 +int SDL_RenderCopy_BGR888_RGB888(SDL_RenderCopyData *data)
  12.986 +{
  12.987 +    const int flags = data->flags;
  12.988 +    Uint32 pixel;
  12.989 +    Uint32 R, G, B, A;
  12.990 +
  12.991 +    while (data->dst_h--) {
  12.992 +        Uint32 *src = (Uint32 *)data->src;
  12.993 +        Uint32 *dst = (Uint32 *)data->dst;
  12.994 +        int n = data->dst_w;
  12.995 +        while (n--) {
  12.996 +            pixel = *src;
  12.997 +            B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; A = 0xFF;
  12.998 +            pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B;
  12.999 +            *dst = pixel;
 12.1000 +            ++src;
 12.1001 +            ++dst;
 12.1002 +        }
 12.1003 +        data->src += data->src_pitch;
 12.1004 +        data->dst += data->dst_pitch;
 12.1005 +    }
 12.1006 +    return 0;
 12.1007 +}
 12.1008 +
 12.1009 +int SDL_RenderCopy_BGR888_RGB888_Scale(SDL_RenderCopyData *data)
 12.1010 +{
 12.1011 +    const int flags = data->flags;
 12.1012 +    Uint32 pixel;
 12.1013 +    Uint32 R, G, B, A;
 12.1014 +    int srcy, srcx;
 12.1015 +    int posy, posx;
 12.1016 +    int incy, incx;
 12.1017 +
 12.1018 +    srcy = 0;
 12.1019 +    posy = 0;
 12.1020 +    incy = (data->src_h << 16) / data->dst_h;
 12.1021 +    incx = (data->src_w << 16) / data->dst_w;
 12.1022 +
 12.1023 +    while (data->dst_h--) {
 12.1024 +        Uint32 *src;
 12.1025 +        Uint32 *dst = (Uint32 *)data->dst;
 12.1026 +        int n = data->dst_w;
 12.1027 +        srcx = -1;
 12.1028 +        posx = 0x10000L;
 12.1029 +        while (posy >= 0x10000L) {
 12.1030 +            ++srcy;
 12.1031 +            posy -= 0x10000L;
 12.1032 +        }
 12.1033 +        while (n--) {
 12.1034 +            if (posx >= 0x10000L) {
 12.1035 +                while (posx >= 0x10000L) {
 12.1036 +                    ++srcx;
 12.1037 +                    posx -= 0x10000L;
 12.1038 +                }
 12.1039 +                src = (Uint32 *)(data->src + (srcy * data->src_pitch) + (srcx * 4));
 12.1040 +            }
 12.1041 +            pixel = *src;
 12.1042 +            B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; A = 0xFF;
 12.1043 +            pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B;
 12.1044 +            *dst = pixel;
 12.1045 +            posx += incx;
 12.1046 +            ++dst;
 12.1047 +        }
 12.1048 +        posy += incy;
 12.1049 +        data->dst += data->dst_pitch;
 12.1050 +    }
 12.1051 +    return 0;
 12.1052 +}
 12.1053 +
 12.1054 +int SDL_RenderCopy_BGR888_RGB888_Blend(SDL_RenderCopyData *data)
 12.1055 +{
 12.1056 +    const int flags = data->flags;
 12.1057 +    Uint32 srcpixel;
 12.1058 +    Uint32 srcR, srcG, srcB, srcA;
 12.1059 +    Uint32 dstpixel;
 12.1060 +    Uint32 dstR, dstG, dstB, dstA;
 12.1061 +
 12.1062 +    while (data->dst_h--) {
 12.1063 +        Uint32 *src = (Uint32 *)data->src;
 12.1064 +        Uint32 *dst = (Uint32 *)data->dst;
 12.1065 +        int n = data->dst_w;
 12.1066 +        while (n--) {
 12.1067 +            srcpixel = *src;
 12.1068 +            srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = 0xFF;
 12.1069 +            dstpixel = *dst;
 12.1070 +            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
 12.1071 +            if (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD)) {
 12.1072 +                /* This goes away if we ever use premultiplied alpha */
 12.1073 +                srcR = (srcR * srcA) / 255;
 12.1074 +                srcG = (srcG * srcA) / 255;
 12.1075 +                srcB = (srcB * srcA) / 255;
 12.1076 +            }
 12.1077 +            switch (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD|SDL_RENDERCOPY_MOD)) {
 12.1078 +            case SDL_RENDERCOPY_BLEND:
 12.1079 +                dstR = srcR + ((255 - srcA) * dstR) / 255;
 12.1080 +                dstG = srcG + ((255 - srcA) * dstG) / 255;
 12.1081 +                dstB = srcB + ((255 - srcA) * dstB) / 255;
 12.1082 +                break;
 12.1083 +            case SDL_RENDERCOPY_ADD:
 12.1084 +                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
 12.1085 +                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
 12.1086 +                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
 12.1087 +                break;
 12.1088 +            case SDL_RENDERCOPY_MOD:
 12.1089 +                dstR = (srcR * dstR) / 255;
 12.1090 +                dstG = (srcG * dstG) / 255;
 12.1091 +                dstB = (srcB * dstB) / 255;
 12.1092 +                break;
 12.1093 +            }
 12.1094 +            dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
 12.1095 +            *dst = dstpixel;
 12.1096 +            ++src;
 12.1097 +            ++dst;
 12.1098 +        }
 12.1099 +        data->src += data->src_pitch;
 12.1100 +        data->dst += data->dst_pitch;
 12.1101 +    }
 12.1102 +    return 0;
 12.1103 +}
 12.1104 +
 12.1105 +int SDL_RenderCopy_BGR888_RGB888_Blend_Scale(SDL_RenderCopyData *data)
 12.1106 +{
 12.1107 +    const int flags = data->flags;
 12.1108 +    Uint32 srcpixel;
 12.1109 +    Uint32 srcR, srcG, srcB, srcA;
 12.1110 +    Uint32 dstpixel;
 12.1111 +    Uint32 dstR, dstG, dstB, dstA;
 12.1112 +    int srcy, srcx;
 12.1113 +    int posy, posx;
 12.1114 +    int incy, incx;
 12.1115 +
 12.1116 +    srcy = 0;
 12.1117 +    posy = 0;
 12.1118 +    incy = (data->src_h << 16) / data->dst_h;
 12.1119 +    incx = (data->src_w << 16) / data->dst_w;
 12.1120 +
 12.1121 +    while (data->dst_h--) {
 12.1122 +        Uint32 *src;
 12.1123 +        Uint32 *dst = (Uint32 *)data->dst;
 12.1124 +        int n = data->dst_w;
 12.1125 +        srcx = -1;
 12.1126 +        posx = 0x10000L;
 12.1127 +        while (posy >= 0x10000L) {
 12.1128 +            ++srcy;
 12.1129 +            posy -= 0x10000L;
 12.1130 +        }
 12.1131 +        while (n--) {
 12.1132 +            if (posx >= 0x10000L) {
 12.1133 +                while (posx >= 0x10000L) {
 12.1134 +                    ++srcx;
 12.1135 +                    posx -= 0x10000L;
 12.1136 +                }
 12.1137 +                src = (Uint32 *)(data->src + (srcy * data->src_pitch) + (srcx * 4));
 12.1138 +            }
 12.1139 +            srcpixel = *src;
 12.1140 +            srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = 0xFF;
 12.1141 +            dstpixel = *dst;
 12.1142 +            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
 12.1143 +            if (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD)) {
 12.1144 +                /* This goes away if we ever use premultiplied alpha */
 12.1145 +                srcR = (srcR * srcA) / 255;
 12.1146 +                srcG = (srcG * srcA) / 255;
 12.1147 +                srcB = (srcB * srcA) / 255;
 12.1148 +            }
 12.1149 +            switch (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD|SDL_RENDERCOPY_MOD)) {
 12.1150 +            case SDL_RENDERCOPY_BLEND:
 12.1151 +                dstR = srcR + ((255 - srcA) * dstR) / 255;
 12.1152 +                dstG = srcG + ((255 - srcA) * dstG) / 255;
 12.1153 +                dstB = srcB + ((255 - srcA) * dstB) / 255;
 12.1154 +                break;
 12.1155 +            case SDL_RENDERCOPY_ADD:
 12.1156 +                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
 12.1157 +                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
 12.1158 +                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
 12.1159 +                break;
 12.1160 +            case SDL_RENDERCOPY_MOD:
 12.1161 +                dstR = (srcR * dstR) / 255;
 12.1162 +                dstG = (srcG * dstG) / 255;
 12.1163 +                dstB = (srcB * dstB) / 255;
 12.1164 +                break;
 12.1165 +            }
 12.1166 +            dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
 12.1167 +            *dst = dstpixel;
 12.1168 +            posx += incx;
 12.1169 +            ++dst;
 12.1170 +        }
 12.1171 +        posy += incy;
 12.1172 +        data->dst += data->dst_pitch;
 12.1173 +    }
 12.1174 +    return 0;
 12.1175 +}
 12.1176 +
 12.1177 +int SDL_RenderCopy_BGR888_RGB888_Modulate(SDL_RenderCopyData *data)
 12.1178 +{
 12.1179 +    const int flags = data->flags;
 12.1180 +    const Uint32 modulateR = data->r;
 12.1181 +    const Uint32 modulateG = data->g;
 12.1182 +    const Uint32 modulateB = data->b;
 12.1183 +    const Uint32 modulateA = data->a;
 12.1184 +    Uint32 pixel;
 12.1185 +    Uint32 R, G, B, A;
 12.1186 +
 12.1187 +    while (data->dst_h--) {
 12.1188 +        Uint32 *src = (Uint32 *)data->src;
 12.1189 +        Uint32 *dst = (Uint32 *)data->dst;
 12.1190 +        int n = data->dst_w;
 12.1191 +        while (n--) {
 12.1192 +            pixel = *src;
 12.1193 +            B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; A = 0xFF;
 12.1194 +            if (flags & SDL_RENDERCOPY_MODULATE_COLOR) {
 12.1195 +                R = (R * modulateR) / 255;
 12.1196 +                G = (G * modulateG) / 255;
 12.1197 +                B = (B * modulateB) / 255;
 12.1198 +            }
 12.1199 +            pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B;
 12.1200 +            *dst = pixel;
 12.1201 +            ++src;
 12.1202 +            ++dst;
 12.1203 +        }
 12.1204 +        data->src += data->src_pitch;
 12.1205 +        data->dst += data->dst_pitch;
 12.1206 +    }
 12.1207 +    return 0;
 12.1208 +}
 12.1209 +
 12.1210 +int SDL_RenderCopy_BGR888_RGB888_Modulate_Scale(SDL_RenderCopyData *data)
 12.1211 +{
 12.1212 +    const int flags = data->flags;
 12.1213 +    const Uint32 modulateR = data->r;
 12.1214 +    const Uint32 modulateG = data->g;
 12.1215 +    const Uint32 modulateB = data->b;
 12.1216 +    const Uint32 modulateA = data->a;
 12.1217 +    Uint32 pixel;
 12.1218 +    Uint32 R, G, B, A;
 12.1219 +    int srcy, srcx;
 12.1220 +    int posy, posx;
 12.1221 +    int incy, incx;
 12.1222 +
 12.1223 +    srcy = 0;
 12.1224 +    posy = 0;
 12.1225 +    incy = (data->src_h << 16) / data->dst_h;
 12.1226 +    incx = (data->src_w << 16) / data->dst_w;
 12.1227 +
 12.1228 +    while (data->dst_h--) {
 12.1229 +        Uint32 *src;
 12.1230 +        Uint32 *dst = (Uint32 *)data->dst;
 12.1231 +        int n = data->dst_w;
 12.1232 +        srcx = -1;
 12.1233 +        posx = 0x10000L;
 12.1234 +        while (posy >= 0x10000L) {
 12.1235 +            ++srcy;
 12.1236 +            posy -= 0x10000L;
 12.1237 +        }
 12.1238 +        while (n--) {
 12.1239 +            if (posx >= 0x10000L) {
 12.1240 +                while (posx >= 0x10000L) {
 12.1241 +                    ++srcx;
 12.1242 +                    posx -= 0x10000L;
 12.1243 +                }
 12.1244 +                src = (Uint32 *)(data->src + (srcy * data->src_pitch) + (srcx * 4));
 12.1245 +            }
 12.1246 +            pixel = *src;
 12.1247 +            B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; A = 0xFF;
 12.1248 +            if (flags & SDL_RENDERCOPY_MODULATE_COLOR) {
 12.1249 +                R = (R * modulateR) / 255;
 12.1250 +                G = (G * modulateG) / 255;
 12.1251 +                B = (B * modulateB) / 255;
 12.1252 +            }
 12.1253 +            pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B;
 12.1254 +            *dst = pixel;
 12.1255 +            posx += incx;
 12.1256 +            ++dst;
 12.1257 +        }
 12.1258 +        posy += incy;
 12.1259 +        data->dst += data->dst_pitch;
 12.1260 +    }
 12.1261 +    return 0;
 12.1262 +}
 12.1263 +
 12.1264 +int SDL_RenderCopy_BGR888_RGB888_Modulate_Blend(SDL_RenderCopyData *data)
 12.1265 +{
 12.1266 +    const int flags = data->flags;
 12.1267 +    const Uint32 modulateR = data->r;
 12.1268 +    const Uint32 modulateG = data->g;
 12.1269 +    const Uint32 modulateB = data->b;
 12.1270 +    const Uint32 modulateA = data->a;
 12.1271 +    Uint32 srcpixel;
 12.1272 +    Uint32 srcR, srcG, srcB, srcA;
 12.1273 +    Uint32 dstpixel;
 12.1274 +    Uint32 dstR, dstG, dstB, dstA;
 12.1275 +
 12.1276 +    while (data->dst_h--) {
 12.1277 +        Uint32 *src = (Uint32 *)data->src;
 12.1278 +        Uint32 *dst = (Uint32 *)data->dst;
 12.1279 +        int n = data->dst_w;
 12.1280 +        while (n--) {
 12.1281 +            srcpixel = *src;
 12.1282 +            srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = 0xFF;
 12.1283 +            dstpixel = *dst;
 12.1284 +            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
 12.1285 +            if (flags & SDL_RENDERCOPY_MODULATE_COLOR) {
 12.1286 +                srcR = (srcR * modulateR) / 255;
 12.1287 +                srcG = (srcG * modulateG) / 255;
 12.1288 +                srcB = (srcB * modulateB) / 255;
 12.1289 +            }
 12.1290 +            if (flags & SDL_RENDERCOPY_MODULATE_ALPHA) {
 12.1291 +                srcA = (srcA * modulateA) / 255;
 12.1292 +            }
 12.1293 +            if (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD)) {
 12.1294 +                /* This goes away if we ever use premultiplied alpha */
 12.1295 +                srcR = (srcR * srcA) / 255;
 12.1296 +                srcG = (srcG * srcA) / 255;
 12.1297 +                srcB = (srcB * srcA) / 255;
 12.1298 +            }
 12.1299 +            switch (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD|SDL_RENDERCOPY_MOD)) {
 12.1300 +            case SDL_RENDERCOPY_BLEND:
 12.1301 +                dstR = srcR + ((255 - srcA) * dstR) / 255;
 12.1302 +                dstG = srcG + ((255 - srcA) * dstG) / 255;
 12.1303 +                dstB = srcB + ((255 - srcA) * dstB) / 255;
 12.1304 +                break;
 12.1305 +            case SDL_RENDERCOPY_ADD:
 12.1306 +                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
 12.1307 +                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
 12.1308 +                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
 12.1309 +                break;
 12.1310 +            case SDL_RENDERCOPY_MOD:
 12.1311 +                dstR = (srcR * dstR) / 255;
 12.1312 +                dstG = (srcG * dstG) / 255;
 12.1313 +                dstB = (srcB * dstB) / 255;
 12.1314 +                break;
 12.1315 +            }
 12.1316 +            dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
 12.1317 +            *dst = dstpixel;
 12.1318 +            ++src;
 12.1319 +            ++dst;
 12.1320 +        }
 12.1321 +        data->src += data->src_pitch;
 12.1322 +        data->dst += data->dst_pitch;
 12.1323 +    }
 12.1324 +    return 0;
 12.1325 +}
 12.1326 +
 12.1327 +int SDL_RenderCopy_BGR888_RGB888_Modulate_Blend_Scale(SDL_RenderCopyData *data)
 12.1328 +{
 12.1329 +    const int flags = data->flags;
 12.1330 +    const Uint32 modulateR = data->r;
 12.1331 +    const Uint32 modulateG = data->g;
 12.1332 +    const Uint32 modulateB = data->b;
 12.1333 +    const Uint32 modulateA = data->a;
 12.1334 +    Uint32 srcpixel;
 12.1335 +    Uint32 srcR, srcG, srcB, srcA;
 12.1336 +    Uint32 dstpixel;
 12.1337 +    Uint32 dstR, dstG, dstB, dstA;
 12.1338 +    int srcy, srcx;
 12.1339 +    int posy, posx;
 12.1340 +    int incy, incx;
 12.1341 +
 12.1342 +    srcy = 0;
 12.1343 +    posy = 0;
 12.1344 +    incy = (data->src_h << 16) / data->dst_h;
 12.1345 +    incx = (data->src_w << 16) / data->dst_w;
 12.1346 +
 12.1347 +    while (data->dst_h--) {
 12.1348 +        Uint32 *src;
 12.1349 +        Uint32 *dst = (Uint32 *)data->dst;
 12.1350 +        int n = data->dst_w;
 12.1351 +        srcx = -1;
 12.1352 +        posx = 0x10000L;
 12.1353 +        while (posy >= 0x10000L) {
 12.1354 +            ++srcy;
 12.1355 +            posy -= 0x10000L;
 12.1356 +        }
 12.1357 +        while (n--) {
 12.1358 +            if (posx >= 0x10000L) {
 12.1359 +                while (posx >= 0x10000L) {
 12.1360 +                    ++srcx;
 12.1361 +                    posx -= 0x10000L;
 12.1362 +                }
 12.1363 +                src = (Uint32 *)(data->src + (srcy * data->src_pitch) + (srcx * 4));
 12.1364 +            }
 12.1365 +            srcpixel = *src;
 12.1366 +            srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = 0xFF;
 12.1367 +            dstpixel = *dst;
 12.1368 +            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
 12.1369 +            if (flags & SDL_RENDERCOPY_MODULATE_COLOR) {
 12.1370 +                srcR = (srcR * modulateR) / 255;
 12.1371 +                srcG = (srcG * modulateG) / 255;
 12.1372 +                srcB = (srcB * modulateB) / 255;
 12.1373 +            }
 12.1374 +            if (flags & SDL_RENDERCOPY_MODULATE_ALPHA) {
 12.1375 +                srcA = (srcA * modulateA) / 255;
 12.1376 +            }
 12.1377 +            if (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD)) {
 12.1378 +                /* This goes away if we ever use premultiplied alpha */
 12.1379 +                srcR = (srcR * srcA) / 255;
 12.1380 +                srcG = (srcG * srcA) / 255;
 12.1381 +                srcB = (srcB * srcA) / 255;
 12.1382 +            }
 12.1383 +            switch (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD|SDL_RENDERCOPY_MOD)) {
 12.1384 +            case SDL_RENDERCOPY_BLEND:
 12.1385 +                dstR = srcR + ((255 - srcA) * dstR) / 255;
 12.1386 +                dstG = srcG + ((255 - srcA) * dstG) / 255;
 12.1387 +                dstB = srcB + ((255 - srcA) * dstB) / 255;
 12.1388 +                break;
 12.1389 +            case SDL_RENDERCOPY_ADD:
 12.1390 +                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
 12.1391 +                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
 12.1392 +                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
 12.1393 +                break;
 12.1394 +            case SDL_RENDERCOPY_MOD:
 12.1395 +                dstR = (srcR * dstR) / 255;
 12.1396 +                dstG = (srcG * dstG) / 255;
 12.1397 +                dstB = (srcB * dstB) / 255;
 12.1398 +                break;
 12.1399 +            }
 12.1400 +            dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
 12.1401 +            *dst = dstpixel;
 12.1402 +            posx += incx;
 12.1403 +            ++dst;
 12.1404 +        }
 12.1405 +        posy += incy;
 12.1406 +        data->dst += data->dst_pitch;
 12.1407 +    }
 12.1408 +    return 0;
 12.1409 +}
 12.1410 +
 12.1411 +int SDL_RenderCopy_BGR888_BGR888_Scale(SDL_RenderCopyData *data)
 12.1412 +{
 12.1413 +    const int flags = data->flags;
 12.1414 +    int srcy, srcx;
 12.1415 +    int posy, posx;
 12.1416 +    int incy, incx;
 12.1417 +
 12.1418 +    srcy = 0;
 12.1419 +    posy = 0;
 12.1420 +    incy = (data->src_h << 16) / data->dst_h;
 12.1421 +    incx = (data->src_w << 16) / data->dst_w;
 12.1422 +
 12.1423 +    while (data->dst_h--) {
 12.1424 +        Uint32 *src;
 12.1425 +        Uint32 *dst = (Uint32 *)data->dst;
 12.1426 +        int n = data->dst_w;
 12.1427 +        srcx = -1;
 12.1428 +        posx = 0x10000L;
 12.1429 +        while (posy >= 0x10000L) {
 12.1430 +            ++srcy;
 12.1431 +            posy -= 0x10000L;
 12.1432 +        }
 12.1433 +        while (n--) {
 12.1434 +            if (posx >= 0x10000L) {
 12.1435 +                while (posx >= 0x10000L) {
 12.1436 +                    ++srcx;
 12.1437 +                    posx -= 0x10000L;
 12.1438 +                }
 12.1439 +                src = (Uint32 *)(data->src + (srcy * data->src_pitch) + (srcx * 4));
 12.1440 +            }
 12.1441 +            *dst = *src;
 12.1442 +            posx += incx;
 12.1443 +            ++dst;
 12.1444 +        }
 12.1445 +        posy += incy;
 12.1446 +        data->dst += data->dst_pitch;
 12.1447 +    }
 12.1448 +    return 0;
 12.1449 +}
 12.1450 +
 12.1451 +int SDL_RenderCopy_BGR888_BGR888_Blend(SDL_RenderCopyData *data)
 12.1452 +{
 12.1453 +    const int flags = data->flags;
 12.1454 +    Uint32 srcpixel;
 12.1455 +    Uint32 srcR, srcG, srcB, srcA;
 12.1456 +    Uint32 dstpixel;
 12.1457 +    Uint32 dstR, dstG, dstB, dstA;
 12.1458 +
 12.1459 +    while (data->dst_h--) {
 12.1460 +        Uint32 *src = (Uint32 *)data->src;
 12.1461 +        Uint32 *dst = (Uint32 *)data->dst;
 12.1462 +        int n = data->dst_w;
 12.1463 +        while (n--) {
 12.1464 +            srcpixel = *src;
 12.1465 +            srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = 0xFF;
 12.1466 +            dstpixel = *dst;
 12.1467 +            dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
 12.1468 +            if (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD)) {
 12.1469 +                /* This goes away if we ever use premultiplied alpha */
 12.1470 +                srcR = (srcR * srcA) / 255;
 12.1471 +                srcG = (srcG * srcA) / 255;
 12.1472 +                srcB = (srcB * srcA) / 255;
 12.1473 +            }
 12.1474 +            switch (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD|SDL_RENDERCOPY_MOD)) {
 12.1475 +            case SDL_RENDERCOPY_BLEND:
 12.1476 +                dstR = srcR + ((255 - srcA) * dstR) / 255;
 12.1477 +                dstG = srcG + ((255 - srcA) * dstG) / 255;
 12.1478 +                dstB = srcB + ((255 - srcA) * dstB) / 255;
 12.1479 +                break;
 12.1480 +            case SDL_RENDERCOPY_ADD:
 12.1481 +                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
 12.1482 +                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
 12.1483 +                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
 12.1484 +                break;
 12.1485 +            case SDL_RENDERCOPY_MOD:
 12.1486 +                dstR = (srcR * dstR) / 255;
 12.1487 +                dstG = (srcG * dstG) / 255;
 12.1488 +                dstB = (srcB * dstB) / 255;
 12.1489 +                break;
 12.1490 +            }
 12.1491 +            dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
 12.1492 +            *dst = dstpixel;
 12.1493 +            ++src;
 12.1494 +            ++dst;
 12.1495 +        }
 12.1496 +        data->src += data->src_pitch;
 12.1497 +        data->dst += data->dst_pitch;
 12.1498 +    }
 12.1499 +    return 0;
 12.1500 +}
 12.1501 +
 12.1502 +int SDL_RenderCopy_BGR888_BGR888_Blend_Scale(SDL_RenderCopyData *data)
 12.1503 +{
 12.1504 +    const int flags = data->flags;
 12.1505 +    Uint32 srcpixel;
 12.1506 +    Uint32 srcR, srcG, srcB, srcA;
 12.1507 +    Uint32 dstpixel;
 12.1508 +    Uint32 dstR, dstG, dstB, dstA;
 12.1509 +    int srcy, srcx;
 12.1510 +    int posy, posx;
 12.1511 +    int incy, incx;
 12.1512 +
 12.1513 +    srcy = 0;
 12.1514 +    posy = 0;
 12.1515 +    incy = (data->src_h << 16) / data->dst_h;
 12.1516 +    incx = (data->src_w << 16) / data->dst_w;
 12.1517 +
 12.1518 +    while (data->dst_h--) {
 12.1519 +        Uint32 *src;
 12.1520 +        Uint32 *dst = (Uint32 *)data->dst;
 12.1521 +        int n = data->dst_w;
 12.1522 +        srcx = -1;
 12.1523 +        posx = 0x10000L;
 12.1524 +        while (posy >= 0x10000L) {
 12.1525 +            ++srcy;
 12.1526 +            posy -= 0x10000L;
 12.1527 +        }
 12.1528 +        while (n--) {
 12.1529 +            if (posx >= 0x10000L) {
 12.1530 +                while (posx >= 0x10000L) {
 12.1531 +                    ++srcx;
 12.1532 +                    posx -= 0x10000L;
 12.1533 +                }
 12.1534 +                src = (Uint32 *)(data->src + (srcy * data->src_pitch) + (srcx * 4));
 12.1535 +            }
 12.1536 +            srcpixel = *src;
 12.1537 +            srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = 0xFF;
 12.1538 +            dstpixel = *dst;
 12.1539 +            dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
 12.1540 +            if (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD)) {
 12.1541 +                /* This goes away if we ever use premultiplied alpha */
 12.1542 +                srcR = (srcR * srcA) / 255;
 12.1543 +                srcG = (srcG * srcA) / 255;
 12.1544 +                srcB = (srcB * srcA) / 255;
 12.1545 +            }
 12.1546 +            switch (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD|SDL_RENDERCOPY_MOD)) {
 12.1547 +            case SDL_RENDERCOPY_BLEND:
 12.1548 +                dstR = srcR + ((255 - srcA) * dstR) / 255;
 12.1549 +                dstG = srcG + ((255 - srcA) * dstG) / 255;
 12.1550 +                dstB = srcB + ((255 - srcA) * dstB) / 255;
 12.1551 +                break;
 12.1552 +            case SDL_RENDERCOPY_ADD:
 12.1553 +                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
 12.1554 +                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
 12.1555 +                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
 12.1556 +                break;
 12.1557 +            case SDL_RENDERCOPY_MOD:
 12.1558 +                dstR = (srcR * dstR) / 255;
 12.1559 +                dstG = (srcG * dstG) / 255;
 12.1560 +                dstB = (srcB * dstB) / 255;
 12.1561 +                break;
 12.1562 +            }
 12.1563 +            dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
 12.1564 +            *dst = dstpixel;
 12.1565 +            posx += incx;
 12.1566 +            ++dst;
 12.1567 +        }
 12.1568 +        posy += incy;
 12.1569 +        data->dst += data->dst_pitch;
 12.1570 +    }
 12.1571 +    return 0;
 12.1572 +}
 12.1573 +
 12.1574 +int SDL_RenderCopy_BGR888_BGR888_Modulate(SDL_RenderCopyData *data)
 12.1575 +{
 12.1576 +    const int flags = data->flags;
 12.1577 +    const Uint32 modulateR = data->r;
 12.1578 +    const Uint32 modulateG = data->g;
 12.1579 +    const Uint32 modulateB = data->b;
 12.1580 +    const Uint32 modulateA = data->a;
 12.1581 +    Uint32 pixel;
 12.1582 +    Uint32 R, G, B, A;
 12.1583 +
 12.1584 +    while (data->dst_h--) {
 12.1585 +        Uint32 *src = (Uint32 *)data->src;
 12.1586 +        Uint32 *dst = (Uint32 *)data->dst;
 12.1587 +        int n = data->dst_w;
 12.1588 +        while (n--) {
 12.1589 +            pixel = *src;
 12.1590 +            B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; A = 0xFF;
 12.1591 +            if (flags & SDL_RENDERCOPY_MODULATE_COLOR) {
 12.1592 +                R = (R * modulateR) / 255;
 12.1593 +                G = (G * modulateG) / 255;
 12.1594 +                B = (B * modulateB) / 255;
 12.1595 +            }
 12.1596 +            pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R;
 12.1597 +            *dst = pixel;
 12.1598 +            ++src;
 12.1599 +            ++dst;
 12.1600 +        }
 12.1601 +        data->src += data->src_pitch;
 12.1602 +        data->dst += data->dst_pitch;
 12.1603 +    }
 12.1604 +    return 0;
 12.1605 +}
 12.1606 +
 12.1607 +int SDL_RenderCopy_BGR888_BGR888_Modulate_Scale(SDL_RenderCopyData *data)
 12.1608 +{
 12.1609 +    const int flags = data->flags;
 12.1610 +    const Uint32 modulateR = data->r;
 12.1611 +    const Uint32 modulateG = data->g;
 12.1612 +    const Uint32 modulateB = data->b;
 12.1613 +    const Uint32 modulateA = data->a;
 12.1614 +    Uint32 pixel;
 12.1615 +    Uint32 R, G, B, A;
 12.1616 +    int srcy, srcx;
 12.1617 +    int posy, posx;
 12.1618 +    int incy, incx;
 12.1619 +
 12.1620 +    srcy = 0;
 12.1621 +    posy = 0;
 12.1622 +    incy = (data->src_h << 16) / data->dst_h;
 12.1623 +    incx = (data->src_w << 16) / data->dst_w;
 12.1624 +
 12.1625 +    while (data->dst_h--) {
 12.1626 +        Uint32 *src;
 12.1627 +        Uint32 *dst = (Uint32 *)data->dst;
 12.1628 +        int n = data->dst_w;
 12.1629 +        srcx = -1;
 12.1630 +        posx = 0x10000L;
 12.1631 +        while (posy >= 0x10000L) {
 12.1632 +            ++srcy;
 12.1633 +            posy -= 0x10000L;
 12.1634 +        }
 12.1635 +        while (n--) {
 12.1636 +            if (posx >= 0x10000L) {
 12.1637 +                while (posx >= 0x10000L) {
 12.1638 +                    ++srcx;
 12.1639 +                    posx -= 0x10000L;
 12.1640 +                }
 12.1641 +                src = (Uint32 *)(data->src + (srcy * data->src_pitch) + (srcx * 4));
 12.1642 +            }
 12.1643 +            pixel = *src;
 12.1644 +            B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; A = 0xFF;
 12.1645 +            if (flags & SDL_RENDERCOPY_MODULATE_COLOR) {
 12.1646 +                R = (R * modulateR) / 255;
 12.1647 +                G = (G * modulateG) / 255;
 12.1648 +                B = (B * modulateB) / 255;
 12.1649 +            }
 12.1650 +            pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R;
 12.1651 +            *dst = pixel;
 12.1652 +            posx += incx;
 12.1653 +            ++dst;
 12.1654 +        }
 12.1655 +        posy += incy;
 12.1656 +        data->dst += data->dst_pitch;
 12.1657 +    }
 12.1658 +    return 0;
 12.1659 +}
 12.1660 +
 12.1661 +int SDL_RenderCopy_BGR888_BGR888_Modulate_Blend(SDL_RenderCopyData *data)
 12.1662 +{
 12.1663 +    const int flags = data->flags;
 12.1664 +    const Uint32 modulateR = data->r;
 12.1665 +    const Uint32 modulateG = data->g;
 12.1666 +    const Uint32 modulateB = data->b;
 12.1667 +    const Uint32 modulateA = data->a;
 12.1668 +    Uint32 srcpixel;
 12.1669 +    Uint32 srcR, srcG, srcB, srcA;
 12.1670 +    Uint32 dstpixel;
 12.1671 +    Uint32 dstR, dstG, dstB, dstA;
 12.1672 +
 12.1673 +    while (data->dst_h--) {
 12.1674 +        Uint32 *src = (Uint32 *)data->src;
 12.1675 +        Uint32 *dst = (Uint32 *)data->dst;
 12.1676 +        int n = data->dst_w;
 12.1677 +        while (n--) {
 12.1678 +            srcpixel = *src;
 12.1679 +            srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = 0xFF;
 12.1680 +            dstpixel = *dst;
 12.1681 +            dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
 12.1682 +            if (flags & SDL_RENDERCOPY_MODULATE_COLOR) {
 12.1683 +                srcR = (srcR * modulateR) / 255;
 12.1684 +                srcG = (srcG * modulateG) / 255;
 12.1685 +                srcB = (srcB * modulateB) / 255;
 12.1686 +            }
 12.1687 +            if (flags & SDL_RENDERCOPY_MODULATE_ALPHA) {
 12.1688 +                srcA = (srcA * modulateA) / 255;
 12.1689 +            }
 12.1690 +            if (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD)) {
 12.1691 +                /* This goes away if we ever use premultiplied alpha */
 12.1692 +                srcR = (srcR * srcA) / 255;
 12.1693 +                srcG = (srcG * srcA) / 255;
 12.1694 +                srcB = (srcB * srcA) / 255;
 12.1695 +            }
 12.1696 +            switch (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD|SDL_RENDERCOPY_MOD)) {
 12.1697 +            case SDL_RENDERCOPY_BLEND:
 12.1698 +                dstR = srcR + ((255 - srcA) * dstR) / 255;
 12.1699 +                dstG = srcG + ((255 - srcA) * dstG) / 255;
 12.1700 +                dstB = srcB + ((255 - srcA) * dstB) / 255;
 12.1701 +                break;
 12.1702 +            case SDL_RENDERCOPY_ADD:
 12.1703 +                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
 12.1704 +                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
 12.1705 +                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
 12.1706 +                break;
 12.1707 +            case SDL_RENDERCOPY_MOD:
 12.1708 +                dstR = (srcR * dstR) / 255;
 12.1709 +                dstG = (srcG * dstG) / 255;
 12.1710 +                dstB = (srcB * dstB) / 255;
 12.1711 +                break;
 12.1712 +            }
 12.1713 +            dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
 12.1714 +            *dst = dstpixel;
 12.1715 +            ++src;
 12.1716 +            ++dst;
 12.1717 +        }
 12.1718 +        data->src += data->src_pitch;
 12.1719 +        data->dst += data->dst_pitch;
 12.1720 +    }
 12.1721 +    return 0;
 12.1722 +}
 12.1723 +
 12.1724 +int SDL_RenderCopy_BGR888_BGR888_Modulate_Blend_Scale(SDL_RenderCopyData *data)
 12.1725 +{
 12.1726 +    const int flags = data->flags;
 12.1727 +    const Uint32 modulateR = data->r;
 12.1728 +    const Uint32 modulateG = data->g;
 12.1729 +    const Uint32 modulateB = data->b;
 12.1730 +    const Uint32 modulateA = data->a;
 12.1731 +    Uint32 srcpixel;
 12.1732 +    Uint32 srcR, srcG, srcB, srcA;
 12.1733 +    Uint32 dstpixel;
 12.1734 +    Uint32 dstR, dstG, dstB, dstA;
 12.1735 +    int srcy, srcx;
 12.1736 +    int posy, posx;
 12.1737 +    int incy, incx;
 12.1738 +
 12.1739 +    srcy = 0;
 12.1740 +    posy = 0;
 12.1741 +    incy = (data->src_h << 16) / data->dst_h;
 12.1742 +    incx = (data->src_w << 16) / data->dst_w;
 12.1743 +
 12.1744 +    while (data->dst_h--) {
 12.1745 +        Uint32 *src;
 12.1746 +        Uint32 *dst = (Uint32 *)data->dst;
 12.1747 +        int n = data->dst_w;
 12.1748 +        srcx = -1;
 12.1749 +        posx = 0x10000L;
 12.1750 +        while (posy >= 0x10000L) {
 12.1751 +            ++srcy;
 12.1752 +            posy -= 0x10000L;
 12.1753 +        }
 12.1754 +        while (n--) {
 12.1755 +            if (posx >= 0x10000L) {
 12.1756 +                while (posx >= 0x10000L) {
 12.1757 +                    ++srcx;
 12.1758 +                    posx -= 0x10000L;
 12.1759 +                }
 12.1760 +                src = (Uint32 *)(data->src + (srcy * data->src_pitch) + (srcx * 4));
 12.1761 +            }
 12.1762 +            srcpixel = *src;
 12.1763 +            srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = 0xFF;
 12.1764 +            dstpixel = *dst;
 12.1765 +            dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
 12.1766 +            if (flags & SDL_RENDERCOPY_MODULATE_COLOR) {
 12.1767 +                srcR = (srcR * modulateR) / 255;
 12.1768 +                srcG = (srcG * modulateG) / 255;
 12.1769 +                srcB = (srcB * modulateB) / 255;
 12.1770 +            }
 12.1771 +            if (flags & SDL_RENDERCOPY_MODULATE_ALPHA) {
 12.1772 +                srcA = (srcA * modulateA) / 255;
 12.1773 +            }
 12.1774 +            if (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD)) {
 12.1775 +                /* This goes away if we ever use premultiplied alpha */
 12.1776 +                srcR = (srcR * srcA) / 255;
 12.1777 +                srcG = (srcG * srcA) / 255;
 12.1778 +                srcB = (srcB * srcA) / 255;
 12.1779 +            }
 12.1780 +            switch (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD|SDL_RENDERCOPY_MOD)) {
 12.1781 +            case SDL_RENDERCOPY_BLEND:
 12.1782 +                dstR = srcR + ((255 - srcA) * dstR) / 255;
 12.1783 +                dstG = srcG + ((255 - srcA) * dstG) / 255;
 12.1784 +                dstB = srcB + ((255 - srcA) * dstB) / 255;
 12.1785 +                break;
 12.1786 +            case SDL_RENDERCOPY_ADD:
 12.1787 +                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
 12.1788 +                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
 12.1789 +                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
 12.1790 +                break;
 12.1791 +            case SDL_RENDERCOPY_MOD:
 12.1792 +                dstR = (srcR * dstR) / 255;
 12.1793 +                dstG = (srcG * dstG) / 255;
 12.1794 +                dstB = (srcB * dstB) / 255;
 12.1795 +                break;
 12.1796 +            }
 12.1797 +            dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
 12.1798 +            *dst = dstpixel;
 12.1799 +            posx += incx;
 12.1800 +            ++dst;
 12.1801 +        }
 12.1802 +        posy += incy;
 12.1803 +        data->dst += data->dst_pitch;
 12.1804 +    }
 12.1805 +    return 0;
 12.1806 +}
 12.1807 +
 12.1808 +int SDL_RenderCopy_ARGB8888_RGB888(SDL_RenderCopyData *data)
 12.1809 +{
 12.1810 +    const int flags = data->flags;
 12.1811 +    Uint32 pixel;
 12.1812 +    Uint32 R, G, B, A;
 12.1813 +
 12.1814 +    while (data->dst_h--) {
 12.1815 +        Uint32 *src = (Uint32 *)data->src;
 12.1816 +        Uint32 *dst = (Uint32 *)data->dst;
 12.1817 +        int n = data->dst_w;
 12.1818 +        while (n--) {
 12.1819 +            pixel = *src;
 12.1820 +            A = (Uint8)(pixel >> 24); R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel;
 12.1821 +            pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B;
 12.1822 +            *dst = pixel;
 12.1823 +            ++src;
 12.1824 +            ++dst;
 12.1825 +        }
 12.1826 +        data->src += data->src_pitch;
 12.1827 +        data->dst += data->dst_pitch;
 12.1828 +    }
 12.1829 +    return 0;
 12.1830 +}
 12.1831 +
 12.1832 +int SDL_RenderCopy_ARGB8888_RGB888_Scale(SDL_RenderCopyData *data)
 12.1833 +{
 12.1834 +    const int flags = data->flags;
 12.1835 +    Uint32 pixel;
 12.1836 +    Uint32 R, G, B, A;
 12.1837 +    int srcy, srcx;
 12.1838 +    int posy, posx;
 12.1839 +    int incy, incx;
 12.1840 +
 12.1841 +    srcy = 0;
 12.1842 +    posy = 0;
 12.1843 +    incy = (data->src_h << 16) / data->dst_h;
 12.1844 +    incx = (data->src_w << 16) / data->dst_w;
 12.1845 +
 12.1846 +    while (data->dst_h--) {
 12.1847 +        Uint32 *src;
 12.1848 +        Uint32 *dst = (Uint32 *)data->dst;
 12.1849 +        int n = data->dst_w;
 12.1850 +        srcx = -1;
 12.1851 +        posx = 0x10000L;
 12.1852 +        while (posy >= 0x10000L) {
 12.1853 +            ++srcy;
 12.1854 +            posy -= 0x10000L;
 12.1855 +        }
 12.1856 +        while (n--) {
 12.1857 +            if (posx >= 0x10000L) {
 12.1858 +                while (posx >= 0x10000L) {
 12.1859 +                    ++srcx;
 12.1860 +                    posx -= 0x10000L;
 12.1861 +                }
 12.1862 +                src = (Uint32 *)(data->src + (srcy * data->src_pitch) + (srcx * 4));
 12.1863 +            }
 12.1864 +            pixel = *src;
 12.1865 +            A = (Uint8)(pixel >> 24); R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel;
 12.1866 +            pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B;
 12.1867 +            *dst = pixel;
 12.1868 +            posx += incx;
 12.1869 +            ++dst;
 12.1870 +        }
 12.1871 +        posy += incy;
 12.1872 +        data->dst += data->dst_pitch;
 12.1873 +    }
 12.1874 +    return 0;
 12.1875 +}
 12.1876 +
 12.1877 +int SDL_RenderCopy_ARGB8888_RGB888_Blend(SDL_RenderCopyData *data)
 12.1878 +{
 12.1879 +    const int flags = data->flags;
 12.1880 +    Uint32 srcpixel;
 12.1881 +    Uint32 srcR, srcG, srcB, srcA;
 12.1882 +    Uint32 dstpixel;
 12.1883 +    Uint32 dstR, dstG, dstB, dstA;
 12.1884 +
 12.1885 +    while (data->dst_h--) {
 12.1886 +        Uint32 *src = (Uint32 *)data->src;
 12.1887 +        Uint32 *dst = (Uint32 *)data->dst;
 12.1888 +        int n = data->dst_w;
 12.1889 +        while (n--) {
 12.1890 +            srcpixel = *src;
 12.1891 +            srcA = (Uint8)(srcpixel >> 24); srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel;
 12.1892 +            dstpixel = *dst;
 12.1893 +            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
 12.1894 +            if (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD)) {
 12.1895 +                /* This goes away if we ever use premultiplied alpha */
 12.1896 +                srcR = (srcR * srcA) / 255;
 12.1897 +                srcG = (srcG * srcA) / 255;
 12.1898 +                srcB = (srcB * srcA) / 255;
 12.1899 +            }
 12.1900 +            switch (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD|SDL_RENDERCOPY_MOD)) {
 12.1901 +            case SDL_RENDERCOPY_BLEND:
 12.1902 +                dstR = srcR + ((255 - srcA) * dstR) / 255;
 12.1903 +                dstG = srcG + ((255 - srcA) * dstG) / 255;
 12.1904 +                dstB = srcB + ((255 - srcA) * dstB) / 255;
 12.1905 +                break;
 12.1906 +            case SDL_RENDERCOPY_ADD:
 12.1907 +                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
 12.1908 +                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
 12.1909 +                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
 12.1910 +                break;
 12.1911 +            case SDL_RENDERCOPY_MOD:
 12.1912 +                dstR = (srcR * dstR) / 255;
 12.1913 +                dstG = (srcG * dstG) / 255;
 12.1914 +                dstB = (srcB * dstB) / 255;
 12.1915 +                break;
 12.1916 +            }
 12.1917 +            dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
 12.1918 +            *dst = dstpixel;
 12.1919 +            ++src;
 12.1920 +            ++dst;
 12.1921 +        }
 12.1922 +        data->src += data->src_pitch;
 12.1923 +        data->dst += data->dst_pitch;
 12.1924 +    }
 12.1925 +    return 0;
 12.1926 +}
 12.1927 +
 12.1928 +int SDL_RenderCopy_ARGB8888_RGB888_Blend_Scale(SDL_RenderCopyData *data)
 12.1929 +{
 12.1930 +    const int flags = data->flags;
 12.1931 +    Uint32 srcpixel;
 12.1932 +    Uint32 srcR, srcG, srcB, srcA;
 12.1933 +    Uint32 dstpixel;
 12.1934 +    Uint32 dstR, dstG, dstB, dstA;
 12.1935 +    int srcy, srcx;
 12.1936 +    int posy, posx;
 12.1937 +    int incy, incx;
 12.1938 +
 12.1939 +    srcy = 0;
 12.1940 +    posy = 0;
 12.1941 +    incy = (data->src_h << 16) / data->dst_h;
 12.1942 +    incx = (data->src_w << 16) / data->dst_w;
 12.1943 +
 12.1944 +    while (data->dst_h--) {
 12.1945 +        Uint32 *src;
 12.1946 +        Uint32 *dst = (Uint32 *)data->dst;
 12.1947 +        int n = data->dst_w;
 12.1948 +        srcx = -1;
 12.1949 +        posx = 0x10000L;
 12.1950 +        while (posy >= 0x10000L) {
 12.1951 +            ++srcy;
 12.1952 +            posy -= 0x10000L;
 12.1953 +        }
 12.1954 +        while (n--) {
 12.1955 +            if (posx >= 0x10000L) {
 12.1956 +                while (posx >= 0x10000L) {
 12.1957 +                    ++srcx;
 12.1958 +                    posx -= 0x10000L;
 12.1959 +                }
 12.1960 +                src = (Uint32 *)(data->src + (srcy * data->src_pitch) + (srcx * 4));
 12.1961 +            }
 12.1962 +            srcpixel = *src;
 12.1963 +            srcA = (Uint8)(srcpixel >> 24); srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel;
 12.1964 +            dstpixel = *dst;
 12.1965 +            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
 12.1966 +            if (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD)) {
 12.1967 +                /* This goes away if we ever use premultiplied alpha */
 12.1968 +                srcR = (srcR * srcA) / 255;
 12.1969 +                srcG = (srcG * srcA) / 255;
 12.1970 +                srcB = (srcB * srcA) / 255;
 12.1971 +            }
 12.1972 +            switch (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD|SDL_RENDERCOPY_MOD)) {
 12.1973 +            case SDL_RENDERCOPY_BLEND:
 12.1974 +                dstR = srcR + ((255 - srcA) * dstR) / 255;
 12.1975 +                dstG = srcG + ((255 - srcA) * dstG) / 255;
 12.1976 +                dstB = srcB + ((255 - srcA) * dstB) / 255;
 12.1977 +                break;
 12.1978 +            case SDL_RENDERCOPY_ADD:
 12.1979 +                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
 12.1980 +                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
 12.1981 +                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
 12.1982 +                break;
 12.1983 +            case SDL_RENDERCOPY_MOD:
 12.1984 +                dstR = (srcR * dstR) / 255;
 12.1985 +                dstG = (srcG * dstG) / 255;
 12.1986 +                dstB = (srcB * dstB) / 255;
 12.1987 +                break;
 12.1988 +            }
 12.1989 +            dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
 12.1990 +            *dst = dstpixel;
 12.1991 +            posx += incx;
 12.1992 +            ++dst;
 12.1993 +        }
 12.1994 +        posy += incy;
 12.1995 +        data->dst += data->dst_pitch;
 12.1996 +    }
 12.1997 +    return 0;
 12.1998 +}
 12.1999 +
 12.2000 +int SDL_RenderCopy_ARGB8888_RGB888_Modulate(SDL_RenderCopyData *data)
 12.2001 +{
 12.2002 +    const int flags = data->flags;
 12.2003 +    const Uint32 modulateR = data->r;
 12.2004 +    const Uint32 modulateG = data->g;
 12.2005 +    const Uint32 modulateB = data->b;
 12.2006 +    const Uint32 modulateA = data->a;
 12.2007 +    Uint32 pixel;
 12.2008 +    Uint32 R, G, B, A;
 12.2009 +
 12.2010 +    while (data->dst_h--) {
 12.2011 +        Uint32 *src = (Uint32 *)data->src;
 12.2012 +        Uint32 *dst = (Uint32 *)data->dst;
 12.2013 +        int n = data->dst_w;
 12.2014 +        while (n--) {
 12.2015 +            pixel = *src;
 12.2016 +            A = (Uint8)(pixel >> 24); R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel;
 12.2017 +            if (flags & SDL_RENDERCOPY_MODULATE_COLOR) {
 12.2018 +                R = (R * modulateR) / 255;
 12.2019 +                G = (G * modulateG) / 255;
 12.2020 +                B = (B * modulateB) / 255;
 12.2021 +            }
 12.2022 +            pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B;
 12.2023 +            *dst = pixel;
 12.2024 +            ++src;
 12.2025 +            ++dst;
 12.2026 +        }
 12.2027 +        data->src += data->src_pitch;
 12.2028 +        data->dst += data->dst_pitch;
 12.2029 +    }
 12.2030 +    return 0;
 12.2031 +}
 12.2032 +
 12.2033 +int SDL_RenderCopy_ARGB8888_RGB888_Modulate_Scale(SDL_RenderCopyData *data)
 12.2034 +{
 12.2035 +    const int flags = data->flags;
 12.2036 +    const Uint32 modulateR = data->r;
 12.2037 +    const Uint32 modulateG = data->g;
 12.2038 +    const Uint32 modulateB = data->b;
 12.2039 +    const Uint32 modulateA = data->a;
 12.2040 +    Uint32 pixel;
 12.2041 +    Uint32 R, G, B, A;
 12.2042 +    int srcy, srcx;
 12.2043 +    int posy, posx;
 12.2044 +    int incy, incx;
 12.2045 +
 12.2046 +    srcy = 0;
 12.2047 +    posy = 0;
 12.2048 +    incy = (data->src_h << 16) / data->dst_h;
 12.2049 +    incx = (data->src_w << 16) / data->dst_w;
 12.2050 +
 12.2051 +    while (data->dst_h--) {
 12.2052 +        Uint32 *src;
 12.2053 +        Uint32 *dst = (Uint32 *)data->dst;
 12.2054 +        int n = data->dst_w;
 12.2055 +        srcx = -1;
 12.2056 +        posx = 0x10000L;
 12.2057 +        while (posy >= 0x10000L) {
 12.2058 +            ++srcy;
 12.2059 +            posy -= 0x10000L;
 12.2060 +        }
 12.2061 +        while (n--) {
 12.2062 +            if (posx >= 0x10000L) {
 12.2063 +                while (posx >= 0x10000L) {
 12.2064 +                    ++srcx;
 12.2065 +                    posx -= 0x10000L;
 12.2066 +                }
 12.2067 +                src = (Uint32 *)(data->src + (srcy * data->src_pitch) + (srcx * 4));
 12.2068 +            }
 12.2069 +            pixel = *src;
 12.2070 +            A = (Uint8)(pixel >> 24); R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel;
 12.2071 +            if (flags & SDL_RENDERCOPY_MODULATE_COLOR) {
 12.2072 +                R = (R * modulateR) / 255;
 12.2073 +                G = (G * modulateG) / 255;
 12.2074 +                B = (B * modulateB) / 255;
 12.2075 +            }
 12.2076 +            pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B;
 12.2077 +            *dst = pixel;
 12.2078 +            posx += incx;
 12.2079 +            ++dst;
 12.2080 +        }
 12.2081 +        posy += incy;
 12.2082 +        data->dst += data->dst_pitch;
 12.2083 +    }
 12.2084 +    return 0;
 12.2085 +}
 12.2086 +
 12.2087 +int SDL_RenderCopy_ARGB8888_RGB888_Modulate_Blend(SDL_RenderCopyData *data)
 12.2088 +{
 12.2089 +    const int flags = data->flags;
 12.2090 +    const Uint32 modulateR = data->r;
 12.2091 +    const Uint32 modulateG = data->g;
 12.2092 +    const Uint32 modulateB = data->b;
 12.2093 +    const Uint32 modulateA = data->a;
 12.2094 +    Uint32 srcpixel;
 12.2095 +    Uint32 srcR, srcG, srcB, srcA;
 12.2096 +    Uint32 dstpixel;
 12.2097 +    Uint32 dstR, dstG, dstB, dstA;
 12.2098 +
 12.2099 +    while (data->dst_h--) {
 12.2100 +        Uint32 *src = (Uint32 *)data->src;
 12.2101 +        Uint32 *dst = (Uint32 *)data->dst;
 12.2102 +        int n = data->dst_w;
 12.2103 +        while (n--) {
 12.2104 +            srcpixel = *src;
 12.2105 +            srcA = (Uint8)(srcpixel >> 24); srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel;
 12.2106 +            dstpixel = *dst;
 12.2107 +            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
 12.2108 +            if (flags & SDL_RENDERCOPY_MODULATE_COLOR) {
 12.2109 +                srcR = (srcR * modulateR) / 255;
 12.2110 +                srcG = (srcG * modulateG) / 255;
 12.2111 +                srcB = (srcB * modulateB) / 255;
 12.2112 +            }
 12.2113 +            if (flags & SDL_RENDERCOPY_MODULATE_ALPHA) {
 12.2114 +                srcA = (srcA * modulateA) / 255;
 12.2115 +            }
 12.2116 +            if (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD)) {
 12.2117 +                /* This goes away if we ever use premultiplied alpha */
 12.2118 +                srcR = (srcR * srcA) / 255;
 12.2119 +                srcG = (srcG * srcA) / 255;
 12.2120 +                srcB = (srcB * srcA) / 255;
 12.2121 +            }
 12.2122 +            switch (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD|SDL_RENDERCOPY_MOD)) {
 12.2123 +            case SDL_RENDERCOPY_BLEND:
 12.2124 +                dstR = srcR + ((255 - srcA) * dstR) / 255;
 12.2125 +                dstG = srcG + ((255 - srcA) * dstG) / 255;
 12.2126 +                dstB = srcB + ((255 - srcA) * dstB) / 255;
 12.2127 +                break;
 12.2128 +            case SDL_RENDERCOPY_ADD:
 12.2129 +                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
 12.2130 +                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
 12.2131 +                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
 12.2132 +                break;
 12.2133 +            case SDL_RENDERCOPY_MOD:
 12.2134 +                dstR = (srcR * dstR) / 255;
 12.2135 +                dstG = (srcG * dstG) / 255;
 12.2136 +                dstB = (srcB * dstB) / 255;
 12.2137 +                break;
 12.2138 +            }
 12.2139 +            dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
 12.2140 +            *dst = dstpixel;
 12.2141 +            ++src;
 12.2142 +            ++dst;
 12.2143 +        }
 12.2144 +        data->src += data->src_pitch;
 12.2145 +        data->dst += data->dst_pitch;
 12.2146 +    }
 12.2147 +    return 0;
 12.2148 +}
 12.2149 +
 12.2150 +int SDL_RenderCopy_ARGB8888_RGB888_Modulate_Blend_Scale(SDL_RenderCopyData *data)
 12.2151 +{
 12.2152 +    const int flags = data->flags;
 12.2153 +    const Uint32 modulateR = data->r;
 12.2154 +    const Uint32 modulateG = data->g;
 12.2155 +    const Uint32 modulateB = data->b;
 12.2156 +    const Uint32 modulateA = data->a;
 12.2157 +    Uint32 srcpixel;
 12.2158 +    Uint32 srcR, srcG, srcB, srcA;
 12.2159 +    Uint32 dstpixel;
 12.2160 +    Uint32 dstR, dstG, dstB, dstA;
 12.2161 +    int srcy, srcx;
 12.2162 +    int posy, posx;
 12.2163 +    int incy, incx;
 12.2164 +
 12.2165 +    srcy = 0;
 12.2166 +    posy = 0;
 12.2167 +    incy = (data->src_h << 16) / data->dst_h;
 12.2168 +    incx = (data->src_w << 16) / data->dst_w;
 12.2169 +
 12.2170 +    while (data->dst_h--) {
 12.2171 +        Uint32 *src;
 12.2172 +        Uint32 *dst = (Uint32 *)data->dst;
 12.2173 +        int n = data->dst_w;
 12.2174 +        srcx = -1;
 12.2175 +        posx = 0x10000L;
 12.2176 +        while (posy >= 0x10000L) {
 12.2177 +            ++srcy;
 12.2178 +            posy -= 0x10000L;
 12.2179 +        }
 12.2180 +        while (n--) {
 12.2181 +            if (posx >= 0x10000L) {
 12.2182 +                while (posx >= 0x10000L) {
 12.2183 +                    ++srcx;
 12.2184 +                    posx -= 0x10000L;
 12.2185 +                }
 12.2186 +                src = (Uint32 *)(data->src + (srcy * data->src_pitch) + (srcx * 4));
 12.2187 +            }
 12.2188 +            srcpixel = *src;
 12.2189 +            srcA = (Uint8)(srcpixel >> 24); srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel;
 12.2190 +            dstpixel = *dst;
 12.2191 +            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
 12.2192 +            if (flags & SDL_RENDERCOPY_MODULATE_COLOR) {
 12.2193 +                srcR = (srcR * modulateR) / 255;
 12.2194 +                srcG = (srcG * modulateG) / 255;
 12.2195 +                srcB = (srcB * modulateB) / 255;
 12.2196 +            }
 12.2197 +            if (flags & SDL_RENDERCOPY_MODULATE_ALPHA) {
 12.2198 +                srcA = (srcA * modulateA) / 255;
 12.2199 +            }
 12.2200 +            if (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD)) {
 12.2201 +                /* This goes away if we ever use premultiplied alpha */
 12.2202 +                srcR = (srcR * srcA) / 255;
 12.2203 +                srcG = (srcG * srcA) / 255;
 12.2204 +                srcB = (srcB * srcA) / 255;
 12.2205 +            }
 12.2206 +            switch (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD|SDL_RENDERCOPY_MOD)) {
 12.2207 +            case SDL_RENDERCOPY_BLEND:
 12.2208 +                dstR = srcR + ((255 - srcA) * dstR) / 255;
 12.2209 +                dstG = srcG + ((255 - srcA) * dstG) / 255;
 12.2210 +                dstB = srcB + ((255 - srcA) * dstB) / 255;
 12.2211 +                break;
 12.2212 +            case SDL_RENDERCOPY_ADD:
 12.2213 +                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
 12.2214 +                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
 12.2215 +                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
 12.2216 +                break;
 12.2217 +            case SDL_RENDERCOPY_MOD:
 12.2218 +                dstR = (srcR * dstR) / 255;
 12.2219 +                dstG = (srcG * dstG) / 255;
 12.2220 +                dstB = (srcB * dstB) / 255;
 12.2221 +                break;
 12.2222 +            }
 12.2223 +            dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
 12.2224 +            *dst = dstpixel;
 12.2225 +            posx += incx;
 12.2226 +            ++dst;
 12.2227 +        }
 12.2228 +        posy += incy;
 12.2229 +        data->dst += data->dst_pitch;
 12.2230 +    }
 12.2231 +    return 0;
 12.2232 +}
 12.2233 +
 12.2234 +int SDL_RenderCopy_ARGB8888_BGR888(SDL_RenderCopyData *data)
 12.2235 +{
 12.2236 +    const int flags = data->flags;
 12.2237 +    Uint32 pixel;
 12.2238 +    Uint32 R, G, B, A;
 12.2239 +
 12.2240 +    while (data->dst_h--) {
 12.2241 +        Uint32 *src = (Uint32 *)data->src;
 12.2242 +        Uint32 *dst = (Uint32 *)data->dst;
 12.2243 +        int n = data->dst_w;
 12.2244 +        while (n--) {
 12.2245 +            pixel = *src;
 12.2246 +            A = (Uint8)(pixel >> 24); R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel;
 12.2247 +            pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R;
 12.2248 +            *dst = pixel;
 12.2249 +            ++src;
 12.2250 +            ++dst;
 12.2251 +        }
 12.2252 +        data->src += data->src_pitch;
 12.2253 +        data->dst += data->dst_pitch;
 12.2254 +    }
 12.2255 +    return 0;
 12.2256 +}
 12.2257 +
 12.2258 +int SDL_RenderCopy_ARGB8888_BGR888_Scale(SDL_RenderCopyData *data)
 12.2259 +{
 12.2260 +    const int flags = data->flags;
 12.2261 +    Uint32 pixel;
 12.2262 +    Uint32 R, G, B, A;
 12.2263 +    int srcy, srcx;
 12.2264 +    int posy, posx;
 12.2265 +    int incy, incx;
 12.2266 +
 12.2267 +    srcy = 0;
 12.2268 +    posy = 0;
 12.2269 +    incy = (data->src_h << 16) / data->dst_h;
 12.2270 +    incx = (data->src_w << 16) / data->dst_w;
 12.2271 +
 12.2272 +    while (data->dst_h--) {
 12.2273 +        Uint32 *src;
 12.2274 +        Uint32 *dst = (Uint32 *)data->dst;
 12.2275 +        int n = data->dst_w;
 12.2276 +        srcx = -1;
 12.2277 +        posx = 0x10000L;
 12.2278 +        while (posy >= 0x10000L) {
 12.2279 +            ++srcy;
 12.2280 +            posy -= 0x10000L;
 12.2281 +        }
 12.2282 +        while (n--) {
 12.2283 +            if (posx >= 0x10000L) {
 12.2284 +                while (posx >= 0x10000L) {
 12.2285 +                    ++srcx;
 12.2286 +                    posx -= 0x10000L;
 12.2287 +                }
 12.2288 +                src = (Uint32 *)(data->src + (srcy * data->src_pitch) + (srcx * 4));
 12.2289 +            }
 12.2290 +            pixel = *src;
 12.2291 +            A = (Uint8)(pixel >> 24); R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel;
 12.2292 +            pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R;
 12.2293 +            *dst = pixel;
 12.2294 +            posx += incx;
 12.2295 +            ++dst;
 12.2296 +        }
 12.2297 +        posy += incy;
 12.2298 +        data->dst += data->dst_pitch;
 12.2299 +    }
 12.2300 +    return 0;
 12.2301 +}
 12.2302 +
 12.2303 +int SDL_RenderCopy_ARGB8888_BGR888_Blend(SDL_RenderCopyData *data)
 12.2304 +{
 12.2305 +    const int flags = data->flags;
 12.2306 +    Uint32 srcpixel;
 12.2307 +    Uint32 srcR, srcG, srcB, srcA;
 12.2308 +    Uint32 dstpixel;
 12.2309 +    Uint32 dstR, dstG, dstB, dstA;
 12.2310 +
 12.2311 +    while (data->dst_h--) {
 12.2312 +        Uint32 *src = (Uint32 *)data->src;
 12.2313 +        Uint32 *dst = (Uint32 *)data->dst;
 12.2314 +        int n = data->dst_w;
 12.2315 +        while (n--) {
 12.2316 +            srcpixel = *src;
 12.2317 +            srcA = (Uint8)(srcpixel >> 24); srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel;
 12.2318 +            dstpixel = *dst;
 12.2319 +            dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
 12.2320 +            if (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD)) {
 12.2321 +                /* This goes away if we ever use premultiplied alpha */
 12.2322 +                srcR = (srcR * srcA) / 255;
 12.2323 +                srcG = (srcG * srcA) / 255;
 12.2324 +                srcB = (srcB * srcA) / 255;
 12.2325 +            }
 12.2326 +            switch (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD|SDL_RENDERCOPY_MOD)) {
 12.2327 +            case SDL_RENDERCOPY_BLEND:
 12.2328 +                dstR = srcR + ((255 - srcA) * dstR) / 255;
 12.2329 +                dstG = srcG + ((255 - srcA) * dstG) / 255;
 12.2330 +                dstB = srcB + ((255 - srcA) * dstB) / 255;
 12.2331 +                break;
 12.2332 +            case SDL_RENDERCOPY_ADD:
 12.2333 +                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
 12.2334 +                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
 12.2335 +                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
 12.2336 +                break;
 12.2337 +            case SDL_RENDERCOPY_MOD:
 12.2338 +                dstR = (srcR * dstR) / 255;
 12.2339 +                dstG = (srcG * dstG) / 255;
 12.2340 +                dstB = (srcB * dstB) / 255;
 12.2341 +                break;
 12.2342 +            }
 12.2343 +            dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
 12.2344 +            *dst = dstpixel;
 12.2345 +            ++src;
 12.2346 +            ++dst;
 12.2347 +        }
 12.2348 +        data->src += data->src_pitch;
 12.2349 +        data->dst += data->dst_pitch;
 12.2350 +    }
 12.2351 +    return 0;
 12.2352 +}
 12.2353 +
 12.2354 +int SDL_RenderCopy_ARGB8888_BGR888_Blend_Scale(SDL_RenderCopyData *data)
 12.2355 +{
 12.2356 +    const int flags = data->flags;
 12.2357 +    Uint32 srcpixel;
 12.2358 +    Uint32 srcR, srcG, srcB, srcA;
 12.2359 +    Uint32 dstpixel;
 12.2360 +    Uint32 dstR, dstG, dstB, dstA;
 12.2361 +    int srcy, srcx;
 12.2362 +    int posy, posx;
 12.2363 +    int incy, incx;
 12.2364 +
 12.2365 +    srcy = 0;
 12.2366 +    posy = 0;
 12.2367 +    incy = (data->src_h << 16) / data->dst_h;
 12.2368 +    incx = (data->src_w << 16) / data->dst_w;
 12.2369 +
 12.2370 +    while (data->dst_h--) {
 12.2371 +        Uint32 *src;
 12.2372 +        Uint32 *dst = (Uint32 *)data->dst;
 12.2373 +        int n = data->dst_w;
 12.2374 +        srcx = -1;
 12.2375 +        posx = 0x10000L;
 12.2376 +        while (posy >= 0x10000L) {
 12.2377 +            ++srcy;
 12.2378 +            posy -= 0x10000L;
 12.2379 +        }
 12.2380 +        while (n--) {
 12.2381 +            if (posx >= 0x10000L) {
 12.2382 +                while (posx >= 0x10000L) {
 12.2383 +                    ++srcx;
 12.2384 +                    posx -= 0x10000L;
 12.2385 +                }
 12.2386 +                src = (Uint32 *)(data->src + (srcy * data->src_pitch) + (srcx * 4));
 12.2387 +            }
 12.2388 +            srcpixel = *src;
 12.2389 +            srcA = (Uint8)(srcpixel >> 24); srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel;
 12.2390 +            dstpixel = *dst;
 12.2391 +            dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
 12.2392 +            if (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD)) {
 12.2393 +                /* This goes away if we ever use premultiplied alpha */
 12.2394 +                srcR = (srcR * srcA) / 255;
 12.2395 +                srcG = (srcG * srcA) / 255;
 12.2396 +                srcB = (srcB * srcA) / 255;
 12.2397 +            }
 12.2398 +            switch (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD|SDL_RENDERCOPY_MOD)) {
 12.2399 +            case SDL_RENDERCOPY_BLEND:
 12.2400 +                dstR = srcR + ((255 - srcA) * dstR) / 255;
 12.2401 +                dstG = srcG + ((255 - srcA) * dstG) / 255;
 12.2402 +                dstB = srcB + ((255 - srcA) * dstB) / 255;
 12.2403 +                break;
 12.2404 +            case SDL_RENDERCOPY_ADD:
 12.2405 +                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
 12.2406 +                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
 12.2407 +                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
 12.2408 +                break;
 12.2409 +            case SDL_RENDERCOPY_MOD:
 12.2410 +                dstR = (srcR * dstR) / 255;
 12.2411 +                dstG = (srcG * dstG) / 255;
 12.2412 +                dstB = (srcB * dstB) / 255;
 12.2413 +                break;
 12.2414 +            }
 12.2415 +            dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
 12.2416 +            *dst = dstpixel;
 12.2417 +            posx += incx;
 12.2418 +            ++dst;
 12.2419 +        }
 12.2420 +        posy += incy;
 12.2421 +        data->dst += data->dst_pitch;
 12.2422 +    }
 12.2423 +    return 0;
 12.2424 +}
 12.2425 +
 12.2426 +int SDL_RenderCopy_ARGB8888_BGR888_Modulate(SDL_RenderCopyData *data)
 12.2427 +{
 12.2428 +    const int flags = data->flags;
 12.2429 +    const Uint32 modulateR = data->r;
 12.2430 +    const Uint32 modulateG = data->g;
 12.2431 +    const Uint32 modulateB = data->b;
 12.2432 +    const Uint32 modulateA = data->a;
 12.2433 +    Uint32 pixel;
 12.2434 +    Uint32 R, G, B, A;
 12.2435 +
 12.2436 +    while (data->dst_h--) {
 12.2437 +        Uint32 *src = (Uint32 *)data->src;
 12.2438 +        Uint32 *dst = (Uint32 *)data->dst;
 12.2439 +        int n = data->dst_w;
 12.2440 +        while (n--) {
 12.2441 +            pixel = *src;
 12.2442 +            A = (Uint8)(pixel >> 24); R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel;
 12.2443 +            if (flags & SDL_RENDERCOPY_MODULATE_COLOR) {
 12.2444 +                R = (R * modulateR) / 255;
 12.2445 +                G = (G * modulateG) / 255;
 12.2446 +                B = (B * modulateB) / 255;
 12.2447 +            }
 12.2448 +            pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R;
 12.2449 +            *dst = pixel;
 12.2450 +            ++src;
 12.2451 +            ++dst;
 12.2452 +        }
 12.2453 +        data->src += data->src_pitch;
 12.2454 +        data->dst += data->dst_pitch;
 12.2455 +    }
 12.2456 +    return 0;
 12.2457 +}
 12.2458 +
 12.2459 +int SDL_RenderCopy_ARGB8888_BGR888_Modulate_Scale(SDL_RenderCopyData *data)
 12.2460 +{
 12.2461 +    const int flags = data->flags;
 12.2462 +    const Uint32 modulateR = data->r;
 12.2463 +    const Uint32 modulateG = data->g;
 12.2464 +    const Uint32 modulateB = data->b;
 12.2465 +    const Uint32 modulateA = data->a;
 12.2466 +    Uint32 pixel;
 12.2467 +    Uint32 R, G, B, A;
 12.2468 +    int srcy, srcx;
 12.2469 +    int posy, posx;
 12.2470 +    int incy, incx;
 12.2471 +
 12.2472 +    srcy = 0;
 12.2473 +    posy = 0;
 12.2474 +    incy = (data->src_h << 16) / data->dst_h;
 12.2475 +    incx = (data->src_w << 16) / data->dst_w;
 12.2476 +
 12.2477 +    while (data->dst_h--) {
 12.2478 +        Uint32 *src;
 12.2479 +        Uint32 *dst = (Uint32 *)data->dst;
 12.2480 +        int n = data->dst_w;
 12.2481 +        srcx = -1;
 12.2482 +        posx = 0x10000L;
 12.2483 +        while (posy >= 0x10000L) {
 12.2484 +            ++srcy;
 12.2485 +            posy -= 0x10000L;
 12.2486 +        }
 12.2487 +        while (n--) {
 12.2488 +            if (posx >= 0x10000L) {
 12.2489 +                while (posx >= 0x10000L) {
 12.2490 +                    ++srcx;
 12.2491 +                    posx -= 0x10000L;
 12.2492 +                }
 12.2493 +                src = (Uint32 *)(data->src + (srcy * data->src_pitch) + (srcx * 4));
 12.2494 +            }
 12.2495 +            pixel = *src;
 12.2496 +            A = (Uint8)(pixel >> 24); R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel;
 12.2497 +            if (flags & SDL_RENDERCOPY_MODULATE_COLOR) {
 12.2498 +                R = (R * modulateR) / 255;
 12.2499 +                G = (G * modulateG) / 255;
 12.2500 +                B = (B * modulateB) / 255;
 12.2501 +            }
 12.2502 +            pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R;
 12.2503 +            *dst = pixel;
 12.2504 +            posx += incx;
 12.2505 +            ++dst;
 12.2506 +        }
 12.2507 +        posy += incy;
 12.2508 +        data->dst += data->dst_pitch;
 12.2509 +    }
 12.2510 +    return 0;
 12.2511 +}
 12.2512 +
 12.2513 +int SDL_RenderCopy_ARGB8888_BGR888_Modulate_Blend(SDL_RenderCopyData *data)
 12.2514 +{
 12.2515 +    const int flags = data->flags;
 12.2516 +    const Uint32 modulateR = data->r;
 12.2517 +    const Uint32 modulateG = data->g;
 12.2518 +    const Uint32 modulateB = data->b;
 12.2519 +    const Uint32 modulateA = data->a;
 12.2520 +    Uint32 srcpixel;
 12.2521 +    Uint32 srcR, srcG, srcB, srcA;
 12.2522 +    Uint32 dstpixel;
 12.2523 +    Uint32 dstR, dstG, dstB, dstA;
 12.2524 +
 12.2525 +    while (data->dst_h--) {
 12.2526 +        Uint32 *src = (Uint32 *)data->src;
 12.2527 +        Uint32 *dst = (Uint32 *)data->dst;
 12.2528 +        int n = data->dst_w;
 12.2529 +        while (n--) {
 12.2530 +            srcpixel = *src;
 12.2531 +            srcA = (Uint8)(srcpixel >> 24); srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel;
 12.2532 +            dstpixel = *dst;
 12.2533 +            dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
 12.2534 +            if (flags & SDL_RENDERCOPY_MODULATE_COLOR) {
 12.2535 +                srcR = (srcR * modulateR) / 255;
 12.2536 +                srcG = (srcG * modulateG) / 255;
 12.2537 +                srcB = (srcB * modulateB) / 255;
 12.2538 +            }
 12.2539 +            if (flags & SDL_RENDERCOPY_MODULATE_ALPHA) {
 12.2540 +                srcA = (srcA * modulateA) / 255;
 12.2541 +            }
 12.2542 +            if (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD)) {
 12.2543 +                /* This goes away if we ever use premultiplied alpha */
 12.2544 +                srcR = (srcR * srcA) / 255;
 12.2545 +                srcG = (srcG * srcA) / 255;
 12.2546 +                srcB = (srcB * srcA) / 255;
 12.2547 +            }
 12.2548 +            switch (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD|SDL_RENDERCOPY_MOD)) {
 12.2549 +            case SDL_RENDERCOPY_BLEND:
 12.2550 +                dstR = srcR + ((255 - srcA) * dstR) / 255;
 12.2551 +                dstG = srcG + ((255 - srcA) * dstG) / 255;
 12.2552 +                dstB = srcB + ((255 - srcA) * dstB) / 255;
 12.2553 +                break;
 12.2554 +            case SDL_RENDERCOPY_ADD:
 12.2555 +                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
 12.2556 +                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
 12.2557 +                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
 12.2558 +                break;
 12.2559 +            case SDL_RENDERCOPY_MOD:
 12.2560 +                dstR = (srcR * dstR) / 255;
 12.2561 +                dstG = (srcG * dstG) / 255;
 12.2562 +                dstB = (srcB * dstB) / 255;
 12.2563 +                break;
 12.2564 +            }
 12.2565 +            dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
 12.2566 +            *dst = dstpixel;
 12.2567 +            ++src;
 12.2568 +            ++dst;
 12.2569 +        }
 12.2570 +        data->src += data->src_pitch;
 12.2571 +        data->dst += data->dst_pitch;
 12.2572 +    }
 12.2573 +    return 0;
 12.2574 +}
 12.2575 +
 12.2576 +int SDL_RenderCopy_ARGB8888_BGR888_Modulate_Blend_Scale(SDL_RenderCopyData *data)
 12.2577 +{
 12.2578 +    const int flags = data->flags;
 12.2579 +    const Uint32 modulateR = data->r;
 12.2580 +    const Uint32 modulateG = data->g;
 12.2581 +    const Uint32 modulateB = data->b;
 12.2582 +    const Uint32 modulateA = data->a;
 12.2583 +    Uint32 srcpixel;
 12.2584 +    Uint32 srcR, srcG, srcB, srcA;
 12.2585 +    Uint32 dstpixel;
 12.2586 +    Uint32 dstR, dstG, dstB, dstA;
 12.2587 +    int srcy, srcx;
 12.2588 +    int posy, posx;
 12.2589 +    int incy, incx;
 12.2590 +
 12.2591 +    srcy = 0;
 12.2592 +    posy = 0;
 12.2593 +    incy = (data->src_h << 16) / data->dst_h;
 12.2594 +    incx = (data->src_w << 16) / data->dst_w;
 12.2595 +
 12.2596 +    while (data->dst_h--) {
 12.2597 +        Uint32 *src;
 12.2598 +        Uint32 *dst = (Uint32 *)data->dst;
 12.2599 +        int n = data->dst_w;
 12.2600 +        srcx = -1;
 12.2601 +        posx = 0x10000L;
 12.2602 +        while (posy >= 0x10000L) {
 12.2603 +            ++srcy;
 12.2604 +            posy -= 0x10000L;
 12.2605 +        }
 12.2606 +        while (n--) {
 12.2607 +            if (posx >= 0x10000L) {
 12.2608 +                while (posx >= 0x10000L) {
 12.2609 +                    ++srcx;
 12.2610 +                    posx -= 0x10000L;
 12.2611 +                }
 12.2612 +                src = (Uint32 *)(data->src + (srcy * data->src_pitch) + (srcx * 4));
 12.2613 +            }
 12.2614 +            srcpixel = *src;
 12.2615 +            srcA = (Uint8)(srcpixel >> 24); srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel;
 12.2616 +            dstpixel = *dst;
 12.2617 +            dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
 12.2618 +            if (flags & SDL_RENDERCOPY_MODULATE_COLOR) {
 12.2619 +                srcR = (srcR * modulateR) / 255;
 12.2620 +                srcG = (srcG * modulateG) / 255;
 12.2621 +                srcB = (srcB * modulateB) / 255;
 12.2622 +            }
 12.2623 +            if (flags & SDL_RENDERCOPY_MODULATE_ALPHA) {
 12.2624 +                srcA = (srcA * modulateA) / 255;
 12.2625 +            }
 12.2626 +            if (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD)) {
 12.2627 +                /* This goes away if we ever use premultiplied alpha */
 12.2628 +                srcR = (srcR * srcA) / 255;
 12.2629 +                srcG = (srcG * srcA) / 255;
 12.2630 +                srcB = (srcB * srcA) / 255;
 12.2631 +            }
 12.2632 +            switch (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD|SDL_RENDERCOPY_MOD)) {
 12.2633 +            case SDL_RENDERCOPY_BLEND:
 12.2634 +                dstR = srcR + ((255 - srcA) * dstR) / 255;
 12.2635 +                dstG = srcG + ((255 - srcA) * dstG) / 255;
 12.2636 +                dstB = srcB + ((255 - srcA) * dstB) / 255;
 12.2637 +                break;
 12.2638 +            case SDL_RENDERCOPY_ADD:
 12.2639 +                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
 12.2640 +                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
 12.2641 +                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
 12.2642 +                break;
 12.2643 +            case SDL_RENDERCOPY_MOD:
 12.2644 +                dstR = (srcR * dstR) / 255;
 12.2645 +                dstG = (srcG * dstG) / 255;
 12.2646 +                dstB = (srcB * dstB) / 255;
 12.2647 +                break;
 12.2648 +            }
 12.2649 +            dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
 12.2650 +            *dst = dstpixel;
 12.2651 +            posx += incx;
 12.2652 +            ++dst;
 12.2653 +        }
 12.2654 +        posy += incy;
 12.2655 +        data->dst += data->dst_pitch;
 12.2656 +    }
 12.2657 +    return 0;
 12.2658 +}
 12.2659 +
 12.2660 +int SDL_RenderCopy_RGBA8888_RGB888(SDL_RenderCopyData *data)
 12.2661 +{
 12.2662 +    const int flags = data->flags;
 12.2663 +    Uint32 pixel;
 12.2664 +    Uint32 R, G, B, A;
 12.2665 +
 12.2666 +    while (data->dst_h--) {
 12.2667 +        Uint32 *src = (Uint32 *)data->src;
 12.2668 +        Uint32 *dst = (Uint32 *)data->dst;
 12.2669 +        int n = data->dst_w;
 12.2670 +        while (n--) {
 12.2671 +            pixel = *src;
 12.2672 +            R = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); B = (Uint8)(pixel >> 8); A = (Uint8)pixel;
 12.2673 +            pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B;
 12.2674 +            *dst = pixel;
 12.2675 +            ++src;
 12.2676 +            ++dst;
 12.2677 +        }
 12.2678 +        data->src += data->src_pitch;
 12.2679 +        data->dst += data->dst_pitch;
 12.2680 +    }
 12.2681 +    return 0;
 12.2682 +}
 12.2683 +
 12.2684 +int SDL_RenderCopy_RGBA8888_RGB888_Scale(SDL_RenderCopyData *data)
 12.2685 +{
 12.2686 +    const int flags = data->flags;
 12.2687 +    Uint32 pixel;
 12.2688 +    Uint32 R, G, B, A;
 12.2689 +    int srcy, srcx;
 12.2690 +    int posy, posx;
 12.2691 +    int incy, incx;
 12.2692 +
 12.2693 +    srcy = 0;
 12.2694 +    posy = 0;
 12.2695 +    incy = (data->src_h << 16) / data->dst_h;
 12.2696 +    incx = (data->src_w << 16) / data->dst_w;
 12.2697 +
 12.2698 +    while (data->dst_h--) {
 12.2699 +        Uint32 *src;
 12.2700 +        Uint32 *dst = (Uint32 *)data->dst;
 12.2701 +        int n = data->dst_w;
 12.2702 +        srcx = -1;
 12.2703 +        posx = 0x10000L;
 12.2704 +        while (posy >= 0x10000L) {
 12.2705 +            ++srcy;
 12.2706 +            posy -= 0x10000L;
 12.2707 +        }
 12.2708 +        while (n--) {
 12.2709 +            if (posx >= 0x10000L) {
 12.2710 +                while (posx >= 0x10000L) {
 12.2711 +                    ++srcx;
 12.2712 +                    posx -= 0x10000L;
 12.2713 +                }
 12.2714 +                src = (Uint32 *)(data->src + (srcy * data->src_pitch) + (srcx * 4));
 12.2715 +            }
 12.2716 +            pixel = *src;
 12.2717 +            R = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); B = (Uint8)(pixel >> 8); A = (Uint8)pixel;
 12.2718 +            pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B;
 12.2719 +            *dst = pixel;
 12.2720 +            posx += incx;
 12.2721 +            ++dst;
 12.2722 +        }
 12.2723 +        posy += incy;
 12.2724 +        data->dst += data->dst_pitch;
 12.2725 +    }
 12.2726 +    return 0;
 12.2727 +}
 12.2728 +
 12.2729 +int SDL_RenderCopy_RGBA8888_RGB888_Blend(SDL_RenderCopyData *data)
 12.2730 +{
 12.2731 +    const int flags = data->flags;
 12.2732 +    Uint32 srcpixel;
 12.2733 +    Uint32 srcR, srcG, srcB, srcA;
 12.2734 +    Uint32 dstpixel;
 12.2735 +    Uint32 dstR, dstG, dstB, dstA;
 12.2736 +
 12.2737 +    while (data->dst_h--) {
 12.2738 +        Uint32 *src = (Uint32 *)data->src;
 12.2739 +        Uint32 *dst = (Uint32 *)data->dst;
 12.2740 +        int n = data->dst_w;
 12.2741 +        while (n--) {
 12.2742 +            srcpixel = *src;
 12.2743 +            srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
 12.2744 +            dstpixel = *dst;
 12.2745 +            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
 12.2746 +            if (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD)) {
 12.2747 +                /* This goes away if we ever use premultiplied alpha */
 12.2748 +                srcR = (srcR * srcA) / 255;
 12.2749 +                srcG = (srcG * srcA) / 255;
 12.2750 +                srcB = (srcB * srcA) / 255;
 12.2751 +            }
 12.2752 +            switch (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD|SDL_RENDERCOPY_MOD)) {
 12.2753 +            case SDL_RENDERCOPY_BLEND:
 12.2754 +                dstR = srcR + ((255 - srcA) * dstR) / 255;
 12.2755 +                dstG = srcG + ((255 - srcA) * dstG) / 255;
 12.2756 +                dstB = srcB + ((255 - srcA) * dstB) / 255;
 12.2757 +                break;
 12.2758 +            case SDL_RENDERCOPY_ADD:
 12.2759 +                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
 12.2760 +                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
 12.2761 +                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
 12.2762 +                break;
 12.2763 +            case SDL_RENDERCOPY_MOD:
 12.2764 +                dstR = (srcR * dstR) / 255;
 12.2765 +                dstG = (srcG * dstG) / 255;
 12.2766 +                dstB = (srcB * dstB) / 255;
 12.2767 +                break;
 12.2768 +            }
 12.2769 +            dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
 12.2770 +            *dst = dstpixel;
 12.2771 +            ++src;
 12.2772 +            ++dst;
 12.2773 +        }
 12.2774 +        data->src += data->src_pitch;
 12.2775 +        data->dst += data->dst_pitch;
 12.2776 +    }
 12.2777 +    return 0;
 12.2778 +}
 12.2779 +
 12.2780 +int SDL_RenderCopy_RGBA8888_RGB888_Blend_Scale(SDL_RenderCopyData *data)
 12.2781 +{
 12.2782 +    const int flags = data->flags;
 12.2783 +    Uint32 srcpixel;
 12.2784 +    Uint32 srcR, srcG, srcB, srcA;
 12.2785 +    Uint32 dstpixel;
 12.2786 +    Uint32 dstR, dstG, dstB, dstA;
 12.2787 +    int srcy, srcx;
 12.2788 +    int posy, posx;
 12.2789 +    int incy, incx;
 12.2790 +
 12.2791 +    srcy = 0;
 12.2792 +    posy = 0;
 12.2793 +    incy = (data->src_h << 16) / data->dst_h;
 12.2794 +    incx = (data->src_w << 16) / data->dst_w;
 12.2795 +
 12.2796 +    while (data->dst_h--) {
 12.2797 +        Uint32 *src;
 12.2798 +        Uint32 *dst = (Uint32 *)data->dst;
 12.2799 +        int n = data->dst_w;
 12.2800 +        srcx = -1;
 12.2801 +        posx = 0x10000L;
 12.2802 +        while (posy >= 0x10000L) {
 12.2803 +            ++srcy;
 12.2804 +            posy -= 0x10000L;
 12.2805 +        }
 12.2806 +        while (n--) {
 12.2807 +            if (posx >= 0x10000L) {
 12.2808 +                while (posx >= 0x10000L) {
 12.2809 +                    ++srcx;
 12.2810 +                    posx -= 0x10000L;
 12.2811 +                }
 12.2812 +                src = (Uint32 *)(data->src + (srcy * data->src_pitch) + (srcx * 4));
 12.2813 +            }
 12.2814 +            srcpixel = *src;
 12.2815 +            srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
 12.2816 +            dstpixel = *dst;
 12.2817 +            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
 12.2818 +            if (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD)) {
 12.2819 +                /* This goes away if we ever use premultiplied alpha */
 12.2820 +                srcR = (srcR * srcA) / 255;
 12.2821 +                srcG = (srcG * srcA) / 255;
 12.2822 +                srcB = (srcB * srcA) / 255;
 12.2823 +            }
 12.2824 +            switch (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD|SDL_RENDERCOPY_MOD)) {
 12.2825 +            case SDL_RENDERCOPY_BLEND:
 12.2826 +                dstR = srcR + ((255 - srcA) * dstR) / 255;
 12.2827 +                dstG = srcG + ((255 - srcA) * dstG) / 255;
 12.2828 +                dstB = srcB + ((255 - srcA) * dstB) / 255;
 12.2829 +                break;
 12.2830 +            case SDL_RENDERCOPY_ADD:
 12.2831 +                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
 12.2832 +                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
 12.2833 +                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
 12.2834 +                break;
 12.2835 +            case SDL_RENDERCOPY_MOD:
 12.2836 +                dstR = (srcR * dstR) / 255;
 12.2837 +                dstG = (srcG * dstG) / 255;
 12.2838 +                dstB = (srcB * dstB) / 255;
 12.2839 +                break;
 12.2840 +            }
 12.2841 +            dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
 12.2842 +            *dst = dstpixel;
 12.2843 +            posx += incx;
 12.2844 +            ++dst;
 12.2845 +        }
 12.2846 +        posy += incy;
 12.2847 +        data->dst += data->dst_pitch;
 12.2848 +    }
 12.2849 +    return 0;
 12.2850 +}
 12.2851 +
 12.2852 +int SDL_RenderCopy_RGBA8888_RGB888_Modulate(SDL_RenderCopyData *data)
 12.2853 +{
 12.2854 +    const int flags = data->flags;
 12.2855 +    const Uint32 modulateR = data->r;
 12.2856 +    const Uint32 modulateG = data->g;
 12.2857 +    const Uint32 modulateB = data->b;
 12.2858 +    const Uint32 modulateA = data->a;
 12.2859 +    Uint32 pixel;
 12.2860 +    Uint32 R, G, B, A;
 12.2861 +
 12.2862 +    while (data->dst_h--) {
 12.2863 +        Uint32 *src = (Uint32 *)data->src;
 12.2864 +        Uint32 *dst = (Uint32 *)data->dst;
 12.2865 +        int n = data->dst_w;
 12.2866 +        while (n--) {
 12.2867 +            pixel = *src;
 12.2868 +            R = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); B = (Uint8)(pixel >> 8); A = (Uint8)pixel;
 12.2869 +            if (flags & SDL_RENDERCOPY_MODULATE_COLOR) {
 12.2870 +                R = (R * modulateR) / 255;
 12.2871 +                G = (G * modulateG) / 255;
 12.2872 +                B = (B * modulateB) / 255;
 12.2873 +            }
 12.2874 +            pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B;
 12.2875 +            *dst = pixel;
 12.2876 +            ++src;
 12.2877 +            ++dst;
 12.2878 +        }
 12.2879 +        data->src += data->src_pitch;
 12.2880 +        data->dst += data->dst_pitch;
 12.2881 +    }
 12.2882 +    return 0;
 12.2883 +}
 12.2884 +
 12.2885 +int SDL_RenderCopy_RGBA8888_RGB888_Modulate_Scale(SDL_RenderCopyData *data)
 12.2886 +{
 12.2887 +    const int flags = data->flags;
 12.2888 +    const Uint32 modulateR = data->r;
 12.2889 +    const Uint32 modulateG = data->g;
 12.2890 +    const Uint32 modulateB = data->b;
 12.2891 +    const Uint32 modulateA = data->a;
 12.2892 +    Uint32 pixel;
 12.2893 +    Uint32 R, G, B, A;
 12.2894 +    int srcy, srcx;
 12.2895 +    int posy, posx;
 12.2896 +    int incy, incx;
 12.2897 +
 12.2898 +    srcy = 0;
 12.2899 +    posy = 0;
 12.2900 +    incy = (data->src_h << 16) / data->dst_h;
 12.2901 +    incx = (data->src_w << 16) / data->dst_w;
 12.2902 +
 12.2903 +    while (data->dst_h--) {
 12.2904 +        Uint32 *src;
 12.2905 +        Uint32 *dst = (Uint32 *)data->dst;
 12.2906 +        int n = data->dst_w;
 12.2907 +        srcx = -1;
 12.2908 +        posx = 0x10000L;
 12.2909 +        while (posy >= 0x10000L) {
 12.2910 +            ++srcy;
 12.2911 +            posy -= 0x10000L;
 12.2912 +        }
 12.2913 +        while (n--) {
 12.2914 +            if (posx >= 0x10000L) {
 12.2915 +                while (posx >= 0x10000L) {
 12.2916 +                    ++srcx;
 12.2917 +                    posx -= 0x10000L;
 12.2918 +                }
 12.2919 +                src = (Uint32 *)(data->src + (srcy * data->src_pitch) + (srcx * 4));
 12.2920 +            }
 12.2921 +            pixel = *src;
 12.2922 +            R = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); B = (Uint8)(pixel >> 8); A = (Uint8)pixel;
 12.2923 +            if (flags & SDL_RENDERCOPY_MODULATE_COLOR) {
 12.2924 +                R = (R * modulateR) / 255;
 12.2925 +                G = (G * modulateG) / 255;
 12.2926 +                B = (B * modulateB) / 255;
 12.2927 +            }
 12.2928 +            pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B;
 12.2929 +            *dst = pixel;
 12.2930 +            posx += incx;
 12.2931 +            ++dst;
 12.2932 +        }
 12.2933 +        posy += incy;
 12.2934 +        data->dst += data->dst_pitch;
 12.2935 +    }
 12.2936 +    return 0;
 12.2937 +}
 12.2938 +
 12.2939 +int SDL_RenderCopy_RGBA8888_RGB888_Modulate_Blend(SDL_RenderCopyData *data)
 12.2940 +{
 12.2941 +    const int flags = data->flags;
 12.2942 +    const Uint32 modulateR = data->r;
 12.2943 +    const Uint32 modulateG = data->g;
 12.2944 +    const Uint32 modulateB = data->b;
 12.2945 +    const Uint32 modulateA = data->a;
 12.2946 +    Uint32 srcpixel;
 12.2947 +    Uint32 srcR, srcG, srcB, srcA;
 12.2948 +    Uint32 dstpixel;
 12.2949 +    Uint32 dstR, dstG, dstB, dstA;
 12.2950 +
 12.2951 +    while (data->dst_h--) {
 12.2952 +        Uint32 *src = (Uint32 *)data->src;
 12.2953 +        Uint32 *dst = (Uint32 *)data->dst;
 12.2954 +        int n = data->dst_w;
 12.2955 +        while (n--) {
 12.2956 +            srcpixel = *src;
 12.2957 +            srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
 12.2958 +            dstpixel = *dst;
 12.2959 +            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
 12.2960 +            if (flags & SDL_RENDERCOPY_MODULATE_COLOR) {
 12.2961 +                srcR = (srcR * modulateR) / 255;
 12.2962 +                srcG = (srcG * modulateG) / 255;
 12.2963 +                srcB = (srcB * modulateB) / 255;
 12.2964 +            }
 12.2965 +            if (flags & SDL_RENDERCOPY_MODULATE_ALPHA) {
 12.2966 +                srcA = (srcA * modulateA) / 255;
 12.2967 +            }
 12.2968 +            if (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD)) {
 12.2969 +                /* This goes away if we ever use premultiplied alpha */
 12.2970 +                srcR = (srcR * srcA) / 255;
 12.2971 +                srcG = (srcG * srcA) / 255;
 12.2972 +                srcB = (srcB * srcA) / 255;
 12.2973 +            }
 12.2974 +            switch (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD|SDL_RENDERCOPY_MOD)) {
 12.2975 +            case SDL_RENDERCOPY_BLEND:
 12.2976 +                dstR = srcR + ((255 - srcA) * dstR) / 255;
 12.2977 +                dstG = srcG + ((255 - srcA) * dstG) / 255;
 12.2978 +                dstB = srcB + ((255 - srcA) * dstB) / 255;
 12.2979 +                break;
 12.2980 +            case SDL_RENDERCOPY_ADD:
 12.2981 +                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
 12.2982 +                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
 12.2983 +                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
 12.2984 +                break;
 12.2985 +            case SDL_RENDERCOPY_MOD:
 12.2986 +                dstR = (srcR * dstR) / 255;
 12.2987 +                dstG = (srcG * dstG) / 255;
 12.2988 +                dstB = (srcB * dstB) / 255;
 12.2989 +                break;
 12.2990 +            }
 12.2991 +            dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
 12.2992 +            *dst = dstpixel;
 12.2993 +            ++src;
 12.2994 +            ++dst;
 12.2995 +        }
 12.2996 +        data->src += data->src_pitch;
 12.2997 +        data->dst += data->dst_pitch;
 12.2998 +    }
 12.2999 +    return 0;
 12.3000 +}
 12.3001 +
 12.3002 +int SDL_RenderCopy_RGBA8888_RGB888_Modulate_Blend_Scale(SDL_RenderCopyData *data)
 12.3003 +{
 12.3004 +    const int flags = data->flags;
 12.3005 +    const Uint32 modulateR = data->r;
 12.3006 +    const Uint32 modulateG = data->g;
 12.3007 +    const Uint32 modulateB = data->b;
 12.3008 +    const Uint32 modulateA = data->a;
 12.3009 +    Uint32 srcpixel;
 12.3010 +    Uint32 srcR, srcG, srcB, srcA;
 12.3011 +    Uint32 dstpixel;
 12.3012 +    Uint32 dstR, dstG, dstB, dstA;
 12.3013 +    int srcy, srcx;
 12.3014 +    int posy, posx;
 12.3015 +    int incy, incx;
 12.3016 +
 12.3017 +    srcy = 0;
 12.3018 +    posy = 0;
 12.3019 +    incy = (data->src_h << 16) / data->dst_h;
 12.3020 +    incx = (data->src_w << 16) / data->dst_w;
 12.3021 +
 12.3022 +    while (data->dst_h--) {
 12.3023 +        Uint32 *src;
 12.3024 +        Uint32 *dst = (Uint32 *)data->dst;
 12.3025 +        int n = data->dst_w;
 12.3026 +        srcx = -1;
 12.3027 +        posx = 0x10000L;
 12.3028 +        while (posy >= 0x10000L) {
 12.3029 +            ++srcy;
 12.3030 +            posy -= 0x10000L;
 12.3031 +        }
 12.3032 +        while (n--) {
 12.3033 +            if (posx >= 0x10000L) {
 12.3034 +                while (posx >= 0x10000L) {
 12.3035 +                    ++srcx;
 12.3036 +                    posx -= 0x10000L;
 12.3037 +                }
 12.3038 +                src = (Uint32 *)(data->src + (srcy * data->src_pitch) + (srcx * 4));
 12.3039 +            }
 12.3040 +            srcpixel = *src;
 12.3041 +            srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
 12.3042 +            dstpixel = *dst;
 12.3043 +            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
 12.3044 +            if (flags & SDL_RENDERCOPY_MODULATE_COLOR) {
 12.3045 +                srcR = (srcR * modulateR) / 255;
 12.3046 +                srcG = (srcG * modulateG) / 255;
 12.3047 +                srcB = (srcB * modulateB) / 255;
 12.3048 +            }
 12.3049 +            if (flags & SDL_RENDERCOPY_MODULATE_ALPHA) {
 12.3050 +                srcA = (srcA * modulateA) / 255;
 12.3051 +            }
 12.3052 +            if (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD)) {
 12.3053 +                /* This goes away if we ever use premultiplied alpha */
 12.3054 +                srcR = (srcR * srcA) / 255;
 12.3055 +                srcG = (srcG * srcA) / 255;
 12.3056 +                srcB = (srcB * srcA) / 255;
 12.3057 +            }
 12.3058 +            switch (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD|SDL_RENDERCOPY_MOD)) {
 12.3059 +            case SDL_RENDERCOPY_BLEND:
 12.3060 +                dstR = srcR + ((255 - srcA) * dstR) / 255;
 12.3061 +                dstG = srcG + ((255 - srcA) * dstG) / 255;
 12.3062 +                dstB = srcB + ((255 - srcA) * dstB) / 255;
 12.3063 +                break;
 12.3064 +            case SDL_RENDERCOPY_ADD:
 12.3065 +                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
 12.3066 +                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
 12.3067 +                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
 12.3068 +                break;
 12.3069 +            case SDL_RENDERCOPY_MOD:
 12.3070 +                dstR = (srcR * dstR) / 255;
 12.3071 +                dstG = (srcG * dstG) / 255;
 12.3072 +                dstB = (srcB * dstB) / 255;
 12.3073 +                break;
 12.3074 +            }
 12.3075 +            dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
 12.3076 +            *dst = dstpixel;
 12.3077 +            posx += incx;
 12.3078 +            ++dst;
 12.3079 +        }
 12.3080 +        posy += incy;
 12.3081 +        data->dst += data->dst_pitch;
 12.3082 +    }
 12.3083 +    return 0;
 12.3084 +}
 12.3085 +
 12.3086 +int SDL_RenderCopy_RGBA8888_BGR888(SDL_RenderCopyData *data)
 12.3087 +{
 12.3088 +    const int flags = data->flags;
 12.3089 +    Uint32 pixel;
 12.3090 +    Uint32 R, G, B, A;
 12.3091 +
 12.3092 +    while (data->dst_h--) {
 12.3093 +        Uint32 *src = (Uint32 *)data->src;
 12.3094 +        Uint32 *dst = (Uint32 *)data->dst;
 12.3095 +        int n = data->dst_w;
 12.3096 +        while (n--) {
 12.3097 +            pixel = *src;
 12.3098 +            R = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); B = (Uint8)(pixel >> 8); A = (Uint8)pixel;
 12.3099 +            pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R;
 12.3100 +            *dst = pixel;
 12.3101 +            ++src;
 12.3102 +            ++dst;
 12.3103 +        }
 12.3104 +        data->src += data->src_pitch;
 12.3105 +        data->dst += data->dst_pitch;
 12.3106 +    }
 12.3107 +    return 0;
 12.3108 +}
 12.3109 +
 12.3110 +int SDL_RenderCopy_RGBA8888_BGR888_Scale(SDL_RenderCopyData *data)
 12.3111 +{
 12.3112 +    const int flags = data->flags;
 12.3113 +    Uint32 pixel;
 12.3114 +    Uint32 R, G, B, A;
 12.3115 +    int srcy, srcx;
 12.3116 +    int posy, posx;
 12.3117 +    int incy, incx;
 12.3118 +
 12.3119 +    srcy = 0;
 12.3120 +    posy = 0;
 12.3121 +    incy = (data->src_h << 16) / data->dst_h;
 12.3122 +    incx = (data->src_w << 16) / data->dst_w;
 12.3123 +
 12.3124 +    while (data->dst_h--) {
 12.3125 +        Uint32 *src;
 12.3126 +        Uint32 *dst = (Uint32 *)data->dst;
 12.3127 +        int n = data->dst_w;
 12.3128 +        srcx = -1;
 12.3129 +        posx = 0x10000L;
 12.3130 +        while (posy >= 0x10000L) {
 12.3131 +            ++srcy;
 12.3132 +            posy -= 0x10000L;
 12.3133 +        }
 12.3134 +        while (n--) {
 12.3135 +            if (posx >= 0x10000L) {
 12.3136 +                while (posx >= 0x10000L) {
 12.3137 +                    ++srcx;
 12.3138 +                    posx -= 0x10000L;
 12.3139 +                }
 12.3140 +                src = (Uint32 *)(data->src + (srcy * data->src_pitch) + (srcx * 4));
 12.3141 +            }
 12.3142 +            pixel = *src;
 12.3143 +            R = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); B = (Uint8)(pixel >> 8); A = (Uint8)pixel;
 12.3144 +            pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R;
 12.3145 +            *dst = pixel;
 12.3146 +            posx += incx;
 12.3147 +            ++dst;
 12.3148 +        }
 12.3149 +        posy += incy;
 12.3150 +        data->dst += data->dst_pitch;
 12.3151 +    }
 12.3152 +    return 0;
 12.3153 +}
 12.3154 +
 12.3155 +int SDL_RenderCopy_RGBA8888_BGR888_Blend(SDL_RenderCopyData *data)
 12.3156 +{
 12.3157 +    const int flags = data->flags;
 12.3158 +    Uint32 srcpixel;
 12.3159 +    Uint32 srcR, srcG, srcB, srcA;
 12.3160 +    Uint32 dstpixel;
 12.3161 +    Uint32 dstR, dstG, dstB, dstA;
 12.3162 +
 12.3163 +    while (data->dst_h--) {
 12.3164 +        Uint32 *src = (Uint32 *)data->src;
 12.3165 +        Uint32 *dst = (Uint32 *)data->dst;
 12.3166 +        int n = data->dst_w;
 12.3167 +        while (n--) {
 12.3168 +            srcpixel = *src;
 12.3169 +            srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
 12.3170 +            dstpixel = *dst;
 12.3171 +            dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
 12.3172 +            if (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD)) {
 12.3173 +                /* This goes away if we ever use premultiplied alpha */
 12.3174 +                srcR = (srcR * srcA) / 255;
 12.3175 +                srcG = (srcG * srcA) / 255;
 12.3176 +                srcB = (srcB * srcA) / 255;
 12.3177 +            }
 12.3178 +            switch (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD|SDL_RENDERCOPY_MOD)) {
 12.3179 +            case SDL_RENDERCOPY_BLEND:
 12.3180 +                dstR = srcR + ((255 - srcA) * dstR) / 255;
 12.3181 +                dstG = srcG + ((255 - srcA) * dstG) / 255;
 12.3182 +                dstB = srcB + ((255 - srcA) * dstB) / 255;
 12.3183 +                break;
 12.3184 +            case SDL_RENDERCOPY_ADD:
 12.3185 +                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
 12.3186 +                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
 12.3187 +                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
 12.3188 +                break;
 12.3189 +            case SDL_RENDERCOPY_MOD:
 12.3190 +                dstR = (srcR * dstR) / 255;
 12.3191 +                dstG = (srcG * dstG) / 255;
 12.3192 +                dstB = (srcB * dstB) / 255;
 12.3193 +                break;
 12.3194 +            }
 12.3195 +            dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
 12.3196 +            *dst = dstpixel;
 12.3197 +            ++src;
 12.3198 +            ++dst;
 12.3199 +        }
 12.3200 +        data->src += data->src_pitch;
 12.3201 +        data->dst += data->dst_pitch;
 12.3202 +    }
 12.3203 +    return 0;
 12.3204 +}
 12.3205 +
 12.3206 +int SDL_RenderCopy_RGBA8888_BGR888_Blend_Scale(SDL_RenderCopyData *data)
 12.3207 +{
 12.3208 +    const int flags = data->flags;
 12.3209 +    Uint32 srcpixel;
 12.3210 +    Uint32 srcR, srcG, srcB, srcA;
 12.3211 +    Uint32 dstpixel;
 12.3212 +    Uint32 dstR, dstG, dstB, dstA;
 12.3213 +    int srcy, srcx;
 12.3214 +    int posy, posx;
 12.3215 +    int incy, incx;
 12.3216 +
 12.3217 +    srcy = 0;
 12.3218 +    posy = 0;
 12.3219 +    incy = (data->src_h << 16) / data->dst_h;
 12.3220 +    incx = (data->src_w << 16) / data->dst_w;
 12.3221 +
 12.3222 +    while (data->dst_h--) {
 12.3223 +        Uint32 *src;
 12.3224 +        Uint32 *dst = (Uint32 *)data->dst;
 12.3225 +        int n = data->dst_w;
 12.3226 +        srcx = -1;
 12.3227 +        posx = 0x10000L;
 12.3228 +        while (posy >= 0x10000L) {
 12.3229 +            ++srcy;
 12.3230 +            posy -= 0x10000L;
 12.3231 +        }
 12.3232 +        while (n--) {
 12.3233 +            if (posx >= 0x10000L) {
 12.3234 +                while (posx >= 0x10000L) {
 12.3235 +                    ++srcx;
 12.3236 +                    posx -= 0x10000L;
 12.3237 +                }
 12.3238 +                src = (Uint32 *)(data->src + (srcy * data->src_pitch) + (srcx * 4));
 12.3239 +            }
 12.3240 +            srcpixel = *src;
 12.3241 +            srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
 12.3242 +            dstpixel = *dst;
 12.3243 +            dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
 12.3244 +            if (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD)) {
 12.3245 +                /* This goes away if we ever use premultiplied alpha */
 12.3246 +                srcR = (srcR * srcA) / 255;
 12.3247 +                srcG = (srcG * srcA) / 255;
 12.3248 +                srcB = (srcB * srcA) / 255;
 12.3249 +            }
 12.3250 +            switch (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD|SDL_RENDERCOPY_MOD)) {
 12.3251 +            case SDL_RENDERCOPY_BLEND:
 12.3252 +                dstR = srcR + ((255 - srcA) * dstR) / 255;
 12.3253 +                dstG = srcG + ((255 - srcA) * dstG) / 255;
 12.3254 +                dstB = srcB + ((255 - srcA) * dstB) / 255;
 12.3255 +                break;
 12.3256 +            case SDL_RENDERCOPY_ADD:
 12.3257 +                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
 12.3258 +                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
 12.3259 +                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
 12.3260 +                break;
 12.3261 +            case SDL_RENDERCOPY_MOD:
 12.3262 +                dstR = (srcR * dstR) / 255;
 12.3263 +                dstG = (srcG * dstG) / 255;
 12.3264 +                dstB = (srcB * dstB) / 255;
 12.3265 +                break;
 12.3266 +            }
 12.3267 +            dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
 12.3268 +            *dst = dstpixel;
 12.3269 +            posx += incx;
 12.3270 +            ++dst;
 12.3271 +        }
 12.3272 +        posy += incy;
 12.3273 +        data->dst += data->dst_pitch;
 12.3274 +    }
 12.3275 +    return 0;
 12.3276 +}
 12.3277 +
 12.3278 +int SDL_RenderCopy_RGBA8888_BGR888_Modulate(SDL_RenderCopyData *data)
 12.3279 +{
 12.3280 +    const int flags = data->flags;
 12.3281 +    const Uint32 modulateR = data->r;
 12.3282 +    const Uint32 modulateG = data->g;
 12.3283 +    const Uint32 modulateB = data->b;
 12.3284 +    const Uint32 modulateA = data->a;
 12.3285 +    Uint32 pixel;
 12.3286 +    Uint32 R, G, B, A;
 12.3287 +
 12.3288 +    while (data->dst_h--) {
 12.3289 +        Uint32 *src = (Uint32 *)data->src;
 12.3290 +        Uint32 *dst = (Uint32 *)data->dst;
 12.3291 +        int n = data->dst_w;
 12.3292 +        while (n--) {
 12.3293 +            pixel = *src;
 12.3294 +            R = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); B = (Uint8)(pixel >> 8); A = (Uint8)pixel;
 12.3295 +            if (flags & SDL_RENDERCOPY_MODULATE_COLOR) {
 12.3296 +                R = (R * modulateR) / 255;
 12.3297 +                G = (G * modulateG) / 255;
 12.3298 +                B = (B * modulateB) / 255;
 12.3299 +            }
 12.3300 +            pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R;
 12.3301 +            *dst = pixel;
 12.3302 +            ++src;
 12.3303 +            ++dst;
 12.3304 +        }
 12.3305 +        data->src += data->src_pitch;
 12.3306 +        data->dst += data->dst_pitch;
 12.3307 +    }
 12.3308 +    return 0;
 12.3309 +}
 12.3310 +
 12.3311 +int SDL_RenderCopy_RGBA8888_BGR888_Modulate_Scale(SDL_RenderCopyData *data)
 12.3312 +{
 12.3313 +    const int flags = data->flags;
 12.3314 +    const Uint32 modulateR = data->r;
 12.3315 +    const Uint32 modulateG = data->g;
 12.3316 +    const Uint32 modulateB = data->b;
 12.3317 +    const Uint32 modulateA = data->a;
 12.3318 +    Uint32 pixel;
 12.3319 +    Uint32 R, G, B, A;
 12.3320 +    int srcy, srcx;
 12.3321 +    int posy, posx;
 12.3322 +    int incy, incx;
 12.3323 +
 12.3324 +    srcy = 0;
 12.3325 +    posy = 0;
 12.3326 +    incy = (data->src_h << 16) / data->dst_h;
 12.3327 +    incx = (data->src_w << 16) / data->dst_w;
 12.3328 +
 12.3329 +    while (data->dst_h--) {
 12.3330 +        Uint32 *src;
 12.3331 +        Uint32 *dst = (Uint32 *)data->dst;
 12.3332 +        int n = data->dst_w;
 12.3333 +        srcx = -1;
 12.3334 +        posx = 0x10000L;
 12.3335 +        while (posy >= 0x10000L) {
 12.3336 +            ++srcy;
 12.3337 +            posy -= 0x10000L;
 12.3338 +        }
 12.3339 +        while (n--) {
 12.3340 +            if (posx >= 0x10000L) {
 12.3341 +                while (posx >= 0x10000L) {
 12.3342 +                    ++srcx;
 12.3343 +                    posx -= 0x10000L;
 12.3344 +                }
 12.3345 +                src = (Uint32 *)(data->src + (srcy * data->src_pitch) + (srcx * 4));
 12.3346 +            }
 12.3347 +            pixel = *src;
 12.3348 +            R = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); B = (Uint8)(pixel >> 8); A = (Uint8)pixel;
 12.3349 +            if (flags & SDL_RENDERCOPY_MODULATE_COLOR) {
 12.3350 +                R = (R * modulateR) / 255;
 12.3351 +                G = (G * modulateG) / 255;
 12.3352 +                B = (B * modulateB) / 255;
 12.3353 +            }
 12.3354 +            pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R;
 12.3355 +            *dst = pixel;
 12.3356 +            posx += incx;
 12.3357 +            ++dst;
 12.3358 +        }
 12.3359 +        posy += incy;
 12.3360 +        data->dst += data->dst_pitch;
 12.3361 +    }
 12.3362 +    return 0;
 12.3363 +}
 12.3364 +
 12.3365 +int SDL_RenderCopy_RGBA8888_BGR888_Modulate_Blend(SDL_RenderCopyData *data)
 12.3366 +{
 12.3367 +    const int flags = data->flags;
 12.3368 +    const Uint32 modulateR = data->r;
 12.3369 +    const Uint32 modulateG = data->g;
 12.3370 +    const Uint32 modulateB = data->b;
 12.3371 +    const Uint32 modulateA = data->a;
 12.3372 +    Uint32 srcpixel;
 12.3373 +    Uint32 srcR, srcG, srcB, srcA;
 12.3374 +    Uint32 dstpixel;
 12.3375 +    Uint32 dstR, dstG, dstB, dstA;
 12.3376 +
 12.3377 +    while (data->dst_h--) {
 12.3378 +        Uint32 *src = (Uint32 *)data->src;
 12.3379 +        Uint32 *dst = (Uint32 *)data->dst;
 12.3380 +        int n = data->dst_w;
 12.3381 +        while (n--) {
 12.3382 +            srcpixel = *src;
 12.3383 +            srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
 12.3384 +            dstpixel = *dst;
 12.3385 +            dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
 12.3386 +            if (flags & SDL_RENDERCOPY_MODULATE_COLOR) {
 12.3387 +                srcR = (srcR * modulateR) / 255;
 12.3388 +                srcG = (srcG * modulateG) / 255;
 12.3389 +                srcB = (srcB * modulateB) / 255;
 12.3390 +            }
 12.3391 +            if (flags & SDL_RENDERCOPY_MODULATE_ALPHA) {
 12.3392 +                srcA = (srcA * modulateA) / 255;
 12.3393 +            }
 12.3394 +            if (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD)) {
 12.3395 +                /* This goes away if we ever use premultiplied alpha */
 12.3396 +                srcR = (srcR * srcA) / 255;
 12.3397 +                srcG = (srcG * srcA) / 255;
 12.3398 +                srcB = (srcB * srcA) / 255;
 12.3399 +            }
 12.3400 +            switch (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD|SDL_RENDERCOPY_MOD)) {
 12.3401 +            case SDL_RENDERCOPY_BLEND:
 12.3402 +                dstR = srcR + ((255 - srcA) * dstR) / 255;
 12.3403 +                dstG = srcG + ((255 - srcA) * dstG) / 255;
 12.3404 +                dstB = srcB + ((255 - srcA) * dstB) / 255;
 12.3405 +                break;
 12.3406 +            case SDL_RENDERCOPY_ADD:
 12.3407 +                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
 12.3408 +                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
 12.3409 +                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
 12.3410 +                break;
 12.3411 +            case SDL_RENDERCOPY_MOD:
 12.3412 +                dstR = (srcR * dstR) / 255;
 12.3413 +                dstG = (srcG * dstG) / 255;
 12.3414 +                dstB = (srcB * dstB) / 255;
 12.3415 +                break;
 12.3416 +            }
 12.3417 +            dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
 12.3418 +            *dst = dstpixel;
 12.3419 +            ++src;
 12.3420 +            ++dst;
 12.3421 +        }
 12.3422 +        data->src += data->src_pitch;
 12.3423 +        data->dst += data->dst_pitch;
 12.3424 +    }
 12.3425 +    return 0;
 12.3426 +}
 12.3427 +
 12.3428 +int SDL_RenderCopy_RGBA8888_BGR888_Modulate_Blend_Scale(SDL_RenderCopyData *data)
 12.3429 +{
 12.3430 +    const int flags = data->flags;
 12.3431 +    const Uint32 modulateR = data->r;
 12.3432 +    const Uint32 modulateG = data->g;
 12.3433 +    const Uint32 modulateB = data->b;
 12.3434 +    const Uint32 modulateA = data->a;
 12.3435 +    Uint32 srcpixel;
 12.3436 +    Uint32 srcR, srcG, srcB, srcA;
 12.3437 +    Uint32 dstpixel;
 12.3438 +    Uint32 dstR, dstG, dstB, dstA;
 12.3439 +    int srcy, srcx;
 12.3440 +    int posy, posx;
 12.3441 +    int incy, incx;
 12.3442 +
 12.3443 +    srcy = 0;
 12.3444 +    posy = 0;
 12.3445 +    incy = (data->src_h << 16) / data->dst_h;
 12.3446 +    incx = (data->src_w << 16) / data->dst_w;
 12.3447 +
 12.3448 +    while (data->dst_h--) {
 12.3449 +        Uint32 *src;
 12.3450 +        Uint32 *dst = (Uint32 *)data->dst;
 12.3451 +        int n = data->dst_w;
 12.3452 +        srcx = -1;
 12.3453 +        posx = 0x10000L;
 12.3454 +        while (posy >= 0x10000L) {
 12.3455 +            ++srcy;
 12.3456 +            posy -= 0x10000L;
 12.3457 +        }
 12.3458 +        while (n--) {
 12.3459 +            if (posx >= 0x10000L) {
 12.3460 +                while (posx >= 0x10000L) {
 12.3461 +                    ++srcx;
 12.3462 +                    posx -= 0x10000L;
 12.3463 +                }
 12.3464 +                src = (Uint32 *)(data->src + (srcy * data->src_pitch) + (srcx * 4));
 12.3465 +            }
 12.3466 +            srcpixel = *src;
 12.3467 +            srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
 12.3468 +            dstpixel = *dst;
 12.3469 +            dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
 12.3470 +            if (flags & SDL_RENDERCOPY_MODULATE_COLOR) {
 12.3471 +                srcR = (srcR * modulateR) / 255;
 12.3472 +                srcG = (srcG * modulateG) / 255;
 12.3473 +                srcB = (srcB * modulateB) / 255;
 12.3474 +            }
 12.3475 +            if (flags & SDL_RENDERCOPY_MODULATE_ALPHA) {
 12.3476 +                srcA = (srcA * modulateA) / 255;
 12.3477 +            }
 12.3478 +            if (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD)) {
 12.3479 +                /* This goes away if we ever use premultiplied alpha */
 12.3480 +                srcR = (srcR * srcA) / 255;
 12.3481 +                srcG = (srcG * srcA) / 255;
 12.3482 +                srcB = (srcB * srcA) / 255;
 12.3483 +            }
 12.3484 +            switch (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD|SDL_RENDERCOPY_MOD)) {
 12.3485 +            case SDL_RENDERCOPY_BLEND:
 12.3486 +                dstR = srcR + ((255 - srcA) * dstR) / 255;
 12.3487 +                dstG = srcG + ((255 - srcA) * dstG) / 255;
 12.3488 +                dstB = srcB + ((255 - srcA) * dstB) / 255;
 12.3489 +                break;
 12.3490 +            case SDL_RENDERCOPY_ADD:
 12.3491 +                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
 12.3492 +                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
 12.3493 +                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
 12.3494 +                break;
 12.3495 +            case SDL_RENDERCOPY_MOD:
 12.3496 +                dstR = (srcR * dstR) / 255;
 12.3497 +                dstG = (srcG * dstG) / 255;
 12.3498 +                dstB = (srcB * dstB) / 255;
 12.3499 +                break;
 12.3500 +            }
 12.3501 +            dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
 12.3502 +            *dst = dstpixel;
 12.3503 +            posx += incx;
 12.3504 +            ++dst;
 12.3505 +        }
 12.3506 +        posy += incy;
 12.3507 +        data->dst += data->dst_pitch;
 12.3508 +    }
 12.3509 +    return 0;
 12.3510 +}
 12.3511 +
 12.3512 +int SDL_RenderCopy_ABGR8888_RGB888(SDL_RenderCopyData *data)
 12.3513 +{
 12.3514 +    const int flags = data->flags;
 12.3515 +    Uint32 pixel;
 12.3516 +    Uint32 R, G, B, A;
 12.3517 +
 12.3518 +    while (data->dst_h--) {
 12.3519 +        Uint32 *src = (Uint32 *)data->src;
 12.3520 +        Uint32 *dst = (Uint32 *)data->dst;
 12.3521 +        int n = data->dst_w;
 12.3522 +        while (n--) {
 12.3523 +            pixel = *src;
 12.3524 +            A = (Uint8)(pixel >> 24); B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel;
 12.3525 +            pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B;
 12.3526 +            *dst = pixel;
 12.3527 +            ++src;
 12.3528 +            ++dst;
 12.3529 +        }
 12.3530 +        data->src += data->src_pitch;
 12.3531 +        data->dst += data->dst_pitch;
 12.3532 +    }
 12.3533 +    return 0;
 12.3534 +}
 12.3535 +
 12.3536 +int SDL_RenderCopy_ABGR8888_RGB888_Scale(SDL_RenderCopyData *data)
 12.3537 +{
 12.3538 +    const int flags = data->flags;
 12.3539 +    Uint32 pixel;
 12.3540 +    Uint32 R, G, B, A;
 12.3541 +    int srcy, srcx;
 12.3542 +    int posy, posx;
 12.3543 +    int incy, incx;
 12.3544 +
 12.3545 +    srcy = 0;
 12.3546 +    posy = 0;
 12.3547 +    incy = (data->src_h << 16) / data->dst_h;
 12.3548 +    incx = (data->src_w << 16) / data->dst_w;
 12.3549 +
 12.3550 +    while (data->dst_h--) {
 12.3551 +        Uint32 *src;
 12.3552 +        Uint32 *dst = (Uint32 *)data->dst;
 12.3553 +        int n = data->dst_w;
 12.3554 +        srcx = -1;
 12.3555 +        posx = 0x10000L;
 12.3556 +        while (posy >= 0x10000L) {
 12.3557 +            ++srcy;
 12.3558 +            posy -= 0x10000L;
 12.3559 +        }
 12.3560 +        while (n--) {
 12.3561 +            if (posx >= 0x10000L) {
 12.3562 +                while (posx >= 0x10000L) {
 12.3563 +                    ++srcx;
 12.3564 +                    posx -= 0x10000L;
 12.3565 +                }
 12.3566 +                src = (Uint32 *)(data->src + (srcy * data->src_pitch) + (srcx * 4));
 12.3567 +            }
 12.3568 +            pixel = *src;
 12.3569 +            A = (Uint8)(pixel >> 24); B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel;
 12.3570 +            pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B;
 12.3571 +            *dst = pixel;
 12.3572 +            posx += incx;
 12.3573 +            ++dst;
 12.3574 +        }
 12.3575 +        posy += incy;
 12.3576 +        data->dst += data->dst_pitch;
 12.3577 +    }
 12.3578 +    return 0;
 12.3579 +}
 12.3580 +
 12.3581 +int SDL_RenderCopy_ABGR8888_RGB888_Blend(SDL_RenderCopyData *data)
 12.3582 +{
 12.3583 +    const int flags = data->flags;
 12.3584 +    Uint32 srcpixel;
 12.3585 +    Uint32 srcR, srcG, srcB, srcA;
 12.3586 +    Uint32 dstpixel;
 12.3587 +    Uint32 dstR, dstG, dstB, dstA;
 12.3588 +
 12.3589 +    while (data->dst_h--) {
 12.3590 +        Uint32 *src = (Uint32 *)data->src;
 12.3591 +        Uint32 *dst = (Uint32 *)data->dst;
 12.3592 +        int n = data->dst_w;
 12.3593 +        while (n--) {
 12.3594 +            srcpixel = *src;
 12.3595 +            srcA = (Uint8)(srcpixel >> 24); srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel;
 12.3596 +            dstpixel = *dst;
 12.3597 +            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
 12.3598 +            if (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD)) {
 12.3599 +                /* This goes away if we ever use premultiplied alpha */
 12.3600 +                srcR = (srcR * srcA) / 255;
 12.3601 +                srcG = (srcG * srcA) / 255;
 12.3602 +                srcB = (srcB * srcA) / 255;
 12.3603 +            }
 12.3604 +            switch (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD|SDL_RENDERCOPY_MOD)) {
 12.3605 +            case SDL_RENDERCOPY_BLEND:
 12.3606 +                dstR = srcR + ((255 - srcA) * dstR) / 255;
 12.3607 +                dstG = srcG + ((255 - srcA) * dstG) / 255;
 12.3608 +                dstB = srcB + ((255 - srcA) * dstB) / 255;
 12.3609 +                break;
 12.3610 +            case SDL_RENDERCOPY_ADD:
 12.3611 +                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
 12.3612 +                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
 12.3613 +                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
 12.3614 +                break;
 12.3615 +            case SDL_RENDERCOPY_MOD:
 12.3616 +                dstR = (srcR * dstR) / 255;
 12.3617 +                dstG = (srcG * dstG) / 255;
 12.3618 +                dstB = (srcB * dstB) / 255;
 12.3619 +                break;
 12.3620 +            }
 12.3621 +            dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
 12.3622 +            *dst = dstpixel;
 12.3623 +            ++src;
 12.3624 +            ++dst;
 12.3625 +        }
 12.3626 +        data->src += data->src_pitch;
 12.3627 +        data->dst += data->dst_pitch;
 12.3628 +    }
 12.3629 +    return 0;
 12.3630 +}
 12.3631 +
 12.3632 +int SDL_RenderCopy_ABGR8888_RGB888_Blend_Scale(SDL_RenderCopyData *data)
 12.3633 +{
 12.3634 +    const int flags = data->flags;
 12.3635 +    Uint32 srcpixel;
 12.3636 +    Uint32 srcR, srcG, srcB, srcA;
 12.3637 +    Uint32 dstpixel;
 12.3638 +    Uint32 dstR, dstG, dstB, dstA;
 12.3639 +    int srcy, srcx;
 12.3640 +    int posy, posx;
 12.3641 +    int incy, incx;
 12.3642 +
 12.3643 +    srcy = 0;
 12.3644 +    posy = 0;
 12.3645 +    incy = (data->src_h << 16) / data->dst_h;
 12.3646 +    incx = (data->src_w << 16) / data->dst_w;
 12.3647 +
 12.3648 +    while (data->dst_h--) {
 12.3649 +        Uint32 *src;
 12.3650 +        Uint32 *dst = (Uint32 *)data->dst;
 12.3651 +        int n = data->dst_w;
 12.3652 +        srcx = -1;
 12.3653 +        posx = 0x10000L;
 12.3654 +        while (posy >= 0x10000L) {
 12.3655 +            ++srcy;
 12.3656 +            posy -= 0x10000L;
 12.3657 +        }
 12.3658 +        while (n--) {
 12.3659 +            if (posx >= 0x10000L) {
 12.3660 +                while (posx >= 0x10000L) {
 12.3661 +                    ++srcx;
 12.3662 +                    posx -= 0x10000L;
 12.3663 +                }
 12.3664 +                src = (Uint32 *)(data->src + (srcy * data->src_pitch) + (srcx * 4));
 12.3665 +            }
 12.3666 +            srcpixel = *src;
 12.3667 +            srcA = (Uint8)(srcpixel >> 24); srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel;
 12.3668 +            dstpixel = *dst;
 12.3669 +            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
 12.3670 +            if (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD)) {
 12.3671 +                /* This goes away if we ever use premultiplied alpha */
 12.3672 +                srcR = (srcR * srcA) / 255;
 12.3673 +                srcG = (srcG * srcA) / 255;
 12.3674 +                srcB = (srcB * srcA) / 255;
 12.3675 +            }
 12.3676 +            switch (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD|SDL_RENDERCOPY_MOD)) {
 12.3677 +            case SDL_RENDERCOPY_BLEND:
 12.3678 +                dstR = srcR + ((255 - srcA) * dstR) / 255;
 12.3679 +                dstG = srcG + ((255 - srcA) * dstG) / 255;
 12.3680 +                dstB = srcB + ((255 - srcA) * dstB) / 255;
 12.3681 +                break;
 12.3682 +            case SDL_RENDERCOPY_ADD:
 12.3683 +                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
 12.3684 +                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
 12.3685 +                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
 12.3686 +                break;
 12.3687 +            case SDL_RENDERCOPY_MOD:
 12.3688 +                dstR = (srcR * dstR) / 255;
 12.3689 +                dstG = (srcG * dstG) / 255;
 12.3690 +                dstB = (srcB * dstB) / 255;
 12.3691 +                break;
 12.3692 +            }
 12.3693 +            dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
 12.3694 +            *dst = dstpixel;
 12.3695 +            posx += incx;
 12.3696 +            ++dst;
 12.3697 +        }
 12.3698 +        posy += incy;
 12.3699 +        data->dst += data->dst_pitch;
 12.3700 +    }
 12.3701 +    return 0;
 12.3702 +}
 12.3703 +
 12.3704 +int SDL_RenderCopy_ABGR8888_RGB888_Modulate(SDL_RenderCopyData *data)
 12.3705 +{
 12.3706 +    const int flags = data->flags;
 12.3707 +    const Uint32 modulateR = data->r;
 12.3708 +    const Uint32 modulateG = data->g;
 12.3709 +    const Uint32 modulateB = data->b;
 12.3710 +    const Uint32 modulateA = data->a;
 12.3711 +    Uint32 pixel;
 12.3712 +    Uint32 R, G, B, A;
 12.3713 +
 12.3714 +    while (data->dst_h--) {
 12.3715 +        Uint32 *src = (Uint32 *)data->src;
 12.3716 +        Uint32 *dst = (Uint32 *)data->dst;
 12.3717 +        int n = data->dst_w;
 12.3718 +        while (n--) {
 12.3719 +            pixel = *src;
 12.3720 +            A = (Uint8)(pixel >> 24); B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel;
 12.3721 +            if (flags & SDL_RENDERCOPY_MODULATE_COLOR) {
 12.3722 +                R = (R * modulateR) / 255;
 12.3723 +                G = (G * modulateG) / 255;
 12.3724 +                B = (B * modulateB) / 255;
 12.3725 +            }
 12.3726 +            pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B;
 12.3727 +            *dst = pixel;
 12.3728 +            ++src;
 12.3729 +            ++dst;
 12.3730 +        }
 12.3731 +        data->src += data->src_pitch;
 12.3732 +        data->dst += data->dst_pitch;
 12.3733 +    }
 12.3734 +    return 0;
 12.3735 +}
 12.3736 +
 12.3737 +int SDL_RenderCopy_ABGR8888_RGB888_Modulate_Scale(SDL_RenderCopyData *data)
 12.3738 +{
 12.3739 +    const int flags = data->flags;
 12.3740 +    const Uint32 modulateR = data->r;
 12.3741 +    const Uint32 modulateG = data->g;
 12.3742 +    const Uint32 modulateB = data->b;
 12.3743 +    const Uint32 modulateA = data->a;
 12.3744 +    Uint32 pixel;
 12.3745 +    Uint32 R, G, B, A;
 12.3746 +    int srcy, srcx;
 12.3747 +    int posy, posx;
 12.3748 +    int incy, incx;
 12.3749 +
 12.3750 +    srcy = 0;
 12.3751 +    posy = 0;
 12.3752 +    incy = (data->src_h << 16) / data->dst_h;
 12.3753 +    incx = (data->src_w << 16) / data->dst_w;
 12.3754 +
 12.3755 +    while (data->dst_h--) {
 12.3756 +        Uint32 *src;
 12.3757 +        Uint32 *dst = (Uint32 *)data->dst;
 12.3758 +        int n = data->dst_w;
 12.3759 +        srcx = -1;
 12.3760 +        posx = 0x10000L;
 12.3761 +        while (posy >= 0x10000L) {
 12.3762 +            ++srcy;
 12.3763 +            posy -= 0x10000L;
 12.3764 +        }
 12.3765 +        while (n--) {
 12.3766 +            if (posx >= 0x10000L) {
 12.3767 +                while (posx >= 0x10000L) {
 12.3768 +                    ++srcx;
 12.3769 +                    posx -= 0x10000L;
 12.3770 +                }
 12.3771 +                src = (Uint32 *)(data->src + (srcy * data->src_pitch) + (srcx * 4));
 12.3772 +            }
 12.3773 +            pixel = *src;
 12.3774 +            A = (Uint8)(pixel >> 24); B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel;
 12.3775 +            if (flags & SDL_RENDERCOPY_MODULATE_COLOR) {
 12.3776 +                R = (R * modulateR) / 255;
 12.3777 +                G = (G * modulateG) / 255;
 12.3778 +                B = (B * modulateB) / 255;
 12.3779 +            }
 12.3780 +            pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B;
 12.3781 +            *dst = pixel;
 12.3782 +            posx += incx;
 12.3783 +            ++dst;
 12.3784 +        }
 12.3785 +        posy += incy;
 12.3786 +        data->dst += data->dst_pitch;
 12.3787 +    }
 12.3788 +    return 0;
 12.3789 +}
 12.3790 +
 12.3791 +int SDL_RenderCopy_ABGR8888_RGB888_Modulate_Blend(SDL_RenderCopyData *data)
 12.3792 +{
 12.3793 +    const int flags = data->flags;
 12.3794 +    const Uint32 modulateR = data->r;
 12.3795 +    const Uint32 modulateG = data->g;
 12.3796 +    const Uint32 modulateB = data->b;
 12.3797 +    const Uint32 modulateA = data->a;
 12.3798 +    Uint32 srcpixel;
 12.3799 +    Uint32 srcR, srcG, srcB, srcA;
 12.3800 +    Uint32 dstpixel;
 12.3801 +    Uint32 dstR, dstG, dstB, dstA;
 12.3802 +
 12.3803 +    while (data->dst_h--) {
 12.3804 +        Uint32 *src = (Uint32 *)data->src;
 12.3805 +        Uint32 *dst = (Uint32 *)data->dst;
 12.3806 +        int n = data->dst_w;
 12.3807 +        while (n--) {
 12.3808 +            srcpixel = *src;
 12.3809 +            srcA = (Uint8)(srcpixel >> 24); srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel;
 12.3810 +            dstpixel = *dst;
 12.3811 +            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
 12.3812 +            if (flags & SDL_RENDERCOPY_MODULATE_COLOR) {
 12.3813 +                srcR = (srcR * modulateR) / 255;
 12.3814 +                srcG = (srcG * modulateG) / 255;
 12.3815 +                srcB = (srcB * modulateB) / 255;
 12.3816 +            }
 12.3817 +            if (flags & SDL_RENDERCOPY_MODULATE_ALPHA) {
 12.3818 +                srcA = (srcA * modulateA) / 255;
 12.3819 +            }
 12.3820 +            if (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD)) {
 12.3821 +                /* This goes away if we ever use premultiplied alpha */
 12.3822 +                srcR = (srcR * srcA) / 255;
 12.3823 +                srcG = (srcG * srcA) / 255;
 12.3824 +                srcB = (srcB * srcA) / 255;
 12.3825 +            }
 12.3826 +            switch (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD|SDL_RENDERCOPY_MOD)) {
 12.3827 +            case SDL_RENDERCOPY_BLEND:
 12.3828 +                dstR = srcR + ((255 - srcA) * dstR) / 255;
 12.3829 +                dstG = srcG + ((255 - srcA) * dstG) / 255;
 12.3830 +                dstB = srcB + ((255 - srcA) * dstB) / 255;
 12.3831 +                break;
 12.3832 +            case SDL_RENDERCOPY_ADD:
 12.3833 +                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
 12.3834 +                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
 12.3835 +                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
 12.3836 +                break;
 12.3837 +            case SDL_RENDERCOPY_MOD:
 12.3838 +                dstR = (srcR * dstR) / 255;
 12.3839 +                dstG = (srcG * dstG) / 255;
 12.3840 +                dstB = (srcB * dstB) / 255;
 12.3841 +                break;
 12.3842 +            }
 12.3843 +            dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
 12.3844 +            *dst = dstpixel;
 12.3845 +            ++src;
 12.3846 +            ++dst;
 12.3847 +        }
 12.3848 +        data->src += data->src_pitch;
 12.3849 +        data->dst += data->dst_pitch;
 12.3850 +    }
 12.3851 +    return 0;
 12.3852 +}
 12.3853 +
 12.3854 +int SDL_RenderCopy_ABGR8888_RGB888_Modulate_Blend_Scale(SDL_RenderCopyData *data)
 12.3855 +{
 12.3856 +    const int flags = data->flags;
 12.3857 +    const Uint32 modulateR = data->r;
 12.3858 +    const Uint32 modulateG = data->g;
 12.3859 +    const Uint32 modulateB = data->b;
 12.3860 +    const Uint32 modulateA = data->a;
 12.3861 +    Uint32 srcpixel;
 12.3862 +    Uint32 srcR, srcG, srcB, srcA;
 12.3863 +    Uint32 dstpixel;
 12.3864 +    Uint32 dstR, dstG, dstB, dstA;
 12.3865 +    int srcy, srcx;
 12.3866 +    int posy, posx;
 12.3867 +    int incy, incx;
 12.3868 +
 12.3869 +    srcy = 0;
 12.3870 +    posy = 0;
 12.3871 +    incy = (data->src_h << 16) / data->dst_h;
 12.3872 +    incx = (data->src_w << 16) / data->dst_w;
 12.3873 +
 12.3874 +    while (data->dst_h--) {
 12.3875 +        Uint32 *src;
 12.3876 +        Uint32 *dst = (Uint32 *)data->dst;
 12.3877 +        int n = data->dst_w;
 12.3878 +        srcx = -1;
 12.3879 +        posx = 0x10000L;
 12.3880 +        while (posy >= 0x10000L) {
 12.3881 +            ++srcy;
 12.3882 +            posy -= 0x10000L;
 12.3883 +        }
 12.3884 +        while (n--) {
 12.3885 +            if (posx >= 0x10000L) {
 12.3886 +                while (posx >= 0x10000L) {
 12.3887 +                    ++srcx;
 12.3888 +                    posx -= 0x10000L;
 12.3889 +                }
 12.3890 +                src = (Uint32 *)(data->src + (srcy * data->src_pitch) + (srcx * 4));
 12.3891 +            }
 12.3892 +            srcpixel = *src;
 12.3893 +            srcA = (Uint8)(srcpixel >> 24); srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel;
 12.3894 +            dstpixel = *dst;
 12.3895 +            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
 12.3896 +            if (flags & SDL_RENDERCOPY_MODULATE_COLOR) {
 12.3897 +                srcR = (srcR * modulateR) / 255;
 12.3898 +                srcG = (srcG * modulateG) / 255;
 12.3899 +                srcB = (srcB * modulateB) / 255;
 12.3900 +            }
 12.3901 +            if (flags & SDL_RENDERCOPY_MODULATE_ALPHA) {
 12.3902 +                srcA = (srcA * modulateA) / 255;
 12.3903 +            }
 12.3904 +            if (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD)) {
 12.3905 +                /* This goes away if we ever use premultiplied alpha */
 12.3906 +                srcR = (srcR * srcA) / 255;
 12.3907 +                srcG = (srcG * srcA) / 255;
 12.3908 +                srcB = (srcB * srcA) / 255;
 12.3909 +            }
 12.3910 +            switch (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD|SDL_RENDERCOPY_MOD)) {
 12.3911 +            case SDL_RENDERCOPY_BLEND:
 12.3912 +                dstR = srcR + ((255 - srcA) * dstR) / 255;
 12.3913 +                dstG = srcG + ((255 - srcA) * dstG) / 255;
 12.3914 +                dstB = srcB + ((255 - srcA) * dstB) / 255;
 12.3915 +                break;
 12.3916 +            case SDL_RENDERCOPY_ADD:
 12.3917 +                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
 12.3918 +                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
 12.3919 +                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
 12.3920 +                break;
 12.3921 +            case SDL_RENDERCOPY_MOD:
 12.3922 +                dstR = (srcR * dstR) / 255;
 12.3923 +                dstG = (srcG * dstG) / 255;
 12.3924 +                dstB = (srcB * dstB) / 255;
 12.3925 +                break;
 12.3926 +            }
 12.3927 +            dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
 12.3928 +            *dst = dstpixel;
 12.3929 +            posx += incx;
 12.3930 +            ++dst;
 12.3931 +        }
 12.3932 +        posy += incy;
 12.3933 +        data->dst += data->dst_pitch;
 12.3934 +    }
 12.3935 +    return 0;
 12.3936 +}
 12.3937 +
 12.3938 +int SDL_RenderCopy_ABGR8888_BGR888(SDL_RenderCopyData *data)
 12.3939 +{
 12.3940 +    const int flags = data->flags;
 12.3941 +    Uint32 pixel;
 12.3942 +    Uint32 R, G, B, A;
 12.3943 +
 12.3944 +    while (data->dst_h--) {
 12.3945 +        Uint32 *src = (Uint32 *)data->src;
 12.3946 +        Uint32 *dst = (Uint32 *)data->dst;
 12.3947 +        int n = data->dst_w;
 12.3948 +        while (n--) {
 12.3949 +            pixel = *src;
 12.3950 +            A = (Uint8)(pixel >> 24); B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel;
 12.3951 +            pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R;
 12.3952 +            *dst = pixel;
 12.3953 +            ++src;
 12.3954 +            ++dst;
 12.3955 +        }
 12.3956 +        data->src += data->src_pitch;
 12.3957 +        data->dst += data->dst_pitch;
 12.3958 +    }
 12.3959 +    return 0;
 12.3960 +}
 12.3961 +
 12.3962 +int SDL_RenderCopy_ABGR8888_BGR888_Scale(SDL_RenderCopyData *data)
 12.3963 +{
 12.3964 +    const int flags = data->flags;
 12.3965 +    Uint32 pixel;
 12.3966 +    Uint32 R, G, B, A;
 12.3967 +    int srcy, srcx;
 12.3968 +    int posy, posx;
 12.3969 +    int incy, incx;
 12.3970 +
 12.3971 +    srcy = 0;
 12.3972 +    posy = 0;
 12.3973 +    incy = (data->src_h << 16) / data->dst_h;
 12.3974 +    incx = (data->src_w << 16) / data->dst_w;
 12.3975 +
 12.3976 +    while (data->dst_h--) {
 12.3977 +        Uint32 *src;
 12.3978 +        Uint32 *dst = (Uint32 *)data->dst;
 12.3979 +        int n = data->dst_w;
 12.3980 +        srcx = -1;
 12.3981 +        posx = 0x10000L;
 12.3982 +        while (posy >= 0x10000L) {
 12.3983 +            ++srcy;
 12.3984 +            posy -= 0x10000L;
 12.3985 +        }
 12.3986 +        while (n--) {
 12.3987 +            if (posx >= 0x10000L) {
 12.3988 +                while (posx >= 0x10000L) {
 12.3989 +                    ++srcx;
 12.3990 +                    posx -= 0x10000L;
 12.3991 +                }
 12.3992 +                src = (Uint32 *)(data->src + (srcy * data->src_pitch) + (srcx * 4));
 12.3993 +            }
 12.3994 +            pixel = *src;
 12.3995 +            A = (Uint8)(pixel >> 24); B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel;
 12.3996 +            pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R;
 12.3997 +            *dst = pixel;
 12.3998 +            posx += incx;
 12.3999 +            ++dst;
 12.4000 +        }
 12.4001 +        posy += incy;
 12.4002 +        data->dst += data->dst_pitch;
 12.4003 +    }
 12.4004 +    return 0;
 12.4005 +}
 12.4006 +
 12.4007 +int SDL_RenderCopy_ABGR8888_BGR888_Blend(SDL_RenderCopyData *data)
 12.4008 +{
 12.4009 +    const int flags = data->flags;
 12.4010 +    Uint32 srcpixel;
 12.4011 +    Uint32 srcR, srcG, srcB, srcA;
 12.4012 +    Uint32 dstpixel;
 12.4013 +    Uint32 dstR, dstG, dstB, dstA;
 12.4014 +
 12.4015 +    while (data->dst_h--) {
 12.4016 +        Uint32 *src = (Uint32 *)data->src;
 12.4017 +        Uint32 *dst = (Uint32 *)data->dst;
 12.4018 +        int n = data->dst_w;
 12.4019 +        while (n--) {
 12.4020 +            srcpixel = *src;
 12.4021 +            srcA = (Uint8)(srcpixel >> 24); srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel;
 12.4022 +            dstpixel = *dst;
 12.4023 +            dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
 12.4024 +            if (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD)) {
 12.4025 +                /* This goes away if we ever use premultiplied alpha */
 12.4026 +                srcR = (srcR * srcA) / 255;
 12.4027 +                srcG = (srcG * srcA) / 255;
 12.4028 +                srcB = (srcB * srcA) / 255;
 12.4029 +            }
 12.4030 +            switch (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD|SDL_RENDERCOPY_MOD)) {
 12.4031 +            case SDL_RENDERCOPY_BLEND:
 12.4032 +                dstR = srcR + ((255 - srcA) * dstR) / 255;
 12.4033 +                dstG = srcG + ((255 - srcA) * dstG) / 255;
 12.4034 +                dstB = srcB + ((255 - srcA) * dstB) / 255;
 12.4035 +                break;
 12.4036 +            case SDL_RENDERCOPY_ADD:
 12.4037 +                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
 12.4038 +                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
 12.4039 +                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
 12.4040 +                break;
 12.4041 +            case SDL_RENDERCOPY_MOD:
 12.4042 +                dstR = (srcR * dstR) / 255;
 12.4043 +                dstG = (srcG * dstG) / 255;
 12.4044 +                dstB = (srcB * dstB) / 255;
 12.4045 +                break;
 12.4046 +            }
 12.4047 +            dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
 12.4048 +            *dst = dstpixel;
 12.4049 +            ++src;
 12.4050 +            ++dst;
 12.4051 +        }
 12.4052 +        data->src += data->src_pitch;
 12.4053 +        data->dst += data->dst_pitch;
 12.4054 +    }
 12.4055 +    return 0;
 12.4056 +}
 12.4057 +
 12.4058 +int SDL_RenderCopy_ABGR8888_BGR888_Blend_Scale(SDL_RenderCopyData *data)
 12.4059 +{
 12.4060 +    const int flags = data->flags;
 12.4061 +    Uint32 srcpixel;
 12.4062 +    Uint32 srcR, srcG, srcB, srcA;
 12.4063 +    Uint32 dstpixel;
 12.4064 +    Uint32 dstR, dstG, dstB, dstA;
 12.4065 +    int srcy, srcx;
 12.4066 +    int posy, posx;
 12.4067 +    int incy, incx;
 12.4068 +
 12.4069 +    srcy = 0;
 12.4070 +    posy = 0;
 12.4071 +    incy = (data->src_h << 16) / data->dst_h;
 12.4072 +    incx = (data->src_w << 16) / data->dst_w;
 12.4073 +
 12.4074 +    while (data->dst_h--) {
 12.4075 +        Uint32 *src;
 12.4076 +        Uint32 *dst = (Uint32 *)data->dst;
 12.4077 +        int n = data->dst_w;
 12.4078 +        srcx = -1;
 12.4079 +        posx = 0x10000L;
 12.4080 +        while (posy >= 0x10000L) {
 12.4081 +            ++srcy;
 12.4082 +            posy -= 0x10000L;
 12.4083 +        }
 12.4084 +        while (n--) {
 12.4085 +            if (posx >= 0x10000L) {
 12.4086 +                while (posx >= 0x10000L) {
 12.4087 +                    ++srcx;
 12.4088 +                    posx -= 0x10000L;
 12.4089 +                }
 12.4090 +                src = (Uint32 *)(data->src + (srcy * data->src_pitch) + (srcx * 4));
 12.4091 +            }
 12.4092 +            srcpixel = *src;
 12.4093 +            srcA = (Uint8)(srcpixel >> 24); srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel;
 12.4094 +            dstpixel = *dst;
 12.4095 +            dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
 12.4096 +            if (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD)) {
 12.4097 +                /* This goes away if we ever use premultiplied alpha */
 12.4098 +                srcR = (srcR * srcA) / 255;
 12.4099 +                srcG = (srcG * srcA) / 255;
 12.4100 +                srcB = (srcB * srcA) / 255;
 12.4101 +            }
 12.4102 +            switch (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD|SDL_RENDERCOPY_MOD)) {
 12.4103 +            case SDL_RENDERCOPY_BLEND:
 12.4104 +                dstR = srcR + ((255 - srcA) * dstR) / 255;
 12.4105 +                dstG = srcG + ((255 - srcA) * dstG) / 255;
 12.4106 +                dstB = srcB + ((255 - srcA) * dstB) / 255;
 12.4107 +                break;
 12.4108 +            case SDL_RENDERCOPY_ADD:
 12.4109 +                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
 12.4110 +                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
 12.4111 +                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
 12.4112 +                break;
 12.4113 +            case SDL_RENDERCOPY_MOD:
 12.4114 +                dstR = (srcR * dstR) / 255;
 12.4115 +                dstG = (srcG * dstG) / 255;
 12.4116 +                dstB = (srcB * dstB) / 255;
 12.4117 +                break;
 12.4118 +            }
 12.4119 +            dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
 12.4120 +            *dst = dstpixel;
 12.4121 +            posx += incx;
 12.4122 +            ++dst;
 12.4123 +        }
 12.4124 +        posy += incy;
 12.4125 +        data->dst += data->dst_pitch;
 12.4126 +    }
 12.4127 +    return 0;
 12.4128 +}
 12.4129 +
 12.4130 +int SDL_RenderCopy_ABGR8888_BGR888_Modulate(SDL_RenderCopyData *data)
 12.4131 +{
 12.4132 +    const int flags = data->flags;
 12.4133 +    const Uint32 modulateR = data->r;
 12.4134 +    const Uint32 modulateG = data->g;
 12.4135 +    const Uint32 modulateB = data->b;
 12.4136 +    const Uint32 modulateA = data->a;
 12.4137 +    Uint32 pixel;
 12.4138 +    Uint32 R, G, B, A;
 12.4139 +
 12.4140 +    while (data->dst_h--) {
 12.4141 +        Uint32 *src = (Uint32 *)data->src;
 12.4142 +        Uint32 *dst = (Uint32 *)data->dst;
 12.4143 +        int n = data->dst_w;
 12.4144 +        while (n--) {
 12.4145 +            pixel = *src;
 12.4146 +            A = (Uint8)(pixel >> 24); B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel;
 12.4147 +            if (flags & SDL_RENDERCOPY_MODULATE_COLOR) {
 12.4148 +                R = (R * modulateR) / 255;
 12.4149 +                G = (G * modulateG) / 255;
 12.4150 +                B = (B * modulateB) / 255;
 12.4151 +            }
 12.4152 +            pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R;
 12.4153 +            *dst = pixel;
 12.4154 +            ++src;
 12.4155 +            ++dst;
 12.4156 +        }
 12.4157 +        data->src += data->src_pitch;
 12.4158 +        data->dst += data->dst_pitch;
 12.4159 +    }
 12.4160 +    return 0;
 12.4161 +}
 12.4162 +
 12.4163 +int SDL_RenderCopy_ABGR8888_BGR888_Modulate_Scale(SDL_RenderCopyData *data)
 12.4164 +{
 12.4165 +    const int flags = data->flags;
 12.4166 +    const Uint32 modulateR = data->r;
 12.4167 +    const Uint32 modulateG = data->g;
 12.4168 +    const Uint32 modulateB = data->b;
 12.4169 +    const Uint32 modulateA = data->a;
 12.4170 +    Uint32 pixel;
 12.4171 +    Uint32 R, G, B, A;
 12.4172 +    int srcy, srcx;
 12.4173 +    int posy, posx;
 12.4174 +    int incy, incx;
 12.4175 +
 12.4176 +    srcy = 0;
 12.4177 +    posy = 0;
 12.4178 +    incy = (data->src_h << 16) / data->dst_h;
 12.4179 +    incx = (data->src_w << 16) / data->dst_w;
 12.4180 +
 12.4181 +    while (data->dst_h--) {
 12.4182 +        Uint32 *src;
 12.4183 +        Uint32 *dst = (Uint32 *)data->dst;
 12.4184 +        int n = data->dst_w;
 12.4185 +        srcx = -1;
 12.4186 +        posx = 0x10000L;
 12.4187 +        while (posy >= 0x10000L) {
 12.4188 +            ++srcy;
 12.4189 +            posy -= 0x10000L;
 12.4190 +        }
 12.4191 +        while (n--) {
 12.4192 +            if (posx >= 0x10000L) {
 12.4193 +                while (posx >= 0x10000L) {
 12.4194 +                    ++srcx;
 12.4195 +                    posx -= 0x10000L;
 12.4196 +                }
 12.4197 +                src = (Uint32 *)(data->src + (srcy * data->src_pitch) + (srcx * 4));
 12.4198 +            }
 12.4199 +            pixel = *src;
 12.4200 +            A = (Uint8)(pixel >> 24); B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel;
 12.4201 +            if (flags & SDL_RENDERCOPY_MODULATE_COLOR) {
 12.4202 +                R = (R * modulateR) / 255;
 12.4203 +                G = (G * modulateG) / 255;
 12.4204 +                B = (B * modulateB) / 255;
 12.4205 +            }
 12.4206 +            pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R;
 12.4207 +            *dst = pixel;
 12.4208 +            posx += incx;
 12.4209 +            ++dst;
 12.4210 +        }
 12.4211 +        posy += incy;
 12.4212 +        data->dst += data->dst_pitch;
 12.4213 +    }
 12.4214 +    return 0;
 12.4215 +}
 12.4216 +
 12.4217 +int SDL_RenderCopy_ABGR8888_BGR888_Modulate_Blend(SDL_RenderCopyData *data)
 12.4218 +{
 12.4219 +    const int flags = data->flags;
 12.4220 +    const Uint32 modulateR = data->r;
 12.4221 +    const Uint32 modulateG = data->g;
 12.4222 +    const Uint32 modulateB = data->b;
 12.4223 +    const Uint32 modulateA = data->a;
 12.4224 +    Uint32 srcpixel;
 12.4225 +    Uint32 srcR, srcG, srcB, srcA;
 12.4226 +    Uint32 dstpixel;
 12.4227 +    Uint32 dstR, dstG, dstB, dstA;
 12.4228 +
 12.4229 +    while (data->dst_h--) {
 12.4230 +        Uint32 *src = (Uint32 *)data->src;
 12.4231 +        Uint32 *dst = (Uint32 *)data->dst;
 12.4232 +        int n = data->dst_w;
 12.4233 +        while (n--) {
 12.4234 +            srcpixel = *src;
 12.4235 +            srcA = (Uint8)(srcpixel >> 24); srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel;
 12.4236 +            dstpixel = *dst;
 12.4237 +            dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
 12.4238 +            if (flags & SDL_RENDERCOPY_MODULATE_COLOR) {
 12.4239 +                srcR = (srcR * modulateR) / 255;
 12.4240 +                srcG = (srcG * modulateG) / 255;
 12.4241 +                srcB = (srcB * modulateB) / 255;
 12.4242 +            }
 12.4243 +            if (flags & SDL_RENDERCOPY_MODULATE_ALPHA) {
 12.4244 +                srcA = (srcA * modulateA) / 255;
 12.4245 +            }
 12.4246 +            if (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD)) {
 12.4247 +                /* This goes away if we ever use premultiplied alpha */
 12.4248 +                srcR = (srcR * srcA) / 255;
 12.4249 +                srcG = (srcG * srcA) / 255;
 12.4250 +                srcB = (srcB * srcA) / 255;
 12.4251 +            }
 12.4252 +            switch (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD|SDL_RENDERCOPY_MOD)) {
 12.4253 +            case SDL_RENDERCOPY_BLEND:
 12.4254 +                dstR = srcR + ((255 - srcA) * dstR) / 255;
 12.4255 +                dstG = srcG + ((255 - srcA) * dstG) / 255;
 12.4256 +                dstB = srcB + ((255 - srcA) * dstB) / 255;
 12.4257 +                break;
 12.4258 +            case SDL_RENDERCOPY_ADD:
 12.4259 +                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
 12.4260 +                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
 12.4261 +                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
 12.4262 +                break;
 12.4263 +            case SDL_RENDERCOPY_MOD:
 12.4264 +                dstR = (srcR * dstR) / 255;
 12.4265 +                dstG = (srcG * dstG) / 255;
 12.4266 +                dstB = (srcB * dstB) / 255;
 12.4267 +                break;
 12.4268 +            }
 12.4269 +            dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
 12.4270 +            *dst = dstpixel;
 12.4271 +            ++src;
 12.4272 +            ++dst;
 12.4273 +        }
 12.4274 +        data->src += data->src_pitch;
 12.4275 +        data->dst += data->dst_pitch;
 12.4276 +    }
 12.4277 +    return 0;
 12.4278 +}
 12.4279 +
 12.4280 +int SDL_RenderCopy_ABGR8888_BGR888_Modulate_Blend_Scale(SDL_RenderCopyData *data)
 12.4281 +{
 12.4282 +    const int flags = data->flags;
 12.4283 +    const Uint32 modulateR = data->r;
 12.4284 +    const Uint32 modulateG = data->g;
 12.4285 +    const Uint32 modulateB = data->b;
 12.4286 +    const Uint32 modulateA = data->a;
 12.4287 +    Uint32 srcpixel;
 12.4288 +    Uint32 srcR, srcG, srcB, srcA;
 12.4289 +    Uint32 dstpixel;
 12.4290 +    Uint32 dstR, dstG, dstB, dstA;
 12.4291 +    int srcy, srcx;
 12.4292 +    int posy, posx;
 12.4293 +    int incy, incx;
 12.4294 +
 12.4295 +    srcy = 0;
 12.4296 +    posy = 0;
 12.4297 +    incy = (data->src_h << 16) / data->dst_h;
 12.4298 +    incx = (data->src_w << 16) / data->dst_w;
 12.4299 +
 12.4300 +    while (data->dst_h--) {
 12.4301 +        Uint32 *src;
 12.4302 +        Uint32 *dst = (Uint32 *)data->dst;
 12.4303 +        int n = data->dst_w;
 12.4304 +        srcx = -1;
 12.4305 +        posx = 0x10000L;
 12.4306 +        while (posy >= 0x10000L) {
 12.4307 +            ++srcy;
 12.4308 +            posy -= 0x10000L;
 12.4309 +        }
 12.4310 +        while (n--) {
 12.4311 +            if (posx >= 0x10000L) {
 12.4312 +                while (posx >= 0x10000L) {
 12.4313 +                    ++srcx;
 12.4314 +                    posx -= 0x10000L;
 12.4315 +                }
 12.4316 +                src = (Uint32 *)(data->src + (srcy * data->src_pitch) + (srcx * 4));
 12.4317 +            }
 12.4318 +            srcpixel = *src;
 12.4319 +            srcA = (Uint8)(srcpixel >> 24); srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel;
 12.4320 +            dstpixel = *dst;
 12.4321 +            dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
 12.4322 +            if (flags & SDL_RENDERCOPY_MODULATE_COLOR) {
 12.4323 +                srcR = (srcR * modulateR) / 255;
 12.4324 +                srcG = (srcG * modulateG) / 255;
 12.4325 +                srcB = (srcB * modulateB) / 255;
 12.4326 +            }
 12.4327 +            if (flags & SDL_RENDERCOPY_MODULATE_ALPHA) {
 12.4328 +                srcA = (srcA * modulateA) / 255;
 12.4329 +            }
 12.4330 +            if (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD)) {
 12.4331 +                /* This goes away if we ever use premultiplied alpha */
 12.4332 +                srcR = (srcR * srcA) / 255;
 12.4333 +                srcG = (srcG * srcA) / 255;
 12.4334 +                srcB = (srcB * srcA) / 255;
 12.4335 +            }
 12.4336 +            switch (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD|SDL_RENDERCOPY_MOD)) {
 12.4337 +            case SDL_RENDERCOPY_BLEND:
 12.4338 +                dstR = srcR + ((255 - srcA) * dstR) / 255;
 12.4339 +                dstG = srcG + ((255 - srcA) * dstG) / 255;
 12.4340 +                dstB = srcB + ((255 - srcA) * dstB) / 255;
 12.4341 +                break;
 12.4342 +            case SDL_RENDERCOPY_ADD:
 12.4343 +                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
 12.4344 +                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
 12.4345 +                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
 12.4346 +                break;
 12.4347 +            case SDL_RENDERCOPY_MOD:
 12.4348 +                dstR = (srcR * dstR) / 255;
 12.4349 +                dstG = (srcG * dstG) / 255;
 12.4350 +                dstB = (srcB * dstB) / 255;
 12.4351 +                break;
 12.4352 +            }
 12.4353 +            dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
 12.4354 +            *dst = dstpixel;
 12.4355 +            posx += incx;
 12.4356 +            ++dst;
 12.4357 +        }
 12.4358 +        posy += incy;
 12.4359 +        data->dst += data->dst_pitch;
 12.4360 +    }
 12.4361 +    return 0;
 12.4362 +}
 12.4363 +
 12.4364 +int SDL_RenderCopy_BGRA8888_RGB888(SDL_RenderCopyData *data)
 12.4365 +{
 12.4366 +    const int flags = data->flags;
 12.4367 +    Uint32 pixel;
 12.4368 +    Uint32 R, G, B, A;
 12.4369 +
 12.4370 +    while (data->dst_h--) {
 12.4371 +        Uint32 *src = (Uint32 *)data->src;
 12.4372 +        Uint32 *dst = (Uint32 *)data->dst;
 12.4373 +        int n = data->dst_w;
 12.4374 +        while (n--) {
 12.4375 +            pixel = *src;
 12.4376 +            B = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); R = (Uint8)(pixel >> 8); A = (Uint8)pixel;
 12.4377 +            pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B;
 12.4378 +            *dst = pixel;
 12.4379 +            ++src;
 12.4380 +            ++dst;
 12.4381 +        }
 12.4382 +        data->src += data->src_pitch;
 12.4383 +        data->dst += data->dst_pitch;
 12.4384 +    }
 12.4385 +    return 0;
 12.4386 +}
 12.4387 +
 12.4388 +int SDL_RenderCopy_BGRA8888_RGB888_Scale(SDL_RenderCopyData *data)
 12.4389 +{
 12.4390 +    const int flags = data->flags;
 12.4391 +    Uint32 pixel;
 12.4392 +    Uint32 R, G, B, A;
 12.4393 +    int srcy, srcx;
 12.4394 +    int posy, posx;
 12.4395 +    int incy, incx;
 12.4396 +
 12.4397 +    srcy = 0;
 12.4398 +    posy = 0;
 12.4399 +    incy = (data->src_h << 16) / data->dst_h;
 12.4400 +    incx = (data->src_w << 16) / data->dst_w;
 12.4401 +
 12.4402 +    while (data->dst_h--) {
 12.4403 +        Uint32 *src;
 12.4404 +        Uint32 *dst = (Uint32 *)data->dst;
 12.4405 +        int n = data->dst_w;
 12.4406 +        srcx = -1;
 12.4407 +        posx = 0x10000L;
 12.4408 +        while (posy >= 0x10000L) {
 12.4409 +            ++srcy;
 12.4410 +            posy -= 0x10000L;
 12.4411 +        }
 12.4412 +        while (n--) {
 12.4413 +            if (posx >= 0x10000L) {
 12.4414 +                while (posx >= 0x10000L) {
 12.4415 +                    ++srcx;
 12.4416 +                    posx -= 0x10000L;
 12.4417 +                }
 12.4418 +                src = (Uint32 *)(data->src + (srcy * data->src_pitch) + (srcx * 4));
 12.4419 +            }
 12.4420 +            pixel = *src;
 12.4421 +            B = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); R = (Uint8)(pixel >> 8); A = (Uint8)pixel;
 12.4422 +            pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B;
 12.4423 +            *dst = pixel;
 12.4424 +            posx += incx;
 12.4425 +            ++dst;
 12.4426 +        }
 12.4427 +        posy += incy;
 12.4428 +        data->dst += data->dst_pitch;
 12.4429 +    }
 12.4430 +    return 0;
 12.4431 +}
 12.4432 +
 12.4433 +int SDL_RenderCopy_BGRA8888_RGB888_Blend(SDL_RenderCopyData *data)
 12.4434 +{
 12.4435 +    const int flags = data->flags;
 12.4436 +    Uint32 srcpixel;
 12.4437 +    Uint32 srcR, srcG, srcB, srcA;
 12.4438 +    Uint32 dstpixel;
 12.4439 +    Uint32 dstR, dstG, dstB, dstA;
 12.4440 +
 12.4441 +    while (data->dst_h--) {
 12.4442 +        Uint32 *src = (Uint32 *)data->src;
 12.4443 +        Uint32 *dst = (Uint32 *)data->dst;
 12.4444 +        int n = data->dst_w;
 12.4445 +        while (n--) {
 12.4446 +            srcpixel = *src;
 12.4447 +            srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
 12.4448 +            dstpixel = *dst;
 12.4449 +            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
 12.4450 +            if (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD)) {
 12.4451 +                /* This goes away if we ever use premultiplied alpha */
 12.4452 +                srcR = (srcR * srcA) / 255;
 12.4453 +                srcG = (srcG * srcA) / 255;
 12.4454 +                srcB = (srcB * srcA) / 255;
 12.4455 +            }
 12.4456 +            switch (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD|SDL_RENDERCOPY_MOD)) {
 12.4457 +            case SDL_RENDERCOPY_BLEND:
 12.4458 +                dstR = srcR + ((255 - srcA) * dstR) / 255;
 12.4459 +                dstG = srcG + ((255 - srcA) * dstG) / 255;
 12.4460 +                dstB = srcB + ((255 - srcA) * dstB) / 255;
 12.4461 +                break;
 12.4462 +            case SDL_RENDERCOPY_ADD:
 12.4463 +                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
 12.4464 +                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
 12.4465 +                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
 12.4466 +                break;
 12.4467 +            case SDL_RENDERCOPY_MOD:
 12.4468 +                dstR = (srcR * dstR) / 255;
 12.4469 +                dstG = (srcG * dstG) / 255;
 12.4470 +                dstB = (srcB * dstB) / 255;
 12.4471 +                break;
 12.4472 +            }
 12.4473 +            dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
 12.4474 +            *dst = dstpixel;
 12.4475 +            ++src;
 12.4476 +            ++dst;
 12.4477 +        }
 12.4478 +        data->src += data->src_pitch;
 12.4479 +        data->dst += data->dst_pitch;
 12.4480 +    }
 12.4481 +    return 0;
 12.4482 +}
 12.4483 +
 12.4484 +int SDL_RenderCopy_BGRA8888_RGB888_Blend_Scale(SDL_RenderCopyData *data)
 12.4485 +{
 12.4486 +    const int flags = data->flags;
 12.4487 +    Uint32 srcpixel;
 12.4488 +    Uint32 srcR, srcG, srcB, srcA;
 12.4489 +    Uint32 dstpixel;
 12.4490 +    Uint32 dstR, dstG, dstB, dstA;
 12.4491 +    int srcy, srcx;
 12.4492 +    int posy, posx;
 12.4493 +    int incy, incx;
 12.4494 +
 12.4495 +    srcy = 0;
 12.4496 +    posy = 0;
 12.4497 +    incy = (data->src_h << 16) / data->dst_h;
 12.4498 +    incx = (data->src_w << 16) / data->dst_w;
 12.4499 +
 12.4500 +    while (data->dst_h--) {
 12.4501 +        Uint32 *src;
 12.4502 +        Uint32 *dst = (Uint32 *)data->dst;
 12.4503 +        int n = data->dst_w;
 12.4504 +        srcx = -1;
 12.4505 +        posx = 0x10000L;
 12.4506 +        while (posy >= 0x10000L) {
 12.4507 +            ++srcy;
 12.4508 +            posy -= 0x10000L;
 12.4509 +        }
 12.4510 +        while (n--) {
 12.4511 +            if (posx >= 0x10000L) {
 12.4512 +                while (posx >= 0x10000L) {
 12.4513 +                    ++srcx;
 12.4514 +                    posx -= 0x10000L;
 12.4515 +                }
 12.4516 +                src = (Uint32 *)(data->src + (srcy * data->src_pitch) + (srcx * 4));
 12.4517 +            }
 12.4518 +            srcpixel = *src;
 12.4519 +            srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
 12.4520 +            dstpixel = *dst;
 12.4521 +            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
 12.4522 +            if (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD)) {
 12.4523 +                /* This goes away if we ever use premultiplied alpha */
 12.4524 +                srcR = (srcR * srcA) / 255;
 12.4525 +                srcG = (srcG * srcA) / 255;
 12.4526 +                srcB = (srcB * srcA) / 255;
 12.4527 +            }
 12.4528 +            switch (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD|SDL_RENDERCOPY_MOD)) {
 12.4529 +            case SDL_RENDERCOPY_BLEND:
 12.4530 +                dstR = srcR + ((255 - srcA) * dstR) / 255;
 12.4531 +                dstG = srcG + ((255 - srcA) * dstG) / 255;
 12.4532 +                dstB = srcB + ((255 - srcA) * dstB) / 255;
 12.4533 +                break;
 12.4534 +            case SDL_RENDERCOPY_ADD:
 12.4535 +                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
 12.4536 +                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
 12.4537 +                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
 12.4538 +                break;
 12.4539 +            case SDL_RENDERCOPY_MOD:
 12.4540 +                dstR = (srcR * dstR) / 255;
 12.4541 +                dstG = (srcG * dstG) / 255;
 12.4542 +                dstB = (srcB * dstB) / 255;
 12.4543 +                break;
 12.4544 +            }
 12.4545 +            dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
 12.4546 +            *dst = dstpixel;
 12.4547 +            posx += incx;
 12.4548 +            ++dst;
 12.4549 +        }
 12.4550 +        posy += incy;
 12.4551 +        data->dst += data->dst_pitch;
 12.4552 +    }
 12.4553 +    return 0;
 12.4554 +}
 12.4555 +
 12.4556 +int SDL_RenderCopy_BGRA8888_RGB888_Modulate(SDL_RenderCopyData *data)
 12.4557 +{
 12.4558 +    const int flags = data->flags;
 12.4559 +    const Uint32 modulateR = data->r;
 12.4560 +    const Uint32 modulateG = data->g;
 12.4561 +    const Uint32 modulateB = data->b;
 12.4562 +    const Uint32 modulateA = data->a;
 12.4563 +    Uint32 pixel;
 12.4564 +    Uint32 R, G, B, A;
 12.4565 +
 12.4566 +    while (data->dst_h--) {
 12.4567 +        Uint32 *src = (Uint32 *)data->src;
 12.4568 +        Uint32 *dst = (Uint32 *)data->dst;
 12.4569 +        int n = data->dst_w;
 12.4570 +        while (n--) {
 12.4571 +            pixel = *src;
 12.4572 +            B = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); R = (Uint8)(pixel >> 8); A = (Uint8)pixel;
 12.4573 +            if (flags & SDL_RENDERCOPY_MODULATE_COLOR) {
 12.4574 +                R = (R * modulateR) / 255;
 12.4575 +                G = (G * modulateG) / 255;
 12.4576 +                B = (B * modulateB) / 255;
 12.4577 +            }
 12.4578 +            pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B;
 12.4579 +            *dst = pixel;
 12.4580 +            ++src;
 12.4581 +            ++dst;
 12.4582 +        }
 12.4583 +        data->src += data->src_pitch;
 12.4584 +        data->dst += data->dst_pitch;
 12.4585 +    }
 12.4586 +    return 0;
 12.4587 +}
 12.4588 +
 12.4589 +int SDL_RenderCopy_BGRA8888_RGB888_Modulate_Scale(SDL_RenderCopyData *data)
 12.4590 +{
 12.4591 +    const int flags = data->flags;
 12.4592 +    const Uint32 modulateR = data->r;
 12.4593 +    const Uint32 modulateG = data->g;
 12.4594 +    const Uint32 modulateB = data->b;
 12.4595 +    const Uint32 modulateA = data->a;
 12.4596 +    Uint32 pixel;
 12.4597 +    Uint32 R, G, B, A;
 12.4598 +    int srcy, srcx;
 12.4599 +    int posy, posx;
 12.4600 +    int incy, incx;
 12.4601 +
 12.4602 +    srcy = 0;
 12.4603 +    posy = 0;
 12.4604 +    incy = (data->src_h << 16) / data->dst_h;
 12.4605 +    incx = (data->src_w << 16) / data->dst_w;
 12.4606 +
 12.4607 +    while (data->dst_h--) {
 12.4608 +        Uint32 *src;
 12.4609 +        Uint32 *dst = (Uint32 *)data->dst;
 12.4610 +        int n = data->dst_w;
 12.4611 +        srcx = -1;
 12.4612 +        posx = 0x10000L;
 12.4613 +        while (posy >= 0x10000L) {
 12.4614 +            ++srcy;
 12.4615 +            posy -= 0x10000L;
 12.4616 +        }
 12.4617 +        while (n--) {
 12.4618 +            if (posx >= 0x10000L) {
 12.4619 +                while (posx >= 0x10000L) {
 12.4620 +                    ++srcx;
 12.4621 +                    posx -= 0x10000L;
 12.4622 +                }
 12.4623 +                src = (Uint32 *)(data->src + (srcy * data->src_pitch) + (srcx * 4));
 12.4624 +            }
 12.4625 +            pixel = *src;
 12.4626 +            B = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); R = (Uint8)(pixel >> 8); A = (Uint8)pixel;
 12.4627 +            if (flags & SDL_RENDERCOPY_MODULATE_COLOR) {
 12.4628 +                R = (R * modulateR) / 255;
 12.4629 +                G = (G * modulateG) / 255;
 12.4630 +                B = (B * modulateB) / 255;
 12.4631 +            }
 12.4632 +            pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B;
 12.4633 +            *dst = pixel;
 12.4634 +            posx += incx;
 12.4635 +            ++dst;
 12.4636 +        }
 12.4637 +        posy += incy;
 12.4638 +        data->dst += data->dst_pitch;
 12.4639 +    }
 12.4640 +    return 0;
 12.4641 +}
 12.4642 +
 12.4643 +int SDL_RenderCopy_BGRA8888_RGB888_Modulate_Blend(SDL_RenderCopyData *data)
 12.4644 +{
 12.4645 +    const int flags = data->flags;
 12.4646 +    const Uint32 modulateR = data->r;
 12.4647 +    const Uint32 modulateG = data->g;
 12.4648 +    const Uint32 modulateB = data->b;
 12.4649 +    const Uint32 modulateA = data->a;
 12.4650 +    Uint32 srcpixel;
 12.4651 +    Uint32 srcR, srcG, srcB, srcA;
 12.4652 +    Uint32 dstpixel;
 12.4653 +    Uint32 dstR, dstG, dstB, dstA;
 12.4654 +
 12.4655 +    while (data->dst_h--) {
 12.4656 +        Uint32 *src = (Uint32 *)data->src;
 12.4657 +        Uint32 *dst = (Uint32 *)data->dst;
 12.4658 +        int n = data->dst_w;
 12.4659 +        while (n--) {
 12.4660 +            srcpixel = *src;
 12.4661 +            srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
 12.4662 +            dstpixel = *dst;
 12.4663 +            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
 12.4664 +            if (flags & SDL_RENDERCOPY_MODULATE_COLOR) {
 12.4665 +                srcR = (srcR * modulateR) / 255;
 12.4666 +                srcG = (srcG * modulateG) / 255;
 12.4667 +                srcB = (srcB * modulateB) / 255;
 12.4668 +            }
 12.4669 +            if (flags & SDL_RENDERCOPY_MODULATE_ALPHA) {
 12.4670 +                srcA = (srcA * modulateA) / 255;
 12.4671 +            }
 12.4672 +            if (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD)) {
 12.4673 +                /* This goes away if we ever use premultiplied alpha */
 12.4674 +                srcR = (srcR * srcA) / 255;
 12.4675 +                srcG = (srcG * srcA) / 255;
 12.4676 +                srcB = (srcB * srcA) / 255;
 12.4677 +            }
 12.4678 +            switch (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD|SDL_RENDERCOPY_MOD)) {
 12.4679 +            case SDL_RENDERCOPY_BLEND:
 12.4680 +                dstR = srcR + ((255 - srcA) * dstR) / 255;
 12.4681 +                dstG = srcG + ((255 - srcA) * dstG) / 255;
 12.4682 +                dstB = srcB + ((255 - srcA) * dstB) / 255;
 12.4683 +                break;
 12.4684 +            case SDL_RENDERCOPY_ADD:
 12.4685 +                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
 12.4686 +                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
 12.4687 +                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
 12.4688 +                break;
 12.4689 +            case SDL_RENDERCOPY_MOD:
 12.4690 +                dstR = (srcR * dstR) / 255;
 12.4691 +                dstG = (srcG * dstG) / 255;
 12.4692 +                dstB = (srcB * dstB) / 255;
 12.4693 +                break;
 12.4694 +            }
 12.4695 +            dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
 12.4696 +            *dst = dstpixel;
 12.4697 +            ++src;
 12.4698 +            ++dst;
 12.4699 +        }
 12.4700 +        data->src += data->src_pitch;
 12.4701 +        data->dst += data->dst_pitch;
 12.4702 +    }
 12.4703 +    return 0;
 12.4704 +}
 12.4705 +
 12.4706 +int SDL_RenderCopy_BGRA8888_RGB888_Modulate_Blend_Scale(SDL_RenderCopyData *data)
 12.4707 +{
 12.4708 +    const int flags = data->flags;
 12.4709 +    const Uint32 modulateR = data->r;
 12.4710 +    const Uint32 modulateG = data->g;
 12.4711 +    const Uint32 modulateB = data->b;
 12.4712 +    const Uint32 modulateA = data->a;
 12.4713 +    Uint32 srcpixel;
 12.4714 +    Uint32 srcR, srcG, srcB, srcA;
 12.4715 +    Uint32 dstpixel;
 12.4716 +    Uint32 dstR, dstG, dstB, dstA;
 12.4717 +    int srcy, srcx;
 12.4718 +    int posy, posx;
 12.4719 +    int incy, incx;
 12.4720 +
 12.4721 +    srcy = 0;
 12.4722 +    posy = 0;
 12.4723 +    incy = (data->src_h << 16) / data->dst_h;
 12.4724 +    incx = (data->src_w << 16) / data->dst_w;
 12.4725 +
 12.4726 +    while (data->dst_h--) {
 12.4727 +        Uint32 *src;
 12.4728 +        Uint32 *dst = (Uint32 *)data->dst;
 12.4729 +        int n = data->dst_w;
 12.4730 +        srcx = -1;
 12.4731 +        posx = 0x10000L;
 12.4732 +        while (posy >= 0x10000L) {
 12.4733 +            ++srcy;
 12.4734 +            posy -= 0x10000L;
 12.4735 +        }
 12.4736 +        while (n--) {
 12.4737 +            if (posx >= 0x10000L) {
 12.4738 +                while (posx >= 0x10000L) {
 12.4739 +                    ++srcx;
 12.4740 +                    posx -= 0x10000L;
 12.4741 +                }
 12.4742 +                src = (Uint32 *)(data->src + (srcy * data->src_pitch) + (srcx * 4));
 12.4743 +            }
 12.4744 +            srcpixel = *src;
 12.4745 +            srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
 12.4746 +            dstpixel = *dst;
 12.4747 +            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
 12.4748 +            if (flags & SDL_RENDERCOPY_MODULATE_COLOR) {
 12.4749 +                srcR = (srcR * modulateR) / 255;
 12.4750 +                srcG = (srcG * modulateG) / 255;
 12.4751 +                srcB = (srcB * modulateB) / 255;
 12.4752 +            }
 12.4753 +            if (flags & SDL_RENDERCOPY_MODULATE_ALPHA) {
 12.4754 +                srcA = (srcA * modulateA) / 255;
 12.4755 +            }
 12.4756 +            if (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD)) {
 12.4757 +                /* This goes away if we ever use premultiplied alpha */
 12.4758 +                srcR = (srcR * srcA) / 255;
 12.4759 +                srcG = (srcG * srcA) / 255;
 12.4760 +                srcB = (srcB * srcA) / 255;
 12.4761 +            }
 12.4762 +            switch (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD|SDL_RENDERCOPY_MOD)) {
 12.4763 +            case SDL_RENDERCOPY_BLEND:
 12.4764 +                dstR = srcR + ((255 - srcA) * dstR) / 255;
 12.4765 +                dstG = srcG + ((255 - srcA) * dstG) / 255;
 12.4766 +                dstB = srcB + ((255 - srcA) * dstB) / 255;
 12.4767 +                break;
 12.4768 +            case SDL_RENDERCOPY_ADD:
 12.4769 +                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
 12.4770 +                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
 12.4771 +                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
 12.4772 +                break;
 12.4773 +            case SDL_RENDERCOPY_MOD:
 12.4774 +                dstR = (srcR * dstR) / 255;
 12.4775 +                dstG = (srcG * dstG) / 255;
 12.4776 +                dstB = (srcB * dstB) / 255;
 12.4777 +                break;
 12.4778 +            }
 12.4779 +            dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
 12.4780 +            *dst = dstpixel;
 12.4781 +            posx += incx;
 12.4782 +            ++dst;
 12.4783 +        }
 12.4784 +        posy += incy;
 12.4785 +        data->dst += data->dst_pitch;
 12.4786 +    }
 12.4787 +    return 0;
 12.4788 +}
 12.4789 +
 12.4790 +int SDL_RenderCopy_BGRA8888_BGR888(SDL_RenderCopyData *data)
 12.4791 +{
 12.4792 +    const int flags = data->flags;
 12.4793 +    Uint32 pixel;
 12.4794 +    Uint32 R, G, B, A;
 12.4795 +
 12.4796 +    while (data->dst_h--) {
 12.4797 +        Uint32 *src = (Uint32 *)data->src;
 12.4798 +        Uint32 *dst = (Uint32 *)data->dst;
 12.4799 +        int n = data->dst_w;
 12.4800 +        while (n--) {
 12.4801 +            pixel = *src;
 12.4802 +            B = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); R = (Uint8)(pixel >> 8); A = (Uint8)pixel;
 12.4803 +            pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R;
 12.4804 +            *dst = pixel;
 12.4805 +            ++src;
 12.4806 +            ++dst;
 12.4807 +        }
 12.4808 +        data->src += data->src_pitch;
 12.4809 +        data->dst += data->dst_pitch;
 12.4810 +    }
 12.4811 +    return 0;
 12.4812 +}
 12.4813 +
 12.4814 +int SDL_RenderCopy_BGRA8888_BGR888_Scale(SDL_RenderCopyData *data)
 12.4815 +{
 12.4816 +    const int flags = data->flags;
 12.4817 +    Uint32 pixel;
 12.4818 +    Uint32 R, G, B, A;
 12.4819 +    int srcy, srcx;
 12.4820 +    int posy, posx;
 12.4821 +    int incy, incx;
 12.4822 +
 12.4823 +    srcy = 0;
 12.4824 +    posy = 0;
 12.4825 +    incy = (data->src_h << 16) / data->dst_h;
 12.4826 +    incx = (data->src_w << 16) / data->dst_w;
 12.4827 +
 12.4828 +    while (data->dst_h--) {
 12.4829 +        Uint32 *src;
 12.4830 +        Uint32 *dst = (Uint32 *)data->dst;
 12.4831 +        int n = data->dst_w;
 12.4832 +        srcx = -1;
 12.4833 +        posx = 0x10000L;
 12.4834 +        while (posy >= 0x10000L) {
 12.4835 +            ++srcy;
 12.4836 +            posy -= 0x10000L;
 12.4837 +        }
 12.4838 +        while (n--) {
 12.4839 +            if (posx >= 0x10000L) {
 12.4840 +                while (posx >= 0x10000L) {
 12.4841 +                    ++srcx;
 12.4842 +                    posx -= 0x10000L;
 12.4843 +                }
 12.4844 +                src = (Uint32 *)(data->src + (srcy * data->src_pitch) + (srcx * 4));
 12.4845 +            }
 12.4846 +            pixel = *src;
 12.4847 +            B = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); R = (Uint8)(pixel >> 8); A = (Uint8)pixel;
 12.4848 +            pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R;
 12.4849 +            *dst = pixel;
 12.4850 +            posx += incx;
 12.4851 +            ++dst;
 12.4852 +        }
 12.4853 +        posy += incy;
 12.4854 +        data->dst += data->dst_pitch;
 12.4855 +    }
 12.4856 +    return 0;
 12.4857 +}
 12.4858 +
 12.4859 +int SDL_RenderCopy_BGRA8888_BGR888_Blend(SDL_RenderCopyData *data)
 12.4860 +{
 12.4861 +    const int flags = data->flags;
 12.4862 +    Uint32 srcpixel;
 12.4863 +    Uint32 srcR, srcG, srcB, srcA;
 12.4864 +    Uint32 dstpixel;
 12.4865 +    Uint32 dstR, dstG, dstB, dstA;
 12.4866 +
 12.4867 +    while (data->dst_h--) {
 12.4868 +        Uint32 *src = (Uint32 *)data->src;
 12.4869 +        Uint32 *dst = (Uint32 *)data->dst;
 12.4870 +        int n = data->dst_w;
 12.4871 +        while (n--) {
 12.4872 +            srcpixel = *src;
 12.4873 +            srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
 12.4874 +            dstpixel = *dst;
 12.4875 +            dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
 12.4876 +            if (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD)) {
 12.4877 +                /* This goes away if we ever use premultiplied alpha */
 12.4878 +                srcR = (srcR * srcA) / 255;
 12.4879 +                srcG = (srcG * srcA) / 255;
 12.4880 +                srcB = (srcB * srcA) / 255;
 12.4881 +            }
 12.4882 +            switch (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD|SDL_RENDERCOPY_MOD)) {
 12.4883 +            case SDL_RENDERCOPY_BLEND:
 12.4884 +                dstR = srcR + ((255 - srcA) * dstR) / 255;
 12.4885 +                dstG = srcG + ((255 - srcA) * dstG) / 255;
 12.4886 +                dstB = srcB + ((255 - srcA) * dstB) / 255;
 12.4887 +                break;
 12.4888 +            case SDL_RENDERCOPY_ADD:
 12.4889 +                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
 12.4890 +                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
 12.4891 +                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
 12.4892 +                break;
 12.4893 +            case SDL_RENDERCOPY_MOD:
 12.4894 +                dstR = (srcR * dstR) / 255;
 12.4895 +                dstG = (srcG * dstG) / 255;
 12.4896 +                dstB = (srcB * dstB) / 255;
 12.4897 +                break;
 12.4898 +            }
 12.4899 +            dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
 12.4900 +            *dst = dstpixel;
 12.4901 +            ++src;
 12.4902 +            ++dst;
 12.4903 +        }
 12.4904 +        data->src += data->src_pitch;
 12.4905 +        data->dst += data->dst_pitch;
 12.4906 +    }
 12.4907 +    return 0;
 12.4908 +}
 12.4909 +
 12.4910 +int SDL_RenderCopy_BGRA8888_BGR888_Blend_Scale(SDL_RenderCopyData *data)
 12.4911 +{
 12.4912 +    const int flags = data->flags;
 12.4913 +    Uint32 srcpixel;
 12.4914 +    Uint32 srcR, srcG, srcB, srcA;
 12.4915 +    Uint32 dstpixel;
 12.4916 +    Uint32 dstR, dstG, dstB, dstA;
 12.4917 +    int srcy, srcx;
 12.4918 +    int posy, posx;
 12.4919 +    int incy, incx;
 12.4920 +
 12.4921 +    srcy = 0;
 12.4922 +    posy = 0;
 12.4923 +    incy = (data->src_h << 16) / data->dst_h;
 12.4924 +    incx = (data->src_w << 16) / data->dst_w;
 12.4925 +
 12.4926 +    while (data->dst_h--) {
 12.4927 +        Uint32 *src;
 12.4928 +        Uint32 *dst = (Uint32 *)data->dst;
 12.4929 +        int n = data->dst_w;
 12.4930 +        srcx = -1;
 12.4931 +        posx = 0x10000L;
 12.4932 +        while (posy >= 0x10000L) {
 12.4933 +            ++srcy;
 12.4934 +            posy -= 0x10000L;
 12.4935 +        }
 12.4936 +        while (n--) {
 12.4937 +            if (posx >= 0x10000L) {
 12.4938 +                while (posx >= 0x10000L) {
 12.4939 +                    ++srcx;
 12.4940 +                    posx -= 0x10000L;
 12.4941 +                }
 12.4942 +                src = (Uint32 *)(data->src + (srcy * data->src_pitch) + (srcx * 4));
 12.4943 +            }
 12.4944 +            srcpixel = *src;
 12.4945 +            srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
 12.4946 +            dstpixel = *dst;
 12.4947 +            dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
 12.4948 +            if (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD)) {
 12.4949 +                /* This goes away if we ever use premultiplied alpha */
 12.4950 +                srcR = (srcR * srcA) / 255;
 12.4951 +                srcG = (srcG * srcA) / 255;
 12.4952 +                srcB = (srcB * srcA) / 255;
 12.4953 +            }
 12.4954 +            switch (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD|SDL_RENDERCOPY_MOD)) {
 12.4955 +            case SDL_RENDERCOPY_BLEND:
 12.4956 +                dstR = srcR + ((255 - srcA) * dstR) / 255;
 12.4957 +                dstG = srcG + ((255 - srcA) * dstG) / 255;
 12.4958 +                dstB = srcB + ((255 - srcA) * dstB) / 255;
 12.4959 +                break;
 12.4960 +            case SDL_RENDERCOPY_ADD:
 12.4961 +                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
 12.4962 +                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
 12.4963 +                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
 12.4964 +                break;
 12.4965 +            case SDL_RENDERCOPY_MOD:
 12.4966 +                dstR = (srcR * dstR) / 255;
 12.4967 +                dstG = (srcG * dstG) / 255;
 12.4968 +                dstB = (srcB * dstB) / 255;
 12.4969 +                break;
 12.4970 +            }
 12.4971 +            dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
 12.4972 +            *dst = dstpixel;
 12.4973 +            posx += incx;
 12.4974 +            ++dst;
 12.4975 +        }
 12.4976 +        posy += incy;
 12.4977 +        data->dst += data->dst_pitch;
 12.4978 +    }
 12.4979 +    return 0;
 12.4980 +}
 12.4981 +
 12.4982 +int SDL_RenderCopy_BGRA8888_BGR888_Modulate(SDL_RenderCopyData *data)
 12.4983 +{
 12.4984 +    const int flags = data->flags;
 12.4985 +    const Uint32 modulateR = data->r;
 12.4986 +    const Uint32 modulateG = data->g;
 12.4987 +    const Uint32 modulateB = data->b;
 12.4988 +    const Uint32 modulateA = data->a;
 12.4989 +    Uint32 pixel;
 12.4990 +    Uint32 R, G, B, A;
 12.4991 +
 12.4992 +    while (data->dst_h--) {
 12.4993 +        Uint32 *src = (Uint32 *)data->src;
 12.4994 +        Uint32 *dst = (Uint32 *)data->dst;
 12.4995 +        int n = data->dst_w;
 12.4996 +        while (n--) {
 12.4997 +            pixel = *src;
 12.4998 +            B = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); R = (Uint8)(pixel >> 8); A = (Uint8)pixel;
 12.4999 +            if (flags & SDL_RENDERCOPY_MODULATE_COLOR) {
 12.5000 +                R = (R * modulateR) / 255;
 12.5001 +                G = (G * modulateG) / 255;
 12.5002 +                B = (B * modulateB) / 255;
 12.5003 +            }
 12.5004 +            pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R;
 12.5005 +            *dst = pixel;
 12.5006 +            ++src;
 12.5007 +            ++dst;
 12.5008 +        }
 12.5009 +        data->src += data->src_pitch;
 12.5010 +        data->dst += data->dst_pitch;
 12.5011 +    }
 12.5012 +    return 0;
 12.5013 +}
 12.5014 +
 12.5015 +int SDL_RenderCopy_BGRA8888_BGR888_Modulate_Scale(SDL_RenderCopyData *data)
 12.5016 +{
 12.5017 +    const int flags = data->flags;
 12.5018 +    const Uint32 modulateR = data->r;
 12.5019 +    const Uint32 modulateG = data->g;
 12.5020 +    const Uint32 modulateB = data->b;
 12.5021 +    const Uint32 modulateA = data->a;
 12.5022 +    Uint32 pixel;
 12.5023 +    Uint32 R, G, B, A;
 12.5024 +    int srcy, srcx;
 12.5025 +    int posy, posx;
 12.5026 +    int incy, incx;
 12.5027 +
 12.5028 +    srcy = 0;
 12.5029 +    posy = 0;
 12.5030 +    incy = (data->src_h << 16) / data->dst_h;
 12.5031 +    incx = (data->src_w << 16) / data->dst_w;
 12.5032 +
 12.5033 +    while (data->dst_h--) {
 12.5034 +        Uint32 *src;
 12.5035 +        Uint32 *dst = (Uint32 *)data->dst;
 12.5036 +        int n = data->dst_w;
 12.5037 +        srcx = -1;
 12.5038 +        posx = 0x10000L;
 12.5039 +        while (posy >= 0x10000L) {
 12.5040 +            ++srcy;
 12.5041 +            posy -= 0x10000L;
 12.5042 +        }
 12.5043 +        while (n--) {
 12.5044 +            if (posx >= 0x10000L) {
 12.5045 +                while (posx >= 0x10000L) {
 12.5046 +                    ++srcx;
 12.5047 +                    posx -= 0x10000L;
 12.5048 +                }
 12.5049 +                src = (Uint32 *)(data->src + (srcy * data->src_pitch) + (srcx * 4));
 12.5050 +            }
 12.5051 +            pixel = *src;
 12.5052 +            B = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); R = (Uint8)(pixel >> 8); A = (Uint8)pixel;
 12.5053 +            if (flags & SDL_RENDERCOPY_MODULATE_COLOR) {
 12.5054 +                R = (R * modulateR) / 255;
 12.5055 +                G = (G * modulateG) / 255;
 12.5056 +                B = (B * modulateB) / 255;
 12.5057 +            }
 12.5058 +            pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R;
 12.5059 +            *dst = pixel;
 12.5060 +            posx += incx;
 12.5061 +            ++dst;
 12.5062 +        }
 12.5063 +        posy += incy;
 12.5064 +        data->dst += data->dst_pitch;
 12.5065 +    }
 12.5066 +    return 0;
 12.5067 +}
 12.5068 +
 12.5069 +int SDL_RenderCopy_BGRA8888_BGR888_Modulate_Blend(SDL_RenderCopyData *data)
 12.5070 +{
 12.5071 +    const int flags = data->flags;
 12.5072 +    const Uint32 modulateR = data->r;
 12.5073 +    const Uint32 modulateG = data->g;
 12.5074 +    const Uint32 modulateB = data->b;
 12.5075 +    const Uint32 modulateA = data->a;
 12.5076 +    Uint32 srcpixel;
 12.5077 +    Uint32 srcR, srcG, srcB, srcA;
 12.5078 +    Uint32 dstpixel;
 12.5079 +    Uint32 dstR, dstG, dstB, dstA;
 12.5080 +
 12.5081 +    while (data->dst_h--) {
 12.5082 +        Uint32 *src = (Uint32 *)data->src;
 12.5083 +        Uint32 *dst = (Uint32 *)data->dst;
 12.5084 +        int n = data->dst_w;
 12.5085 +        while (n--) {
 12.5086 +            srcpixel = *src;
 12.5087 +            srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
 12.5088 +            dstpixel = *dst;
 12.5089 +            dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
 12.5090 +            if (flags & SDL_RENDERCOPY_MODULATE_COLOR) {
 12.5091 +                srcR = (srcR * modulateR) / 255;
 12.5092 +                srcG = (srcG * modulateG) / 255;
 12.5093 +                srcB = (srcB * modulateB) / 255;
 12.5094 +            }
 12.5095 +            if (flags & SDL_RENDERCOPY_MODULATE_ALPHA) {
 12.5096 +                srcA = (srcA * modulateA) / 255;
 12.5097 +            }
 12.5098 +            if (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD)) {
 12.5099 +                /* This goes away if we ever use premultiplied alpha */
 12.5100 +                srcR = (srcR * srcA) / 255;
 12.5101 +                srcG = (srcG * srcA) / 255;
 12.5102 +                srcB = (srcB * srcA) / 255;
 12.5103 +            }
 12.5104 +            switch (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD|SDL_RENDERCOPY_MOD)) {
 12.5105 +            case SDL_RENDERCOPY_BLEND:
 12.5106 +                dstR = srcR + ((255 - srcA) * dstR) / 255;
 12.5107 +                dstG = srcG + ((255 - srcA) * dstG) / 255;
 12.5108 +                dstB = srcB + ((255 - srcA) * dstB) / 255;
 12.5109 +                break;
 12.5110 +            case SDL_RENDERCOPY_ADD:
 12.5111 +                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
 12.5112 +                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
 12.5113 +                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
 12.5114 +                break;
 12.5115 +            case SDL_RENDERCOPY_MOD:
 12.5116 +                dstR = (srcR * dstR) / 255;
 12.5117 +                dstG = (srcG * dstG) / 255;
 12.5118 +                dstB = (srcB * dstB) / 255;
 12.5119 +                break;
 12.5120 +            }
 12.5121 +            dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
 12.5122 +            *dst = dstpixel;
 12.5123 +            ++src;
 12.5124 +            ++dst;
 12.5125 +        }
 12.5126 +        data->src += data->src_pitch;
 12.5127 +        data->dst += data->dst_pitch;
 12.5128 +    }
 12.5129 +    return 0;
 12.5130 +}
 12.5131 +
 12.5132 +int SDL_RenderCopy_BGRA8888_BGR888_Modulate_Blend_Scale(SDL_RenderCopyData *data)
 12.5133 +{
 12.5134 +    const int flags = data->flags;
 12.5135 +    const Uint32 modulateR = data->r;
 12.5136 +    const Uint32 modulateG = data->g;
 12.5137 +    const Uint32 modulateB = data->b;
 12.5138 +    const Uint32 modulateA = data->a;
 12.5139 +    Uint32 srcpixel;
 12.5140 +    Uint32 srcR, srcG, srcB, srcA;
 12.5141 +    Uint32 dstpixel;
 12.5142 +    Uint32 dstR, dstG, dstB, dstA;
 12.5143 +    int srcy, srcx;
 12.5144 +    int posy, posx;
 12.5145 +    int incy, incx;
 12.5146 +
 12.5147 +    srcy = 0;
 12.5148 +    posy = 0;
 12.5149 +    incy = (data->src_h << 16) / data->dst_h;
 12.5150 +    incx = (data->src_w << 16) / data->dst_w;
 12.5151 +
 12.5152 +    while (data->dst_h--) {
 12.5153 +        Uint32 *src;
 12.5154 +        Uint32 *dst = (Uint32 *)data->dst;
 12.5155 +        int n = data->dst_w;
 12.5156 +        srcx = -1;
 12.5157 +        posx = 0x10000L;
 12.5158 +        while (posy >= 0x10000L) {
 12.5159 +            ++srcy;
 12.5160 +            posy -= 0x10000L;
 12.5161 +        }
 12.5162 +        while (n--) {
 12.5163 +            if (posx >= 0x10000L) {
 12.5164 +                while (posx >= 0x10000L) {
 12.5165 +                    ++srcx;
 12.5166 +                    posx -= 0x10000L;
 12.5167 +                }
 12.5168 +                src = (Uint32 *)(data->src + (srcy * data->src_pitch) + (srcx * 4));
 12.5169 +            }
 12.5170 +            srcpixel = *src;
 12.5171 +            srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
 12.5172 +            dstpixel = *dst;
 12.5173 +            dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
 12.5174 +            if (flags & SDL_RENDERCOPY_MODULATE_COLOR) {
 12.5175 +                srcR = (srcR * modulateR) / 255;
 12.5176 +                srcG = (srcG * modulateG) / 255;
 12.5177 +                srcB = (srcB * modulateB) / 255;
 12.5178 +            }
 12.5179 +            if (flags & SDL_RENDERCOPY_MODULATE_ALPHA) {
 12.5180 +                srcA = (srcA * modulateA) / 255;
 12.5181 +            }
 12.5182 +            if (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD)) {
 12.5183 +                /* This goes away if we ever use premultiplied alpha */
 12.5184 +                srcR = (srcR * srcA) / 255;
 12.5185 +                srcG = (srcG * srcA) / 255;
 12.5186 +                srcB = (srcB * srcA) / 255;
 12.5187 +            }
 12.5188 +            switch (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD|SDL_RENDERCOPY_MOD)) {
 12.5189 +            case SDL_RENDERCOPY_BLEND:
 12.5190 +                dstR = srcR + ((255 - srcA) * dstR) / 255;
 12.5191 +                dstG = srcG + ((255 - srcA) * dstG) / 255;
 12.5192 +                dstB = srcB + ((255 - srcA) * dstB) / 255;
 12.5193 +                break;
 12.5194 +            case SDL_RENDERCOPY_ADD:
 12.5195 +                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
 12.5196 +                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
 12.5197 +                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
 12.5198 +                break;
 12.5199 +            case SDL_RENDERCOPY_MOD:
 12.5200 +                dstR = (srcR * dstR) / 255;
 12.5201 +                dstG = (srcG * dstG) / 255;
 12.5202 +                dstB = (srcB * dstB) / 255;
 12.5203 +                break;
 12.5204 +            }
 12.5205 +            dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
 12.5206 +            *dst = dstpixel;
 12.5207 +            posx += incx;
 12.5208 +            ++dst;
 12.5209 +        }
 12.5210 +        posy += incy;
 12.5211 +        data->dst += data->dst_pitch;
 12.5212 +    }
 12.5213 +    return 0;
 12.5214 +}
 12.5215 +
 12.5216 +/* *INDENT-ON* */
 12.5217 +
 12.5218 +/* vi: set ts=4 sw=4 expandtab: */
    13.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    13.2 +++ b/src/video/SDL_rendercopy.h	Mon Aug 28 03:17:39 2006 +0000
    13.3 @@ -0,0 +1,147 @@
    13.4 +/* DO NOT EDIT!  This file is generated by sdlgenblit.pl */
    13.5 +/*
    13.6 +    SDL - Simple DirectMedia Layer
    13.7 +    Copyright (C) 1997-2006 Sam Lantinga
    13.8 +
    13.9 +    This library is free software; you can redistribute it and/or
   13.10 +    modify it under the terms of the GNU Lesser General Public
   13.11 +    License as published by the Free Software Foundation; either
   13.12 +    version 2.1 of the License, or (at your option) any later version.
   13.13 +
   13.14 +    This library is distributed in the hope that it will be useful,
   13.15 +    but WITHOUT ANY WARRANTY; without even the implied warranty of
   13.16 +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   13.17 +    Lesser General Public License for more details.
   13.18 +
   13.19 +    You should have received a copy of the GNU Lesser General Public
   13.20 +    License along with this library; if not, write to the Free Software
   13.21 +    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
   13.22 +
   13.23 +    Sam Lantinga
   13.24 +    slouken@libsdl.org
   13.25 +*/
   13.26 +#include "SDL_config.h"
   13.27 +
   13.28 +/* *INDENT-OFF* */
   13.29 +
   13.30 +#define SDL_RENDERCOPY_MODULATE_COLOR   0x0001
   13.31 +#define SDL_RENDERCOPY_MODULATE_ALPHA   0x0002
   13.32 +#define SDL_RENDERCOPY_BLEND            0x0010
   13.33 +#define SDL_RENDERCOPY_ADD              0x0020
   13.34 +#define SDL_RENDERCOPY_MOD              0x0040
   13.35 +#define SDL_RENDERCOPY_NEAREST          0x0100
   13.36 +
   13.37 +typedef struct {
   13.38 +    void *src;
   13.39 +    int src_w, src_h;
   13.40 +    int src_pitch;
   13.41 +    void *dst;
   13.42 +    int dst_w, dst_h;
   13.43 +    int dst_pitch;
   13.44 +    void *aux_data;
   13.45 +    int flags;
   13.46 +    Uint8 r, g, b, a;
   13.47 +} SDL_RenderCopyData;
   13.48 +
   13.49 +typedef int (*SDL_RenderCopyFunc)(SDL_RenderCopyData *data);
   13.50 +
   13.51 +extern SDL_RenderCopyFunc SDLCALL SDL_GetRenderCopyFunc(Uint32 src_format, Uint32 dst_format, int modMode, int blendMode, int scaleMode);
   13.52 +
   13.53 +extern int SDLCALL SDL_RenderCopy_RGB888_RGB888_Scale(SDL_RenderCopyData *data);
   13.54 +extern int SDLCALL SDL_RenderCopy_RGB888_RGB888_Blend(SDL_RenderCopyData *data);
   13.55 +extern int SDLCALL SDL_RenderCopy_RGB888_RGB888_Blend_Scale(SDL_RenderCopyData *data);
   13.56 +extern int SDLCALL SDL_RenderCopy_RGB888_RGB888_Modulate(SDL_RenderCopyData *data);
   13.57 +extern int SDLCALL SDL_RenderCopy_RGB888_RGB888_Modulate_Scale(SDL_RenderCopyData *data);
   13.58 +extern int SDLCALL SDL_RenderCopy_RGB888_RGB888_Modulate_Blend(SDL_RenderCopyData *data);
   13.59 +extern int SDLCALL SDL_RenderCopy_RGB888_RGB888_Modulate_Blend_Scale(SDL_RenderCopyData *data);
   13.60 +extern int SDLCALL SDL_RenderCopy_RGB888_BGR888(SDL_RenderCopyData *data);
   13.61 +extern int SDLCALL SDL_RenderCopy_RGB888_BGR888_Scale(SDL_RenderCopyData *data);
   13.62 +extern int SDLCALL SDL_RenderCopy_RGB888_BGR888_Blend(SDL_RenderCopyData *data);
   13.63 +extern int SDLCALL SDL_RenderCopy_RGB888_BGR888_Blend_Scale(SDL_RenderCopyData *data);
   13.64 +extern int SDLCALL SDL_RenderCopy_RGB888_BGR888_Modulate(SDL_RenderCopyData *data);
   13.65 +extern int SDLCALL SDL_RenderCopy_RGB888_BGR888_Modulate_Scale(SDL_RenderCopyData *data);
   13.66 +extern int SDLCALL SDL_RenderCopy_RGB888_BGR888_Modulate_Blend(SDL_RenderCopyData *data);
   13.67 +extern int SDLCALL SDL_RenderCopy_RGB888_BGR888_Modulate_Blend_Scale(SDL_RenderCopyData *data);
   13.68 +extern int SDLCALL SDL_RenderCopy_BGR888_RGB888(SDL_RenderCopyData *data);
   13.69 +extern int SDLCALL SDL_RenderCopy_BGR888_RGB888_Scale(SDL_RenderCopyData *data);
   13.70 +extern int SDLCALL SDL_RenderCopy_BGR888_RGB888_Blend(SDL_RenderCopyData *data);
   13.71 +extern int SDLCALL SDL_RenderCopy_BGR888_RGB888_Blend_Scale(SDL_RenderCopyData *data);
   13.72 +extern int SDLCALL SDL_RenderCopy_BGR888_RGB888_Modulate(SDL_RenderCopyData *data);
   13.73 +extern int SDLCALL SDL_RenderCopy_BGR888_RGB888_Modulate_Scale(SDL_RenderCopyData *data);
   13.74 +extern int SDLCALL SDL_RenderCopy_BGR888_RGB888_Modulate_Blend(SDL_RenderCopyData *data);
   13.75 +extern int SDLCALL SDL_RenderCopy_BGR888_RGB888_Modulate_Blend_Scale(SDL_RenderCopyData *data);
   13.76 +extern int SDLCALL SDL_RenderCopy_BGR888_BGR888_Scale(SDL_RenderCopyData *data);
   13.77 +extern int SDLCALL SDL_RenderCopy_BGR888_BGR888_Blend(SDL_RenderCopyData *data);
   13.78 +extern int SDLCALL SDL_RenderCopy_BGR888_BGR888_Blend_Scale(SDL_RenderCopyData *data);
   13.79 +extern int SDLCALL SDL_RenderCopy_BGR888_BGR888_Modulate(SDL_RenderCopyData *data);
   13.80 +extern int SDLCALL SDL_RenderCopy_BGR888_BGR888_Modulate_Scale(SDL_RenderCopyData *data);
   13.81 +extern int SDLCALL SDL_RenderCopy_BGR888_BGR888_Modulate_Blend(SDL_RenderCopyData *data);
   13.82 +extern int SDLCALL SDL_RenderCopy_BGR888_BGR888_Modulate_Blend_Scale(SDL_RenderCopyData *data);
   13.83 +extern int SDLCALL SDL_RenderCopy_ARGB8888_RGB888(SDL_RenderCopyData *data);
   13.84 +extern int SDLCALL SDL_RenderCopy_ARGB8888_RGB888_Scale(SDL_RenderCopyData *data);
   13.85 +extern int SDLCALL SDL_RenderCopy_ARGB8888_RGB888_Blend(SDL_RenderCopyData *data);
   13.86 +extern int SDLCALL SDL_RenderCopy_ARGB8888_RGB888_Blend_Scale(SDL_RenderCopyData *data);
   13.87 +extern int SDLCALL SDL_RenderCopy_ARGB8888_RGB888_Modulate(SDL_RenderCopyData *data);
   13.88 +extern int SDLCALL SDL_RenderCopy_ARGB8888_RGB888_Modulate_Scale(SDL_RenderCopyData *data);
   13.89 +extern int SDLCALL SDL_RenderCopy_ARGB8888_RGB888_Modulate_Blend(SDL_RenderCopyData *data);
   13.90 +extern int SDLCALL SDL_RenderCopy_ARGB8888_RGB888_Modulate_Blend_Scale(SDL_RenderCopyData *data);
   13.91 +extern int SDLCALL SDL_RenderCopy_ARGB8888_BGR888(SDL_RenderCopyData *data);
   13.92 +extern int SDLCALL SDL_RenderCopy_ARGB8888_BGR888_Scale(SDL_RenderCopyData *data);
   13.93 +extern int SDLCALL SDL_RenderCopy_ARGB8888_BGR888_Blend(SDL_RenderCopyData *data);
   13.94 +extern int SDLCALL SDL_RenderCopy_ARGB8888_BGR888_Blend_Scale(SDL_RenderCopyData *data);
   13.95 +extern int SDLCALL SDL_RenderCopy_ARGB8888_BGR888_Modulate(SDL_RenderCopyData *data);
   13.96 +extern int SDLCALL SDL_RenderCopy_ARGB8888_BGR888_Modulate_Scale(SDL_RenderCopyData *data);
   13.97 +extern int SDLCALL SDL_RenderCopy_ARGB8888_BGR888_Modulate_Blend(SDL_RenderCopyData *data);
   13.98 +extern int SDLCALL SDL_RenderCopy_ARGB8888_BGR888_Modulate_Blend_Scale(SDL_RenderCopyData *data);
   13.99 +extern int SDLCALL SDL_RenderCopy_RGBA8888_RGB888(SDL_RenderCopyData *data);
  13.100 +extern int SDLCALL SDL_RenderCopy_RGBA8888_RGB888_Scale(SDL_RenderCopyData *data);
  13.101 +extern int SDLCALL SDL_RenderCopy_RGBA8888_RGB888_Blend(SDL_RenderCopyData *data);
  13.102 +extern int SDLCALL SDL_RenderCopy_RGBA8888_RGB888_Blend_Scale(SDL_RenderCopyData *data);
  13.103 +extern int SDLCALL SDL_RenderCopy_RGBA8888_RGB888_Modulate(SDL_RenderCopyData *data);
  13.104 +extern int SDLCALL SDL_RenderCopy_RGBA8888_RGB888_Modulate_Scale(SDL_RenderCopyData *data);
  13.105 +extern int SDLCALL SDL_RenderCopy_RGBA8888_RGB888_Modulate_Blend(SDL_RenderCopyData *data);
  13.106 +extern int SDLCALL SDL_RenderCopy_RGBA8888_RGB888_Modulate_Blend_Scale(SDL_RenderCopyData *data);
  13.107 +extern int SDLCALL SDL_RenderCopy_RGBA8888_BGR888(SDL_RenderCopyData *data);
  13.108 +extern int SDLCALL SDL_RenderCopy_RGBA8888_BGR888_Scale(SDL_RenderCopyData *data);
  13.109 +extern int SDLCALL SDL_RenderCopy_RGBA8888_BGR888_Blend(SDL_RenderCopyData *data);
  13.110 +extern int SDLCALL SDL_RenderCopy_RGBA8888_BGR888_Blend_Scale(SDL_RenderCopyData *data);
  13.111 +extern int SDLCALL SDL_RenderCopy_RGBA8888_BGR888_Modulate(SDL_RenderCopyData *data);
  13.112 +extern int SDLCALL SDL_RenderCopy_RGBA8888_BGR888_Modulate_Scale(SDL_RenderCopyData *data);
  13.113 +extern int SDLCALL SDL_RenderCopy_RGBA8888_BGR888_Modulate_Blend(SDL_RenderCopyData *data);
  13.114 +extern int SDLCALL SDL_RenderCopy_RGBA8888_BGR888_Modulate_Blend_Scale(SDL_RenderCopyData *data);
  13.115 +extern int SDLCALL SDL_RenderCopy_ABGR8888_RGB888(SDL_RenderCopyData *data);
  13.116 +extern int SDLCALL SDL_RenderCopy_ABGR8888_RGB888_Scale(SDL_RenderCopyData *data);
  13.117 +extern int SDLCALL SDL_RenderCopy_ABGR8888_RGB888_Blend(SDL_RenderCopyData *data);
  13.118 +extern int SDLCALL SDL_RenderCopy_ABGR8888_RGB888_Blend_Scale(SDL_RenderCopyData *data);
  13.119 +extern int SDLCALL SDL_RenderCopy_ABGR8888_RGB888_Modulate(SDL_RenderCopyData *data);
  13.120 +extern int SDLCALL SDL_RenderCopy_ABGR8888_RGB888_Modulate_Scale(SDL_RenderCopyData *data);
  13.121 +extern int SDLCALL SDL_RenderCopy_ABGR8888_RGB888_Modulate_Blend(SDL_RenderCopyData *data);
  13.122 +extern int SDLCALL SDL_RenderCopy_ABGR8888_RGB888_Modulate_Blend_Scale(SDL_RenderCopyData *data);
  13.123 +extern int SDLCALL SDL_RenderCopy_ABGR8888_BGR888(SDL_RenderCopyData *data);
  13.124 +extern int SDLCALL SDL_RenderCopy_ABGR8888_BGR888_Scale(SDL_RenderCopyData *data);
  13.125 +extern int SDLCALL SDL_RenderCopy_ABGR8888_BGR888_Blend(SDL_RenderCopyData *data);
  13.126 +extern int SDLCALL SDL_RenderCopy_ABGR8888_BGR888_Blend_Scale(SDL_RenderCopyData *data);
  13.127 +extern int SDLCALL SDL_RenderCopy_ABGR8888_BGR888_Modulate(SDL_RenderCopyData *data);
  13.128 +extern int SDLCALL SDL_RenderCopy_ABGR8888_BGR888_Modulate_Scale(SDL_RenderCopyData *data);
  13.129 +extern int SDLCALL SDL_RenderCopy_ABGR8888_BGR888_Modulate_Blend(SDL_RenderCopyData *data);
  13.130 +extern int SDLCALL SDL_RenderCopy_ABGR8888_BGR888_Modulate_Blend_Scale(SDL_RenderCopyData *data);
  13.131 +extern int SDLCALL SDL_RenderCopy_BGRA8888_RGB888(SDL_RenderCopyData *data);
  13.132 +extern int SDLCALL SDL_RenderCopy_BGRA8888_RGB888_Scale(SDL_RenderCopyData *data);
  13.133 +extern int SDLCALL SDL_RenderCopy_BGRA8888_RGB888_Blend(SDL_RenderCopyData *data);
  13.134 +extern int SDLCALL SDL_RenderCopy_BGRA8888_RGB888_Blend_Scale(SDL_RenderCopyData *data);
  13.135 +extern int SDLCALL SDL_RenderCopy_BGRA8888_RGB888_Modulate(SDL_RenderCopyData *data);
  13.136 +extern int SDLCALL SDL_RenderCopy_BGRA8888_RGB888_Modulate_Scale(SDL_RenderCopyData *data);
  13.137 +extern int SDLCALL SDL_RenderCopy_BGRA8888_RGB888_Modulate_Blend(SDL_RenderCopyData *data);
  13.138 +extern int SDLCALL SDL_RenderCopy_BGRA8888_RGB888_Modulate_Blend_Scale(SDL_RenderCopyData *data);
  13.139 +extern int SDLCALL SDL_RenderCopy_BGRA8888_BGR888(SDL_RenderCopyData *data);
  13.140 +extern int SDLCALL SDL_RenderCopy_BGRA8888_BGR888_Scale(SDL_RenderCopyData *data);
  13.141 +extern int SDLCALL SDL_RenderCopy_BGRA8888_BGR888_Blend(SDL_RenderCopyData *data);
  13.142 +extern int SDLCALL SDL_RenderCopy_BGRA8888_BGR888_Blend_Scale(SDL_RenderCopyData *data);
  13.143 +extern int SDLCALL SDL_RenderCopy_BGRA8888_BGR888_Modulate(SDL_RenderCopyData *data);
  13.144 +extern int SDLCALL SDL_RenderCopy_BGRA8888_BGR888_Modulate_Scale(SDL_RenderCopyData *data);
  13.145 +extern int SDLCALL SDL_RenderCopy_BGRA8888_BGR888_Modulate_Blend(SDL_RenderCopyData *data);
  13.146 +extern int SDLCALL SDL_RenderCopy_BGRA8888_BGR888_Modulate_Blend_Scale(SDL_RenderCopyData *data);
  13.147 +
  13.148 +/* *INDENT-ON* */
  13.149 +
  13.150 +/* vi: set ts=4 sw=4 expandtab: */
    14.1 --- a/src/video/SDL_renderer_gl.c	Thu Aug 24 12:49:59 2006 +0000
    14.2 +++ b/src/video/SDL_renderer_gl.c	Mon Aug 28 03:17:39 2006 +0000
    14.3 @@ -32,6 +32,8 @@
    14.4  
    14.5  /* OpenGL renderer implementation */
    14.6  
    14.7 +static const float inv255f = 1.0f / 255.0f;
    14.8 +
    14.9  static SDL_Renderer *GL_CreateRenderer(SDL_Window * window, Uint32 flags);
   14.10  static int GL_ActivateRenderer(SDL_Renderer * renderer);
   14.11  static int GL_DisplayModeChanged(SDL_Renderer * renderer);
   14.12 @@ -43,20 +45,27 @@
   14.13  static int GL_GetTexturePalette(SDL_Renderer * renderer,
   14.14                                  SDL_Texture * texture, SDL_Color * colors,
   14.15                                  int firstcolor, int ncolors);
   14.16 +static int GL_SetTextureColorMod(SDL_Renderer * renderer,
   14.17 +                                 SDL_Texture * texture);
   14.18 +static int GL_SetTextureAlphaMod(SDL_Renderer * renderer,
   14.19 +                                 SDL_Texture * texture);
   14.20 +static int GL_SetTextureBlendMode(SDL_Renderer * renderer,
   14.21 +                                  SDL_Texture * texture);
   14.22 +static int GL_SetTextureScaleMode(SDL_Renderer * renderer,
   14.23 +                                  SDL_Texture * texture);
   14.24  static int GL_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
   14.25                              const SDL_Rect * rect, const void *pixels,
   14.26                              int pitch);
   14.27  static int GL_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture,
   14.28 -                          const SDL_Rect * rect, int markDirty,
   14.29 -                          void **pixels, int *pitch);
   14.30 +                          const SDL_Rect * rect, int markDirty, void **pixels,
   14.31 +                          int *pitch);
   14.32  static void GL_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture);
   14.33  static void GL_DirtyTexture(SDL_Renderer * renderer, SDL_Texture * texture,
   14.34                              int numrects, const SDL_Rect * rects);
   14.35 -static int GL_RenderFill(SDL_Renderer * renderer, const SDL_Rect * rect,
   14.36 -                         Uint32 color);
   14.37 +static int GL_RenderFill(SDL_Renderer * renderer, Uint8 r, Uint8 g, Uint8 b,
   14.38 +                         Uint8 a, const SDL_Rect * rect);
   14.39  static int GL_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
   14.40 -                         const SDL_Rect * srcrect, const SDL_Rect * dstrect,
   14.41 -                         int blendMode, int scaleMode);
   14.42 +                         const SDL_Rect * srcrect, const SDL_Rect * dstrect);
   14.43  static void GL_RenderPresent(SDL_Renderer * renderer);
   14.44  static void GL_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture);
   14.45  static void GL_DestroyRenderer(SDL_Renderer * renderer);
   14.46 @@ -68,6 +77,8 @@
   14.47       "opengl",
   14.48       (SDL_RENDERER_SINGLEBUFFER | SDL_RENDERER_PRESENTDISCARD |
   14.49        SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_ACCELERATED),
   14.50 +     (SDL_TEXTUREMODULATE_NONE | SDL_TEXTUREMODULATE_COLOR |
   14.51 +      SDL_TEXTUREMODULATE_ALPHA),
   14.52       (SDL_TEXTUREBLENDMODE_NONE | SDL_TEXTUREBLENDMODE_MASK |
   14.53        SDL_TEXTUREBLENDMODE_BLEND | SDL_TEXTUREBLENDMODE_ADD |
   14.54        SDL_TEXTUREBLENDMODE_MOD),
   14.55 @@ -236,6 +247,10 @@
   14.56      renderer->CreateTexture = GL_CreateTexture;
   14.57      renderer->SetTexturePalette = GL_SetTexturePalette;
   14.58      renderer->GetTexturePalette = GL_GetTexturePalette;
   14.59 +    renderer->SetTextureColorMod = GL_SetTextureColorMod;
   14.60 +    renderer->SetTextureAlphaMod = GL_SetTextureAlphaMod;
   14.61 +    renderer->SetTextureBlendMode = GL_SetTextureBlendMode;
   14.62 +    renderer->SetTextureScaleMode = GL_SetTextureScaleMode;
   14.63      renderer->UpdateTexture = GL_UpdateTexture;
   14.64      renderer->LockTexture = GL_LockTexture;
   14.65      renderer->UnlockTexture = GL_UnlockTexture;
   14.66 @@ -570,6 +585,54 @@
   14.67  }
   14.68  
   14.69  static int
   14.70 +GL_SetTextureColorMod(SDL_Renderer * renderer, SDL_Texture * texture)
   14.71 +{
   14.72 +    return -1;
   14.73 +}
   14.74 +
   14.75 +static int
   14.76 +GL_SetTextureAlphaMod(SDL_Renderer * renderer, SDL_Texture * texture)
   14.77 +{
   14.78 +    return -1;
   14.79 +}
   14.80 +
   14.81 +static int
   14.82 +GL_SetTextureBlendMode(SDL_Renderer * renderer, SDL_Texture * texture)
   14.83 +{
   14.84 +    switch (texture->blendMode) {
   14.85 +    case SDL_TEXTUREBLENDMODE_NONE:
   14.86 +    case SDL_TEXTUREBLENDMODE_MASK:
   14.87 +    case SDL_TEXTUREBLENDMODE_BLEND:
   14.88 +    case SDL_TEXTUREBLENDMODE_ADD:
   14.89 +    case SDL_TEXTUREBLENDMODE_MOD:
   14.90 +        return 0;
   14.91 +    default:
   14.92 +        SDL_Unsupported();
   14.93 +        texture->blendMode = SDL_TEXTUREBLENDMODE_NONE;
   14.94 +        return -1;
   14.95 +    }
   14.96 +}
   14.97 +
   14.98 +static int
   14.99 +GL_SetTextureScaleMode(SDL_Renderer * renderer, SDL_Texture * texture)
  14.100 +{
  14.101 +    switch (texture->scaleMode) {
  14.102 +    case SDL_TEXTURESCALEMODE_NONE:
  14.103 +    case SDL_TEXTURESCALEMODE_FAST:
  14.104 +    case SDL_TEXTURESCALEMODE_SLOW:
  14.105 +        return 0;
  14.106 +    case SDL_TEXTURESCALEMODE_BEST:
  14.107 +        SDL_Unsupported();
  14.108 +        texture->scaleMode = SDL_TEXTURESCALEMODE_SLOW;
  14.109 +        return -1;
  14.110 +    default:
  14.111 +        SDL_Unsupported();
  14.112 +        texture->scaleMode = SDL_TEXTURESCALEMODE_NONE;
  14.113 +        return -1;
  14.114 +    }
  14.115 +}
  14.116 +
  14.117 +static int
  14.118  GL_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
  14.119                   const SDL_Rect * rect, const void *pixels, int pitch)
  14.120  {
  14.121 @@ -636,18 +699,14 @@
  14.122  }
  14.123  
  14.124  static int
  14.125 -GL_RenderFill(SDL_Renderer * renderer, const SDL_Rect * rect, Uint32 color)
  14.126 +GL_RenderFill(SDL_Renderer * renderer, Uint8 r, Uint8 g, Uint8 b, Uint8 a,
  14.127 +              const SDL_Rect * rect)
  14.128  {
  14.129      GL_RenderData *data = (GL_RenderData *) renderer->driverdata;
  14.130      SDL_Window *window = SDL_GetWindowFromID(renderer->window);
  14.131 -    GLclampf r, g, b, a;
  14.132  
  14.133 -    a = ((GLclampf) ((color >> 24) & 0xFF)) / 255.0f;
  14.134 -    r = ((GLclampf) ((color >> 16) & 0xFF)) / 255.0f;
  14.135 -    g = ((GLclampf) ((color >> 8) & 0xFF)) / 255.0f;
  14.136 -    b = ((GLclampf) (color & 0xFF)) / 255.0f;
  14.137 -
  14.138 -    data->glClearColor(r, g, b, a);
  14.139 +    data->glClearColor((GLclampf) r * inv255f, (GLclampf) g * inv255f,
  14.140 +                       (GLclampf) b * inv255f, (GLclampf) a * inv255f);
  14.141      data->glViewport(rect->x, window->h - rect->y, rect->w, rect->h);
  14.142      data->glClear(GL_COLOR_BUFFER_BIT);
  14.143      data->glViewport(0, 0, window->w, window->h);
  14.144 @@ -656,8 +715,7 @@
  14.145  
  14.146  static int
  14.147  GL_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
  14.148 -              const SDL_Rect * srcrect, const SDL_Rect * dstrect,
  14.149 -              int blendMode, int scaleMode)
  14.150 +              const SDL_Rect * srcrect, const SDL_Rect * dstrect)
  14.151  {
  14.152      GL_RenderData *data = (GL_RenderData *) renderer->driverdata;
  14.153      GL_TextureData *texturedata = (GL_TextureData *) texture->driverdata;
  14.154 @@ -700,8 +758,17 @@
  14.155  
  14.156      data->glBindTexture(texturedata->type, texturedata->texture);
  14.157  
  14.158 -    if (blendMode != data->blendMode) {
  14.159 -        switch (blendMode) {
  14.160 +    if (texture->modMode) {
  14.161 +        data->glColor4f((GLfloat) texture->r * inv255f,
  14.162 +                        (GLfloat) texture->g * inv255f,
  14.163 +                        (GLfloat) texture->b * inv255f,
  14.164 +                        (GLfloat) texture->a * inv255f);
  14.165 +    } else {
  14.166 +        data->glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
  14.167 +    }
  14.168 +
  14.169 +    if (texture->blendMode != data->blendMode) {
  14.170 +        switch (texture->blendMode) {
  14.171          case SDL_TEXTUREBLENDMODE_NONE:
  14.172              data->glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);
  14.173              data->glDisable(GL_BLEND);
  14.174 @@ -723,11 +790,11 @@
  14.175              data->glBlendFunc(GL_ZERO, GL_SRC_COLOR);
  14.176              break;
  14.177          }
  14.178 -        data->blendMode = blendMode;
  14.179 +        data->blendMode = texture->blendMode;
  14.180      }
  14.181  
  14.182 -    if (scaleMode != data->scaleMode) {
  14.183 -        switch (scaleMode) {
  14.184 +    if (texture->scaleMode != data->scaleMode) {
  14.185 +        switch (texture->scaleMode) {
  14.186          case SDL_TEXTURESCALEMODE_NONE:
  14.187          case SDL_TEXTURESCALEMODE_FAST:
  14.188              data->glTexParameteri(texturedata->type, GL_TEXTURE_MIN_FILTER,
  14.189 @@ -743,7 +810,7 @@
  14.190                                    GL_LINEAR);
  14.191              break;
  14.192          }
  14.193 -        data->scaleMode = scaleMode;
  14.194 +        data->scaleMode = texture->scaleMode;
  14.195      }
  14.196  
  14.197      data->glBegin(GL_TRIANGLE_STRIP);
    15.1 --- a/src/video/SDL_renderer_sw.c	Thu Aug 24 12:49:59 2006 +0000
    15.2 +++ b/src/video/SDL_renderer_sw.c	Mon Aug 28 03:17:39 2006 +0000
    15.3 @@ -26,6 +26,7 @@
    15.4  #include "SDL_pixels_c.h"
    15.5  #include "SDL_rect_c.h"
    15.6  #include "SDL_yuv_sw_c.h"
    15.7 +#include "SDL_rendercopy.h"
    15.8  
    15.9  
   15.10  /* SDL surface based renderer implementation */
   15.11 @@ -44,22 +45,28 @@
   15.12  static int SW_GetTexturePalette(SDL_Renderer * renderer,
   15.13                                  SDL_Texture * texture, SDL_Color * colors,
   15.14                                  int firstcolor, int ncolors);
   15.15 -static int SW_UpdateTexture(SDL_Renderer * renderer,
   15.16 -                            SDL_Texture * texture, const SDL_Rect * rect,
   15.17 -                            const void *pixels, int pitch);
   15.18 +static int SW_SetTextureColorMod(SDL_Renderer * renderer,
   15.19 +                                 SDL_Texture * texture);
   15.20 +static int SW_SetTextureAlphaMod(SDL_Renderer * renderer,
   15.21 +                                 SDL_Texture * texture);
   15.22 +static int SW_SetTextureBlendMode(SDL_Renderer * renderer,
   15.23 +                                  SDL_Texture * texture);
   15.24 +static int SW_SetTextureScaleMode(SDL_Renderer * renderer,
   15.25 +                                  SDL_Texture * texture);
   15.26 +static int SW_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
   15.27 +                            const SDL_Rect * rect, const void *pixels,
   15.28 +                            int pitch);
   15.29  static int SW_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture,
   15.30 -                          const SDL_Rect * rect, int markDirty,
   15.31 -                          void **pixels, int *pitch);
   15.32 +                          const SDL_Rect * rect, int markDirty, void **pixels,
   15.33 +                          int *pitch);
   15.34  static void SW_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture);
   15.35  static void SW_DirtyTexture(SDL_Renderer * renderer,
   15.36                              SDL_Texture * texture, int numrects,
   15.37                              const SDL_Rect * rects);
   15.38 -static int SW_RenderFill(SDL_Renderer * renderer, const SDL_Rect * rect,
   15.39 -                         Uint32 color);
   15.40 +static int SW_RenderFill(SDL_Renderer * renderer, Uint8 r, Uint8 g, Uint8 b,
   15.41 +                         Uint8 a, const SDL_Rect * rect);
   15.42  static int SW_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
   15.43 -                         const SDL_Rect * srcrect,
   15.44 -                         const SDL_Rect * dstrect, int blendMode,
   15.45 -                         int scaleMode);
   15.46 +                         const SDL_Rect * srcrect, const SDL_Rect * dstrect);
   15.47  static void SW_RenderPresent(SDL_Renderer * renderer);
   15.48  static void SW_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture);
   15.49  static void SW_DestroyRenderer(SDL_Renderer * renderer);
   15.50 @@ -72,8 +79,11 @@
   15.51       (SDL_RENDERER_SINGLEBUFFER | SDL_RENDERER_PRESENTCOPY |
   15.52        SDL_RENDERER_PRESENTFLIP2 | SDL_RENDERER_PRESENTFLIP3 |
   15.53        SDL_RENDERER_PRESENTDISCARD | SDL_RENDERER_PRESENTVSYNC),
   15.54 +     (SDL_TEXTUREMODULATE_NONE | SDL_TEXTUREMODULATE_COLOR |
   15.55 +      SDL_TEXTUREMODULATE_ALPHA),
   15.56       (SDL_TEXTUREBLENDMODE_NONE | SDL_TEXTUREBLENDMODE_MASK |
   15.57 -      SDL_TEXTUREBLENDMODE_BLEND),
   15.58 +      SDL_TEXTUREBLENDMODE_BLEND | SDL_TEXTUREBLENDMODE_ADD |
   15.59 +      SDL_TEXTUREBLENDMODE_MOD),
   15.60       (SDL_TEXTURESCALEMODE_NONE | SDL_TEXTURESCALEMODE_FAST),
   15.61       11,
   15.62       {
   15.63 @@ -188,6 +198,10 @@
   15.64      renderer->QueryTexturePixels = SW_QueryTexturePixels;
   15.65      renderer->SetTexturePalette = SW_SetTexturePalette;
   15.66      renderer->GetTexturePalette = SW_GetTexturePalette;
   15.67 +    renderer->SetTextureColorMod = SW_SetTextureColorMod;
   15.68 +    renderer->SetTextureAlphaMod = SW_SetTextureAlphaMod;
   15.69 +    renderer->SetTextureBlendMode = SW_SetTextureBlendMode;
   15.70 +    renderer->SetTextureScaleMode = SW_SetTextureScaleMode;
   15.71      renderer->UpdateTexture = SW_UpdateTexture;
   15.72      renderer->LockTexture = SW_LockTexture;
   15.73      renderer->UnlockTexture = SW_UnlockTexture;
   15.74 @@ -333,6 +347,7 @@
   15.75      if (SDL_ISPIXELFORMAT_FOURCC(texture->format)) {
   15.76          texture->driverdata = SDL_SW_CreateYUVTexture(texture);
   15.77      } else {
   15.78 +        SDL_Surface *surface;
   15.79          int bpp;
   15.80          Uint32 Rmask, Gmask, Bmask, Amask;
   15.81  
   15.82 @@ -400,6 +415,72 @@
   15.83      }
   15.84  }
   15.85  
   15.86 +static void
   15.87 +SW_UpdateRenderCopyFunc(SDL_Renderer * renderer, SDL_Texture * texture)
   15.88 +{
   15.89 +    SW_RenderData *data = (SW_RenderData *) renderer->driverdata;
   15.90 +    SDL_Surface *surface = (SDL_Surface *) texture->driverdata;
   15.91 +
   15.92 +    surface->userdata =
   15.93 +        SDL_GetRenderCopyFunc(texture->format, data->format, texture->modMode,
   15.94 +                              texture->blendMode, texture->scaleMode);
   15.95 +}
   15.96 +
   15.97 +static int
   15.98 +SW_SetTextureColorMod(SDL_Renderer * renderer, SDL_Texture * texture)
   15.99 +{
  15.100 +    SW_UpdateRenderCopyFunc(renderer, texture);
  15.101 +    return 0;
  15.102 +}
  15.103 +
  15.104 +static int
  15.105 +SW_SetTextureAlphaMod(SDL_Renderer * renderer, SDL_Texture * texture)
  15.106 +{
  15.107 +    SW_UpdateRenderCopyFunc(renderer, texture);
  15.108 +    return 0;
  15.109 +}
  15.110 +
  15.111 +static int
  15.112 +SW_SetTextureBlendMode(SDL_Renderer * renderer, SDL_Texture * texture)
  15.113 +{
  15.114 +    switch (texture->blendMode) {
  15.115 +    case SDL_TEXTUREBLENDMODE_NONE:
  15.116 +    case SDL_TEXTUREBLENDMODE_MASK:
  15.117 +    case SDL_TEXTUREBLENDMODE_BLEND:
  15.118 +    case SDL_TEXTUREBLENDMODE_ADD:
  15.119 +    case SDL_TEXTUREBLENDMODE_MOD:
  15.120 +        SW_UpdateRenderCopyFunc(renderer, texture);
  15.121 +        return 0;
  15.122 +    default:
  15.123 +        SDL_Unsupported();
  15.124 +        texture->blendMode = SDL_TEXTUREBLENDMODE_NONE;
  15.125 +        SW_UpdateRenderCopyFunc(renderer, texture);
  15.126 +        return -1;
  15.127 +    }
  15.128 +}
  15.129 +
  15.130 +static int
  15.131 +SW_SetTextureScaleMode(SDL_Renderer * renderer, SDL_Texture * texture)
  15.132 +{
  15.133 +    switch (texture->scaleMode) {
  15.134 +    case SDL_TEXTURESCALEMODE_NONE:
  15.135 +    case SDL_TEXTURESCALEMODE_FAST:
  15.136 +        SW_UpdateRenderCopyFunc(renderer, texture);
  15.137 +        return 0;
  15.138 +    case SDL_TEXTURESCALEMODE_SLOW:
  15.139 +    case SDL_TEXTURESCALEMODE_BEST:
  15.140 +        SDL_Unsupported();
  15.141 +        texture->scaleMode = SDL_TEXTURESCALEMODE_FAST;
  15.142 +        SW_UpdateRenderCopyFunc(renderer, texture);
  15.143 +        return -1;
  15.144 +    default:
  15.145 +        SDL_Unsupported();
  15.146 +        texture->scaleMode = SDL_TEXTURESCALEMODE_NONE;
  15.147 +        SW_UpdateRenderCopyFunc(renderer, texture);
  15.148 +        return -1;
  15.149 +    }
  15.150 +}
  15.151 +
  15.152  static int
  15.153  SW_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
  15.154                   const SDL_Rect * rect, const void *pixels, int pitch)
  15.155 @@ -462,10 +543,11 @@
  15.156  }
  15.157  
  15.158  static int
  15.159 -SW_RenderFill(SDL_Renderer * renderer, const SDL_Rect * rect, Uint32 color)
  15.160 +SW_RenderFill(SDL_Renderer * renderer, Uint8 r, Uint8 g, Uint8 b, Uint8 a,
  15.161 +              const SDL_Rect * rect)
  15.162  {
  15.163      SW_RenderData *data = (SW_RenderData *) renderer->driverdata;
  15.164 -    Uint8 r, g, b, a;
  15.165 +    Uint32 color;
  15.166      SDL_Rect real_rect;
  15.167      int status;
  15.168  
  15.169 @@ -473,10 +555,6 @@
  15.170          SDL_AddDirtyRect(&data->dirty, rect);
  15.171      }
  15.172  
  15.173 -    a = (Uint8) ((color >> 24) & 0xFF);
  15.174 -    r = (Uint8) ((color >> 16) & 0xFF);
  15.175 -    g = (Uint8) ((color >> 8) & 0xFF);
  15.176 -    b = (Uint8) (color & 0xFF);
  15.177      color = SDL_MapRGBA(data->surface.format, r, g, b, a);
  15.178  
  15.179      if (data->renderer->
  15.180 @@ -500,8 +578,7 @@
  15.181  
  15.182  static int
  15.183  SW_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
  15.184 -              const SDL_Rect * srcrect, const SDL_Rect * dstrect,
  15.185 -              int blendMode, int scaleMode)
  15.186 +              const SDL_Rect * srcrect, const SDL_Rect * dstrect)
  15.187  {
  15.188      SW_RenderData *data = (SW_RenderData *) renderer->driverdata;
  15.189      SDL_Window *window = SDL_GetWindowFromID(renderer->window);
  15.190 @@ -525,27 +602,55 @@
  15.191                                  data->surface.pixels, data->surface.pitch);
  15.192      } else {
  15.193          SDL_Surface *surface = (SDL_Surface *) texture->driverdata;
  15.194 -        SDL_Rect real_srcrect = *srcrect;
  15.195 -        SDL_Rect real_dstrect;
  15.196 +        SDL_RenderCopyFunc copyfunc = (SDL_RenderCopyFunc) surface->userdata;
  15.197  
  15.198 -        data->surface.w = dstrect->w;
  15.199 -        data->surface.h = dstrect->h;
  15.200 -        data->surface.clip_rect.w = dstrect->w;
  15.201 -        data->surface.clip_rect.h = dstrect->h;
  15.202 -        real_dstrect = data->surface.clip_rect;
  15.203 +        if (copyfunc) {
  15.204 +            SDL_RenderCopyData copydata;
  15.205  
  15.206 -        if (blendMode &
  15.207 -            (SDL_TEXTUREBLENDMODE_MASK | SDL_TEXTUREBLENDMODE_BLEND)) {
  15.208 -            SDL_SetAlpha(surface, SDL_SRCALPHA, 0);
  15.209 +            copydata.src =
  15.210 +                (Uint8 *) surface->pixels + srcrect->y * surface->pitch +
  15.211 +                srcrect->x * surface->format->BytesPerPixel;
  15.212 +            copydata.src_w = srcrect->w;
  15.213 +            copydata.src_h = srcrect->h;
  15.214 +            copydata.src_pitch = surface->pitch;
  15.215 +            copydata.dst = (Uint8 *) data->surface.pixels;
  15.216 +            copydata.dst_w = dstrect->w;
  15.217 +            copydata.dst_h = dstrect->h;
  15.218 +            copydata.dst_pitch = data->surface.pitch;
  15.219 +            copydata.flags = 0;
  15.220 +            if (texture->modMode & SDL_TEXTUREMODULATE_COLOR) {
  15.221 +                copydata.flags |= SDL_RENDERCOPY_MODULATE_COLOR;
  15.222 +                copydata.r = texture->r;
  15.223 +                copydata.g = texture->g;
  15.224 +                copydata.b = texture->b;
  15.225 +            }
  15.226 +            if (texture->modMode & SDL_TEXTUREMODULATE_ALPHA) {
  15.227 +                copydata.flags |= SDL_RENDERCOPY_MODULATE_ALPHA;
  15.228 +                copydata.a = texture->a;
  15.229 +            }
  15.230 +            if (texture->
  15.231 +                blendMode & (SDL_TEXTUREBLENDMODE_MASK |
  15.232 +                             SDL_TEXTUREBLENDMODE_BLEND)) {
  15.233 +                copydata.flags |= SDL_RENDERCOPY_BLEND;
  15.234 +            } else if (texture->blendMode & SDL_TEXTUREBLENDMODE_ADD) {
  15.235 +                copydata.flags |= SDL_RENDERCOPY_ADD;
  15.236 +            } else if (texture->blendMode & SDL_TEXTUREBLENDMODE_MOD) {
  15.237 +                copydata.flags |= SDL_RENDERCOPY_MOD;
  15.238 +            }
  15.239 +            if (texture->scaleMode) {
  15.240 +                copydata.flags |= SDL_RENDERCOPY_NEAREST;
  15.241 +            }
  15.242 +            status = copyfunc(&copydata);
  15.243          } else {
  15.244 -            SDL_SetAlpha(surface, 0, 0);
  15.245 -        }
  15.246 -        if (scaleMode != SDL_TEXTURESCALEMODE_NONE &&
  15.247 -            (srcrect->w != dstrect->w || srcrect->h != dstrect->h)) {
  15.248 -            status =
  15.249 -                SDL_SoftStretch(surface, &real_srcrect, &data->surface,
  15.250 -                                &real_dstrect);
  15.251 -        } else {
  15.252 +            SDL_Rect real_srcrect = *srcrect;
  15.253 +            SDL_Rect real_dstrect;
  15.254 +
  15.255 +            data->surface.w = dstrect->w;
  15.256 +            data->surface.h = dstrect->h;
  15.257 +            data->surface.clip_rect.w = dstrect->w;
  15.258 +            data->surface.clip_rect.h = dstrect->h;
  15.259 +            real_dstrect = data->surface.clip_rect;
  15.260 +
  15.261              status =
  15.262                  SDL_LowerBlit(surface, &real_srcrect, &data->surface,
  15.263                                &real_dstrect);
  15.264 @@ -567,9 +672,7 @@
  15.265          SDL_DirtyRect *dirty;
  15.266          for (dirty = data->dirty.list; dirty; dirty = dirty->next) {
  15.267              data->renderer->RenderCopy(data->renderer, texture, &dirty->rect,
  15.268 -                                       &dirty->rect,
  15.269 -                                       SDL_TEXTUREBLENDMODE_NONE,
  15.270 -                                       SDL_TEXTURESCALEMODE_NONE);
  15.271 +                                       &dirty->rect);
  15.272          }
  15.273          SDL_ClearDirtyRects(&data->dirty);
  15.274      } else {
  15.275 @@ -578,9 +681,7 @@
  15.276          rect.y = 0;
  15.277          rect.w = texture->w;
  15.278          rect.h = texture->h;
  15.279 -        data->renderer->RenderCopy(data->renderer, texture, &rect, &rect,
  15.280 -                                   SDL_TEXTUREBLENDMODE_NONE,
  15.281 -                                   SDL_TEXTURESCALEMODE_NONE);
  15.282 +        data->renderer->RenderCopy(data->renderer, texture, &rect, &rect);
  15.283      }
  15.284      data->renderer->RenderPresent(data->renderer);
  15.285  
    16.1 --- a/src/video/SDL_stretch.c	Thu Aug 24 12:49:59 2006 +0000
    16.2 +++ b/src/video/SDL_stretch.c	Mon Aug 28 03:17:39 2006 +0000
    16.3 @@ -121,30 +121,33 @@
    16.4  
    16.5  #else
    16.6  
    16.7 -#define DEFINE_COPY_ROW(name, type)			\
    16.8 -void name(type *src, int src_w, type *dst, int dst_w)	\
    16.9 -{							\
   16.10 -	int i;						\
   16.11 -	int pos, inc;					\
   16.12 -	type pixel = 0;					\
   16.13 -							\
   16.14 -	pos = 0x10000;					\
   16.15 -	inc = (src_w << 16) / dst_w;			\
   16.16 -	for ( i=dst_w; i>0; --i ) {			\
   16.17 -		while ( pos >= 0x10000L ) {		\
   16.18 -			pixel = *src++;			\
   16.19 -			pos -= 0x10000L;		\
   16.20 -		}					\
   16.21 -		*dst++ = pixel;				\
   16.22 -		pos += inc;				\
   16.23 -	}						\
   16.24 +#define DEFINE_COPY_ROW(name, type)                     \
   16.25 +void name(type *src, int src_w, type *dst, int dst_w)   \
   16.26 +{                                                       \
   16.27 +    int i;                                              \
   16.28 +    int pos, inc;                                       \
   16.29 +    type pixel = 0;                                     \
   16.30 +                                                        \
   16.31 +    pos = 0x10000;                                      \
   16.32 +    inc = (src_w << 16) / dst_w;                        \
   16.33 +    for ( i=dst_w; i>0; --i ) {                         \
   16.34 +        while ( pos >= 0x10000L ) {                     \
   16.35 +            pixel = *src++;                             \
   16.36 +            pos -= 0x10000L;                            \
   16.37 +        }                                               \
   16.38 +        *dst++ = pixel;                                 \
   16.39 +        pos += inc;                                     \
   16.40 +    }                                                   \
   16.41  }
   16.42 +/* *INDENT-OFF* */
   16.43  DEFINE_COPY_ROW(copy_row1, Uint8)
   16.44 -    DEFINE_COPY_ROW(copy_row2, Uint16) DEFINE_COPY_ROW(copy_row4, Uint32)
   16.45 +DEFINE_COPY_ROW(copy_row2, Uint16)
   16.46 +DEFINE_COPY_ROW(copy_row4, Uint32)
   16.47 +/* *INDENT-ON* */
   16.48  #endif /* USE_ASM_STRETCH */
   16.49  /* The ASM code doesn't handle 24-bpp stretch blits */
   16.50 -     void
   16.51 -     copy_row3(Uint8 * src, int src_w, Uint8 * dst, int dst_w)
   16.52 +void
   16.53 +copy_row3(Uint8 * src, int src_w, Uint8 * dst, int dst_w)
   16.54  {
   16.55      int i;
   16.56      int pos, inc;
   16.57 @@ -278,14 +281,20 @@
   16.58  #ifdef __GNUC__
   16.59            __asm__ __volatile__("call *%4": "=&D"(u1), "=&S"(u2): "0"(dstp), "1"(srcp), "r"(copy_row):"memory");
   16.60  #elif defined(_MSC_VER) || defined(__WATCOMC__)
   16.61 +            /* *INDENT-OFF* */
   16.62              {
   16.63                  void *code = copy_row;
   16.64                  __asm {
   16.65 -                push edi
   16.66 -                        push esi
   16.67 -                        mov edi, dstp
   16.68 -                        mov esi, srcp call dword ptr code pop esi pop edi}
   16.69 +                    push edi
   16.70 +                    push esi
   16.71 +                    mov edi, dstp
   16.72 +                    mov esi, srcp
   16.73 +                    call dword ptr code
   16.74 +                    pop esi
   16.75 +                    pop edi
   16.76 +                }
   16.77              }
   16.78 +            /* *INDENT-ON* */
   16.79  #else
   16.80  #error Need inline assembly for this compiler
   16.81  #endif
    17.1 --- a/src/video/SDL_sysvideo.h	Thu Aug 24 12:49:59 2006 +0000
    17.2 +++ b/src/video/SDL_sysvideo.h	Mon Aug 28 03:17:39 2006 +0000
    17.3 @@ -44,6 +44,10 @@
    17.4      int access;         /**< SDL_TextureAccess */
    17.5      int w;              /**< The width of the texture */
    17.6      int h;              /**< The height of the texture */
    17.7 +    int modMode;        /**< The texture modulation mode */
    17.8 +    int blendMode;      /**< The texture blend mode */
    17.9 +    int scaleMode;      /**< The texture scale mode */
   17.10 +    Uint8 r, g, b, a;   /**< Texture modulation values */
   17.11  
   17.12      SDL_Renderer *renderer;
   17.13  
   17.14 @@ -66,6 +70,14 @@
   17.15      int (*GetTexturePalette) (SDL_Renderer * renderer, SDL_Texture * texture,
   17.16                                SDL_Color * colors, int firstcolor,
   17.17                                int ncolors);
   17.18 +    int (*SetTextureColorMod) (SDL_Renderer * renderer,
   17.19 +                               SDL_Texture * texture);
   17.20 +    int (*SetTextureAlphaMod) (SDL_Renderer * renderer,
   17.21 +                               SDL_Texture * texture);
   17.22 +    int (*SetTextureBlendMode) (SDL_Renderer * renderer,
   17.23 +                                SDL_Texture * texture);
   17.24 +    int (*SetTextureScaleMode) (SDL_Renderer * renderer,
   17.25 +                                SDL_Texture * texture);
   17.26      int (*UpdateTexture) (SDL_Renderer * renderer, SDL_Texture * texture,
   17.27                            const SDL_Rect * rect, const void *pixels,
   17.28                            int pitch);
   17.29 @@ -75,11 +87,10 @@
   17.30      void (*UnlockTexture) (SDL_Renderer * renderer, SDL_Texture * texture);
   17.31      void (*DirtyTexture) (SDL_Renderer * renderer, SDL_Texture * texture,
   17.32                            int numrects, const SDL_Rect * rects);
   17.33 -    int (*RenderFill) (SDL_Renderer * renderer, const SDL_Rect * rect,
   17.34 -                       Uint32 color);
   17.35 +    int (*RenderFill) (SDL_Renderer * renderer, Uint8 r, Uint8 g, Uint8 b,
   17.36 +                       Uint8 a, const SDL_Rect * rect);
   17.37      int (*RenderCopy) (SDL_Renderer * renderer, SDL_Texture * texture,
   17.38 -                       const SDL_Rect * srcrect, const SDL_Rect * dstrect,
   17.39 -                       int blendMode, int scaleMode);
   17.40 +                       const SDL_Rect * srcrect, const SDL_Rect * dstrect);
   17.41      void (*RenderPresent) (SDL_Renderer * renderer);
   17.42      void (*DestroyTexture) (SDL_Renderer * renderer, SDL_Texture * texture);
   17.43  
    18.1 --- a/src/video/SDL_video.c	Thu Aug 24 12:49:59 2006 +0000
    18.2 +++ b/src/video/SDL_video.c	Mon Aug 28 03:17:39 2006 +0000
    18.3 @@ -1510,6 +1510,10 @@
    18.4      texture->access = access;
    18.5      texture->w = w;
    18.6      texture->h = h;
    18.7 +    texture->r = 255;
    18.8 +    texture->g = 255;
    18.9 +    texture->b = 255;
   18.10 +    texture->a = 255;
   18.11      texture->renderer = renderer;
   18.12  
   18.13      if (renderer->CreateTexture(renderer, texture) < 0) {
   18.14 @@ -1772,6 +1776,162 @@
   18.15  }
   18.16  
   18.17  int
   18.18 +SDL_SetTextureColorMod(SDL_TextureID textureID, Uint8 r, Uint8 g, Uint8 b)
   18.19 +{
   18.20 +    SDL_Texture *texture = SDL_GetTextureFromID(textureID);
   18.21 +    SDL_Renderer *renderer;
   18.22 +
   18.23 +    if (!texture) {
   18.24 +        return -1;
   18.25 +    }
   18.26 +
   18.27 +    renderer = texture->renderer;
   18.28 +    if (!renderer->SetTextureColorMod) {
   18.29 +        return -1;
   18.30 +    }
   18.31 +    if (r < 255 | g < 255 | b < 255) {
   18.32 +        texture->modMode |= SDL_TEXTUREMODULATE_COLOR;
   18.33 +    } else {
   18.34 +        texture->modMode &= ~SDL_TEXTUREMODULATE_COLOR;
   18.35 +    }
   18.36 +    texture->r = r;
   18.37 +    texture->g = g;
   18.38 +    texture->b = b;
   18.39 +    return renderer->SetTextureColorMod(renderer, texture);
   18.40 +}
   18.41 +
   18.42 +int
   18.43 +SDL_GetTextureColorMod(SDL_TextureID textureID, Uint8 * r, Uint8 * g,
   18.44 +                       Uint8 * b)
   18.45 +{
   18.46 +    SDL_Texture *texture = SDL_GetTextureFromID(textureID);
   18.47 +    SDL_Renderer *renderer;
   18.48 +
   18.49 +    if (!texture) {
   18.50 +        return -1;
   18.51 +    }
   18.52 +
   18.53 +    renderer = texture->renderer;
   18.54 +    if (r) {
   18.55 +        *r = texture->r;
   18.56 +    }
   18.57 +    if (g) {
   18.58 +        *g = texture->g;
   18.59 +    }
   18.60 +    if (b) {
   18.61 +        *b = texture->b;
   18.62 +    }
   18.63 +    return 0;
   18.64 +}
   18.65 +
   18.66 +int
   18.67 +SDL_SetTextureAlphaMod(SDL_TextureID textureID, Uint8 alpha)
   18.68 +{
   18.69 +    SDL_Texture *texture = SDL_GetTextureFromID(textureID);
   18.70 +    SDL_Renderer *renderer;
   18.71 +
   18.72 +    if (!texture) {
   18.73 +        return -1;
   18.74 +    }
   18.75 +
   18.76 +    renderer = texture->renderer;
   18.77 +    if (!renderer->SetTextureAlphaMod) {
   18.78 +        return -1;
   18.79 +    }
   18.80 +    if (alpha < 255) {
   18.81 +        texture->modMode |= SDL_TEXTUREMODULATE_ALPHA;
   18.82 +    } else {
   18.83 +        texture->modMode &= ~SDL_TEXTUREMODULATE_ALPHA;
   18.84 +    }
   18.85 +    texture->a = alpha;
   18.86 +    return renderer->SetTextureAlphaMod(renderer, texture);
   18.87 +}
   18.88 +
   18.89 +int
   18.90 +SDL_GetTextureAlphaMod(SDL_TextureID textureID, Uint8 * alpha)
   18.91 +{
   18.92 +    SDL_Texture *texture = SDL_GetTextureFromID(textureID);
   18.93 +    SDL_Renderer *renderer;
   18.94 +
   18.95 +    if (!texture) {
   18.96 +        return -1;
   18.97 +    }
   18.98 +
   18.99 +    if (alpha) {
  18.100 +        *alpha = texture->a;
  18.101 +    }
  18.102 +    return 0;
  18.103 +}
  18.104 +
  18.105 +int
  18.106 +SDL_SetTextureBlendMode(SDL_TextureID textureID, int blendMode)
  18.107 +{
  18.108 +    SDL_Texture *texture = SDL_GetTextureFromID(textureID);
  18.109 +    SDL_Renderer *renderer;
  18.110 +
  18.111 +    if (!texture) {
  18.112 +        return -1;
  18.113 +    }
  18.114 +
  18.115 +    renderer = texture->renderer;
  18.116 +    if (!renderer->SetTextureBlendMode) {
  18.117 +        return -1;
  18.118 +    }
  18.119 +    texture->blendMode = blendMode;
  18.120 +    return renderer->SetTextureBlendMode(renderer, texture);
  18.121 +}
  18.122 +
  18.123 +int
  18.124 +SDL_GetTextureBlendMode(SDL_TextureID textureID, int *blendMode)
  18.125 +{
  18.126 +    SDL_Texture *texture = SDL_GetTextureFromID(textureID);
  18.127 +    SDL_Renderer *renderer;
  18.128 +
  18.129 +    if (!texture) {
  18.130 +        return -1;
  18.131 +    }
  18.132 +
  18.133 +    if (blendMode) {
  18.134 +        *blendMode = texture->blendMode;
  18.135 +    }
  18.136 +    return 0;
  18.137 +}
  18.138 +
  18.139 +int
  18.140 +SDL_SetTextureScaleMode(SDL_TextureID textureID, int scaleMode)
  18.141 +{
  18.142 +    SDL_Texture *texture = SDL_GetTextureFromID(textureID);
  18.143 +    SDL_Renderer *renderer;
  18.144 +
  18.145 +    if (!texture) {
  18.146 +        return -1;
  18.147 +    }
  18.148 +
  18.149 +    renderer = texture->renderer;
  18.150 +    if (!renderer->SetTextureScaleMode) {
  18.151 +        return -1;
  18.152 +    }
  18.153 +    texture->scaleMode = scaleMode;
  18.154 +    return renderer->SetTextureScaleMode(renderer, texture);
  18.155 +}
  18.156 +
  18.157 +int
  18.158 +SDL_GetTextureScaleMode(SDL_TextureID textureID, int *scaleMode)
  18.159 +{
  18.160 +    SDL_Texture *texture = SDL_GetTextureFromID(textureID);
  18.161 +    SDL_Renderer *renderer;
  18.162 +
  18.163 +    if (!texture) {
  18.164 +        return -1;
  18.165 +    }
  18.166 +
  18.167 +    if (scaleMode) {
  18.168 +        *scaleMode = texture->scaleMode;
  18.169 +    }
  18.170 +    return 0;
  18.171 +}
  18.172 +
  18.173 +int
  18.174  SDL_UpdateTexture(SDL_TextureID textureID, const SDL_Rect * rect,
  18.175                    const void *pixels, int pitch)
  18.176  {
  18.177 @@ -1864,7 +2024,7 @@
  18.178  }
  18.179  
  18.180  int
  18.181 -SDL_RenderFill(const SDL_Rect * rect, Uint32 color)
  18.182 +SDL_RenderFill(Uint8 r, Uint8 g, Uint8 b, Uint8 a, const SDL_Rect * rect)
  18.183  {
  18.184      SDL_Renderer *renderer;
  18.185      SDL_Window *window;
  18.186 @@ -1891,12 +2051,12 @@
  18.187          }
  18.188      }
  18.189  
  18.190 -    return renderer->RenderFill(renderer, &real_rect, color);
  18.191 +    return renderer->RenderFill(renderer, r, g, b, a, &real_rect);
  18.192  }
  18.193  
  18.194  int
  18.195  SDL_RenderCopy(SDL_TextureID textureID, const SDL_Rect * srcrect,
  18.196 -               const SDL_Rect * dstrect, int blendMode, int scaleMode)
  18.197 +               const SDL_Rect * dstrect)
  18.198  {
  18.199      SDL_Texture *texture = SDL_GetTextureFromID(textureID);
  18.200      SDL_Renderer *renderer;
  18.201 @@ -1932,7 +2092,7 @@
  18.202      }
  18.203  
  18.204      return renderer->RenderCopy(renderer, texture, &real_srcrect,
  18.205 -                                &real_dstrect, blendMode, scaleMode);
  18.206 +                                &real_dstrect);
  18.207  }
  18.208  
  18.209  void
    19.1 --- a/src/video/dummy/SDL_nullrender.c	Thu Aug 24 12:49:59 2006 +0000
    19.2 +++ b/src/video/dummy/SDL_nullrender.c	Mon Aug 28 03:17:39 2006 +0000
    19.3 @@ -24,6 +24,7 @@
    19.4  #include "SDL_video.h"
    19.5  #include "../SDL_sysvideo.h"
    19.6  #include "../SDL_yuv_sw_c.h"
    19.7 +#include "../SDL_rendercopy.h"
    19.8  
    19.9  
   19.10  /* SDL surface based renderer implementation */
   19.11 @@ -43,6 +44,14 @@
   19.12                                         SDL_Texture * texture,
   19.13                                         SDL_Color * colors, int firstcolor,
   19.14                                         int ncolors);
   19.15 +static int SDL_DUMMY_SetTextureColorMod(SDL_Renderer * renderer,
   19.16 +                                        SDL_Texture * texture);
   19.17 +static int SDL_DUMMY_SetTextureAlphaMod(SDL_Renderer * renderer,
   19.18 +                                        SDL_Texture * texture);
   19.19 +static int SDL_DUMMY_SetTextureBlendMode(SDL_Renderer * renderer,
   19.20 +                                         SDL_Texture * texture);
   19.21 +static int SDL_DUMMY_SetTextureScaleMode(SDL_Renderer * renderer,
   19.22 +                                         SDL_Texture * texture);
   19.23  static int SDL_DUMMY_UpdateTexture(SDL_Renderer * renderer,
   19.24                                     SDL_Texture * texture,
   19.25                                     const SDL_Rect * rect, const void *pixels,
   19.26 @@ -57,13 +66,12 @@
   19.27                                     const SDL_Rect * rects);
   19.28  static void SDL_DUMMY_SelectRenderTexture(SDL_Renderer * renderer,
   19.29                                            SDL_Texture * texture);
   19.30 -static int SDL_DUMMY_RenderFill(SDL_Renderer * renderer,
   19.31 -                                const SDL_Rect * rect, Uint32 color);
   19.32 +static int SDL_DUMMY_RenderFill(SDL_Renderer * renderer, Uint8 r, Uint8 g,
   19.33 +                                Uint8 b, Uint8 a, const SDL_Rect * rect);
   19.34  static int SDL_DUMMY_RenderCopy(SDL_Renderer * renderer,
   19.35                                  SDL_Texture * texture,
   19.36                                  const SDL_Rect * srcrect,
   19.37 -                                const SDL_Rect * dstrect, int blendMode,
   19.38 -                                int scaleMode);
   19.39 +                                const SDL_Rect * dstrect);
   19.40  static int SDL_DUMMY_RenderReadPixels(SDL_Renderer * renderer,
   19.41                                        const SDL_Rect * rect, void *pixels,
   19.42                                        int pitch);
   19.43 @@ -83,8 +91,11 @@
   19.44       (SDL_RENDERER_SINGLEBUFFER | SDL_RENDERER_PRESENTCOPY |
   19.45        SDL_RENDERER_PRESENTFLIP2 | SDL_RENDERER_PRESENTFLIP3 |
   19.46        SDL_RENDERER_PRESENTDISCARD),
   19.47 +     (SDL_TEXTUREMODULATE_NONE | SDL_TEXTUREMODULATE_COLOR |
   19.48 +      SDL_TEXTUREMODULATE_ALPHA),
   19.49       (SDL_TEXTUREBLENDMODE_NONE | SDL_TEXTUREBLENDMODE_MASK |
   19.50 -      SDL_TEXTUREBLENDMODE_BLEND),
   19.51 +      SDL_TEXTUREBLENDMODE_BLEND | SDL_TEXTUREBLENDMODE_ADD |
   19.52 +      SDL_TEXTUREBLENDMODE_MOD),
   19.53       (SDL_TEXTURESCALEMODE_NONE | SDL_TEXTURESCALEMODE_FAST),
   19.54       11,
   19.55       {
   19.56 @@ -144,6 +155,10 @@
   19.57      renderer->QueryTexturePixels = SDL_DUMMY_QueryTexturePixels;
   19.58      renderer->SetTexturePalette = SDL_DUMMY_SetTexturePalette;
   19.59      renderer->GetTexturePalette = SDL_DUMMY_GetTexturePalette;
   19.60 +    renderer->SetTextureColorMod = SDL_DUMMY_SetTextureColorMod;
   19.61 +    renderer->SetTextureAlphaMod = SDL_DUMMY_SetTextureAlphaMod;
   19.62 +    renderer->SetTextureBlendMode = SDL_DUMMY_SetTextureBlendMode;
   19.63 +    renderer->SetTextureScaleMode = SDL_DUMMY_SetTextureScaleMode;
   19.64      renderer->UpdateTexture = SDL_DUMMY_UpdateTexture;
   19.65      renderer->LockTexture = SDL_DUMMY_LockTexture;
   19.66      renderer->UnlockTexture = SDL_DUMMY_UnlockTexture;
   19.67 @@ -258,6 +273,74 @@
   19.68      }
   19.69  }
   19.70  
   19.71 +static void
   19.72 +SDL_DUMMY_UpdateRenderCopyFunc(SDL_Renderer * renderer, SDL_Texture * texture)
   19.73 +{
   19.74 +    SDL_Window *window = SDL_GetWindowFromID(renderer->window);
   19.75 +    SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window);
   19.76 +    SDL_Surface *surface = (SDL_Surface *) texture->driverdata;
   19.77 +
   19.78 +    surface->userdata =
   19.79 +        SDL_GetRenderCopyFunc(texture->format, display->current_mode.format,
   19.80 +                              texture->modMode, texture->blendMode,
   19.81 +                              texture->scaleMode);
   19.82 +}
   19.83 +
   19.84 +static int
   19.85 +SDL_DUMMY_SetTextureColorMod(SDL_Renderer * renderer, SDL_Texture * texture)
   19.86 +{
   19.87 +    SDL_DUMMY_UpdateRenderCopyFunc(renderer, texture);
   19.88 +    return 0;
   19.89 +}
   19.90 +
   19.91 +static int
   19.92 +SDL_DUMMY_SetTextureAlphaMod(SDL_Renderer * renderer, SDL_Texture * texture)
   19.93 +{
   19.94 +    SDL_DUMMY_UpdateRenderCopyFunc(renderer, texture);
   19.95 +    return 0;
   19.96 +}
   19.97 +
   19.98 +static int
   19.99 +SDL_DUMMY_SetTextureBlendMode(SDL_Renderer * renderer, SDL_Texture * texture)
  19.100 +{
  19.101 +    switch (texture->blendMode) {
  19.102 +    case SDL_TEXTUREBLENDMODE_NONE:
  19.103 +    case SDL_TEXTUREBLENDMODE_MASK:
  19.104 +    case SDL_TEXTUREBLENDMODE_BLEND:
  19.105 +    case SDL_TEXTUREBLENDMODE_ADD:
  19.106 +    case SDL_TEXTUREBLENDMODE_MOD:
  19.107 +        SDL_DUMMY_UpdateRenderCopyFunc(renderer, texture);
  19.108 +        return 0;
  19.109 +    default:
  19.110 +        SDL_Unsupported();
  19.111 +        texture->blendMode = SDL_TEXTUREBLENDMODE_NONE;
  19.112 +        SDL_DUMMY_UpdateRenderCopyFunc(renderer, texture);
  19.113 +        return -1;
  19.114 +    }
  19.115 +}
  19.116 +
  19.117 +static int
  19.118 +SDL_DUMMY_SetTextureScaleMode(SDL_Renderer * renderer, SDL_Texture * texture)
  19.119 +{
  19.120 +    switch (texture->scaleMode) {
  19.121 +    case SDL_TEXTURESCALEMODE_NONE:
  19.122 +    case SDL_TEXTURESCALEMODE_FAST:
  19.123 +        SDL_DUMMY_UpdateRenderCopyFunc(renderer, texture);
  19.124 +        return 0;
  19.125 +    case SDL_TEXTURESCALEMODE_SLOW:
  19.126 +    case SDL_TEXTURESCALEMODE_BEST:
  19.127 +        SDL_Unsupported();
  19.128 +        texture->scaleMode = SDL_TEXTURESCALEMODE_FAST;
  19.129 +        SDL_DUMMY_UpdateRenderCopyFunc(renderer, texture);
  19.130 +        return -1;
  19.131 +    default:
  19.132 +        SDL_Unsupported();
  19.133 +        texture->scaleMode = SDL_TEXTURESCALEMODE_NONE;
  19.134 +        SDL_DUMMY_UpdateRenderCopyFunc(renderer, texture);
  19.135 +        return -1;
  19.136 +    }
  19.137 +}
  19.138 +
  19.139  static int
  19.140  SDL_DUMMY_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
  19.141                          const SDL_Rect * rect, const void *pixels, int pitch)
  19.142 @@ -320,19 +403,15 @@
  19.143  }
  19.144  
  19.145  static int
  19.146 -SDL_DUMMY_RenderFill(SDL_Renderer * renderer, const SDL_Rect * rect,
  19.147 -                     Uint32 color)
  19.148 +SDL_DUMMY_RenderFill(SDL_Renderer * renderer, Uint8 r, Uint8 g, Uint8 b,
  19.149 +                     Uint8 a, const SDL_Rect * rect)
  19.150  {
  19.151      SDL_DUMMY_RenderData *data =
  19.152          (SDL_DUMMY_RenderData *) renderer->driverdata;
  19.153      SDL_Surface *target = data->screens[data->current_screen];
  19.154 +    Uint32 color;
  19.155      SDL_Rect real_rect = *rect;
  19.156 -    Uint8 r, g, b, a;
  19.157  
  19.158 -    a = (Uint8) ((color >> 24) & 0xFF);
  19.159 -    r = (Uint8) ((color >> 16) & 0xFF);
  19.160 -    g = (Uint8) ((color >> 8) & 0xFF);
  19.161 -    b = (Uint8) (color & 0xFF);
  19.162      color = SDL_MapRGBA(target->format, r, g, b, a);
  19.163  
  19.164      return SDL_FillRect(target, &real_rect, color);
  19.165 @@ -340,8 +419,7 @@
  19.166  
  19.167  static int
  19.168  SDL_DUMMY_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
  19.169 -                     const SDL_Rect * srcrect, const SDL_Rect * dstrect,
  19.170 -                     int blendMode, int scaleMode)
  19.171 +                     const SDL_Rect * srcrect, const SDL_Rect * dstrect)
  19.172  {
  19.173      SDL_DUMMY_RenderData *data =
  19.174          (SDL_DUMMY_RenderData *) renderer->driverdata;
  19.175 @@ -360,20 +438,51 @@
  19.176      } else {
  19.177          SDL_Surface *surface = (SDL_Surface *) texture->driverdata;
  19.178          SDL_Surface *target = data->screens[data->current_screen];
  19.179 -        SDL_Rect real_srcrect = *srcrect;
  19.180 -        SDL_Rect real_dstrect = *dstrect;
  19.181 +        SDL_RenderCopyFunc copyfunc = (SDL_RenderCopyFunc) surface->userdata;
  19.182  
  19.183 -        if (blendMode &
  19.184 -            (SDL_TEXTUREBLENDMODE_MASK | SDL_TEXTUREBLENDMODE_BLEND)) {
  19.185 -            SDL_SetAlpha(surface, SDL_SRCALPHA, 0);
  19.186 +        if (copyfunc) {
  19.187 +            SDL_RenderCopyData copydata;
  19.188 +
  19.189 +            copydata.src =
  19.190 +                (Uint8 *) surface->pixels + srcrect->y * surface->pitch +
  19.191 +                srcrect->x * surface->format->BytesPerPixel;
  19.192 +            copydata.src_w = srcrect->w;
  19.193 +            copydata.src_h = srcrect->h;
  19.194 +            copydata.src_pitch = surface->pitch;
  19.195 +            copydata.dst =
  19.196 +                (Uint8 *) target->pixels + dstrect->y * target->pitch +
  19.197 +                dstrect->x * target->format->BytesPerPixel;
  19.198 +            copydata.dst_w = dstrect->w;
  19.199 +            copydata.dst_h = dstrect->h;
  19.200 +            copydata.dst_pitch = target->pitch;
  19.201 +            copydata.flags = 0;
  19.202 +            if (texture->modMode & SDL_TEXTUREMODULATE_COLOR) {
  19.203 +                copydata.flags |= SDL_RENDERCOPY_MODULATE_COLOR;
  19.204 +                copydata.r = texture->r;
  19.205 +                copydata.g = texture->g;
  19.206 +                copydata.b = texture->b;
  19.207 +            }
  19.208 +            if (texture->modMode & SDL_TEXTUREMODULATE_ALPHA) {
  19.209 +                copydata.flags |= SDL_RENDERCOPY_MODULATE_ALPHA;
  19.210 +                copydata.a = texture->a;
  19.211 +            }
  19.212 +            if (texture->
  19.213 +                blendMode & (SDL_TEXTUREBLENDMODE_MASK |
  19.214 +                             SDL_TEXTUREBLENDMODE_BLEND)) {
  19.215 +                copydata.flags |= SDL_RENDERCOPY_BLEND;
  19.216 +            } else if (texture->blendMode & SDL_TEXTUREBLENDMODE_ADD) {
  19.217 +                copydata.flags |= SDL_RENDERCOPY_ADD;
  19.218 +            } else if (texture->blendMode & SDL_TEXTUREBLENDMODE_MOD) {
  19.219 +                copydata.flags |= SDL_RENDERCOPY_MOD;
  19.220 +            }
  19.221 +            if (texture->scaleMode) {
  19.222 +                copydata.flags |= SDL_RENDERCOPY_NEAREST;
  19.223 +            }
  19.224 +            return copyfunc(&copydata);
  19.225          } else {
  19.226 -            SDL_SetAlpha(surface, 0, 0);
  19.227 -        }
  19.228 -        if (scaleMode != SDL_TEXTURESCALEMODE_NONE &&
  19.229 -            (srcrect->w != dstrect->w || srcrect->h != dstrect->h)) {
  19.230 -            return SDL_SoftStretch(surface, &real_srcrect, target,
  19.231 -                                   &real_dstrect);
  19.232 -        } else {
  19.233 +            SDL_Rect real_srcrect = *srcrect;
  19.234 +            SDL_Rect real_dstrect = *dstrect;
  19.235 +
  19.236              return SDL_LowerBlit(surface, &real_srcrect, target,
  19.237                                   &real_dstrect);
  19.238          }
    20.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    20.2 +++ b/src/video/sdlgenblit.pl	Mon Aug 28 03:17:39 2006 +0000
    20.3 @@ -0,0 +1,521 @@
    20.4 +#!/usr/bin/perl -w
    20.5 +#
    20.6 +# A script to generate optimized C blitters for Simple DirectMedia Layer
    20.7 +# http://www.libsdl.org/
    20.8 +
    20.9 +use warnings;
   20.10 +use strict;
   20.11 +
   20.12 +my %file;
   20.13 +
   20.14 +# The formats potentially supported by this script:
   20.15 +# SDL_PIXELFORMAT_INDEX8
   20.16 +# SDL_PIXELFORMAT_RGB332
   20.17 +# SDL_PIXELFORMAT_RGB444
   20.18 +# SDL_PIXELFORMAT_RGB555
   20.19 +# SDL_PIXELFORMAT_ARGB4444
   20.20 +# SDL_PIXELFORMAT_ARGB1555
   20.21 +# SDL_PIXELFORMAT_RGB565
   20.22 +# SDL_PIXELFORMAT_RGB24
   20.23 +# SDL_PIXELFORMAT_BGR24
   20.24 +# SDL_PIXELFORMAT_RGB888
   20.25 +# SDL_PIXELFORMAT_BGR888
   20.26 +# SDL_PIXELFORMAT_ARGB8888
   20.27 +# SDL_PIXELFORMAT_RGBA8888
   20.28 +# SDL_PIXELFORMAT_ABGR8888
   20.29 +# SDL_PIXELFORMAT_BGRA8888
   20.30 +# SDL_PIXELFORMAT_ARGB2101010
   20.31 +
   20.32 +# The formats we're actually creating blitters for:
   20.33 +my @src_formats = (
   20.34 +    "RGB888",
   20.35 +    "BGR888",
   20.36 +    "ARGB8888",
   20.37 +    "RGBA8888",
   20.38 +    "ABGR8888",
   20.39 +    "BGRA8888",
   20.40 +);
   20.41 +my @dst_formats = (
   20.42 +    "RGB888",
   20.43 +    "BGR888",
   20.44 +);
   20.45 +
   20.46 +my %format_size = (
   20.47 +    "RGB888" => 4,
   20.48 +    "BGR888" => 4,
   20.49 +    "ARGB8888" => 4,
   20.50 +    "RGBA8888" => 4,
   20.51 +    "ABGR8888" => 4,
   20.52 +    "BGRA8888" => 4,
   20.53 +);
   20.54 +
   20.55 +my %format_type = (
   20.56 +    "RGB888" => "Uint32",
   20.57 +    "BGR888" => "Uint32",
   20.58 +    "ARGB8888" => "Uint32",
   20.59 +    "RGBA8888" => "Uint32",
   20.60 +    "ABGR8888" => "Uint32",
   20.61 +    "BGRA8888" => "Uint32",
   20.62 +);
   20.63 +
   20.64 +my %get_rgba_string = (
   20.65 +    "RGB888" => "_R = (Uint8)(_pixel >> 16); _G = (Uint8)(_pixel >> 8); _B = (Uint8)_pixel; _A = 0xFF;",
   20.66 +    "BGR888" => "_B = (Uint8)(_pixel >> 16); _G = (Uint8)(_pixel >> 8); _R = (Uint8)_pixel; _A = 0xFF;",
   20.67 +    "ARGB8888" => "_A = (Uint8)(_pixel >> 24); _R = (Uint8)(_pixel >> 16); _G = (Uint8)(_pixel >> 8); _B = (Uint8)_pixel;",
   20.68 +    "RGBA8888" => "_R = (Uint8)(_pixel >> 24); _G = (Uint8)(_pixel >> 16); _B = (Uint8)(_pixel >> 8); _A = (Uint8)_pixel;",
   20.69 +    "ABGR8888" => "_A = (Uint8)(_pixel >> 24); _B = (Uint8)(_pixel >> 16); _G = (Uint8)(_pixel >> 8); _R = (Uint8)_pixel;",
   20.70 +    "BGRA8888" => "_B = (Uint8)(_pixel >> 24); _G = (Uint8)(_pixel >> 16); _R = (Uint8)(_pixel >> 8); _A = (Uint8)_pixel;",
   20.71 +);
   20.72 +
   20.73 +my %set_rgba_string = (
   20.74 +    "RGB888" => "_pixel = ((Uint32)_R << 16) | ((Uint32)_G << 8) | _B;",
   20.75 +    "BGR888" => "_pixel = ((Uint32)_B << 16) | ((Uint32)_G << 8) | _R;",
   20.76 +);
   20.77 +
   20.78 +sub open_file {
   20.79 +    my $name = shift;
   20.80 +    open(FILE, ">$name.new") || die "Cant' open $name.new: $!";
   20.81 +    print FILE <<__EOF__;
   20.82 +/* DO NOT EDIT!  This file is generated by sdlgenblit.pl */
   20.83 +/*
   20.84 +    SDL - Simple DirectMedia Layer
   20.85 +    Copyright (C) 1997-2006 Sam Lantinga
   20.86 +
   20.87 +    This library is free software; you can redistribute it and/or
   20.88 +    modify it under the terms of the GNU Lesser General Public
   20.89 +    License as published by the Free Software Foundation; either
   20.90 +    version 2.1 of the License, or (at your option) any later version.
   20.91 +
   20.92 +    This library is distributed in the hope that it will be useful,
   20.93 +    but WITHOUT ANY WARRANTY; without even the implied warranty of
   20.94 +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   20.95 +    Lesser General Public License for more details.
   20.96 +
   20.97 +    You should have received a copy of the GNU Lesser General Public
   20.98 +    License along with this library; if not, write to the Free Software
   20.99 +    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  20.100 +
  20.101 +    Sam Lantinga
  20.102 +    slouken\@libsdl.org
  20.103 +*/
  20.104 +#include "SDL_config.h"
  20.105 +
  20.106 +/* *INDENT-OFF* */
  20.107 +
  20.108 +__EOF__
  20.109 +}
  20.110 +
  20.111 +sub close_file {
  20.112 +    my $name = shift;
  20.113 +    print FILE <<__EOF__;
  20.114 +/* *INDENT-ON* */
  20.115 +
  20.116 +/* vi: set ts=4 sw=4 expandtab: */
  20.117 +__EOF__
  20.118 +    close FILE;
  20.119 +    if ( ! -f $name || system("cmp -s $name $name.new") != 0 ) {
  20.120 +        rename("$name.new", "$name");
  20.121 +    } else {
  20.122 +        unlink("$name.new");
  20.123 +    }
  20.124 +}
  20.125 +
  20.126 +sub output_copydefs
  20.127 +{
  20.128 +    print FILE <<__EOF__;
  20.129 +#define SDL_RENDERCOPY_MODULATE_COLOR   0x0001
  20.130 +#define SDL_RENDERCOPY_MODULATE_ALPHA   0x0002
  20.131 +#define SDL_RENDERCOPY_BLEND            0x0010
  20.132 +#define SDL_RENDERCOPY_ADD              0x0020
  20.133 +#define SDL_RENDERCOPY_MOD              0x0040
  20.134 +#define SDL_RENDERCOPY_NEAREST          0x0100
  20.135 +
  20.136 +typedef struct {
  20.137 +    void *src;
  20.138 +    int src_w, src_h;
  20.139 +    int src_pitch;
  20.140 +    void *dst;
  20.141 +    int dst_w, dst_h;
  20.142 +    int dst_pitch;
  20.143 +    void *aux_data;
  20.144 +    int flags;
  20.145 +    Uint8 r, g, b, a;
  20.146 +} SDL_RenderCopyData;
  20.147 +
  20.148 +typedef int (*SDL_RenderCopyFunc)(SDL_RenderCopyData *data);
  20.149 +
  20.150 +extern SDL_RenderCopyFunc SDLCALL SDL_GetRenderCopyFunc(Uint32 src_format, Uint32 dst_format, int modMode, int blendMode, int scaleMode);
  20.151 +
  20.152 +__EOF__
  20.153 +}
  20.154 +
  20.155 +sub output_copyfuncname
  20.156 +{
  20.157 +    my $prefix = shift;
  20.158 +    my $src = shift;
  20.159 +    my $dst = shift;
  20.160 +    my $modulate = shift;
  20.161 +    my $blend = shift;
  20.162 +    my $scale = shift;
  20.163 +    my $args = shift;
  20.164 +    my $suffix = shift;
  20.165 +
  20.166 +    print FILE "$prefix SDL_RenderCopy_${src}_${dst}";
  20.167 +    if ( $modulate ) {
  20.168 +        print FILE "_Modulate";
  20.169 +    }
  20.170 +    if ( $blend ) {
  20.171 +        print FILE "_Blend";
  20.172 +    }
  20.173 +    if ( $scale ) {
  20.174 +        print FILE "_Scale";
  20.175 +    }
  20.176 +    if ( $args ) {
  20.177 +        print FILE "(SDL_RenderCopyData *data)";
  20.178 +    }
  20.179 +    print FILE "$suffix";
  20.180 +}
  20.181 +
  20.182 +sub get_rgba
  20.183 +{
  20.184 +    my $prefix = shift;
  20.185 +    my $format = shift;
  20.186 +    my $string = $get_rgba_string{$format};
  20.187 +    $string =~ s/_/$prefix/g;
  20.188 +    if ( $prefix ne "" ) {
  20.189 +        print FILE <<__EOF__;
  20.190 +            ${prefix}pixel = *$prefix;
  20.191 +__EOF__
  20.192 +    } else {
  20.193 +        print FILE <<__EOF__;
  20.194 +            pixel = *src;
  20.195 +__EOF__
  20.196 +    }
  20.197 +    print FILE <<__EOF__;
  20.198 +            $string
  20.199 +__EOF__
  20.200 +}
  20.201 +
  20.202 +sub set_rgba
  20.203 +{
  20.204 +    my $prefix = shift;
  20.205 +    my $format = shift;
  20.206 +    my $string = $set_rgba_string{$format};
  20.207 +    $string =~ s/_/$prefix/g;
  20.208 +    print FILE <<__EOF__;
  20.209 +            $string
  20.210 +            *dst = ${prefix}pixel;
  20.211 +__EOF__
  20.212 +}
  20.213 +
  20.214 +sub output_copycore
  20.215 +{
  20.216 +    my $src = shift;
  20.217 +    my $dst = shift;
  20.218 +    my $modulate = shift;
  20.219 +    my $blend = shift;
  20.220 +    if ( $modulate ) {
  20.221 +        print FILE <<__EOF__;
  20.222 +            if (flags & SDL_RENDERCOPY_MODULATE_COLOR) {
  20.223 +                ${src}R = (${src}R * modulateR) / 255;
  20.224 +                ${src}G = (${src}G * modulateG) / 255;
  20.225 +                ${src}B = (${src}B * modulateB) / 255;
  20.226 +            }
  20.227 +__EOF__
  20.228 +    }
  20.229 +    if ( $modulate && $blend ) {
  20.230 +        print FILE <<__EOF__;
  20.231 +            if (flags & SDL_RENDERCOPY_MODULATE_ALPHA) {
  20.232 +                ${src}A = (${src}A * modulateA) / 255;
  20.233 +            }
  20.234 +__EOF__
  20.235 +    }
  20.236 +    if ( $blend ) {
  20.237 +        print FILE <<__EOF__;
  20.238 +            if (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD)) {
  20.239 +                /* This goes away if we ever use premultiplied alpha */
  20.240 +                ${src}R = (${src}R * ${src}A) / 255;
  20.241 +                ${src}G = (${src}G * ${src}A) / 255;
  20.242 +                ${src}B = (${src}B * ${src}A) / 255;
  20.243 +            }
  20.244 +            switch (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD|SDL_RENDERCOPY_MOD)) {
  20.245 +            case SDL_RENDERCOPY_BLEND:
  20.246 +                ${dst}R = ${src}R + ((255 - ${src}A) * ${dst}R) / 255;
  20.247 +                ${dst}G = ${src}G + ((255 - ${src}A) * ${dst}G) / 255;
  20.248 +                ${dst}B = ${src}B + ((255 - ${src}A) * ${dst}B) / 255;
  20.249 +                break;
  20.250 +            case SDL_RENDERCOPY_ADD:
  20.251 +                ${dst}R = ${src}R + ${dst}R; if (${dst}R > 255) ${dst}R = 255;
  20.252 +                ${dst}G = ${src}G + ${dst}G; if (${dst}G > 255) ${dst}G = 255;
  20.253 +                ${dst}B = ${src}B + ${dst}B; if (${dst}B > 255) ${dst}B = 255;
  20.254 +                break;
  20.255 +            case SDL_RENDERCOPY_MOD:
  20.256 +                ${dst}R = (${src}R * ${dst}R) / 255;
  20.257 +                ${dst}G = (${src}G * ${dst}G) / 255;
  20.258 +                ${dst}B = (${src}B * ${dst}B) / 255;
  20.259 +                break;
  20.260 +            }
  20.261 +__EOF__
  20.262 +    }
  20.263 +}
  20.264 +
  20.265 +sub output_copyfunc
  20.266 +{
  20.267 +    my $src = shift;
  20.268 +    my $dst = shift;
  20.269 +    my $modulate = shift;
  20.270 +    my $blend = shift;
  20.271 +    my $scale = shift;
  20.272 +
  20.273 +    output_copyfuncname("int", $src, $dst, $modulate, $blend, $scale, 1, "\n");
  20.274 +    print FILE <<__EOF__;
  20.275 +{
  20.276 +    const int flags = data->flags;
  20.277 +__EOF__
  20.278 +    if ( $modulate ) {
  20.279 +        print FILE <<__EOF__;
  20.280 +    const Uint32 modulateR = data->r;
  20.281 +    const Uint32 modulateG = data->g;
  20.282 +    const Uint32 modulateB = data->b;
  20.283 +    const Uint32 modulateA = data->a;
  20.284 +__EOF__
  20.285 +    }
  20.286 +    if ( $blend ) {
  20.287 +        print FILE <<__EOF__;
  20.288 +    Uint32 srcpixel;
  20.289 +    Uint32 srcR, srcG, srcB, srcA;
  20.290 +    Uint32 dstpixel;
  20.291 +    Uint32 dstR, dstG, dstB, dstA;
  20.292 +__EOF__
  20.293 +    } elsif ( $modulate || $src ne $dst ) {
  20.294 +        print FILE <<__EOF__;
  20.295 +    Uint32 pixel;
  20.296 +    Uint32 R, G, B, A;
  20.297 +__EOF__
  20.298 +    }
  20.299 +    if ( $scale ) {
  20.300 +        print FILE <<__EOF__;
  20.301 +    int srcy, srcx;
  20.302 +    int posy, posx;
  20.303 +    int incy, incx;
  20.304 +
  20.305 +    srcy = 0;
  20.306 +    posy = 0;
  20.307 +    incy = (data->src_h << 16) / data->dst_h;
  20.308 +    incx = (data->src_w << 16) / data->dst_w;
  20.309 +
  20.310 +    while (data->dst_h--) {
  20.311 +        $format_type{$src} *src;
  20.312 +        $format_type{$dst} *dst = ($format_type{$dst} *)data->dst;
  20.313 +        int n = data->dst_w;
  20.314 +        srcx = -1;
  20.315 +        posx = 0x10000L;
  20.316 +        while (posy >= 0x10000L) {
  20.317 +            ++srcy;
  20.318 +            posy -= 0x10000L;
  20.319 +        }
  20.320 +        while (n--) {
  20.321 +            if (posx >= 0x10000L) {
  20.322 +                while (posx >= 0x10000L) {
  20.323 +                    ++srcx;
  20.324 +                    posx -= 0x10000L;
  20.325 +                }
  20.326 +                src = ($format_type{$src} *)(data->src + (srcy * data->src_pitch) + (srcx * $format_size{$src}));
  20.327 +__EOF__
  20.328 +        print FILE <<__EOF__;
  20.329 +            }
  20.330 +__EOF__
  20.331 +        if ( $blend ) {
  20.332 +            get_rgba("src", $src);
  20.333 +            get_rgba("dst", $dst);
  20.334 +            output_copycore("src", "dst", $modulate, $blend);
  20.335 +            set_rgba("dst", $dst);
  20.336 +        } elsif ( $modulate || $src ne $dst ) {
  20.337 +            get_rgba("", $src);
  20.338 +            output_copycore("", "", $modulate, $blend);
  20.339 +            set_rgba("", $dst);
  20.340 +        } else {
  20.341 +            print FILE <<__EOF__;
  20.342 +            *dst = *src;
  20.343 +__EOF__
  20.344 +        }
  20.345 +        print FILE <<__EOF__;
  20.346 +            posx += incx;
  20.347 +            ++dst;
  20.348 +        }
  20.349 +        posy += incy;
  20.350 +        data->dst += data->dst_pitch;
  20.351 +    }
  20.352 +__EOF__
  20.353 +    } else {
  20.354 +        print FILE <<__EOF__;
  20.355 +
  20.356 +    while (data->dst_h--) {
  20.357 +        $format_type{$src} *src = ($format_type{$src} *)data->src;
  20.358 +        $format_type{$dst} *dst = ($format_type{$dst} *)data->dst;
  20.359 +        int n = data->dst_w;
  20.360 +        while (n--) {
  20.361 +__EOF__
  20.362 +        if ( $blend ) {
  20.363 +            get_rgba("src", $src);
  20.364 +            get_rgba("dst", $dst);
  20.365 +            output_copycore("src", "dst", $modulate, $blend);
  20.366 +            set_rgba("dst", $dst);
  20.367 +        } elsif ( $modulate || $src ne $dst ) {
  20.368 +            get_rgba("", $src);
  20.369 +            output_copycore("", "", $modulate, $blend);
  20.370 +            set_rgba("", $dst);
  20.371 +        } else {
  20.372 +            print FILE <<__EOF__;
  20.373 +            *dst = *src;
  20.374 +__EOF__
  20.375 +        }
  20.376 +        print FILE <<__EOF__;