From 99668c286b0948c3f5c1ca62a7af8498fc69516b Mon Sep 17 00:00:00 2001 From: Sylvain Date: Wed, 15 Mar 2023 21:21:57 +0100 Subject: [PATCH] Simplify SDL_BLENDMODE_MUL --- include/SDL3/SDL_blendmode.h | 2 +- src/render/software/SDL_draw.h | 5 +---- src/render/software/SDL_triangle.c | 4 ---- src/video/SDL_blit_slow.c | 4 ---- 4 files changed, 2 insertions(+), 13 deletions(-) diff --git a/include/SDL3/SDL_blendmode.h b/include/SDL3/SDL_blendmode.h index 50337cda7..7276c9237 100644 --- a/include/SDL3/SDL_blendmode.h +++ b/include/SDL3/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 1f3a7ce78..4dcb64a87 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 1f1b115e3..b147aabc2 100644 --- a/src/render/software/SDL_triangle.c +++ b/src/render/software/SDL_triangle.c @@ -868,10 +868,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 5b3b87b15..560436f9e 100644 --- a/src/video/SDL_blit_slow.c +++ b/src/video/SDL_blit_slow.c @@ -177,10 +177,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)) {