vcl/source/outdev/gradient.cxx | 36 +++++++++++++++++++++++++++--------- 1 file changed, 27 insertions(+), 9 deletions(-)
New commits: commit f1ee0f93e2589514ed20f096c5440b9d1113023b Author: Patrick Luby <plub...@neooffice.org> AuthorDate: Sat Sep 23 19:26:09 2023 -0400 Commit: Patrick Luby <plub...@neooffice.org> CommitDate: Sun Sep 24 03:19:01 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 <plub...@neooffice.org> (cherry picked from commit b2b115447614f39ae190a7fa861722bbbfc1c84d) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157127 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 ); }