summaryrefslogtreecommitdiff
path: root/canvas
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2014-12-11 17:48:44 +0000
committerCaolán McNamara <caolanm@redhat.com>2014-12-11 20:44:26 +0000
commit94d935eecbba0161de2616c2234b4a5d9d3cad88 (patch)
treed078affcce3feae6f486fe87c132cc1f0b5cc19c /canvas
parentf88b5ab8692ee7ecf58b570e703d0e7f10cc2f0d (diff)
Resolves: fdo#87242 reuse vcl clip for cairo during animations
Change-Id: I0a26d4c4092226732620c3852b0402ee45d4fa1d
Diffstat (limited to 'canvas')
-rw-r--r--canvas/source/cairo/cairo_canvashelper.hxx3
-rw-r--r--canvas/source/cairo/cairo_canvashelper_text.cxx25
2 files changed, 25 insertions, 3 deletions
diff --git a/canvas/source/cairo/cairo_canvashelper.hxx b/canvas/source/cairo/cairo_canvashelper.hxx
index 4adcb3b57e72..f6f009981a5b 100644
--- a/canvas/source/cairo/cairo_canvashelper.hxx
+++ b/canvas/source/cairo/cairo_canvashelper.hxx
@@ -310,6 +310,9 @@ namespace cairocanvas
::cairo::CairoSharedPtr mpCairo;
::cairo::SurfaceSharedPtr mpSurface;
::basegfx::B2ISize maSize;
+
+ void clip_cairo_from_dev(::OutputDevice& rOutDev);
+
};
/// also needed from SpriteHelper
diff --git a/canvas/source/cairo/cairo_canvashelper_text.cxx b/canvas/source/cairo/cairo_canvashelper_text.cxx
index 91b385716422..f3c4c05083c3 100644
--- a/canvas/source/cairo/cairo_canvashelper_text.cxx
+++ b/canvas/source/cairo/cairo_canvashelper_text.cxx
@@ -176,12 +176,15 @@ namespace cairocanvas
{
private:
OutputDevice *mpVirtualDevice;
+ cairo_t *mpCairo;
bool mbMappingWasEnabled;
public:
- DeviceSettingsGuard(OutputDevice *pVirtualDevice)
+ DeviceSettingsGuard(OutputDevice *pVirtualDevice, cairo_t *pCairo)
: mpVirtualDevice(pVirtualDevice)
+ , mpCairo(pCairo)
, mbMappingWasEnabled(mpVirtualDevice->IsMapModeEnabled())
{
+ cairo_save(mpCairo);
mpVirtualDevice->Push();
mpVirtualDevice->EnableMapMode(false);
}
@@ -190,6 +193,7 @@ namespace cairocanvas
{
mpVirtualDevice->EnableMapMode(mbMappingWasEnabled);
mpVirtualDevice->Pop();
+ cairo_restore(mpCairo);
}
};
@@ -229,6 +233,17 @@ namespace cairocanvas
return true;
}
+ //set the clip of the rOutDev to the cairo surface
+ void CanvasHelper::clip_cairo_from_dev(::OutputDevice& rOutDev)
+ {
+ vcl::Region aRegion(rOutDev.GetClipRegion());
+ if (!aRegion.IsEmpty() && !aRegion.IsNull())
+ {
+ doPolyPolygonImplementation(aRegion.GetAsB2DPolyPolygon(), Clip, mpCairo.get(),
+ NULL, mpSurfaceProvider, rendering::FillRule_EVEN_ODD);
+ }
+ }
+
uno::Reference< rendering::XCachedPrimitive > CanvasHelper::drawText( const rendering::XCanvas* pOwner,
const rendering::StringContext& text,
const uno::Reference< rendering::XCanvasFont >& xFont,
@@ -249,7 +264,7 @@ namespace cairocanvas
if( mpVirtualDevice )
{
- DeviceSettingsGuard aGuard(mpVirtualDevice.get());
+ DeviceSettingsGuard aGuard(mpVirtualDevice.get(), mpCairo.get());
#if defined CAIRO_HAS_WIN32_SURFACE
// FIXME: Some kind of work-araound...
@@ -283,6 +298,8 @@ namespace cairocanvas
// TODO(F2): alpha
mpVirtualDevice->SetLayoutMode( nLayoutMode );
+ clip_cairo_from_dev(*mpVirtualDevice);
+
OSL_TRACE(":cairocanvas::CanvasHelper::drawText(O,t,f,v,r,d): %s", OUStringToOString( text.Text.copy( text.StartPosition, text.Length ),
RTL_TEXTENCODING_UTF8 ).getStr());
@@ -310,7 +327,7 @@ namespace cairocanvas
if( mpVirtualDevice )
{
- DeviceSettingsGuard aGuard(mpVirtualDevice.get());
+ DeviceSettingsGuard aGuard(mpVirtualDevice.get(), mpCairo.get());
#if defined CAIRO_HAS_WIN32_SURFACE
// FIXME: Some kind of work-araound...
@@ -326,6 +343,8 @@ namespace cairocanvas
if( !setupTextOutput( *mpVirtualDevice, pOwner, aOutpos, viewState, renderState, xLayoutedText->getFont() ) )
return uno::Reference< rendering::XCachedPrimitive >(NULL); // no output necessary
+ clip_cairo_from_dev(*mpVirtualDevice);
+
// TODO(F2): What about the offset scalings?
pTextLayout->draw(mpCairo, *mpVirtualDevice, aOutpos, viewState, renderState);
}