From 03f8528315fa46c95991a34f3325d7b33ae5538c Mon Sep 17 00:00:00 2001
From: Edward Rudd <urkle@outoforder.cc>
Date: Sat, 02 May 2020 21:48:36 +0000
Subject: [PATCH] Update source to SDL2 2.0.12

---
 source/src/video/SDL_RLEaccel.c |   50 ++++++++++++++++++++++++++++++--------------------
 1 files changed, 30 insertions(+), 20 deletions(-)

diff --git a/source/src/video/SDL_RLEaccel.c b/source/src/video/SDL_RLEaccel.c
index 661cb1f..c9b84e3 100644
--- a/source/src/video/SDL_RLEaccel.c
+++ b/source/src/video/SDL_RLEaccel.c
@@ -1,6 +1,6 @@
 /*
   Simple DirectMedia Layer
-  Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org>
+  Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
 
   This software is provided 'as-is', without any express or implied
   warranty.  In no event will the authors be held liable for any damages
@@ -19,6 +19,8 @@
   3. This notice may not be removed or altered from any source distribution.
 */
 #include "../SDL_internal.h"
+
+#if SDL_HAVE_RLE
 
 /*
  * RLE encoding for software colorkey and alpha-channel acceleration
@@ -295,10 +297,10 @@
     } while(0)
 
 #define ALPHA_BLIT16_565_50(to, from, length, bpp, alpha)       \
-    ALPHA_BLIT16_50(to, from, length, bpp, alpha, 0xf7de)
+    ALPHA_BLIT16_50(to, from, length, bpp, alpha, 0xf7deU)
 
 #define ALPHA_BLIT16_555_50(to, from, length, bpp, alpha)       \
-    ALPHA_BLIT16_50(to, from, length, bpp, alpha, 0xfbde)
+    ALPHA_BLIT16_50(to, from, length, bpp, alpha, 0xfbdeU)
 
 #define CHOOSE_BLIT(blitter, alpha, fmt)                        \
     do {                                                        \
@@ -445,7 +447,7 @@
 
 
 /* blit a colorkeyed RLE surface */
-int SDLCALL
+static int SDLCALL
 SDL_RLEBlit(SDL_Surface * surf_src, SDL_Rect * srcrect,
             SDL_Surface * surf_dst, SDL_Rect * dstrect)
 {
@@ -723,7 +725,7 @@
 }
 
 /* blit a pixel-alpha RLE surface */
-int SDLCALL
+static int SDLCALL
 SDL_RLEAlphaBlit(SDL_Surface * surf_src, SDL_Rect * srcrect,
                  SDL_Surface * surf_dst, SDL_Rect * dstrect)
 {
@@ -1220,8 +1222,9 @@
 
     /* Now that we have it encoded, release the original pixels */
     if (!(surface->flags & SDL_PREALLOC)) {
-        SDL_free(surface->pixels);
+        SDL_SIMDFree(surface->pixels);
         surface->pixels = NULL;
+        surface->flags &= ~SDL_SIMD_ALIGNED;
     }
 
     /* realloc the buffer to release unused memory */
@@ -1236,19 +1239,19 @@
 }
 
 static Uint32
-getpix_8(Uint8 * srcbuf)
+getpix_8(const Uint8 * srcbuf)
 {
     return *srcbuf;
 }
 
 static Uint32
-getpix_16(Uint8 * srcbuf)
+getpix_16(const Uint8 * srcbuf)
 {
-    return *(Uint16 *) srcbuf;
+    return *(const Uint16 *) srcbuf;
 }
 
 static Uint32
-getpix_24(Uint8 * srcbuf)
+getpix_24(const Uint8 * srcbuf)
 {
 #if SDL_BYTEORDER == SDL_LIL_ENDIAN
     return srcbuf[0] + (srcbuf[1] << 8) + (srcbuf[2] << 16);
@@ -1258,12 +1261,12 @@
 }
 
 static Uint32
-getpix_32(Uint8 * srcbuf)
+getpix_32(const Uint8 * srcbuf)
 {
-    return *(Uint32 *) srcbuf;
+    return *(const Uint32 *) srcbuf;
 }
 
-typedef Uint32(*getpix_func) (Uint8 *);
+typedef Uint32(*getpix_func) (const Uint8 *);
 
 static const getpix_func getpixes[4] = {
     getpix_8, getpix_16, getpix_24, getpix_32
@@ -1383,8 +1386,9 @@
 
     /* Now that we have it encoded, release the original pixels */
     if (!(surface->flags & SDL_PREALLOC)) {
-        SDL_free(surface->pixels);
+        SDL_SIMDFree(surface->pixels);
         surface->pixels = NULL;
+        surface->flags &= ~SDL_SIMD_ALIGNED;
     }
 
     /* realloc the buffer to release unused memory */
@@ -1428,7 +1432,7 @@
     /* Pass on combinations not supported */
     if ((flags & SDL_COPY_MODULATE_COLOR) ||
         ((flags & SDL_COPY_MODULATE_ALPHA) && surface->format->Amask) ||
-        (flags & (SDL_COPY_ADD | SDL_COPY_MOD)) ||
+        (flags & (SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL)) ||
         (flags & SDL_COPY_NEAREST)) {
         return -1;
     }
@@ -1484,10 +1488,11 @@
         uncopy_opaque = uncopy_transl = uncopy_32;
     }
 
-    surface->pixels = SDL_malloc(surface->h * surface->pitch);
+    surface->pixels = SDL_SIMDAlloc(surface->h * surface->pitch);
     if (!surface->pixels) {
         return (SDL_FALSE);
     }
+    surface->flags |= SDL_SIMD_ALIGNED;
     /* fill background with transparent pixels */
     SDL_memset(surface->pixels, 0, surface->h * surface->pitch);
 
@@ -1510,8 +1515,9 @@
             if (run) {
                 srcbuf += uncopy_opaque(dst + ofs, srcbuf, run, df, sf);
                 ofs += run;
-            } else if (!ofs)
-                return (SDL_TRUE);
+            } else if (!ofs) {
+                goto end_function;
+            }
         } while (ofs < w);
 
         /* skip padding if needed */
@@ -1532,7 +1538,8 @@
         } while (ofs < w);
         dst += surface->pitch >> 2;
     }
-    /* Make the compiler happy */
+
+end_function:
     return (SDL_TRUE);
 }
 
@@ -1547,12 +1554,13 @@
                 SDL_Rect full;
 
                 /* re-create the original surface */
-                surface->pixels = SDL_malloc(surface->h * surface->pitch);
+                surface->pixels = SDL_SIMDAlloc(surface->h * surface->pitch);
                 if (!surface->pixels) {
                     /* Oh crap... */
                     surface->flags |= SDL_RLEACCEL;
                     return;
                 }
+                surface->flags |= SDL_SIMD_ALIGNED;
 
                 /* fill it with the background color */
                 SDL_FillRect(surface, NULL, surface->map->info.colorkey);
@@ -1578,4 +1586,6 @@
     }
 }
 
+#endif /* SDL_HAVE_RLE */
+
 /* vi: set ts=4 sw=4 expandtab: */

--
Gitblit v1.9.3