include/vcl/skia/SkiaHelper.hxx |    1 +
 vcl/skia/SkiaHelper.cxx         |    3 +++
 vcl/skia/gdiimpl.cxx            |   10 ++++++++++
 vcl/source/outdev/bitmap.cxx    |    2 +-
 4 files changed, 15 insertions(+), 1 deletion(-)

New commits:
commit 3c63cb1298fc17b71629e04d181244b5acdf8409
Author:     Patrick Luby <plub...@neooffice.org>
AuthorDate: Thu Jul 20 09:22:46 2023 -0400
Commit:     Patrick Luby <plub...@neooffice.org>
CommitDate: Thu Jul 20 19:58:35 2023 +0200

    tdf#156361 use slow blending path if alpha mask blending is diabled
    
    SkiaSalGraphicsImpl::blendBitmap() fails unexpectedly in the following
    cases so return false and use the non-Skia alpha mask blending code:
    - Unexpected white areas when running a slideshow or printing:
        https://bugs.documentfoundation.org/attachment.cgi?id=188447
    - Unexpected scaling of bitmap and/or alpha mask when exporting to PDF:
        https://bugs.documentfoundation.org/attachment.cgi?id=188498
    
    Change-Id: I13ae613f24bff4cd018110a08ed70559a1714687
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154678
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>
    Tested-by: Jenkins
    Reviewed-by: Patrick Luby <plub...@neooffice.org>

diff --git a/include/vcl/skia/SkiaHelper.hxx b/include/vcl/skia/SkiaHelper.hxx
index 37fed7ff4de9..769c4d27a9ac 100644
--- a/include/vcl/skia/SkiaHelper.hxx
+++ b/include/vcl/skia/SkiaHelper.hxx
@@ -19,6 +19,7 @@ namespace SkiaHelper
 {
 VCL_DLLPUBLIC bool isVCLSkiaEnabled();
 VCL_DLLPUBLIC OUString readLog();
+VCL_DLLPUBLIC bool isAlphaMaskBlendingEnabled();
 
 #if HAVE_FEATURE_SKIA
 
diff --git a/vcl/skia/SkiaHelper.cxx b/vcl/skia/SkiaHelper.cxx
index a8332cfe7e1d..41ce5518112e 100644
--- a/vcl/skia/SkiaHelper.cxx
+++ b/vcl/skia/SkiaHelper.cxx
@@ -18,6 +18,7 @@
 namespace SkiaHelper
 {
 bool isVCLSkiaEnabled() { return false; }
+bool isAlphaMaskBlendingEnabled() { return false; }
 
 } // namespace
 
@@ -400,6 +401,8 @@ bool isVCLSkiaEnabled()
     return bRet;
 }
 
+bool isAlphaMaskBlendingEnabled() { return false; }
+
 static RenderMethod methodToUse = RenderRaster;
 
 static bool initRenderMethodToUse()
diff --git a/vcl/skia/gdiimpl.cxx b/vcl/skia/gdiimpl.cxx
index 45f3fc1c1b97..77aaa19df85c 100644
--- a/vcl/skia/gdiimpl.cxx
+++ b/vcl/skia/gdiimpl.cxx
@@ -1297,6 +1297,16 @@ bool SkiaSalGraphicsImpl::blendAlphaBitmap(const 
SalTwoRect& rPosAry,
                                            const SalBitmap& rMaskBitmap,
                                            const SalBitmap& rAlphaBitmap)
 {
+    // tdf#156361 use slow blending path if alpha mask blending is diabled
+    // SkiaSalGraphicsImpl::blendBitmap() fails unexpectedly in the following
+    // cases so return false and use the non-Skia alpha mask blending code:
+    // - Unexpected white areas when running a slideshow or printing:
+    //     https://bugs.documentfoundation.org/attachment.cgi?id=188447
+    // - Unexpected scaling of bitmap and/or alpha mask when exporting to PDF:
+    //     https://bugs.documentfoundation.org/attachment.cgi?id=188498
+    if (!SkiaHelper::isAlphaMaskBlendingEnabled())
+        return false;
+
     if (checkInvalidSourceOrDestination(rPosAry))
         return false;
 
diff --git a/vcl/source/outdev/bitmap.cxx b/vcl/source/outdev/bitmap.cxx
index 612ea5dc605d..d77b3ddd48c2 100644
--- a/vcl/source/outdev/bitmap.cxx
+++ b/vcl/source/outdev/bitmap.cxx
@@ -359,7 +359,7 @@ void OutputDevice::DrawDeviceAlphaBitmap( const Bitmap& 
rBmp, const AlphaMask& r
 
         // we need to make sure Skia never reaches this slow code path
         // (but do not fail in no-op cases)
-        assert(!SkiaHelper::isVCLSkiaEnabled()
+        assert(!SkiaHelper::isVCLSkiaEnabled() || 
!SkiaHelper::isAlphaMaskBlendingEnabled()
             || tools::Rectangle(Point(), rBmp.GetSizePixel())
                 .Intersection(tools::Rectangle(rSrcPtPixel, 
rSrcSizePixel)).IsEmpty()
             || 
mpAlphaVDev->LogicToPixel(mpAlphaVDev->GetOutputSizePixel()).IsEmpty());

Reply via email to