summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorPatrick Luby <plubius@neooffice.org>2023-09-23 19:26:09 -0400
committerAndras Timar <andras.timar@collabora.com>2023-10-11 17:34:14 +0200
commitdd5baf571c5f0782abba44ec8cbe8ea1fd4f779a (patch)
tree8838403853d9bb3c69cd08847e6d3156e52aca3b /vcl
parent3adf09263022041cf9b42b86bc30b62c03271c79 (diff)
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 <plubius@neooffice.org> (cherry picked from commit b2b115447614f39ae190a7fa861722bbbfc1c84d) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157127 (cherry picked from commit f662285f0ae6704b78311c997f31d2be74c3aab3) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157128 Tested-by: Caolán McNamara <caolan.mcnamara@collabora.com> Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Diffstat (limited to 'vcl')
-rw-r--r--vcl/source/outdev/gradient.cxx36
1 files changed, 27 insertions, 9 deletions
diff --git a/vcl/source/outdev/gradient.cxx b/vcl/source/outdev/gradient.cxx
index b89fb477c62b..b7018352606e 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 );
}