From 92067587039473db38b139ecb56a3c64544e975b Mon Sep 17 00:00:00 2001 From: "Armin Le Grand (allotropia)" Date: Thu, 19 Sep 2024 20:25:18 +0200 Subject: Correct usage of premultiply for ENABLE_WASM_STRIP_PREMULTIPLY MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The order of parameters for vcl::bitmap::premultiply and vcl::bitmap::unpremultiply was wrong because when doing that I just used the same order that the indexing that was to be replaced used it. Corrected that. Change-Id: I59473acca8afdc58105b3381d1fdcedd6c0fd83b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/173683 Reviewed-by: Armin Le Grand Reviewed-by: Caolán McNamara Tested-by: Jenkins --- vcl/headless/CairoCommon.cxx | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) (limited to 'vcl/headless') diff --git a/vcl/headless/CairoCommon.cxx b/vcl/headless/CairoCommon.cxx index 163007e46823..f72046ddda53 100644 --- a/vcl/headless/CairoCommon.cxx +++ b/vcl/headless/CairoCommon.cxx @@ -558,15 +558,15 @@ void CairoCommon::doXorOnRelease(sal_Int32 nExtentsLeft, sal_Int32 nExtentsTop, sal_uInt8 a = true_data[SVP_CAIRO_ALPHA]; sal_uInt8 xor_a = xor_data[SVP_CAIRO_ALPHA]; #if ENABLE_WASM_STRIP_PREMULTIPLY - sal_uInt8 b = vcl::bitmap::unpremultiply(a, true_data[SVP_CAIRO_BLUE]) - ^ vcl::bitmap::unpremultiply(xor_a, xor_data[SVP_CAIRO_BLUE]); - sal_uInt8 g = vcl::bitmap::unpremultiply(a, true_data[SVP_CAIRO_GREEN]) - ^ vcl::bitmap::unpremultiply(xor_a, xor_data[SVP_CAIRO_GREEN]); - sal_uInt8 r = vcl::bitmap::unpremultiply(a, true_data[SVP_CAIRO_RED]) - ^ vcl::bitmap::unpremultiply(xor_a, xor_data[SVP_CAIRO_RED]); - true_data[SVP_CAIRO_BLUE] = vcl::bitmap::premultiply(a, b); - true_data[SVP_CAIRO_GREEN] = vcl::bitmap::premultiply(a, g); - true_data[SVP_CAIRO_RED] = vcl::bitmap::premultiply(a, r); + sal_uInt8 b = vcl::bitmap::unpremultiply(true_data[SVP_CAIRO_BLUE], a) + ^ vcl::bitmap::unpremultiply(xor_data[SVP_CAIRO_BLUE], xor_a); + sal_uInt8 g = vcl::bitmap::unpremultiply(true_data[SVP_CAIRO_GREEN], a) + ^ vcl::bitmap::unpremultiply(xor_data[SVP_CAIRO_GREEN], xor_a); + sal_uInt8 r = vcl::bitmap::unpremultiply(true_data[SVP_CAIRO_RED], a) + ^ vcl::bitmap::unpremultiply(xor_data[SVP_CAIRO_RED], xor_a); + true_data[SVP_CAIRO_BLUE] = vcl::bitmap::premultiply(b, a); + true_data[SVP_CAIRO_GREEN] = vcl::bitmap::premultiply(g, a); + true_data[SVP_CAIRO_RED] = vcl::bitmap::premultiply(r, a); #else sal_uInt8 b = unpremultiply_table[a][true_data[SVP_CAIRO_BLUE]] ^ unpremultiply_table[xor_a][xor_data[SVP_CAIRO_BLUE]]; @@ -731,9 +731,9 @@ Color CairoCommon::getPixel(cairo_surface_t* pSurface, tools::Long nX, tools::Lo unsigned char* data = cairo_image_surface_get_data(target); sal_uInt8 a = data[SVP_CAIRO_ALPHA]; #if ENABLE_WASM_STRIP_PREMULTIPLY - sal_uInt8 b = vcl::bitmap::unpremultiply(a, data[SVP_CAIRO_BLUE]); - sal_uInt8 g = vcl::bitmap::unpremultiply(a, data[SVP_CAIRO_GREEN]); - sal_uInt8 r = vcl::bitmap::unpremultiply(a, data[SVP_CAIRO_RED]); + sal_uInt8 b = vcl::bitmap::unpremultiply(data[SVP_CAIRO_BLUE], a); + sal_uInt8 g = vcl::bitmap::unpremultiply(data[SVP_CAIRO_GREEN], a); + sal_uInt8 r = vcl::bitmap::unpremultiply(data[SVP_CAIRO_RED], a); #else sal_uInt8 b = unpremultiply_table[a][data[SVP_CAIRO_BLUE]]; sal_uInt8 g = unpremultiply_table[a][data[SVP_CAIRO_GREEN]]; @@ -1840,9 +1840,9 @@ void CairoCommon::drawMask(const SalTwoRect& rTR, const SalBitmap& rSalBitmap, C { sal_uInt8 a = data[SVP_CAIRO_ALPHA]; #if ENABLE_WASM_STRIP_PREMULTIPLY - sal_uInt8 b = vcl::bitmap::unpremultiply(a, data[SVP_CAIRO_BLUE]); - sal_uInt8 g = vcl::bitmap::unpremultiply(a, data[SVP_CAIRO_GREEN]); - sal_uInt8 r = vcl::bitmap::unpremultiply(a, data[SVP_CAIRO_RED]); + sal_uInt8 b = vcl::bitmap::unpremultiply(data[SVP_CAIRO_BLUE], a); + sal_uInt8 g = vcl::bitmap::unpremultiply(data[SVP_CAIRO_GREEN], a); + sal_uInt8 r = vcl::bitmap::unpremultiply(data[SVP_CAIRO_RED], a); #else sal_uInt8 b = unpremultiply_table[a][data[SVP_CAIRO_BLUE]]; sal_uInt8 g = unpremultiply_table[a][data[SVP_CAIRO_GREEN]]; -- cgit