diff options
author | Kurt Zenker <kz@openoffice.org> | 2006-02-28 09:33:59 +0000 |
---|---|---|
committer | Kurt Zenker <kz@openoffice.org> | 2006-02-28 09:33:59 +0000 |
commit | 137eec3727a17fd6dfc85761c3e6e837d9317da2 (patch) | |
tree | 5d0bbd6024977ca459149e6d7a38e274eb80c316 /canvas | |
parent | f582732ea0bdaa239ac052106c7b31dc6285db40 (diff) |
INTEGRATION: CWS cairocanvas (1.1.2); FILE ADDED
2006/01/11 12:29:01 radekdoulik 1.1.2.6: Issue number: #51657
Submitted by: radekdoulik
Reviewed by: radekdoulik
optimizes resizes and adds fallback to rgb surfaces for fully opaque bitmap
draws on sprites
2005/12/14 15:38:04 radekdoulik 1.1.2.5: Issue number: #51657
Submitted by: radekdoulik
Reviewed by: radekdoulik
use vcl to draw text to virtual device created from our pixmaps
2005/11/11 15:14:00 thb 1.1.2.4: #i10000# Fixed build issues (sprite.hxx was missing, took available cairoo_sprite.hxx instead)
2005/11/08 21:23:01 radekdoulik 1.1.2.3: Issue number: #51657
Submitted by: radekdoulik
Reviewed by: radekdoulik
updated cairo canvas to be usable by canvas02
2005/09/14 10:50:56 radekdoulik 1.1.2.2: Issue number: #51657
Submitted by: radekdoulik
Reviewed by: radekdoulik
Sync code in ooo-build with cairo canvas cws
2005/07/07 07:57:56 radekdoulik 1.1.2.1: Issue number: 51657
Submitted by: radekdoulik
Reviewed by: radekdoulik
initial import of cairo canvas code
Diffstat (limited to 'canvas')
-rw-r--r-- | canvas/source/cairo/cairo_canvascustomsprite.cxx | 159 |
1 files changed, 159 insertions, 0 deletions
diff --git a/canvas/source/cairo/cairo_canvascustomsprite.cxx b/canvas/source/cairo/cairo_canvascustomsprite.cxx new file mode 100644 index 000000000000..13f35808e403 --- /dev/null +++ b/canvas/source/cairo/cairo_canvascustomsprite.cxx @@ -0,0 +1,159 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: cairo_canvascustomsprite.cxx,v $ + * + * $Revision: 1.2 $ + * + * last change: $Author: kz $ $Date: 2006-02-28 10:33:59 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + ************************************************************************/ + +#include <canvas/debug.hxx> +#include <canvas/verbosetrace.hxx> + +#include <rtl/logfile.hxx> +#include <rtl/math.hxx> + +#include <canvas/canvastools.hxx> + +#include <basegfx/matrix/b2dhommatrix.hxx> +#include <basegfx/point/b2dpoint.hxx> + +#include "cairo_canvascustomsprite.hxx" +#include "cairo_spritecanvas.hxx" + + +using namespace ::cairo; +using namespace ::com::sun::star; + +namespace cairocanvas +{ + CanvasCustomSprite::CanvasCustomSprite( const ::com::sun::star::geometry::RealSize2D& rSpriteSize, + const SpriteCanvasRef& rRefDevice ) : + mpSpriteCanvas( rRefDevice ), + maSize( ::canvas::tools::roundUp( rSpriteSize.Width ), + ::canvas::tools::roundUp( rSpriteSize.Height ) ) + { + ENSURE_AND_THROW( rRefDevice.get(), + "CanvasCustomSprite::CanvasCustomSprite(): Invalid sprite canvas" ); + + //mpBufferSurface = mpSpriteCanvas->getSurface( aSize, CAIRO_CONTENT_COLOR ); + mpBufferSurface = mpSpriteCanvas->getSurface( maSize ); + + maCanvasHelper.init( maSize, *rRefDevice.get() ); + maCanvasHelper.setSurface( mpBufferSurface, true, this ); + + maSpriteHelper.init( rSpriteSize, + rRefDevice ); + maSpriteHelper.setSurface( mpBufferSurface ); + } + + ::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; + } + + // forward to parent + CanvasCustomSpriteBaseT::disposing(); + } + + void CanvasCustomSprite::redraw( Cairo* pCairo, + bool bBufferedUpdate ) const + { + ::osl::MutexGuard aGuard( m_aMutex ); + + redraw( pCairo, maSpriteHelper.getPosPixel(), bBufferedUpdate ); + } + + void CanvasCustomSprite::redraw( Cairo* pCairo, + const ::basegfx::B2DPoint& rOrigOutputPos, + bool bBufferedUpdate ) const + { + ::osl::MutexGuard aGuard( m_aMutex ); + + maSpriteHelper.redraw( pCairo, + rOrigOutputPos, + mbSurfaceDirty, + bBufferedUpdate ); + + mbSurfaceDirty = false; + } + + bool CanvasCustomSprite::repaint( Surface* pSurface, + const rendering::ViewState& viewState, + const rendering::RenderState& renderState ) + { + return maCanvasHelper.repaint( pSurface, viewState, renderState ); + } + +#define IMPLEMENTATION_NAME "CairoCanvas.CanvasCustomSprite" +#define SERVICE_NAME "com.sun.star.rendering.CanvasCustomSprite" + + ::rtl::OUString SAL_CALL CanvasCustomSprite::getImplementationName() throw( uno::RuntimeException ) + { + return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( IMPLEMENTATION_NAME ) ); + } + + sal_Bool SAL_CALL CanvasCustomSprite::supportsService( const ::rtl::OUString& ServiceName ) throw( uno::RuntimeException ) + { + return ServiceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM ( SERVICE_NAME ) ); + } + + uno::Sequence< ::rtl::OUString > SAL_CALL CanvasCustomSprite::getSupportedServiceNames() throw( uno::RuntimeException ) + { + uno::Sequence< ::rtl::OUString > aRet(1); + aRet[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( SERVICE_NAME ) ); + + return aRet; + } +} |