summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2018-06-01 13:06:44 +0100
committerCaolán McNamara <caolanm@redhat.com>2018-06-02 18:02:36 +0200
commitf9de5f7ea0130a9bad889f9702ac311d6be3deb6 (patch)
tree06e8d7e0f662d2ef932ec36945321aa0ee8d279c
parent40b7062ffa972ae0a8f51da0b257becfab749d53 (diff)
share the cairo clipping code
Change-Id: I2dc8f55fd2612b5fc4440b46ee3184341fd56859 Reviewed-on: https://gerrit.libreoffice.org/55180 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r--vcl/headless/svpgdi.cxx11
-rw-r--r--vcl/inc/headless/svpgdi.hxx1
-rw-r--r--vcl/unx/generic/gdi/salgdi.cxx15
3 files changed, 10 insertions, 17 deletions
diff --git a/vcl/headless/svpgdi.cxx b/vcl/headless/svpgdi.cxx
index 8bc15fb861dc..4b5050420e7a 100644
--- a/vcl/headless/svpgdi.cxx
+++ b/vcl/headless/svpgdi.cxx
@@ -489,12 +489,12 @@ bool SvpSalGraphics::drawTransformedBitmap(
return true;
}
-void SvpSalGraphics::clipRegion(cairo_t* cr)
+void SvpSalGraphics::clipRegion(cairo_t* cr, const vcl::Region& rClipRegion)
{
RectangleVector aRectangles;
- if (!m_aClipRegion.IsEmpty())
+ if (!rClipRegion.IsEmpty())
{
- m_aClipRegion.GetRegionRectangles(aRectangles);
+ rClipRegion.GetRegionRectangles(aRectangles);
}
if (!aRectangles.empty())
{
@@ -506,6 +506,11 @@ void SvpSalGraphics::clipRegion(cairo_t* cr)
}
}
+void SvpSalGraphics::clipRegion(cairo_t* cr)
+{
+ SvpSalGraphics::clipRegion(cr, m_aClipRegion);
+}
+
bool SvpSalGraphics::drawAlphaRect(long nX, long nY, long nWidth, long nHeight, sal_uInt8 nTransparency)
{
cairo_t* cr = getCairoContext(false);
diff --git a/vcl/inc/headless/svpgdi.hxx b/vcl/inc/headless/svpgdi.hxx
index 37ae2822bf53..c5a0639498ca 100644
--- a/vcl/inc/headless/svpgdi.hxx
+++ b/vcl/inc/headless/svpgdi.hxx
@@ -96,6 +96,7 @@ public:
cairo_surface_t* getSurface() const { return m_pSurface; }
static cairo_user_data_key_t* getDamageKey();
+ static void clipRegion(cairo_t* cr, const vcl::Region& rClipRegion);
static basegfx::B2DRange drawPolyLine(
cairo_t* cr,
const Color& rLineColor,
diff --git a/vcl/unx/generic/gdi/salgdi.cxx b/vcl/unx/generic/gdi/salgdi.cxx
index dd09e8d3c62b..e09766c1e598 100644
--- a/vcl/unx/generic/gdi/salgdi.cxx
+++ b/vcl/unx/generic/gdi/salgdi.cxx
@@ -690,20 +690,7 @@ bool X11SalGraphics::drawPolyPolygon( const basegfx::B2DPolyPolygon& rOrigPolyPo
#if ENABLE_CAIRO_CANVAS
void X11SalGraphics::clipRegion(cairo_t* cr)
{
- if(!maClipRegion.IsEmpty())
- {
- RectangleVector aRectangles;
- maClipRegion.GetRegionRectangles(aRectangles);
-
- if (!aRectangles.empty())
- {
- for (auto const& rectangle : aRectangles)
- {
- cairo_rectangle(cr, rectangle.Left(), rectangle.Top(), rectangle.GetWidth(), rectangle.GetHeight());
- }
- cairo_clip(cr);
- }
- }
+ SvpSalGraphics::clipRegion(cr, maClipRegion);
}
#endif // ENABLE_CAIRO_CANVAS