vcl/source/outdev/gradient.cxx |   36 +++++++++++++++++++++++++++---------
 1 file changed, 27 insertions(+), 9 deletions(-)

New commits:
commit c43d11cbbabc871a3c71062239b0d9b6db99961e
Author:     Patrick Luby <[email protected]>
AuthorDate: Sat Sep 23 19:26:09 2023 -0400
Commit:     Patrick Luby <[email protected]>
CommitDate: Sun Sep 24 02:25:12 2023 +0200

    tdf#156539 Draw the gradient with polypolygonal clip when using Skia
    
    For some unkown reason, the previous "draw gradient with XOR, draw
    polygon with N0, and draw gradient again with XOR" does not work
    with Skia/Raster (at least on macOS). Fortunately, Skia supports
    polypolygonal clipping so just clip and draw the gradient.
    
    Change-Id: Id069160312a270096f5ec9c670615eb95ec6200b
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157199
    Tested-by: Jenkins
    Reviewed-by: Patrick Luby <[email protected]>

diff --git a/vcl/source/outdev/gradient.cxx b/vcl/source/outdev/gradient.cxx
index 53dbec354d20..ef4f883c20d2 100644
--- a/vcl/source/outdev/gradient.cxx
+++ b/vcl/source/outdev/gradient.cxx
@@ -24,6 +24,7 @@
 #include <vcl/settings.hxx>
 #include <vcl/virdev.hxx>
 #include <vcl/window.hxx>
+#include <vcl/skia/SkiaHelper.hxx>
 
 #include <salgdi.hxx>
 
@@ -159,15 +160,32 @@ void OutputDevice::ClipAndDrawGradientMetafile ( const 
Gradient &rGradient, cons
     const bool  bOldOutput = IsOutputEnabled();
 
     EnableOutput( false );
-    Push( vcl::PushFlags::RASTEROP );
-    SetRasterOp( RasterOp::Xor );
-    DrawGradient( aBoundRect, rGradient );
-    SetFillColor( COL_BLACK );
-    SetRasterOp( RasterOp::N0 );
-    DrawPolyPolygon( rPolyPoly );
-    SetRasterOp( RasterOp::Xor );
-    DrawGradient( aBoundRect, rGradient );
-    Pop();
+#if HAVE_FEATURE_SKIA
+    // tdf#156539 Draw the gradient with polypolygonal clip when using Skia
+    // For some unkown reason, the previous "draw gradient with XOR, draw
+    // polygon with N0, and draw gradient again with XOR" does not work
+    // with Skia/Raster (at least on macOS). Fortunately, Skia supports
+    // polypolygonal clipping so just clip and draw the gradient.
+    if ( SkiaHelper::isVCLSkiaEnabled() )
+    {
+        Push( vcl::PushFlags::CLIPREGION );
+        SetClipRegion( vcl::Region( rPolyPoly ) );
+        DrawGradient( aBoundRect, rGradient );
+        Pop();
+    }
+    else
+#endif
+    {
+        Push( vcl::PushFlags::RASTEROP );
+        SetRasterOp( RasterOp::Xor );
+        DrawGradient( aBoundRect, rGradient );
+        SetFillColor( COL_BLACK );
+        SetRasterOp( RasterOp::N0 );
+        DrawPolyPolygon( rPolyPoly );
+        SetRasterOp( RasterOp::Xor );
+        DrawGradient( aBoundRect, rGradient );
+        Pop();
+    }
     EnableOutput( bOldOutput );
 }
 

Reply via email to