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_blit.c |   66 ++++++++++++++++----------------
 1 files changed, 33 insertions(+), 33 deletions(-)

diff --git a/source/src/video/SDL_blit.c b/source/src/video/SDL_blit.c
index 0d4e2fd..a5df0b9 100644
--- a/source/src/video/SDL_blit.c
+++ b/source/src/video/SDL_blit.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
@@ -99,6 +99,8 @@
     return (okay ? 0 : -1);
 }
 
+#if SDL_HAVE_BLIT_AUTO
+
 #ifdef __MACOSX__
 #include <sys/sysctl.h>
 
@@ -128,11 +130,11 @@
 SDL_ChooseBlitFunc(Uint32 src_format, Uint32 dst_format, int flags,
                    SDL_BlitFuncEntry * entries)
 {
-    int i, flagcheck;
-    static Uint32 features = 0xffffffff;
+    int i, flagcheck = (flags & (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_COLORKEY | SDL_COPY_NEAREST));
+    static int features = 0x7fffffff;
 
     /* Get the available CPU features */
-    if (features == 0xffffffff) {
+    if (features == 0x7fffffff) {
         const char *override = SDL_getenv("SDL_BLIT_CPU_FEATURES");
 
         features = SDL_CPU_ANY;
@@ -172,36 +174,13 @@
             continue;
         }
 
-        /* Check modulation flags */
-        flagcheck =
-            (flags & (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA));
-        if ((flagcheck & entries[i].flags) != flagcheck) {
-            continue;
-        }
-
-        /* Check blend flags */
-        flagcheck =
-            (flags &
-             (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD));
-        if ((flagcheck & entries[i].flags) != flagcheck) {
-            continue;
-        }
-
-        /* Check colorkey flag */
-        flagcheck = (flags & SDL_COPY_COLORKEY);
-        if ((flagcheck & entries[i].flags) != flagcheck) {
-            continue;
-        }
-
-        /* Check scaling flags */
-        flagcheck = (flags & SDL_COPY_NEAREST);
+        /* Check flags */
         if ((flagcheck & entries[i].flags) != flagcheck) {
             continue;
         }
 
         /* Check CPU features */
-        flagcheck = entries[i].cpu;
-        if ((flagcheck & features) != flagcheck) {
+        if ((entries[i].cpu & features) != entries[i].cpu) {
             continue;
         }
 
@@ -210,6 +189,7 @@
     }
     return NULL;
 }
+#endif /* SDL_HAVE_BLIT_AUTO */
 
 /* Figure out which of many blit routines to set up on a surface */
 int
@@ -225,22 +205,27 @@
         return SDL_SetError("Blit combination not supported");
     }
 
+#if SDL_HAVE_RLE
     /* Clean everything out to start */
     if ((surface->flags & SDL_RLEACCEL) == SDL_RLEACCEL) {
         SDL_UnRLESurface(surface, 1);
     }
+#endif
+
     map->blit = SDL_SoftBlit;
     map->info.src_fmt = surface->format;
     map->info.src_pitch = surface->pitch;
     map->info.dst_fmt = dst->format;
     map->info.dst_pitch = dst->pitch;
 
+#if SDL_HAVE_RLE
     /* See if we can do RLE acceleration */
     if (map->info.flags & SDL_COPY_RLE_DESIRED) {
         if (SDL_RLESurface(surface) == 0) {
             return 0;
         }
     }
+#endif
 
     /* Choose a standard blit function */
     if (map->identity && !(map->info.flags & ~SDL_COPY_RLE_DESIRED)) {
@@ -249,17 +234,30 @@
         /* Greater than 8 bits per channel not supported yet */
         SDL_InvalidateMap(map);
         return SDL_SetError("Blit combination not supported");
-    } else if (surface->format->BitsPerPixel < 8 &&
+    }
+#if SDL_HAVE_BLIT_0
+    else if (surface->format->BitsPerPixel < 8 &&
                SDL_ISPIXELFORMAT_INDEXED(surface->format->format)) {
         blit = SDL_CalculateBlit0(surface);
-    } else if (surface->format->BytesPerPixel == 1 &&
+    }
+#endif
+#if SDL_HAVE_BLIT_1
+    else if (surface->format->BytesPerPixel == 1 &&
                SDL_ISPIXELFORMAT_INDEXED(surface->format->format)) {
         blit = SDL_CalculateBlit1(surface);
-    } else if (map->info.flags & SDL_COPY_BLEND) {
+    }
+#endif
+#if SDL_HAVE_BLIT_A
+    else if (map->info.flags & SDL_COPY_BLEND) {
         blit = SDL_CalculateBlitA(surface);
-    } else {
+    }
+#endif
+#if SDL_HAVE_BLIT_N
+    else {
         blit = SDL_CalculateBlitN(surface);
     }
+#endif
+#if SDL_HAVE_BLIT_AUTO
     if (blit == NULL) {
         Uint32 src_format = surface->format->format;
         Uint32 dst_format = dst->format->format;
@@ -268,6 +266,8 @@
             SDL_ChooseBlitFunc(src_format, dst_format, map->info.flags,
                                SDL_GeneratedBlitFuncTable);
     }
+#endif
+
 #ifndef TEST_SLOW_BLIT
     if (blit == NULL)
 #endif

--
Gitblit v1.9.3