From 2990e72b23b51d4700417325763eb86484944fc6 Mon Sep 17 00:00:00 2001 From: Benjamin Date: Sat, 3 May 2025 14:19:59 -0700 Subject: [PATCH] sw_engine: ++raster color accuracy Improves the color accuracy of rasterized images by skipping the pre-multiply step when the alpha is full opaque or fully transparent. fixes: #3429 --- src/renderer/sw_engine/tvgSwRaster.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/renderer/sw_engine/tvgSwRaster.cpp b/src/renderer/sw_engine/tvgSwRaster.cpp index 26114bce..e1dfde50 100644 --- a/src/renderer/sw_engine/tvgSwRaster.cpp +++ b/src/renderer/sw_engine/tvgSwRaster.cpp @@ -1706,6 +1706,7 @@ void rasterPremultiply(RenderSurface* surface) for (uint32_t x = 0; x < surface->w; ++x, ++dst) { auto c = *dst; auto a = (c >> 24); + if (a == 255 || a == 0) continue; *dst = (c & 0xff000000) + ((((c >> 8) & 0xff) * a) & 0xff00) + ((((c & 0x00ff00ff) * a) >> 8) & 0x00ff00ff); } }