vcl/source/gdi/alpha.cxx | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-)
New commits: commit bdd9c9ab3ec20db4ce83cebbfc2e90bf73e2e7ec Author: Luboš Luňák <l.lu...@collabora.com> AuthorDate: Wed Jun 24 10:39:35 2020 +0200 Commit: Adolfo Jayme Barrientos <fit...@ubuntu.com> CommitDate: Fri Jun 26 07:56:30 2020 +0200 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.kagan...@collabora.com> Reviewed-by: Luboš Luňák <l.lu...@collabora.com> (cherry picked from commit a3ef92cfb512ce70c7dc48f7957b40f9f78f5628) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/97005 Reviewed-by: Adolfo Jayme Barrientos <fit...@ubuntu.com> 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; } } } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits