diff options
author | Radek Doulik <rodo@novell.com> | 2013-03-14 09:36:43 +0100 |
---|---|---|
committer | Radek Doulik <rodo@novell.com> | 2013-03-14 13:21:24 +0100 |
commit | 22f63477a3300d474c3d6832232b888f75c7290c (patch) | |
tree | 7fc4d0970fd5d58fe950e9b618ba87533c53b6e8 /canvas | |
parent | 87354e7fc1f63480bdef092047f912682bc7ac58 (diff) |
pass argb32 pixmaps from vcl to canvas, avoiding costly x11 roundtrips
- fixes also problem with emf+ rendering for slideshow
Change-Id: Icb894d3f37b29f23d3f267c944d827eefbf47fda
Diffstat (limited to 'canvas')
-rw-r--r-- | canvas/source/cairo/cairo_canvasbitmap.cxx | 30 | ||||
-rw-r--r-- | canvas/source/cairo/cairo_canvasbitmap.hxx | 4 | ||||
-rw-r--r-- | canvas/source/cairo/cairo_xlib_cairo.cxx | 7 | ||||
-rw-r--r-- | canvas/source/cairo/cairo_xlib_cairo.hxx | 1 |
4 files changed, 37 insertions, 5 deletions
diff --git a/canvas/source/cairo/cairo_canvasbitmap.cxx b/canvas/source/cairo/cairo_canvasbitmap.cxx index 91f61940dc1d..c0759c02653e 100644 --- a/canvas/source/cairo/cairo_canvasbitmap.cxx +++ b/canvas/source/cairo/cairo_canvasbitmap.cxx @@ -134,6 +134,30 @@ namespace cairocanvas return maCanvasHelper.repaint( pSurface, viewState, renderState ); } + void SAL_CALL CanvasBitmap::setFastPropertyValue( sal_Int32 nHandle, const ::com::sun::star::uno::Any& rAny ) throw (uno::RuntimeException) + { + sal_Int64 nPointer; + + if ( nHandle == 0 ) + { + rAny >>= nPointer; + + if ( nPointer ) + { + ::Bitmap *pBitmap = reinterpret_cast< ::Bitmap* >( nPointer ); + + mpBufferSurface = createSurface( *pBitmap ); + mpBufferCairo = mpBufferSurface->getCairo(); + + ::Size aSize( pBitmap->GetSizePixel() ); + maSize = ::basegfx::B2ISize( aSize.getWidth(), aSize.getHeight() ); + + maCanvasHelper.setSize( maSize ); + maCanvasHelper.setSurface( mpBufferSurface, mbHasAlpha ); + } + } + } + uno::Any SAL_CALL CanvasBitmap::getFastPropertyValue( sal_Int32 nHandle ) throw (uno::RuntimeException) { uno::Any aRV( sal_Int32(0) ); @@ -152,10 +176,11 @@ namespace cairocanvas #ifdef CAIRO_HAS_XLIB_SURFACE X11Surface* pXlibSurface=dynamic_cast<X11Surface*>(mpBufferSurface.get()); OSL_ASSERT(pXlibSurface); - uno::Sequence< uno::Any > args( 3 ); + uno::Sequence< uno::Any > args( 4 ); args[0] = uno::Any( false ); // do not call XFreePixmap on it args[1] = uno::Any( pXlibSurface->getPixmap()->mhDrawable ); args[2] = uno::Any( sal_Int32( pXlibSurface->getDepth() ) ); + args[3] = uno::Any( sal_Int64( pXlibSurface->getVisual () ) ); aRV = uno::Any( args ); #elif defined CAIRO_HAS_QUARTZ_SURFACE @@ -180,7 +205,7 @@ namespace cairocanvas case 2: { #ifdef CAIRO_HAS_XLIB_SURFACE - uno::Sequence< uno::Any > args( 3 ); + uno::Sequence< uno::Any > args( 4 ); SurfaceSharedPtr pAlphaSurface = mpSurfaceProvider->createSurface( maSize, CAIRO_CONTENT_COLOR ); CairoSharedPtr pAlphaCairo = pAlphaSurface->getCairo(); X11Surface* pXlibSurface=dynamic_cast<X11Surface*>(pAlphaSurface.get()); @@ -199,6 +224,7 @@ namespace cairocanvas args[0] = uno::Any( true ); args[1] = ::com::sun::star::uno::Any( pPixmap->mhDrawable ); args[2] = ::com::sun::star::uno::Any( sal_Int32( pXlibSurface->getDepth () ) ); + args[3] = ::com::sun::star::uno::Any( sal_Int64( pXlibSurface->getVisual () ) ); pPixmap->clear(); // caller takes ownership of pixmap // return pixmap and alphachannel pixmap - it will be used in BitmapEx diff --git a/canvas/source/cairo/cairo_canvasbitmap.hxx b/canvas/source/cairo/cairo_canvasbitmap.hxx index b1d669ed5713..bef03f557cd0 100644 --- a/canvas/source/cairo/cairo_canvasbitmap.hxx +++ b/canvas/source/cairo/cairo_canvasbitmap.hxx @@ -115,14 +115,14 @@ namespace cairocanvas // 2nd the pixmap handle // 3rd the pixmap depth virtual ::com::sun::star::uno::Any SAL_CALL getFastPropertyValue(sal_Int32 nHandle) throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL setFastPropertyValue(sal_Int32, const ::com::sun::star::uno::Any&) throw (::com::sun::star::uno::RuntimeException) {} + virtual void SAL_CALL setFastPropertyValue(sal_Int32, const ::com::sun::star::uno::Any&) throw (::com::sun::star::uno::RuntimeException); private: SurfaceProviderRef mpSurfaceProvider; ::cairo::SurfaceSharedPtr mpBufferSurface; ::cairo::CairoSharedPtr mpBufferCairo; - const ::basegfx::B2ISize maSize; + ::basegfx::B2ISize maSize; const bool mbHasAlpha; }; } diff --git a/canvas/source/cairo/cairo_xlib_cairo.cxx b/canvas/source/cairo/cairo_xlib_cairo.cxx index cd13ea133004..3086fd562096 100644 --- a/canvas/source/cairo/cairo_xlib_cairo.cxx +++ b/canvas/source/cairo/cairo_xlib_cairo.cxx @@ -187,7 +187,7 @@ namespace cairo mpSurface( cairo_xlib_surface_create( (Display*)rSysData.pDisplay, (Drawable)rData.aPixmap, - (Visual*) rSysData.pVisual, + (Visual*) (rData.aVisual ? rData.aVisual : rSysData.pVisual), rData.mnWidth, rData.mnHeight ), &cairo_surface_destroy) { @@ -312,6 +312,11 @@ namespace cairo return -1; } + void* X11Surface::getVisual() const + { + return cairo_xlib_surface_get_visual( mpSurface.get() ); + } + SurfaceSharedPtr createSurface( const CairoSurfaceSharedPtr& rSurface ) { return SurfaceSharedPtr(new X11Surface(rSurface)); diff --git a/canvas/source/cairo/cairo_xlib_cairo.hxx b/canvas/source/cairo/cairo_xlib_cairo.hxx index 105c570eae7d..080258bb04d2 100644 --- a/canvas/source/cairo/cairo_xlib_cairo.hxx +++ b/canvas/source/cairo/cairo_xlib_cairo.hxx @@ -92,6 +92,7 @@ namespace cairo { X11PixmapSharedPtr getPixmap() const { return mpPixmap; } void* getRenderFormat() const { return maSysData.pRenderFormat; } long getDrawable() const { return mpPixmap ? mpPixmap->mhDrawable : maSysData.hDrawable; } + void* getVisual() const; }; } |