diff options
author | Caolán McNamara <caolanm@redhat.com> | 2014-12-11 16:31:22 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2014-12-11 20:44:26 +0000 |
commit | f88b5ab8692ee7ecf58b570e703d0e7f10cc2f0d (patch) | |
tree | dce878d99bfe4287a4c9e80466dfbf97bc7fafb5 /canvas/source/cairo | |
parent | f95b0743da4239e047db8638c61f90f8bbe54306 (diff) |
Related: fdo#87242 merge duplicate clip setup code
favoring the vclcanvas one for the places where
they diverge
Change-Id: I18e3d4e7659ebd4cb90c86718c1b1035671b4be3
Diffstat (limited to 'canvas/source/cairo')
-rw-r--r-- | canvas/source/cairo/cairo_canvashelper_text.cxx | 98 |
1 files changed, 27 insertions, 71 deletions
diff --git a/canvas/source/cairo/cairo_canvashelper_text.cxx b/canvas/source/cairo/cairo_canvashelper_text.cxx index 5530eede33a9..91b385716422 100644 --- a/canvas/source/cairo/cairo_canvashelper_text.cxx +++ b/canvas/source/cairo/cairo_canvashelper_text.cxx @@ -127,73 +127,7 @@ namespace cairocanvas // TODO(P2): Don't change clipping all the time, maintain current clip // state and change only when update is necessary - - // accumulate non-empty clips into one region - // ========================================== - - vcl::Region aClipRegion; - - if( viewState.Clip.is() ) - { - ::basegfx::B2DPolyPolygon aClipPoly( - ::basegfx::unotools::b2DPolyPolygonFromXPolyPolygon2D( - viewState.Clip) ); - - if( aClipPoly.count() ) - { - // setup non-empty clipping - ::basegfx::B2DHomMatrix aMatrix; - aClipPoly.transform( - ::basegfx::unotools::homMatrixFromAffineMatrix( aMatrix, - viewState.AffineTransform ) ); - - aClipRegion = vcl::Region::GetRegionFromPolyPolygon( tools::PolyPolygon( aClipPoly ) ); - } - } - - if( renderState.Clip.is() ) - { - ::basegfx::B2DPolyPolygon aClipPoly( - ::basegfx::unotools::b2DPolyPolygonFromXPolyPolygon2D( - renderState.Clip) ); - - ::basegfx::B2DHomMatrix aMatrix; - aClipPoly.transform( - ::canvas::tools::mergeViewAndRenderTransform( aMatrix, - viewState, - renderState ) ); - - if( aClipPoly.count() ) - { - // setup non-empty clipping - vcl::Region aRegion = vcl::Region::GetRegionFromPolyPolygon( tools::PolyPolygon( aClipPoly ) ); - - if( aClipRegion.IsEmpty() ) - aClipRegion = aRegion; - else - aClipRegion.Intersect( aRegion ); - } - else - { - // clip polygon is empty - aClipRegion.SetEmpty(); - } - } - - // setup accumulated clip region. Note that setting an - // empty clip region denotes "clip everything" on the - // OutputDevice (which is why we translate that into - // SetClipRegion() here). When both view and render clip - // are empty, aClipRegion remains default-constructed, - // i.e. empty, too. - if( aClipRegion.IsEmpty() ) - { - rOutDev.SetClipRegion(); - } - else - { - rOutDev.SetClipRegion( aClipRegion ); - } + ::canvas::tools::clipOutDev(viewState, renderState, rOutDev); if( eColorType != IGNORE_COLOR ) { @@ -238,6 +172,27 @@ namespace cairocanvas return nTransparency; } + class DeviceSettingsGuard + { + private: + OutputDevice *mpVirtualDevice; + bool mbMappingWasEnabled; + public: + DeviceSettingsGuard(OutputDevice *pVirtualDevice) + : mpVirtualDevice(pVirtualDevice) + , mbMappingWasEnabled(mpVirtualDevice->IsMapModeEnabled()) + { + mpVirtualDevice->Push(); + mpVirtualDevice->EnableMapMode(false); + } + + ~DeviceSettingsGuard() + { + mpVirtualDevice->EnableMapMode(mbMappingWasEnabled); + mpVirtualDevice->Pop(); + } + }; + bool setupTextOutput( OutputDevice& rOutDev, const rendering::XCanvas* pOwner, ::Point& o_rOutPos, @@ -247,14 +202,12 @@ namespace cairocanvas { setupOutDevState( rOutDev, pOwner, viewState, renderState, TEXT_COLOR ); - vcl::Font aVCLFont; - CanvasFont* pFont = dynamic_cast< CanvasFont* >( xFont.get() ); ENSURE_ARG_OR_THROW( pFont, "CanvasHelper::setupTextOutput(): Font not compatible with this canvas" ); - aVCLFont = pFont->getVCLFont(); + vcl::Font aVCLFont = pFont->getVCLFont(); Color aColor( COL_BLACK ); @@ -273,7 +226,6 @@ namespace cairocanvas rOutDev.SetFont( aVCLFont ); - return true; } @@ -297,6 +249,8 @@ namespace cairocanvas if( mpVirtualDevice ) { + DeviceSettingsGuard aGuard(mpVirtualDevice.get()); + #if defined CAIRO_HAS_WIN32_SURFACE // FIXME: Some kind of work-araound... cairo_rectangle (mpCairo.get(), 0, 0, 0, 0); @@ -356,6 +310,8 @@ namespace cairocanvas if( mpVirtualDevice ) { + DeviceSettingsGuard aGuard(mpVirtualDevice.get()); + #if defined CAIRO_HAS_WIN32_SURFACE // FIXME: Some kind of work-araound... cairo_rectangle(mpCairo.get(), 0, 0, 0, 0); |