From 5e1d3772ca43af225d4e4c7bf375210d72b9c02a Mon Sep 17 00:00:00 2001 From: Mira Grudzinska Date: Fri, 5 Feb 2021 01:45:26 +0100 Subject: [PATCH] sw_engine raster: fixing rasterization of an image with InvMask In case of the image rasterization with an inverse mask the opacity was omitted and the alpha value instead of the inverse alpha value was used. --- src/lib/sw_engine/tvgSwRaster.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/lib/sw_engine/tvgSwRaster.cpp b/src/lib/sw_engine/tvgSwRaster.cpp index 4fe13460..e0611b8b 100644 --- a/src/lib/sw_engine/tvgSwRaster.cpp +++ b/src/lib/sw_engine/tvgSwRaster.cpp @@ -454,7 +454,8 @@ static bool _translucentImageInvAlphaMask(SwSurface* surface, const uint32_t *im auto rX = static_cast(roundf(x * invTransform->e11 + ey1)); auto rY = static_cast(roundf(x * invTransform->e21 + ey2)); if (rX >= w || rY >= h) continue; - auto tmp = ALPHA_BLEND(img[rX + (rY * w)], ALPHA_MULTIPLY(opacity, surface->blender.alpha(*cmp))); //TODO: need to use image's stride + auto ialpha = 255 - surface->blender.alpha(*cmp); + auto tmp = ALPHA_BLEND(img[rX + (rY * w)], ALPHA_MULTIPLY(opacity, ialpha)); //TODO: need to use image's stride *dst = tmp + ALPHA_BLEND(*dst, 255 - surface->blender.alpha(tmp)); } } @@ -534,7 +535,7 @@ static bool _translucentImageInvAlphaMask(SwSurface* surface, uint32_t *img, uin auto src = &sbuffer[y * w]; //TODO: need to use image's stride for (uint32_t x = 0; x < w2; ++x, ++dst, ++src, ++cmp) { auto ialpha = 255 - surface->blender.alpha(*cmp); - auto tmp = ALPHA_BLEND(*src, ialpha); + auto tmp = ALPHA_BLEND(*src, ALPHA_MULTIPLY(opacity, ialpha)); *dst = tmp + ALPHA_BLEND(*dst, 255 - surface->blender.alpha(tmp)); } }