drawinglayer/source/primitive2d/GlowSoftEgdeShadowTools.cxx |   10 +++++++++-
 drawinglayer/source/primitive2d/glowprimitive2d.cxx         |    6 ------
 drawinglayer/source/primitive2d/softedgeprimitive2d.cxx     |    4 ----
 3 files changed, 9 insertions(+), 11 deletions(-)

New commits:
commit cfd7cffb00f9f4ee934006a706184fefc8cb8d9d
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Fri Nov 3 10:12:57 2023 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Sun Nov 5 06:32:17 2023 +0100

    tdf#158014 Skia adds filled white areas in .svg when exporting to PDF
    
    So my strategy here is to assume that ProcessAndBlurAlphaMask
    was doing the right thing before
        commit 81994cb2b8b32453a92bcb011830fcb884f22ff3
        Date:   Fri Apr 16 20:33:10 2021 +0200
        Convert internal vcl bitmap formats transparency->alpha (II)
    but the subsequent naiving changing of its logic undermines it
    because of some subtle interaction.
    
    So take the brute force approach of reverting most of the code
    to its prior state (i.e. working in the transparency domain),
    and doing an Invert() before and after the original code.
    
    This seems to fix all of the test files I have on hand
    for this situation for both Skia and non-Skia cases.
    
    Change-Id: If4c4d4c5351a4ec55897bed96b57d28eda88f5dd
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158793
    Tested-by: Jenkins
    Reviewed-by: Patrick Luby <plub...@neooffice.org>
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/drawinglayer/source/primitive2d/GlowSoftEgdeShadowTools.cxx 
b/drawinglayer/source/primitive2d/GlowSoftEgdeShadowTools.cxx
index 298713517d2f..bcd5f779af79 100644
--- a/drawinglayer/source/primitive2d/GlowSoftEgdeShadowTools.cxx
+++ b/drawinglayer/source/primitive2d/GlowSoftEgdeShadowTools.cxx
@@ -33,9 +33,14 @@ namespace drawinglayer::primitive2d
 AlphaMask ProcessAndBlurAlphaMask(const Bitmap& rMask, double 
fErodeDilateRadius,
                                   double fBlurRadius, sal_uInt8 nTransparency, 
bool bConvertTo1Bit)
 {
+    // Invert it to operate in the transparency domain. Trying to update this 
method to
+    // work in the alpha domain is fraught with hazards.
+    Bitmap tmpMask = rMask;
+    tmpMask.Invert();
+
     // Only completely white pixels on the initial mask must be considered for 
transparency. Any
     // other color must be treated as black. This creates 1-bit B&W bitmap.
-    BitmapEx mask(bConvertTo1Bit ? rMask.CreateMask(COL_BLACK) : rMask);
+    BitmapEx mask(bConvertTo1Bit ? tmpMask.CreateMask(COL_WHITE) : tmpMask);
 
     // Scaling down increases performance without noticeable quality loss. 
Additionally,
     // current blur implementation can only handle blur radius between 2 and 
254.
@@ -71,6 +76,9 @@ AlphaMask ProcessAndBlurAlphaMask(const Bitmap& rMask, double 
fErodeDilateRadius
 
     mask.Scale(rMask.GetSizePixel());
 
+    // And switch to the alpha domain.
+    mask.Invert();
+
     return AlphaMask(mask.GetBitmap());
 }
 
diff --git a/drawinglayer/source/primitive2d/glowprimitive2d.cxx 
b/drawinglayer/source/primitive2d/glowprimitive2d.cxx
index c49ea68c9089..fb1a12fa1421 100644
--- a/drawinglayer/source/primitive2d/glowprimitive2d.cxx
+++ b/drawinglayer/source/primitive2d/glowprimitive2d.cxx
@@ -209,12 +209,6 @@ void GlowPrimitive2D::create2DDecomposition(
                                                    fDiscreteGlowRadius * 
fScale / 2.0,
                                                    255 - 
getGlowColor().GetAlpha()));
 
-            // tdf#157502 and tdf#157652 invert alpha mask
-            // Due to the switch from transparency to alpha in commit
-            // 81994cb2b8b32453a92bcb011830fcb884f22ff3, invert the alpha
-            // mask.
-            mask.Invert();
-
             // The end result is the bitmap filled with glow color and blurred 
8-bit alpha mask
             Bitmap bmp(aAlpha.GetSizePixel(), vcl::PixelFormat::N24_BPP);
             bmp.Erase(getGlowColor());
diff --git a/drawinglayer/source/primitive2d/softedgeprimitive2d.cxx 
b/drawinglayer/source/primitive2d/softedgeprimitive2d.cxx
index bfd8ebf71656..87e60467f1ac 100644
--- a/drawinglayer/source/primitive2d/softedgeprimitive2d.cxx
+++ b/drawinglayer/source/primitive2d/softedgeprimitive2d.cxx
@@ -206,10 +206,6 @@ void SoftEdgePrimitive2D::create2DDecomposition(
             break;
         AlphaMask blurMask(drawinglayer::primitive2d::ProcessAndBlurAlphaMask(
             aMask, -fDiscreteSoftRadius * fScale, fDiscreteSoftRadius * 
fScale, 0));
-        // tdf#157086 invert the blur mask instead of the alpha mask
-        // An invert is needed to fix tdf#156808 but inverting the alpha mask
-        // causes tdf#157086 so invert the blur mask instead.
-        blurMask.Invert();
         aMask.BlendWith(blurMask);
 
         // The end result is the original bitmap with blurred 8-bit alpha mask

Reply via email to