vcl/skia/salbmp.cxx |    6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

New commits:
commit d33f5a5783e025fe7a66bc09e1a55b4fa71d629d
Author:     Mike Kaganski <mike.kagan...@collabora.com>
AuthorDate: Sat Oct 28 10:08:01 2023 +0300
Commit:     Mike Kaganski <mike.kagan...@collabora.com>
CommitDate: Sat Oct 28 10:59:51 2023 +0200

    Simplify calculation
    
    ... after commit 9b5a00d2281bebaac5fccfde17de6ca5134fc229.
    
    It passes a sanity check:
    
        for (sal_uInt16 nGrey1 = 0; nGrey1 < 256; ++nGrey1)
        {
            for (sal_uInt16 nGrey2 = 0; nGrey2 < 256; ++nGrey2)
            {
                const sal_uInt8 n1 = static_cast<sal_uInt8>(
                    255 - ((255 - nGrey1) + (255 - nGrey2) - (255 - nGrey1) * 
(255 - nGrey2) / 255));
                const sal_uInt8 n2 = static_cast<sal_uInt8>(nGrey1 * nGrey2 / 
255);
                CPPUNIT_ASSERT_EQUAL(n1, n2);
            }
        }
    
    
    Change-Id: Ib4b4e700a50027fb502767d72843b271f993f9c0
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158582
    Tested-by: Mike Kaganski <mike.kagan...@collabora.com>
    Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com>

diff --git a/vcl/skia/salbmp.cxx b/vcl/skia/salbmp.cxx
index 44997798db8b..fe92a7a44110 100644
--- a/vcl/skia/salbmp.cxx
+++ b/vcl/skia/salbmp.cxx
@@ -628,11 +628,7 @@ bool SkiaSalBitmap::AlphaBlendWith(const SalBitmap& 
rSalBmp)
     {
         const sal_uInt16 nGrey1 = mEraseColor.GetRed();
         const sal_uInt16 nGrey2 = otherBitmap->mEraseColor.GetRed();
-        // Awkward calculation because the original used transparency, and to 
replicate
-        // the logic we need to translate into transparency, perform the 
original logic,
-        // then translate back to alpha.
-        const sal_uInt8 nGrey = static_cast<sal_uInt8>(
-            255 - ((255 - nGrey1) + (255 - nGrey2) - (255 - nGrey1) * (255 - 
nGrey2) / 255));
+        const sal_uInt8 nGrey = static_cast<sal_uInt8>(nGrey1 * nGrey2 / 255);
         mEraseColor = Color(nGrey, nGrey, nGrey);
         DataChanged();
         SAL_INFO("vcl.skia.trace",

Reply via email to