[Libreoffice-commits] core.git: 3 commits - canvas/source desktop/source include/canvas include/vcl vcl/source
Caolán McNamara
caolanm at redhat.com
Thu Dec 11 12:44:59 PST 2014
canvas/source/cairo/cairo_canvashelper.hxx | 3
canvas/source/cairo/cairo_canvashelper_text.cxx | 117 +++++++++---------------
canvas/source/cairo/cairo_quartz_cairo.cxx | 2
canvas/source/cairo/cairo_win32_cairo.cxx | 2
canvas/source/cairo/cairo_xlib_cairo.cxx | 7 +
canvas/source/tools/canvastools.cxx | 75 +++++++++++++++
canvas/source/vcl/canvashelper.cxx | 80 ----------------
desktop/source/lib/init.cxx | 2
include/canvas/canvastools.hxx | 6 +
include/vcl/virdev.hxx | 3
vcl/source/gdi/virdev.cxx | 6 -
11 files changed, 149 insertions(+), 154 deletions(-)
New commits:
commit 94d935eecbba0161de2616c2234b4a5d9d3cad88
Author: Caolán McNamara <caolanm at redhat.com>
Date: Thu Dec 11 17:48:44 2014 +0000
Resolves: fdo#87242 reuse vcl clip for cairo during animations
Change-Id: I0a26d4c4092226732620c3852b0402ee45d4fa1d
diff --git a/canvas/source/cairo/cairo_canvashelper.hxx b/canvas/source/cairo/cairo_canvashelper.hxx
index 4adcb3b..f6f0099 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 91b3857..f3c4c05 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);
}
commit f88b5ab8692ee7ecf58b570e703d0e7f10cc2f0d
Author: Caolán McNamara <caolanm at redhat.com>
Date: Thu Dec 11 16:31:22 2014 +0000
Related: fdo#87242 merge duplicate clip setup code
favoring the vclcanvas one for the places where
they diverge
Change-Id: I18e3d4e7659ebd4cb90c86718c1b1035671b4be3
diff --git a/canvas/source/cairo/cairo_canvashelper_text.cxx b/canvas/source/cairo/cairo_canvashelper_text.cxx
index 5530eed..91b3857 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);
diff --git a/canvas/source/tools/canvastools.cxx b/canvas/source/tools/canvastools.cxx
index 3feb235..7b3ae29 100644
--- a/canvas/source/tools/canvastools.cxx
+++ b/canvas/source/tools/canvastools.cxx
@@ -1291,6 +1291,81 @@ namespace canvas
nColorSteps ) );
}
+ void clipOutDev(const rendering::ViewState& viewState,
+ const rendering::RenderState& renderState,
+ OutputDevice& rOutDev,
+ OutputDevice* p2ndOutDev)
+ {
+ // accumulate non-empty clips into one region
+ vcl::Region aClipRegion(true);
+
+ 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 ) );
+ }
+ else
+ {
+ // clip polygon is empty
+ aClipRegion.SetEmpty();
+ }
+ }
+
+ 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 ) );
+ 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.IsNull() )
+ {
+ rOutDev.SetClipRegion();
+
+ if( p2ndOutDev )
+ p2ndOutDev->SetClipRegion();
+ }
+ else
+ {
+ rOutDev.SetClipRegion( aClipRegion );
+
+ if( p2ndOutDev )
+ p2ndOutDev->SetClipRegion( aClipRegion );
+ }
+ }
} // namespace tools
} // namespace canvas
diff --git a/canvas/source/vcl/canvashelper.cxx b/canvas/source/vcl/canvashelper.cxx
index 9510d7e..c9fe640 100644
--- a/canvas/source/vcl/canvashelper.cxx
+++ b/canvas/source/vcl/canvashelper.cxx
@@ -1228,78 +1228,7 @@ namespace vclcanvas
// 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(true);
-
- 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 ) );
- }
- else
- {
- // clip polygon is empty
- aClipRegion.SetEmpty();
- }
- }
-
- 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 ) );
- 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.IsNull() )
- {
- rOutDev.SetClipRegion();
-
- if( p2ndOutDev )
- p2ndOutDev->SetClipRegion();
- }
- else
- {
- rOutDev.SetClipRegion( aClipRegion );
-
- if( p2ndOutDev )
- p2ndOutDev->SetClipRegion( aClipRegion );
- }
+ ::canvas::tools::clipOutDev(viewState, renderState, rOutDev, p2ndOutDev);
Color aColor( COL_WHITE );
@@ -1365,18 +1294,17 @@ namespace vclcanvas
ENSURE_OR_THROW( mpOutDev.get(),
"outdev null. Are we disposed?" );
- setupOutDevState( viewState, renderState, TEXT_COLOR );
-
OutputDevice& rOutDev( mpOutDev->getOutDev() );
- vcl::Font aVCLFont;
+ rOutDev.SetClipRegion(vcl::Region(true));
+ setupOutDevState( viewState, renderState, TEXT_COLOR );
CanvasFont* pFont = dynamic_cast< CanvasFont* >( xFont.get() );
ENSURE_ARG_OR_THROW( pFont,
"Font not compatible with this canvas" );
- aVCLFont = pFont->getVCLFont();
+ vcl::Font aVCLFont = pFont->getVCLFont();
Color aColor( COL_BLACK );
diff --git a/include/canvas/canvastools.hxx b/include/canvas/canvastools.hxx
index de5a76c..3881537 100644
--- a/include/canvas/canvastools.hxx
+++ b/include/canvas/canvastools.hxx
@@ -77,6 +77,7 @@ namespace com { namespace sun { namespace star { namespace awt
} } } }
class Color;
+class OutputDevice;
namespace canvas
{
@@ -579,6 +580,11 @@ namespace canvas
::std::size_t mnEntries;
bool mbCaseSensitive;
};
+
+ CANVASTOOLS_DLLPUBLIC void clipOutDev(const css::rendering::ViewState& viewState,
+ const css::rendering::RenderState& renderState,
+ OutputDevice& rOutDev,
+ OutputDevice* p2ndOutDev=NULL);
}
}
commit f95b0743da4239e047db8638c61f90f8bbe54306
Author: Caolán McNamara <caolanm at redhat.com>
Date: Thu Dec 11 16:20:49 2014 +0000
Related: fdo#87242 init VirtualDevice with size of surface
otherwise vcl's clipping doesn't work quite right when the render text
with vcl apis fallback is used.
Manually forced in my case, but it should happen in practice with vertical
text, so if there is a bug about vertical text not appearing in slideshows then
this is part of the fix for that.
Windows and Mac remain unchanged as initialized with 1, 1. If the same problem
affects those platforms then they'll need to be adjusted to remember their
height/widths from the ctor and those values plugged in here instead
Change-Id: I2f82f0db0cf446d7db21f0a7ee4f8c15c7ebdb42
diff --git a/canvas/source/cairo/cairo_quartz_cairo.cxx b/canvas/source/cairo/cairo_quartz_cairo.cxx
index 390402a..b87b993 100644
--- a/canvas/source/cairo/cairo_quartz_cairo.cxx
+++ b/canvas/source/cairo/cairo_quartz_cairo.cxx
@@ -269,7 +269,7 @@ namespace cairo
aSystemGraphicsData.nSize = sizeof(SystemGraphicsData);
aSystemGraphicsData.rCGContext = getCGContext();
return boost::shared_ptr<VirtualDevice>(
- new VirtualDevice( &aSystemGraphicsData, getDepth() ));
+ new VirtualDevice( &aSystemGraphicsData, Size(1, 1), getDepth() ));
}
/**
diff --git a/canvas/source/cairo/cairo_win32_cairo.cxx b/canvas/source/cairo/cairo_win32_cairo.cxx
index 8d4a4d2..6e1cf6f 100644
--- a/canvas/source/cairo/cairo_win32_cairo.cxx
+++ b/canvas/source/cairo/cairo_win32_cairo.cxx
@@ -197,7 +197,7 @@ namespace cairo
aSystemGraphicsData.hDC = cairo_win32_surface_get_dc( mpSurface.get() );
return boost::shared_ptr<VirtualDevice>(
- new VirtualDevice( &aSystemGraphicsData, sal::static_int_cast<USHORT>(getDepth()) ));
+ new VirtualDevice( &aSystemGraphicsData, Size(1, 1), sal::static_int_cast<USHORT>(getDepth()) ));
}
diff --git a/canvas/source/cairo/cairo_xlib_cairo.cxx b/canvas/source/cairo/cairo_xlib_cairo.cxx
index a9e2069..ae9cecb 100644
--- a/canvas/source/cairo/cairo_xlib_cairo.cxx
+++ b/canvas/source/cairo/cairo_xlib_cairo.cxx
@@ -278,8 +278,13 @@ namespace cairo
aSystemGraphicsData.hDrawable = getDrawable();
aSystemGraphicsData.pXRenderFormat = getRenderFormat();
+ int width = cairo_xlib_surface_get_width(mpSurface.get());
+ int height = cairo_xlib_surface_get_height(mpSurface.get());
+
return boost::shared_ptr<VirtualDevice>(
- new VirtualDevice( &aSystemGraphicsData, std::max( getDepth(), 0 ) ));
+ new VirtualDevice(&aSystemGraphicsData,
+ Size(width, height),
+ std::max(getDepth(), 0)));
}
/**
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 282cb99..9910fd1 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -578,7 +578,7 @@ void doc_paintTile (LibreOfficeKitDocument* pThis,
SvpSalInstance* pSalInstance = static_cast< SvpSalInstance* >(pSVData->mpDefInst);
pSalInstance->setBitCountFormatMapping( 32, ::basebmp::FORMAT_THIRTYTWO_BIT_TC_MASK_RGBA );
- VirtualDevice aDevice(0, (sal_uInt16)32);
+ VirtualDevice aDevice(0, Size(1, 1), (sal_uInt16)32);
boost::shared_array< sal_uInt8 > aBuffer( pBuffer, NoDelete< sal_uInt8 >() );
aDevice.SetOutputSizePixelScaleOffsetAndBuffer(
Size(nCanvasWidth, nCanvasHeight), Fraction(1.0), Point(),
diff --git a/include/vcl/virdev.hxx b/include/vcl/virdev.hxx
index 624cb2f..b6361bf 100644
--- a/include/vcl/virdev.hxx
+++ b/include/vcl/virdev.hxx
@@ -116,7 +116,8 @@ public:
Any rendering will happen directly on the context and not on any intermediate bitmap.
Note: This might not be supported on all platforms !
*/
- explicit VirtualDevice( const SystemGraphicsData *pData, sal_uInt16 nBitCount );
+ explicit VirtualDevice(const SystemGraphicsData *pData, const Size &rSize,
+ sal_uInt16 nBitCount);
virtual ~VirtualDevice();
diff --git a/vcl/source/gdi/virdev.cxx b/vcl/source/gdi/virdev.cxx
index 063bef1..eec2fa9 100644
--- a/vcl/source/gdi/virdev.cxx
+++ b/vcl/source/gdi/virdev.cxx
@@ -241,13 +241,15 @@ VirtualDevice::VirtualDevice( const OutputDevice& rCompDev, sal_uInt16 nBitCount
mnAlphaDepth = sal::static_int_cast<sal_Int8>(nAlphaBitCount);
}
-VirtualDevice::VirtualDevice( const SystemGraphicsData *pData, sal_uInt16 nBitCount )
+VirtualDevice::VirtualDevice(const SystemGraphicsData *pData, const Size &rSize,
+ sal_uInt16 nBitCount)
: mpVirDev( NULL ),
meRefDevMode( REFDEV_NONE )
{
SAL_INFO( "vcl.gdi", "VirtualDevice::VirtualDevice( " << nBitCount << " )" );
- ImplInitVirDev( Application::GetDefaultDevice(), 1, 1, nBitCount, pData );
+ ImplInitVirDev(Application::GetDefaultDevice(), rSize.Width(), rSize.Height(),
+ nBitCount, pData);
}
VirtualDevice::~VirtualDevice()
More information about the Libreoffice-commits
mailing list