Commit 7d26ba754a2defbbe5d575884802f6228fdc16a6

Sylvain 2023-03-16T09:46:44

Simplify SDL_BLENDMODE_MUL

diff --git a/include/SDL_blendmode.h b/include/SDL_blendmode.h
index b862116..4ecbe50 100644
--- a/include/SDL_blendmode.h
+++ b/include/SDL_blendmode.h
@@ -52,7 +52,7 @@ typedef enum
                                               dstA = dstA */
     SDL_BLENDMODE_MUL = 0x00000008,      /**< color multiply
                                               dstRGB = (srcRGB * dstRGB) + (dstRGB * (1-srcA))
-                                              dstA = (srcA * dstA) + (dstA * (1-srcA)) */
+                                              dstA = dstA */
     SDL_BLENDMODE_INVALID = 0x7FFFFFFF
 
     /* Additional custom blend modes can be returned by SDL_ComposeCustomBlendMode() */
diff --git a/src/render/software/SDL_draw.h b/src/render/software/SDL_draw.h
index 1492286..db593f4 100644
--- a/src/render/software/SDL_draw.h
+++ b/src/render/software/SDL_draw.h
@@ -91,7 +91,7 @@
 #define DRAW_SETPIXEL_MUL(getpixel, setpixel)      \
     do {                                           \
         unsigned sr, sg, sb, sa;                   \
-        sa = 0xFF;                                 \
+        (void)sa;                                  \
         getpixel;                                  \
         sr = DRAW_MUL(sr, r) + DRAW_MUL(inva, sr); \
         if (sr > 0xff)                             \
@@ -102,9 +102,6 @@
         sb = DRAW_MUL(sb, b) + DRAW_MUL(inva, sb); \
         if (sb > 0xff)                             \
             sb = 0xff;                             \
-        sa = DRAW_MUL(sa, a) + DRAW_MUL(inva, sa); \
-        if (sa > 0xff)                             \
-            sa = 0xff;                             \
         setpixel;                                  \
     } while (0)
 
diff --git a/src/render/software/SDL_triangle.c b/src/render/software/SDL_triangle.c
index 77ae3ac..fc429db 100644
--- a/src/render/software/SDL_triangle.c
+++ b/src/render/software/SDL_triangle.c
@@ -869,10 +869,6 @@ static void SDL_BlitTriangle_Slow(SDL_BlitInfo *info,
             if (dstB > 255) {
                 dstB = 255;
             }
-            dstA = ((srcA * dstA) + (dstA * (255 - srcA))) / 255;
-            if (dstA > 255) {
-                dstA = 255;
-            }
             break;
         }
         if (FORMAT_HAS_ALPHA(dstfmt_val)) {
diff --git a/src/video/SDL_blit_slow.c b/src/video/SDL_blit_slow.c
index bbdfb1d..9ea5c38 100644
--- a/src/video/SDL_blit_slow.c
+++ b/src/video/SDL_blit_slow.c
@@ -178,10 +178,6 @@ void SDL_Blit_Slow(SDL_BlitInfo *info)
                 if (dstB > 255) {
                     dstB = 255;
                 }
-                dstA = ((srcA * dstA) + (dstA * (255 - srcA))) / 255;
-                if (dstA > 255) {
-                    dstA = 255;
-                }
                 break;
             }
             if (FORMAT_HAS_ALPHA(dstfmt_val)) {