diff options
author | Kurt Zenker <kz@openoffice.org> | 2008-06-24 09:19:49 +0000 |
---|---|---|
committer | Kurt Zenker <kz@openoffice.org> | 2008-06-24 09:19:49 +0000 |
commit | b7d60c17d4278ec3f8d61c9f4f0c6117818ec12f (patch) | |
tree | 666be2facfdf70a259c114ee4a982e58403072e9 /canvas/source/cairo/cairo_canvascustomsprite.cxx | |
parent | cde07c6fb9d324f1e29d84c4cffd5ac1e34f8cec (diff) |
INTEGRATION: CWS canvas05 (1.5.26); FILE MERGED
2008/04/21 07:32:53 thb 1.5.26.7: RESYNC: (1.5-1.6); FILE MERGED
2008/04/04 22:08:33 thb 1.5.26.6: Fixed output of bezier polygons for cairo; fixed missing surfaces here and there; removed useless refcounted SurfaceProvider arguments (that lead to premature canvas death, as called during ctor)
2008/04/02 22:56:27 thb 1.5.26.5: Reworked Surface class to abstract interface; changed all manual refcount handling to RAII
2008/03/28 23:38:46 thb 1.5.26.4: Backbuffer-less canvas implementation on top of cairo
2008/03/18 22:00:56 thb 1.5.26.3: Implementing non-backbuffered canvas for cairocanvas as well - reworked to share most of the code
2007/12/20 22:18:56 thb 1.5.26.2: #i81092# #i78888# #i78925# #i79258# #i79437# #i84784# Large canvas rework, completing various areas such as color spaces, bitmap data access, true sprite and non-sprite implementations, and upstreaming the canvas parts of rodos emf+ rendering
2007/10/01 13:02:01 thb 1.5.26.1: #i78888# #i78925# #i79258# #i79437# Merge from CWS picom
Diffstat (limited to 'canvas/source/cairo/cairo_canvascustomsprite.cxx')
-rw-r--r-- | canvas/source/cairo/cairo_canvascustomsprite.cxx | 90 |
1 files changed, 52 insertions, 38 deletions
diff --git a/canvas/source/cairo/cairo_canvascustomsprite.cxx b/canvas/source/cairo/cairo_canvascustomsprite.cxx index 3aec8364e45c..5f53b005a600 100644 --- a/canvas/source/cairo/cairo_canvascustomsprite.cxx +++ b/canvas/source/cairo/cairo_canvascustomsprite.cxx @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: cairo_canvascustomsprite.cxx,v $ - * $Revision: 1.6 $ + * $Revision: 1.7 $ * * This file is part of OpenOffice.org. * @@ -33,6 +33,7 @@ #include <canvas/debug.hxx> #include <canvas/verbosetrace.hxx> +#include <tools/diagnose_ex.h> #include <rtl/logfile.hxx> #include <rtl/math.hxx> @@ -57,18 +58,19 @@ namespace cairocanvas maSize( ::canvas::tools::roundUp( rSpriteSize.Width ), ::canvas::tools::roundUp( rSpriteSize.Height ) ) { - ENSURE_AND_THROW( rRefDevice.get(), + ENSURE_OR_THROW( rRefDevice.get(), "CanvasCustomSprite::CanvasCustomSprite(): Invalid sprite canvas" ); OSL_TRACE("sprite size: %d, %d", ::canvas::tools::roundUp( rSpriteSize.Width ), ::canvas::tools::roundUp( rSpriteSize.Height )); - //mpBufferSurface = mpSpriteCanvas->getSurface( aSize, CAIRO_CONTENT_COLOR ); - mpBufferSurface = mpSpriteCanvas->getSurface( maSize ); + mpBufferSurface = mpSpriteCanvas->createSurface( maSize ); - maCanvasHelper.init( maSize, *rRefDevice.get() ); - maCanvasHelper.setSurface( mpBufferSurface, true, this ); + maCanvasHelper.init( maSize, + *rRefDevice, + rRefDevice.get() ); + maCanvasHelper.setSurface( mpBufferSurface, true ); maSpriteHelper.init( rSpriteSize, rRefDevice ); @@ -78,51 +80,28 @@ namespace cairocanvas maCanvasHelper.clear(); } - ::cairo::Surface* CanvasCustomSprite::changeSurface( bool bHasAlpha, bool bCopyContent ) - { - if( !bHasAlpha && !bCopyContent ) - { - OSL_TRACE("replacing sprite background surface"); - - if( mpBufferSurface ) - mpBufferSurface->Unref(); - mpBufferSurface = mpSpriteCanvas->getSurface( maSize, CAIRO_CONTENT_COLOR ); - - maSpriteHelper.setSurface( mpBufferSurface ); - - return mpBufferSurface; - } - - return NULL; - } - void SAL_CALL CanvasCustomSprite::disposing() { ::osl::MutexGuard aGuard( m_aMutex ); mpSpriteCanvas.clear(); - - if( mpBufferSurface ) - { - mpBufferSurface->Unref(); - mpBufferSurface = NULL; - } + mpBufferSurface.reset(); // forward to parent CanvasCustomSpriteBaseT::disposing(); } - void CanvasCustomSprite::redraw( Cairo* pCairo, - bool bBufferedUpdate ) const + void CanvasCustomSprite::redraw( const CairoSharedPtr& pCairo, + bool bBufferedUpdate ) const { ::osl::MutexGuard aGuard( m_aMutex ); redraw( pCairo, maSpriteHelper.getPosPixel(), bBufferedUpdate ); } - void CanvasCustomSprite::redraw( Cairo* pCairo, + void CanvasCustomSprite::redraw( const CairoSharedPtr& pCairo, const ::basegfx::B2DPoint& rOrigOutputPos, - bool bBufferedUpdate ) const + bool bBufferedUpdate ) const { ::osl::MutexGuard aGuard( m_aMutex ); @@ -134,11 +113,46 @@ namespace cairocanvas mbSurfaceDirty = false; } - bool CanvasCustomSprite::repaint( Surface* pSurface, - const rendering::ViewState& viewState, - const rendering::RenderState& renderState ) + bool CanvasCustomSprite::repaint( const SurfaceSharedPtr& pSurface, + const rendering::ViewState& viewState, + const rendering::RenderState& renderState ) + { + return maCanvasHelper.repaint( pSurface, viewState, renderState ); + } + + SurfaceSharedPtr CanvasCustomSprite::getSurface() + { + return mpBufferSurface; + } + + SurfaceSharedPtr CanvasCustomSprite::createSurface( const ::basegfx::B2ISize& rSize, Content aContent ) + { + return mpSpriteCanvas->createSurface(rSize,aContent); + } + + SurfaceSharedPtr CanvasCustomSprite::createSurface( ::Bitmap& rBitmap ) + { + return mpSpriteCanvas->createSurface(rBitmap); + } + + SurfaceSharedPtr CanvasCustomSprite::changeSurface( bool bHasAlpha, bool bCopyContent ) + { + if( !bHasAlpha && !bCopyContent ) + { + OSL_TRACE("replacing sprite background surface"); + + mpBufferSurface = mpSpriteCanvas->createSurface( maSize, CAIRO_CONTENT_COLOR ); + maSpriteHelper.setSurface( mpBufferSurface ); + + return mpBufferSurface; + } + + return SurfaceSharedPtr(); + } + + OutputDevice* CanvasCustomSprite::getOutputDevice() { - return maCanvasHelper.repaint( pSurface, viewState, renderState ); + return mpSpriteCanvas->getOutputDevice(); } #define IMPLEMENTATION_NAME "CairoCanvas.CanvasCustomSprite" |