summaryrefslogtreecommitdiff
path: root/canvas
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2015-03-19 10:13:57 +0000
committerCaolán McNamara <caolanm@redhat.com>2015-03-19 13:17:46 +0000
commit6c806749421caf9267325cd86372c488f585ab5a (patch)
treec4a0dadbe78dbaaa2964eceef70125370f4cfa9d /canvas
parentc5e012fc65403e960d7f7ab5a3da50f6a2d1c53a (diff)
reorganize resizing surfaces logic
the only case where we don't just create a new surface is the X11 case Change-Id: I98a3c8f227e208ac9db969ed7711e293fb237c2e Reviewed-on: https://gerrit.libreoffice.org/14902 Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'canvas')
-rw-r--r--canvas/source/cairo/cairo_cairo.hxx5
-rw-r--r--canvas/source/cairo/cairo_devicehelper.cxx15
-rw-r--r--canvas/source/cairo/cairo_quartz_cairo.cxx15
-rw-r--r--canvas/source/cairo/cairo_quartz_cairo.hxx2
-rw-r--r--canvas/source/cairo/cairo_win32_cairo.cxx14
-rw-r--r--canvas/source/cairo/cairo_win32_cairo.hxx2
-rw-r--r--canvas/source/cairo/cairo_xlib_cairo.cxx5
-rw-r--r--canvas/source/cairo/cairo_xlib_cairo.hxx2
8 files changed, 14 insertions, 46 deletions
diff --git a/canvas/source/cairo/cairo_cairo.hxx b/canvas/source/cairo/cairo_cairo.hxx
index ab73a569dd92..e256610a54d4 100644
--- a/canvas/source/cairo/cairo_cairo.hxx
+++ b/canvas/source/cairo/cairo_cairo.hxx
@@ -63,8 +63,9 @@ namespace cairo {
/// factory for VirDev on this surface
virtual boost::shared_ptr<VirtualDevice> createVirtualDevice() const = 0;
- /// Resize the surface (possibly destroying content)
- virtual void Resize( int width, int height ) = 0;
+ /// Resize the surface (possibly destroying content), only possible for X11 typically
+ /// so on failure create a new surface instead
+ virtual bool Resize( int /*width*/, int /*height*/ ) { return false; }
/// Flush all pending output to surface
virtual void flush() const = 0;
diff --git a/canvas/source/cairo/cairo_devicehelper.cxx b/canvas/source/cairo/cairo_devicehelper.cxx
index 920481e92875..c5296b733277 100644
--- a/canvas/source/cairo/cairo_devicehelper.cxx
+++ b/canvas/source/cairo/cairo_devicehelper.cxx
@@ -90,15 +90,14 @@ namespace cairocanvas
if( !mpRefDevice )
return; // disposed
- OutputDevice* pOutDev=getOutputDevice();
+ OutputDevice* pOutDev = getOutputDevice();
- if (mpSurface && pOutDev->CanResizeCairoSurface())
- {
- // X11 only
- mpSurface->Resize( rSize.getX() + pOutDev->GetOutOffXPixel(),
- rSize.getY() + pOutDev->GetOutOffYPixel() );
- }
- else
+ // X11 only
+ bool bReuseSurface = mpSurface &&
+ mpSurface->Resize(rSize.getX() + pOutDev->GetOutOffXPixel(),
+ rSize.getY() + pOutDev->GetOutOffYPixel());
+
+ if (!bReuseSurface)
{
mpSurface = cairo::createSurface(
*pOutDev,
diff --git a/canvas/source/cairo/cairo_quartz_cairo.cxx b/canvas/source/cairo/cairo_quartz_cairo.cxx
index f4456aa596b4..8da24f3391dd 100644
--- a/canvas/source/cairo/cairo_quartz_cairo.cxx
+++ b/canvas/source/cairo/cairo_quartz_cairo.cxx
@@ -163,21 +163,6 @@ namespace cairo
}
/**
- * QuartzSurface::Resize: Resizes the Canvas surface.
- * @param width new width of the surface
- * @param height new height of the surface
- *
- * Only used on X11.
- *
- * @return The new surface or NULL
- **/
- void QuartzSurface::Resize( int /* width */, int /* height */ )
- {
- OSL_FAIL("not supposed to be called!");
- }
-
-
- /**
* QuartzSurface::flush: Draw the data to screen
**/
void QuartzSurface::flush() const
diff --git a/canvas/source/cairo/cairo_quartz_cairo.hxx b/canvas/source/cairo/cairo_quartz_cairo.hxx
index cbcbf2786e75..a3f94d20abf3 100644
--- a/canvas/source/cairo/cairo_quartz_cairo.hxx
+++ b/canvas/source/cairo/cairo_quartz_cairo.hxx
@@ -57,8 +57,6 @@ namespace cairo {
virtual boost::shared_ptr<VirtualDevice> createVirtualDevice() const;
- virtual void Resize( int width, int height );
-
virtual void flush() const;
int getDepth() const;
diff --git a/canvas/source/cairo/cairo_win32_cairo.cxx b/canvas/source/cairo/cairo_win32_cairo.cxx
index 20efd3381764..a54c7e1d33d7 100644
--- a/canvas/source/cairo/cairo_win32_cairo.cxx
+++ b/canvas/source/cairo/cairo_win32_cairo.cxx
@@ -139,20 +139,6 @@ namespace cairo
&cairo_surface_destroy )));
}
- /**
- * Surface::Resize: Resizes the Canvas surface.
- * @param width new width of the surface
- * @param height new height of the surface
- *
- * Only used on X11.
- *
- * @return The new surface or NULL
- **/
- void Win32Surface::Resize( int /*width*/, int /*height*/ )
- {
- OSL_FAIL("not supposed to be called!");
- }
-
void Win32Surface::flush() const
{
GdiFlush();
diff --git a/canvas/source/cairo/cairo_win32_cairo.hxx b/canvas/source/cairo/cairo_win32_cairo.hxx
index c6f4d7ea0051..50bd1373e1d6 100644
--- a/canvas/source/cairo/cairo_win32_cairo.hxx
+++ b/canvas/source/cairo/cairo_win32_cairo.hxx
@@ -45,8 +45,6 @@ namespace cairo {
virtual boost::shared_ptr<VirtualDevice> createVirtualDevice() const;
- virtual void Resize( int width, int height );
-
virtual void flush() const;
int getDepth() const;
diff --git a/canvas/source/cairo/cairo_xlib_cairo.cxx b/canvas/source/cairo/cairo_xlib_cairo.cxx
index a4665e14aa04..f6720d34eaec 100644
--- a/canvas/source/cairo/cairo_xlib_cairo.cxx
+++ b/canvas/source/cairo/cairo_xlib_cairo.cxx
@@ -281,9 +281,10 @@ namespace cairo
*
* @return The new surface or NULL
**/
- void X11Surface::Resize( int width, int height )
+ bool X11Surface::Resize(int width, int height)
{
- cairo_xlib_surface_set_size( mpSurface.get(), width, height );
+ cairo_xlib_surface_set_size(mpSurface.get(), width, height);
+ return true;
}
void X11Surface::flush() const
diff --git a/canvas/source/cairo/cairo_xlib_cairo.hxx b/canvas/source/cairo/cairo_xlib_cairo.hxx
index f040b9bc0ced..a7071cecd6bd 100644
--- a/canvas/source/cairo/cairo_xlib_cairo.hxx
+++ b/canvas/source/cairo/cairo_xlib_cairo.hxx
@@ -88,7 +88,7 @@ namespace cairo {
virtual boost::shared_ptr<VirtualDevice> createVirtualDevice() const SAL_OVERRIDE;
- virtual void Resize( int width, int height ) SAL_OVERRIDE;
+ virtual bool Resize( int width, int height ) SAL_OVERRIDE;
virtual void flush() const SAL_OVERRIDE;