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.
This commit is contained in:
Mira Grudzinska 2021-02-05 01:45:26 +01:00 committed by Hermet Park
parent 028e1fa251
commit 5e1d3772ca

View file

@ -454,7 +454,8 @@ static bool _translucentImageInvAlphaMask(SwSurface* surface, const uint32_t *im
auto rX = static_cast<uint32_t>(roundf(x * invTransform->e11 + ey1));
auto rY = static_cast<uint32_t>(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));
}
}