vcl/source/outdev/gradient.cxx | 36 +++++++++++++++++++++++++++--------- 1 file changed, 27 insertions(+), 9 deletions(-)
New commits: commit e90163ed127a760704ffdaa7f97c70aa6e463935 Author: Patrick Luby <plub...@neooffice.org> AuthorDate: Sat Sep 23 19:26:09 2023 -0400 Commit: Caolán McNamara <caolan.mcnam...@collabora.com> CommitDate: Mon Oct 2 09:36:16 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 (cherry picked from commit f662285f0ae6704b78311c997f31d2be74c3aab3) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157128 Tested-by: Caolán McNamara <caolan.mcnam...@collabora.com> Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com> diff --git a/vcl/source/outdev/gradient.cxx b/vcl/source/outdev/gradient.cxx index 5a60184abfff..657c82b64fce 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 ); }