From c825c2f929505b73f2ecabf1e909b2e39d548422 Mon Sep 17 00:00:00 2001 From: Hermet Park Date: Wed, 17 Jul 2024 17:03:38 +0900 Subject: [PATCH] sw_engine: ++alpha blending operation. Reduce instructions, improving its performance by ~15% --- src/renderer/sw_engine/tvgSwCommon.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/renderer/sw_engine/tvgSwCommon.h b/src/renderer/sw_engine/tvgSwCommon.h index bac635dd..38ba7dad 100644 --- a/src/renderer/sw_engine/tvgSwCommon.h +++ b/src/renderer/sw_engine/tvgSwCommon.h @@ -297,8 +297,8 @@ static inline uint32_t JOIN(uint8_t c0, uint8_t c1, uint8_t c2, uint8_t c3) static inline uint32_t ALPHA_BLEND(uint32_t c, uint32_t a) { - return (((((c >> 8) & 0x00ff00ff) * a + 0x00ff00ff) & 0xff00ff00) + - ((((c & 0x00ff00ff) * a + 0x00ff00ff) >> 8) & 0x00ff00ff)); + ++a; + return (((((c >> 8) & 0x00ff00ff) * a) & 0xff00ff00) + ((((c & 0x00ff00ff) * a) >> 8) & 0x00ff00ff)); } static inline uint32_t INTERPOLATE(uint32_t s, uint32_t d, uint8_t a)