vcl/qa/cppunit/outdev.cxx      |   38 ++------------------------------------
 vcl/source/outdev/gradient.cxx |   35 ++++++-----------------------------
 2 files changed, 8 insertions(+), 65 deletions(-)

New commits:
commit ee38eea6dd2ef487a4a6014ed2a36f46946648c7
Author:     Noel Grandin <noelgran...@gmail.com>
AuthorDate: Sun Nov 5 20:23:32 2023 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Tue Nov 7 06:10:47 2023 +0100

    simplify OutputDevice::ClipAndDrawGradientMetafile
    
    using a poly clip is better than using XOR, so make this the
    default.
    
    Change-Id: I48bb6b5d617b8b6dc82760277d72a50a2123ae0f
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158957
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/vcl/qa/cppunit/outdev.cxx b/vcl/qa/cppunit/outdev.cxx
index 379346dd0b76..83325db08b60 100644
--- a/vcl/qa/cppunit/outdev.cxx
+++ b/vcl/qa/cppunit/outdev.cxx
@@ -1920,47 +1920,13 @@ static size_t ClipGradientTest(GDIMetaFile& rMtf, 
size_t nIndex)
     pAction = rMtf.GetAction(nIndex);
     CPPUNIT_ASSERT_EQUAL_MESSAGE("Not a push action", MetaActionType::PUSH, 
pAction->GetType());
     MetaPushAction* pPushAction = dynamic_cast<MetaPushAction*>(pAction);
-    CPPUNIT_ASSERT_EQUAL_MESSAGE("Not using XOR push flags", 
vcl::PushFlags::RASTEROP,
+    CPPUNIT_ASSERT_EQUAL_MESSAGE("Not using CLIPREGION push flags", 
vcl::PushFlags::CLIPREGION,
                                  pPushAction->GetFlags());
 
     nIndex++;
     pAction = rMtf.GetAction(nIndex);
-    CPPUNIT_ASSERT_EQUAL_MESSAGE("Not a rasterop action", 
MetaActionType::RASTEROP,
+    CPPUNIT_ASSERT_EQUAL_MESSAGE("Not a CLIPREGION action", 
MetaActionType::CLIPREGION,
                                  pAction->GetType());
-    MetaRasterOpAction* pRasterOpAction = 
dynamic_cast<MetaRasterOpAction*>(pAction);
-    CPPUNIT_ASSERT_EQUAL_MESSAGE("Not an XOR rasterop", RasterOp::Xor,
-                                 pRasterOpAction->GetRasterOp());
-
-    nIndex++;
-    pAction = rMtf.GetAction(nIndex);
-    CPPUNIT_ASSERT_EQUAL_MESSAGE("Not a gradient action", 
MetaActionType::GRADIENT,
-                                 pAction->GetType());
-
-    nIndex++;
-    pAction = rMtf.GetAction(nIndex);
-    CPPUNIT_ASSERT_EQUAL_MESSAGE("Not a fill color action", 
MetaActionType::FILLCOLOR,
-                                 pAction->GetType());
-
-    nIndex++;
-    pAction = rMtf.GetAction(nIndex);
-    CPPUNIT_ASSERT_EQUAL_MESSAGE("Not a rasterop action", 
MetaActionType::RASTEROP,
-                                 pAction->GetType());
-    pRasterOpAction = dynamic_cast<MetaRasterOpAction*>(pAction);
-    CPPUNIT_ASSERT_EQUAL_MESSAGE("Not an N0 rasterop", RasterOp::N0,
-                                 pRasterOpAction->GetRasterOp());
-
-    nIndex++;
-    pAction = rMtf.GetAction(nIndex);
-    CPPUNIT_ASSERT_EQUAL_MESSAGE("Not a polypolygon action", 
MetaActionType::POLYPOLYGON,
-                                 pAction->GetType());
-
-    nIndex++;
-    pAction = rMtf.GetAction(nIndex);
-    CPPUNIT_ASSERT_EQUAL_MESSAGE("Not a rasterop action", 
MetaActionType::RASTEROP,
-                                 pAction->GetType());
-    pRasterOpAction = dynamic_cast<MetaRasterOpAction*>(pAction);
-    CPPUNIT_ASSERT_EQUAL_MESSAGE("Not an XOR rasterop", RasterOp::Xor,
-                                 pRasterOpAction->GetRasterOp());
 
     nIndex++;
     pAction = rMtf.GetAction(nIndex);
diff --git a/vcl/source/outdev/gradient.cxx b/vcl/source/outdev/gradient.cxx
index 52359a779061..d7fb11afd5d5 100644
--- a/vcl/source/outdev/gradient.cxx
+++ b/vcl/source/outdev/gradient.cxx
@@ -24,7 +24,6 @@
 #include <vcl/settings.hxx>
 #include <vcl/virdev.hxx>
 #include <vcl/window.hxx>
-#include <vcl/skia/SkiaHelper.hxx>
 
 #include <salgdi.hxx>
 
@@ -156,36 +155,14 @@ void OutputDevice::DrawGradient( const 
tools::PolyPolygon& rPolyPoly,
 
 void OutputDevice::ClipAndDrawGradientMetafile ( const Gradient &rGradient, 
const tools::PolyPolygon &rPolyPoly )
 {
-    const tools::Rectangle aBoundRect( rPolyPoly.GetBoundRect() );
     const bool  bOldOutput = IsOutputEnabled();
-
     EnableOutput( false );
-#if HAVE_FEATURE_SKIA
-    // tdf#156539 Draw the gradient with polypolygonal clip when using Skia
-    // For some unknown 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();
-    }
+
+    Push( vcl::PushFlags::CLIPREGION );
+    SetClipRegion( vcl::Region( rPolyPoly ) );
+    DrawGradient( rPolyPoly.GetBoundRect(), rGradient );
+    Pop();
+
     EnableOutput( bOldOutput );
 }
 

Reply via email to