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
This commit is contained in:
Benjamin 2025-05-03 14:19:59 -07:00 committed by Hermet Park
parent 7bcee79077
commit 2990e72b23

View file

@ -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);
}
}