summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2023-10-28 10:08:01 +0300
committerMike Kaganski <mike.kaganski@collabora.com>2023-10-28 10:59:51 +0200
commitd33f5a5783e025fe7a66bc09e1a55b4fa71d629d (patch)
treed53bb942dfe9d118600a84dbc9a307eaf8eae42d /vcl
parentdf5bb1387b5c7a30e15aad7811a3c0f0d3fe44c8 (diff)
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.kaganski@collabora.com> Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'vcl')
-rw-r--r--vcl/skia/salbmp.cxx6
1 files changed, 1 insertions, 5 deletions
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",