Blob Blame History Raw
From ec864247bc40d92e32e3b0f9916d3e39974c9116 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= <caolanm@redhat.com>
Date: Mon, 20 Mar 2017 15:08:01 +0000
Subject: [PATCH] tdf#106577 cairo_mask pattern affects more surface than
 expected

Change-Id: I7f967c401f7b84fd696fa4cf8a944f7a5730917c
---
 vcl/headless/svpgdi.cxx | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/vcl/headless/svpgdi.cxx b/vcl/headless/svpgdi.cxx
index 91b6f86e87cb..925a5adecd55 100644
--- a/vcl/headless/svpgdi.cxx
+++ b/vcl/headless/svpgdi.cxx
@@ -1201,8 +1201,21 @@ void SvpSalGraphics::invert(const basegfx::B2DPolygon &rPoly, SalInvert nFlags)
         if (nFlags & SalInvert::N50)
         {
             cairo_pattern_t *pattern = create_stipple();
-            cairo_mask(cr, pattern);
+            cairo_surface_t* surface = cairo_surface_create_similar(m_pSurface,
+                                                                    cairo_surface_get_content(m_pSurface),
+                                                                    extents.getWidth() * m_fScale,
+                                                                    extents.getHeight() * m_fScale);
+
+#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 14, 0)
+            cairo_surface_set_device_scale(surface, m_fScale, m_fScale);
+#endif
+            cairo_t* stipple_cr = cairo_create(surface);
+            cairo_set_source_rgb(stipple_cr, 1.0, 1.0, 1.0);
+            cairo_mask(stipple_cr, pattern);
             cairo_pattern_destroy(pattern);
+            cairo_destroy(stipple_cr);
+            cairo_mask_surface(cr, surface, extents.getMinX(), extents.getMinY());
+            cairo_surface_destroy(surface);
         }
         else
         {
-- 
2.17.1