summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuboš Luňák <l.lunak@collabora.com>2020-06-24 10:39:35 +0200
committerAdolfo Jayme Barrientos <fitojb@ubuntu.com>2020-06-26 07:56:30 +0200
commitbdd9c9ab3ec20db4ce83cebbfc2e90bf73e2e7ec (patch)
treef2871e1b54554c5b70624a01c0451b653b1ca795
parent99fd03604aee6e5ea14940e81558dbf8f1f3c81b (diff)
optimize AlphaMask::BlendWith()
It shows up in profiling in some cases (e.g. tdf#134160). - If it's 8-bit, simply work on scanlines instead of pixel by pixel. - The extra precision from using floats doesn't matter and the round() costs something (at least with MSVC). Change-Id: I37bbe31fae03d61946a7382de1fb79cfe2d2ec30 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/97010 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com> Reviewed-by: Luboš Luňák <l.lunak@collabora.com> (cherry picked from commit a3ef92cfb512ce70c7dc48f7957b40f9f78f5628) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/97005 Reviewed-by: Adolfo Jayme Barrientos <fitojb@ubuntu.com>
-rw-r--r--vcl/source/gdi/alpha.cxx15
1 files changed, 9 insertions, 6 deletions
diff --git a/vcl/source/gdi/alpha.cxx b/vcl/source/gdi/alpha.cxx
index 1385f803be8d..bc1d54f36c22 100644
--- a/vcl/source/gdi/alpha.cxx
+++ b/vcl/source/gdi/alpha.cxx
@@ -147,15 +147,18 @@ void AlphaMask::BlendWith(const Bitmap& rOther)
{
const long nHeight = std::min(pOtherAcc->Height(), pAcc->Height());
const long nWidth = std::min(pOtherAcc->Width(), pAcc->Width());
- for (long x = 0; x < nWidth; ++x)
+ for (long y = 0; y < nHeight; ++y)
{
- for (long y = 0; y < nHeight; ++y)
+ Scanline scanline = pAcc->GetScanline( y );
+ ConstScanline otherScanline = pOtherAcc->GetScanline( y );
+ for (long x = 0; x < nWidth; ++x)
{
// Use sal_uInt16 for following multiplication
- const sal_uInt16 nGrey1 = pOtherAcc->GetPixelIndex(y, x);
- const sal_uInt16 nGrey2 = pAcc->GetPixelIndex(y, x);
- const double fGrey = std::round(nGrey1 + nGrey2 - nGrey1 * nGrey2 / 255.0);
- pAcc->SetPixelIndex(y, x, static_cast<sal_uInt8>(fGrey));
+ const sal_uInt16 nGrey1 = *scanline;
+ const sal_uInt16 nGrey2 = *otherScanline;
+ *scanline = static_cast<sal_uInt8>(nGrey1 + nGrey2 - nGrey1 * nGrey2 / 255);
+ ++scanline;
+ ++otherScanline;
}
}
}