diff options
Diffstat (limited to 'canvas/inc/canvas/base')
-rw-r--r-- | canvas/inc/canvas/base/basemutexhelper.hxx | 72 | ||||
-rw-r--r-- | canvas/inc/canvas/base/bitmapcanvasbase.hxx | 137 | ||||
-rw-r--r-- | canvas/inc/canvas/base/bufferedgraphicdevicebase.hxx | 286 | ||||
-rw-r--r-- | canvas/inc/canvas/base/cachedprimitivebase.hxx | 125 | ||||
-rw-r--r-- | canvas/inc/canvas/base/canvasbase.hxx | 486 | ||||
-rw-r--r-- | canvas/inc/canvas/base/canvascustomspritebase.hxx | 280 | ||||
-rw-r--r-- | canvas/inc/canvas/base/canvascustomspritehelper.hxx | 296 | ||||
-rw-r--r-- | canvas/inc/canvas/base/doublebitmapbase.hxx | 154 | ||||
-rw-r--r-- | canvas/inc/canvas/base/floatbitmapbase.hxx | 158 | ||||
-rw-r--r-- | canvas/inc/canvas/base/graphicdevicebase.hxx | 394 | ||||
-rw-r--r-- | canvas/inc/canvas/base/integerbitmapbase.hxx | 154 | ||||
-rw-r--r-- | canvas/inc/canvas/base/sprite.hxx | 122 | ||||
-rw-r--r-- | canvas/inc/canvas/base/spritecanvasbase.hxx | 205 | ||||
-rw-r--r-- | canvas/inc/canvas/base/spritesurface.hxx | 76 |
14 files changed, 2945 insertions, 0 deletions
diff --git a/canvas/inc/canvas/base/basemutexhelper.hxx b/canvas/inc/canvas/base/basemutexhelper.hxx new file mode 100644 index 000000000000..c1c7eed8455e --- /dev/null +++ b/canvas/inc/canvas/base/basemutexhelper.hxx @@ -0,0 +1,72 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef INCLUDED_CANVAS_BASEMUTEXHELPER_HXX +#define INCLUDED_CANVAS_BASEMUTEXHELPER_HXX + +#include <osl/mutex.hxx> + + +/* Definition of the BaseMutexHelper class */ + +namespace canvas +{ + /** Base class, deriving from ::comphelper::OBaseMutex and + initializing its own baseclass with m_aMutex. + + This is necessary to make the CanvasBase, GraphicDeviceBase, + etc. classes freely combinable - letting them perform this + initialization would prohibit deriving e.g. CanvasBase from + GraphicDeviceBase. + */ + template< class Base > class BaseMutexHelper : public Base + { + public: + typedef Base BaseType; + + /** Construct BaseMutexHelper + + This method is the whole purpose of this template: + initializing a base class with the provided m_aMutex + member (the WeakComponentImplHelper templates need that, + as they require the lifetime of the mutex to extend + theirs). + */ + BaseMutexHelper() : + BaseType( m_aMutex ) + { + } + +protected: + mutable ::osl::Mutex m_aMutex; + }; +} + +#endif /* INCLUDED_CANVAS_BASEMUTEXHELPER_HXX */ + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/canvas/inc/canvas/base/bitmapcanvasbase.hxx b/canvas/inc/canvas/base/bitmapcanvasbase.hxx new file mode 100644 index 000000000000..2761b5b09f3a --- /dev/null +++ b/canvas/inc/canvas/base/bitmapcanvasbase.hxx @@ -0,0 +1,137 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef INCLUDED_CANVAS_BITMAPCANVASBASE_HXX +#define INCLUDED_CANVAS_BITMAPCANVASBASE_HXX + +#include <canvas/base/canvasbase.hxx> +#include <com/sun/star/rendering/XBitmapCanvas.hpp> + +namespace canvas +{ + /** Helper template to handle XBitmapCanvas method forwarding to + BitmapCanvasHelper + + Use this helper to handle the XBitmapCanvas part of your + implementation. + + @tpl Base + Base class to use, most probably one of the + WeakComponentImplHelperN templates with the appropriate + interfaces. At least XBitmapCanvas should be among them (why + else would you use this template, then?). Base class must have + an Base( const Mutex& ) constructor (like the + WeakComponentImplHelperN templates have). + + @tpl CanvasHelper + Canvas helper implementation for the backend in question + + @tpl Mutex + Lock strategy to use. Defaults to using the + OBaseMutex-provided lock. Everytime one of the methods is + entered, an object of type Mutex is created with m_aMutex as + the sole parameter, and destroyed again when the method scope + is left. + + @tpl UnambiguousBase + Optional unambiguous base class for XInterface of Base. It's + sometimes necessary to specify this parameter, e.g. if Base + derives from multiple UNO interface (were each provides its + own version of XInterface, making the conversion ambiguous) + + @see CanvasBase for further contractual requirements towards + the CanvasHelper type, and some examples. + */ + template< class Base, + class CanvasHelper, + class Mutex=::osl::MutexGuard, + class UnambiguousBase=::com::sun::star::uno::XInterface > class BitmapCanvasBase : + public CanvasBase< Base, CanvasHelper, Mutex, UnambiguousBase > + { + public: + typedef CanvasBase< Base, CanvasHelper, Mutex, UnambiguousBase > BaseType; + + // XBitmapCanvas + virtual void SAL_CALL copyRect( const ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XBitmapCanvas >& sourceCanvas, + const ::com::sun::star::geometry::RealRectangle2D& sourceRect, + const ::com::sun::star::rendering::ViewState& sourceViewState, + const ::com::sun::star::rendering::RenderState& sourceRenderState, + const ::com::sun::star::geometry::RealRectangle2D& destRect, + const ::com::sun::star::rendering::ViewState& destViewState, + const ::com::sun::star::rendering::RenderState& destRenderState ) throw (::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::uno::RuntimeException) + { + tools::verifyArgs(sourceCanvas, sourceRect, sourceViewState, sourceRenderState, + destRect, destViewState, destRenderState, + BOOST_CURRENT_FUNCTION, + static_cast< typename BaseType::UnambiguousBaseType* >(this)); + + typename BaseType::MutexType aGuard( BaseType::m_aMutex ); + + BaseType::mbSurfaceDirty = true; + BaseType::maCanvasHelper.modifying(); + + BaseType::maCanvasHelper.copyRect( this, + sourceCanvas, + sourceRect, + sourceViewState, + sourceRenderState, + destRect, + destViewState, + destRenderState ); + } + + // XBitmap + virtual ::com::sun::star::geometry::IntegerSize2D SAL_CALL getSize( ) throw (::com::sun::star::uno::RuntimeException) + { + typename BaseType::MutexType aGuard( BaseType::m_aMutex ); + + return BaseType::maCanvasHelper.getSize(); + } + + virtual ::sal_Bool SAL_CALL hasAlpha( ) throw (::com::sun::star::uno::RuntimeException) + { + typename BaseType::MutexType aGuard( BaseType::m_aMutex ); + + return BaseType::maCanvasHelper.hasAlpha(); + } + + virtual ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XBitmap > SAL_CALL getScaledBitmap( const ::com::sun::star::geometry::RealSize2D& newSize, + sal_Bool beFast ) throw (::com::sun::star::uno::RuntimeException) + { + typename BaseType::MutexType aGuard( BaseType::m_aMutex ); + + return BaseType::maCanvasHelper.getScaledBitmap( newSize, beFast ); + } + + }; +} + +#endif /* INCLUDED_CANVAS_BITMAPCANVASBASE_HXX */ + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/canvas/inc/canvas/base/bufferedgraphicdevicebase.hxx b/canvas/inc/canvas/base/bufferedgraphicdevicebase.hxx new file mode 100644 index 000000000000..9e31473ba589 --- /dev/null +++ b/canvas/inc/canvas/base/bufferedgraphicdevicebase.hxx @@ -0,0 +1,286 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef INCLUDED_CANVAS_BUFFEREDGRAPHICDEVICEBASE_HXX +#define INCLUDED_CANVAS_BUFFEREDGRAPHICDEVICEBASE_HXX + +#include <com/sun/star/awt/XWindow2.hpp> +#include <com/sun/star/awt/XTopWindow.hpp> +#include <com/sun/star/awt/XWindowListener.hpp> + +#include <canvas/canvastools.hxx> +#include <canvas/base/graphicdevicebase.hxx> + + +/* Definition of BufferedGraphicDeviceBase class */ + +namespace canvas +{ + /** Helper template base class for XGraphicDevice implementations + on windows. + + Use this base class if your target device is a + window. Additionally to GraphicDeviceBase, this template + provides an implementation of the awt::XWindowListener + interface, to receive notifications about state changes of the + associated window. + + @tpl Base + Base class to use, most probably one of the + WeakComponentImplHelperN templates with the appropriate + interfaces. At least XGraphicDevice should be among them (why else + would you use this template, then?). Base class must have an + Base( const Mutex& ) constructor (like the + WeakComponentImplHelperN templates have). As the very least, + the base class must be derived from uno::XInterface, as some + error reporting mechanisms rely on that. + + @tpl DeviceHelper + Device helper implementation for the backend in question. This + object will be held as a member of this template class, and + basically gets forwarded all XGraphicDevice API calls that + could not be handled generically. + + @tpl Mutex + Lock strategy to use. Defaults to using the + OBaseMutex-provided lock. Everytime one of the methods is + entered, an object of type Mutex is created with m_aMutex as + the sole parameter, and destroyed again when the method scope + is left. + + @tpl UnambiguousBase + Optional unambiguous base class for XInterface of Base. It's + sometimes necessary to specify this parameter, e.g. if Base + derives from multiple UNO interface (were each provides its + own version of XInterface, making the conversion ambiguous) + */ + template< class Base, + class DeviceHelper, + class Mutex=::osl::MutexGuard, + class UnambiguousBase=::com::sun::star::uno::XInterface > class BufferedGraphicDeviceBase : + public GraphicDeviceBase< Base, DeviceHelper, Mutex, UnambiguousBase > + { + public: + typedef GraphicDeviceBase< Base, DeviceHelper, Mutex, UnambiguousBase > BaseType; + typedef BufferedGraphicDeviceBase OurType; + typedef Mutex MutexType; + + BufferedGraphicDeviceBase() : + mxWindow(), + maBounds(), + mbIsVisible( false ), + mbIsTopLevel( false ) + { + BaseType::maPropHelper.addProperties( PropertySetHelper::MakeMap + ("Window", + boost::bind(&OurType::getXWindow, + this))); + } + + // XGraphicDevice + virtual ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XBufferController > SAL_CALL getBufferController( ) throw (::com::sun::star::uno::RuntimeException) + { + return this; + } + + // XBufferController + virtual ::sal_Int32 SAL_CALL createBuffers( ::sal_Int32 nBuffers ) throw (::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::uno::RuntimeException) + { + tools::verifyRange( nBuffers, (sal_Int32)1 ); + + MutexType aGuard( BaseType::m_aMutex ); + + return BaseType::maDeviceHelper.createBuffers( nBuffers ); + } + + virtual void SAL_CALL destroyBuffers( ) throw (::com::sun::star::uno::RuntimeException) + { + MutexType aGuard( BaseType::m_aMutex ); + + BaseType::maDeviceHelper.destroyBuffers(); + } + + virtual ::sal_Bool SAL_CALL showBuffer( ::sal_Bool bUpdateAll ) throw (::com::sun::star::uno::RuntimeException) + { + MutexType aGuard( BaseType::m_aMutex ); + + return BaseType::maDeviceHelper.showBuffer( mbIsVisible, bUpdateAll ); + } + + virtual ::sal_Bool SAL_CALL switchBuffer( ::sal_Bool bUpdateAll ) throw (::com::sun::star::uno::RuntimeException) + { + MutexType aGuard( BaseType::m_aMutex ); + + return BaseType::maDeviceHelper.switchBuffer( mbIsVisible, bUpdateAll ); + } + + + /** Set corresponding canvas window + + Use this method to set the window this canvas displays + on. Comes in handy when the canvas needs to adapt size or + output position to the changing window. + + Whenever the bounds of the window change, <code>void + notifySizeUpdate( const awt::Rectangle& rBounds )</code> + is called, with rBounds the window bound rect relative to + the frame window. + */ + void setWindow( const ::com::sun::star::uno::Reference< + ::com::sun::star::awt::XWindow2 >& rWindow ) + { + if( mxWindow.is() ) + mxWindow->removeWindowListener( this ); + + mxWindow = rWindow; + + if( mxWindow.is() ) + { + mbIsVisible = mxWindow->isVisible(); + mbIsTopLevel = + ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTopWindow >( + mxWindow, + ::com::sun::star::uno::UNO_QUERY ).is(); + + maBounds = transformBounds( mxWindow->getPosSize() ); + mxWindow->addWindowListener( this ); + } + } + + ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow2 > getWindow() const + { + return mxWindow; + } + + ::com::sun::star::uno::Any getXWindow() const + { + return ::com::sun::star::uno::makeAny(mxWindow); + } + +#if defined __SUNPRO_CC + using Base::disposing; +#endif + virtual void SAL_CALL disposing() + { + typename BaseType::MutexType aGuard( BaseType::m_aMutex ); + + if( mxWindow.is() ) + { + mxWindow->removeWindowListener(this); + mxWindow.clear(); + } + + // pass on to base class + BaseType::disposing(); + } + + ::com::sun::star::awt::Rectangle transformBounds( const ::com::sun::star::awt::Rectangle& rBounds ) + { + // notifySizeUpdate's bounds are relative to the toplevel + // window + if( !mbIsTopLevel ) + return tools::getAbsoluteWindowRect( + rBounds, + mxWindow ); + else + return ::com::sun::star::awt::Rectangle( 0,0,rBounds.Width,rBounds.Height ); + } + + void boundsChanged( const ::com::sun::star::awt::WindowEvent& e ) + { + typename BaseType::MutexType aGuard( BaseType::m_aMutex ); + + const ::com::sun::star::awt::Rectangle& rNewBounds( + transformBounds( + ::com::sun::star::awt::Rectangle( e.X, + e.Y, + e.Width, + e.Height ))); + + if( rNewBounds.X != maBounds.X || + rNewBounds.Y != maBounds.Y || + rNewBounds.Width != maBounds.Width || + rNewBounds.Height != maBounds.Height ) + { + maBounds = rNewBounds; + BaseType::maDeviceHelper.notifySizeUpdate( maBounds ); + } + } + + // XWindowListener + virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw (::com::sun::star::uno::RuntimeException) + { + typename BaseType::MutexType aGuard( BaseType::m_aMutex ); + + if( Source.Source == mxWindow ) + mxWindow.clear(); + } + + virtual void SAL_CALL windowResized( const ::com::sun::star::awt::WindowEvent& e ) throw (::com::sun::star::uno::RuntimeException) + { + boundsChanged( e ); + } + + virtual void SAL_CALL windowMoved( const ::com::sun::star::awt::WindowEvent& e ) throw (::com::sun::star::uno::RuntimeException) + { + boundsChanged( e ); + } + + virtual void SAL_CALL windowShown( const ::com::sun::star::lang::EventObject& ) throw (::com::sun::star::uno::RuntimeException) + { + typename BaseType::MutexType aGuard( BaseType::m_aMutex ); + + mbIsVisible = true; + } + + virtual void SAL_CALL windowHidden( const ::com::sun::star::lang::EventObject& ) throw (::com::sun::star::uno::RuntimeException) + { + typename BaseType::MutexType aGuard( BaseType::m_aMutex ); + + mbIsVisible = false; + } + + protected: + ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow2 > mxWindow; + + /// Current bounds of the owning Window + ::com::sun::star::awt::Rectangle maBounds; + + /// True, if the window this canvas is contained in, is visible + bool mbIsVisible; + + private: + /// True, if the window this canvas is contained in, is a toplevel window + bool mbIsTopLevel; + }; +} + +#endif /* INCLUDED_CANVAS_BUFFEREDGRAPHICDEVICEBASE_HXX */ + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/canvas/inc/canvas/base/cachedprimitivebase.hxx b/canvas/inc/canvas/base/cachedprimitivebase.hxx new file mode 100644 index 000000000000..3d7a22cb4940 --- /dev/null +++ b/canvas/inc/canvas/base/cachedprimitivebase.hxx @@ -0,0 +1,125 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef INCLUDED_CANVAS_CACHEDPRIMITIVEBASE_HXX +#define INCLUDED_CANVAS_CACHEDPRIMITIVEBASE_HXX + +#include <com/sun/star/uno/Reference.hxx> +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/rendering/XCanvas.hpp> +#include <com/sun/star/rendering/XCachedPrimitive.hpp> +#include <com/sun/star/rendering/ViewState.hpp> +#include <cppuhelper/compbase2.hxx> +#include <comphelper/broadcasthelper.hxx> + + +/* Definition of CachedPrimitiveBase class */ + +namespace canvas +{ + typedef ::cppu::WeakComponentImplHelper2< ::com::sun::star::rendering::XCachedPrimitive, + ::com::sun::star::lang::XServiceInfo > CachedPrimitiveBase_Base; + + /** Base class, providing common functionality for implementers of + the XCachedPrimitive interface. + */ + class CachedPrimitiveBase : public CachedPrimitiveBase_Base, + public ::comphelper::OBaseMutex + { + public: + + /** Create an XCachedPrimitive for given target canvas + + @param rUsedViewState + The viewstate the original object was rendered with + + @param rTarget + The target canvas the repaint should happen on. + + @param bFailForChangedViewTransform + When true, derived classes will never receive doRedraw() + calls with dissimilar view transformations and + bSameViewTransform set to false. This is useful for cached + objects where re-transforming the generated output is not + desirable, e.g. for hinted font output. + */ + CachedPrimitiveBase( const ::com::sun::star::rendering::ViewState& rUsedViewState, + const ::com::sun::star::uno::Reference< + ::com::sun::star::rendering::XCanvas >& rTarget, + bool bFailForChangedViewTransform ); + + /// Dispose all internal references + virtual void SAL_CALL disposing(); + + // XCachedPrimitive + virtual ::sal_Int8 SAL_CALL redraw( const ::com::sun::star::rendering::ViewState& aState ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); + + // XServiceInfo + virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw (::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw (::com::sun::star::uno::RuntimeException); + + protected: + ~CachedPrimitiveBase(); // we're a ref-counted UNO class. _We_ destroy ourselves. + + private: + CachedPrimitiveBase( const CachedPrimitiveBase& ); + CachedPrimitiveBase& operator=( const CachedPrimitiveBase& ); + + /** Actually perform the requested redraw. + + Clients must override this method, instead of the public + redraw() one. + + @param rNewState + The viewstate to redraw with + + @param rOldState + The viewstate this cache object was created with. + + @param rTargetCanvas + Target canvas to render to. + + @param bSameViewTransform + When true, rNewState and rOldState have the same transformation. + */ + virtual ::sal_Int8 doRedraw( const ::com::sun::star::rendering::ViewState& rNewState, + const ::com::sun::star::rendering::ViewState& rOldState, + const ::com::sun::star::uno::Reference< + ::com::sun::star::rendering::XCanvas >& rTargetCanvas, + bool bSameViewTransform ) = 0; + + ::com::sun::star::rendering::ViewState maUsedViewState; + ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XCanvas > mxTarget; + const bool mbFailForChangedViewTransform; + }; +} + +#endif /* INCLUDED_CANVAS_CACHEDPRIMITIVEBASE_HXX */ + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/canvas/inc/canvas/base/canvasbase.hxx b/canvas/inc/canvas/base/canvasbase.hxx new file mode 100644 index 000000000000..204355da93c3 --- /dev/null +++ b/canvas/inc/canvas/base/canvasbase.hxx @@ -0,0 +1,486 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef INCLUDED_CANVAS_CANVASBASE_HXX +#define INCLUDED_CANVAS_CANVASBASE_HXX + +#include <com/sun/star/uno/Reference.hxx> +#include <com/sun/star/rendering/XCanvas.hpp> +#include <com/sun/star/rendering/TextDirection.hpp> +#include <osl/mutex.hxx> +#include <canvas/verifyinput.hxx> + + +namespace canvas +{ + /** Helper template to handle XCanvas method forwarding to CanvasHelper + + Use this helper to handle the XCanvas part of your + implementation. In theory, we could have provided CanvasHelper + and CanvasBase as a single template, but that would duplicate + a lot of code now residing in CanvasHelper only. + + This template basically interposes itself between the full + interface you implement (i.e. not restricted to XCanvas. The + problem with UNO partial interface implementation actually is, + that you cannot do it the plain way, since deriving from a + common base subclass always introduces the whole set of pure + virtuals, that your baseclass helper just overrided) and your + implementation class. You then only have to implement the + functionality <em>besides</em> XCanvas. + + <pre> + Example: + typedef ::cppu::WeakComponentImplHelper4< ::com::sun::star::rendering::XSpriteCanvas, + ::com::sun::star::lang::XInitialization, + ::com::sun::star::lang::XServiceInfo, + ::com::sun::star::lang::XServiceName > CanvasBase_Base; + typedef ::canvas::internal::CanvasBase< CanvasBase_Base, CanvasHelper > ExampleCanvas_Base; + + class ExampleCanvas : public ExampleCanvas_Base, + public SpriteSurface, + public RepaintTarget + { + }; + </pre> + + @tpl Base + Base class to use, most probably one of the + WeakComponentImplHelperN templates with the appropriate + interfaces. At least XCanvas should be among them (why else + would you use this template, then?). Base class must have an + Base( const Mutex& ) constructor (like the + WeakComponentImplHelperN templates have). As the very least, + the base class must be derived from uno::XInterface, as some + error reporting mechanisms rely on that. + + @tpl CanvasHelper + Canvas helper implementation for the backend in question. This + object will be held as a member of this template class, and + basically gets forwarded all XCanvas API calls. Furthermore, + everytime the canvas API semantically changes the content of + the canvas, CanvasHelper::modifying() will get called + (<em>before</em> the actual modification takes place). + + @tpl Mutex + Lock strategy to use. Defaults to using the + OBaseMutex-provided lock. Everytime one of the methods is + entered, an object of type Mutex is created with m_aMutex as + the sole parameter, and destroyed again when the method scope + is left. + + @tpl UnambiguousBase + Optional unambiguous base class for XInterface of Base. It's + sometimes necessary to specify this parameter, e.g. if Base + derives from multiple UNO interface (were each provides its + own version of XInterface, making the conversion ambiguous) + */ + template< class Base, + class CanvasHelper, + class Mutex=::osl::MutexGuard, + class UnambiguousBase=::com::sun::star::uno::XInterface > class CanvasBase : + public Base + { + public: + typedef Base BaseType; + typedef CanvasHelper HelperType; + typedef Mutex MutexType; + typedef UnambiguousBase UnambiguousBaseType; + + /** Create CanvasBase + */ + CanvasBase() : + maCanvasHelper(), + mbSurfaceDirty( true ) + { + } + +#if defined __SUNPRO_CC + using Base::disposing; +#endif + virtual void SAL_CALL disposing() + { + MutexType aGuard( BaseType::m_aMutex ); + + maCanvasHelper.disposing(); + + // pass on to base class + BaseType::disposing(); + } + + // XCanvas + virtual void SAL_CALL clear() throw (::com::sun::star::uno::RuntimeException) + { + MutexType aGuard( BaseType::m_aMutex ); + + mbSurfaceDirty = true; + maCanvasHelper.modifying(); + + maCanvasHelper.clear(); + } + + virtual void SAL_CALL drawPoint( const ::com::sun::star::geometry::RealPoint2D& aPoint, + const ::com::sun::star::rendering::ViewState& viewState, + const ::com::sun::star::rendering::RenderState& renderState ) throw (::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::uno::RuntimeException) + { + tools::verifyArgs(aPoint, viewState, renderState, + BOOST_CURRENT_FUNCTION, + static_cast< UnambiguousBaseType* >(this)); + + MutexType aGuard( BaseType::m_aMutex ); + + mbSurfaceDirty = true; + maCanvasHelper.modifying(); + + maCanvasHelper.drawPoint( this, aPoint, viewState, renderState ); + } + + virtual void SAL_CALL drawLine( const ::com::sun::star::geometry::RealPoint2D& aStartPoint, + const ::com::sun::star::geometry::RealPoint2D& aEndPoint, + const ::com::sun::star::rendering::ViewState& viewState, + const ::com::sun::star::rendering::RenderState& renderState ) throw (::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::uno::RuntimeException) + { + tools::verifyArgs(aStartPoint, aEndPoint, viewState, renderState, + BOOST_CURRENT_FUNCTION, + static_cast< UnambiguousBaseType* >(this)); + + MutexType aGuard( BaseType::m_aMutex ); + + mbSurfaceDirty = true; + maCanvasHelper.modifying(); + + maCanvasHelper.drawLine( this, aStartPoint, aEndPoint, viewState, renderState ); + } + + virtual void SAL_CALL drawBezier( const ::com::sun::star::geometry::RealBezierSegment2D& aBezierSegment, + const ::com::sun::star::geometry::RealPoint2D& aEndPoint, + const ::com::sun::star::rendering::ViewState& viewState, + const ::com::sun::star::rendering::RenderState& renderState ) throw (::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::uno::RuntimeException) + { + tools::verifyArgs(aBezierSegment, aEndPoint, viewState, renderState, + BOOST_CURRENT_FUNCTION, + static_cast< UnambiguousBaseType* >(this)); + + MutexType aGuard( BaseType::m_aMutex ); + + mbSurfaceDirty = true; + maCanvasHelper.modifying(); + + maCanvasHelper.drawBezier( this, aBezierSegment, aEndPoint, viewState, renderState ); + } + + virtual ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XCachedPrimitive > SAL_CALL + drawPolyPolygon( const ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XPolyPolygon2D >& xPolyPolygon, + const ::com::sun::star::rendering::ViewState& viewState, + const ::com::sun::star::rendering::RenderState& renderState ) throw (::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::uno::RuntimeException) + { + tools::verifyArgs(xPolyPolygon, viewState, renderState, + BOOST_CURRENT_FUNCTION, + static_cast< UnambiguousBaseType* >(this)); + + MutexType aGuard( BaseType::m_aMutex ); + + mbSurfaceDirty = true; + maCanvasHelper.modifying(); + + return maCanvasHelper.drawPolyPolygon( this, xPolyPolygon, viewState, renderState ); + } + + virtual ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XCachedPrimitive > SAL_CALL + strokePolyPolygon( const ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XPolyPolygon2D >& xPolyPolygon, + const ::com::sun::star::rendering::ViewState& viewState, + const ::com::sun::star::rendering::RenderState& renderState, + const ::com::sun::star::rendering::StrokeAttributes& strokeAttributes ) throw (::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::uno::RuntimeException) + { + tools::verifyArgs(xPolyPolygon, viewState, renderState, strokeAttributes, + BOOST_CURRENT_FUNCTION, + static_cast< UnambiguousBaseType* >(this)); + + MutexType aGuard( BaseType::m_aMutex ); + + mbSurfaceDirty = true; + maCanvasHelper.modifying(); + + return maCanvasHelper.strokePolyPolygon( this, xPolyPolygon, viewState, renderState, strokeAttributes ); + } + + virtual ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XCachedPrimitive > SAL_CALL + strokeTexturedPolyPolygon( const ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XPolyPolygon2D >& xPolyPolygon, + const ::com::sun::star::rendering::ViewState& viewState, + const ::com::sun::star::rendering::RenderState& renderState, + const ::com::sun::star::uno::Sequence< ::com::sun::star::rendering::Texture >& textures, + const ::com::sun::star::rendering::StrokeAttributes& strokeAttributes ) throw (::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::uno::RuntimeException) + { + tools::verifyArgs(xPolyPolygon, viewState, renderState, strokeAttributes, + BOOST_CURRENT_FUNCTION, + static_cast< UnambiguousBaseType* >(this)); + + MutexType aGuard( BaseType::m_aMutex ); + + mbSurfaceDirty = true; + maCanvasHelper.modifying(); + + return maCanvasHelper.strokeTexturedPolyPolygon( this, xPolyPolygon, viewState, renderState, textures, strokeAttributes ); + } + + virtual ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XCachedPrimitive > SAL_CALL + strokeTextureMappedPolyPolygon( const ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XPolyPolygon2D >& xPolyPolygon, + const ::com::sun::star::rendering::ViewState& viewState, + const ::com::sun::star::rendering::RenderState& renderState, + const ::com::sun::star::uno::Sequence< ::com::sun::star::rendering::Texture >& textures, + const ::com::sun::star::uno::Reference< ::com::sun::star::geometry::XMapping2D >& xMapping, + const ::com::sun::star::rendering::StrokeAttributes& strokeAttributes ) throw (::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::uno::RuntimeException) + { + tools::verifyArgs(xPolyPolygon, viewState, renderState, textures, xMapping, strokeAttributes, + BOOST_CURRENT_FUNCTION, + static_cast< UnambiguousBaseType* >(this)); + + MutexType aGuard( BaseType::m_aMutex ); + + mbSurfaceDirty = true; + maCanvasHelper.modifying(); + + return maCanvasHelper.strokeTextureMappedPolyPolygon( this, xPolyPolygon, viewState, renderState, textures, xMapping, strokeAttributes ); + } + + virtual ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XPolyPolygon2D > SAL_CALL + queryStrokeShapes( const ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XPolyPolygon2D >& xPolyPolygon, + const ::com::sun::star::rendering::ViewState& viewState, + const ::com::sun::star::rendering::RenderState& renderState, + const ::com::sun::star::rendering::StrokeAttributes& strokeAttributes ) throw (::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::uno::RuntimeException) + { + tools::verifyArgs(xPolyPolygon, viewState, renderState, strokeAttributes, + BOOST_CURRENT_FUNCTION, + static_cast< UnambiguousBaseType* >(this)); + + MutexType aGuard( BaseType::m_aMutex ); + + mbSurfaceDirty = true; + maCanvasHelper.modifying(); + + return maCanvasHelper.queryStrokeShapes( this, xPolyPolygon, viewState, renderState, strokeAttributes ); + } + + virtual ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XCachedPrimitive > SAL_CALL + fillPolyPolygon( const ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XPolyPolygon2D >& xPolyPolygon, + const ::com::sun::star::rendering::ViewState& viewState, + const ::com::sun::star::rendering::RenderState& renderState ) throw (::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::uno::RuntimeException) + { + tools::verifyArgs(xPolyPolygon, viewState, renderState, + BOOST_CURRENT_FUNCTION, + static_cast< UnambiguousBaseType* >(this)); + + MutexType aGuard( BaseType::m_aMutex ); + + mbSurfaceDirty = true; + maCanvasHelper.modifying(); + + return maCanvasHelper.fillPolyPolygon( this, xPolyPolygon, viewState, renderState ); + } + + virtual ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XCachedPrimitive > SAL_CALL + fillTexturedPolyPolygon( const ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XPolyPolygon2D >& xPolyPolygon, + const ::com::sun::star::rendering::ViewState& viewState, + const ::com::sun::star::rendering::RenderState& renderState, + const ::com::sun::star::uno::Sequence< ::com::sun::star::rendering::Texture >& textures ) throw (::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::uno::RuntimeException) + { + tools::verifyArgs(xPolyPolygon, viewState, renderState, textures, + BOOST_CURRENT_FUNCTION, + static_cast< UnambiguousBaseType* >(this)); + + MutexType aGuard( BaseType::m_aMutex ); + + mbSurfaceDirty = true; + maCanvasHelper.modifying(); + + return maCanvasHelper.fillTexturedPolyPolygon( this, xPolyPolygon, viewState, renderState, textures ); + } + + virtual ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XCachedPrimitive > SAL_CALL + fillTextureMappedPolyPolygon( const ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XPolyPolygon2D >& xPolyPolygon, + const ::com::sun::star::rendering::ViewState& viewState, + const ::com::sun::star::rendering::RenderState& renderState, + const ::com::sun::star::uno::Sequence< ::com::sun::star::rendering::Texture >& textures, + const ::com::sun::star::uno::Reference< ::com::sun::star::geometry::XMapping2D >& xMapping ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException) + { + tools::verifyArgs(xPolyPolygon, viewState, renderState, textures, xMapping, + BOOST_CURRENT_FUNCTION, + static_cast< UnambiguousBaseType* >(this)); + + MutexType aGuard( BaseType::m_aMutex ); + + mbSurfaceDirty = true; + maCanvasHelper.modifying(); + + return maCanvasHelper.fillTextureMappedPolyPolygon( this, xPolyPolygon, viewState, renderState, textures, xMapping ); + } + + + virtual ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XCanvasFont > SAL_CALL + createFont( const ::com::sun::star::rendering::FontRequest& fontRequest, + const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& extraFontProperties, + const ::com::sun::star::geometry::Matrix2D& fontMatrix ) throw (::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::uno::RuntimeException) + { + tools::verifyArgs(fontRequest, + // dummy, to keep argPos in sync + fontRequest, + fontMatrix, + BOOST_CURRENT_FUNCTION, + static_cast< UnambiguousBaseType* >(this)); + + MutexType aGuard( BaseType::m_aMutex ); + + return maCanvasHelper.createFont( this, fontRequest, extraFontProperties, fontMatrix ); + } + + + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::rendering::FontInfo > SAL_CALL + queryAvailableFonts( const ::com::sun::star::rendering::FontInfo& aFilter, + const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& aFontProperties ) throw (::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::uno::RuntimeException) + { + tools::verifyArgs(aFilter, + BOOST_CURRENT_FUNCTION, + static_cast< UnambiguousBaseType* >(this)); + + MutexType aGuard( BaseType::m_aMutex ); + + return maCanvasHelper.queryAvailableFonts( this, aFilter, aFontProperties ); + } + + + virtual ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XCachedPrimitive > SAL_CALL + drawText( const ::com::sun::star::rendering::StringContext& text, + const ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XCanvasFont >& xFont, + const ::com::sun::star::rendering::ViewState& viewState, + const ::com::sun::star::rendering::RenderState& renderState, + sal_Int8 textDirection ) throw (::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::uno::RuntimeException) + { + tools::verifyArgs(xFont, viewState, renderState, + BOOST_CURRENT_FUNCTION, + static_cast< UnambiguousBaseType* >(this)); + tools::verifyRange( textDirection, + ::com::sun::star::rendering::TextDirection::WEAK_LEFT_TO_RIGHT, + ::com::sun::star::rendering::TextDirection::STRONG_RIGHT_TO_LEFT ); + + MutexType aGuard( BaseType::m_aMutex ); + + mbSurfaceDirty = true; + maCanvasHelper.modifying(); + + return maCanvasHelper.drawText( this, text, xFont, viewState, renderState, textDirection ); + } + + + virtual ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XCachedPrimitive > SAL_CALL + drawTextLayout( const ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XTextLayout >& layoutetText, + const ::com::sun::star::rendering::ViewState& viewState, + const ::com::sun::star::rendering::RenderState& renderState ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException) + { + tools::verifyArgs(layoutetText, viewState, renderState, + BOOST_CURRENT_FUNCTION, + static_cast< UnambiguousBaseType* >(this)); + + MutexType aGuard( BaseType::m_aMutex ); + + mbSurfaceDirty = true; + maCanvasHelper.modifying(); + + return maCanvasHelper.drawTextLayout( this, layoutetText, viewState, renderState ); + } + + + virtual ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XCachedPrimitive > SAL_CALL + drawBitmap( const ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XBitmap >& xBitmap, + const ::com::sun::star::rendering::ViewState& viewState, + const ::com::sun::star::rendering::RenderState& renderState ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException) + { + tools::verifyArgs(xBitmap, viewState, renderState, + BOOST_CURRENT_FUNCTION, + static_cast< UnambiguousBaseType* >(this)); + + MutexType aGuard( BaseType::m_aMutex ); + + mbSurfaceDirty = true; + maCanvasHelper.modifying(); + + return maCanvasHelper.drawBitmap( this, xBitmap, viewState, renderState ); + } + + virtual ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XCachedPrimitive > SAL_CALL + drawBitmapModulated( const ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XBitmap >& xBitmap, + const ::com::sun::star::rendering::ViewState& viewState, + const ::com::sun::star::rendering::RenderState& renderState ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException) + { + tools::verifyArgs(xBitmap, viewState, renderState, + BOOST_CURRENT_FUNCTION, + static_cast< UnambiguousBaseType* >(this)); + + MutexType aGuard( BaseType::m_aMutex ); + + mbSurfaceDirty = true; + maCanvasHelper.modifying(); + + return maCanvasHelper.drawBitmapModulated( this, xBitmap, viewState, renderState ); + } + + virtual ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XGraphicDevice > SAL_CALL + getDevice() throw (::com::sun::star::uno::RuntimeException) + { + MutexType aGuard( BaseType::m_aMutex ); + + return maCanvasHelper.getDevice(); + } + + protected: + ~CanvasBase() {} // we're a ref-counted UNO class. _We_ destroy ourselves. + + HelperType maCanvasHelper; + mutable bool mbSurfaceDirty; + + private: + CanvasBase( const CanvasBase& ); + CanvasBase& operator=( const CanvasBase& ); + }; +} + +#endif /* INCLUDED_CANVAS_CANVASBASE_HXX */ + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/canvas/inc/canvas/base/canvascustomspritebase.hxx b/canvas/inc/canvas/base/canvascustomspritebase.hxx new file mode 100644 index 000000000000..ec4477ab9cc9 --- /dev/null +++ b/canvas/inc/canvas/base/canvascustomspritebase.hxx @@ -0,0 +1,280 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef INCLUDED_CANVAS_CANVASCUSTOMSPRITEBASE_HXX +#define INCLUDED_CANVAS_CANVASCUSTOMSPRITEBASE_HXX + +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/rendering/XCustomSprite.hpp> +#include <com/sun/star/rendering/XPolyPolygon2D.hpp> +#include <basegfx/point/b2dpoint.hxx> +#include <basegfx/vector/b2dvector.hxx> +#include <basegfx/range/b2drange.hxx> +#include <canvas/base/integerbitmapbase.hxx> +#include <canvas/base/sprite.hxx> + +#include <boost/utility.hpp> + + +namespace canvas +{ + /** Helper template to handle XCustomSprite method forwarding to + CanvasCustomSpriteHelper + + Use this helper to handle the XCustomSprite part of your + implementation. + + @tpl Base + Base class to use, most probably one of the + WeakComponentImplHelperN templates with the appropriate + interfaces. At least XCustomSprite and Sprite should be among + them (why else would you use this template, then?). Base class + must have an Base( const Mutex& ) constructor (like the + WeakComponentImplHelperN templates have). + + @tpl SpriteHelper + Sprite helper implementation for the backend in question + + @tpl CanvasHelper + Canvas helper implementation for the backend in question + + @tpl Mutex + Lock strategy to use. Defaults to using the + OBaseMutex-provided lock. Everytime one of the methods is + entered, an object of type Mutex is created with m_aMutex as + the sole parameter, and destroyed again when the method scope + is left. + + @tpl UnambiguousBase + Optional unambiguous base class for XInterface of Base. It's + sometimes necessary to specify this parameter, e.g. if Base + derives from multiple UNO interface (were each provides its + own version of XInterface, making the conversion ambiguous) + + @see CanvasCustomSpriteHelper for further contractual + requirements towards the SpriteHelper type, and some examples. + */ + template< class Base, + class SpriteHelper, + class CanvasHelper, + class Mutex=::osl::MutexGuard, + class UnambiguousBase=::com::sun::star::uno::XInterface > class CanvasCustomSpriteBase : + public IntegerBitmapBase< Base, CanvasHelper, Mutex, UnambiguousBase > + { + public: + typedef IntegerBitmapBase< Base, CanvasHelper, Mutex, UnambiguousBase > BaseType; + typedef SpriteHelper SpriteHelperType; + + CanvasCustomSpriteBase() : + maSpriteHelper() + { + } + + /** Object is being disposed. + + Called from the cppu helper base, to notify disposal of + this object. Already releases all internal references. + + @derive when overriding this method in derived classes, + <em>always</em> call the base class' method! + */ + virtual void SAL_CALL disposing() + { + typename BaseType::MutexType aGuard( BaseType::m_aMutex ); + + maSpriteHelper.disposing(); + + // pass on to base class + BaseType::disposing(); + } + + // XCanvas: selectively override base's methods here, for opacity tracking + virtual void SAL_CALL clear() throw (::com::sun::star::uno::RuntimeException) + { + typename BaseType::MutexType aGuard( BaseType::m_aMutex ); + + maSpriteHelper.clearingContent( this ); + + // and forward to base class, which handles the actual rendering + return BaseType::clear(); + } + + virtual ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XCachedPrimitive > SAL_CALL + drawBitmap( const ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XBitmap >& xBitmap, + const ::com::sun::star::rendering::ViewState& viewState, + const ::com::sun::star::rendering::RenderState& renderState ) throw (::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::uno::RuntimeException) + { + tools::verifyArgs(xBitmap, viewState, renderState, + BOOST_CURRENT_FUNCTION, + static_cast< typename BaseType::UnambiguousBaseType* >(this)); + + typename BaseType::MutexType aGuard( BaseType::m_aMutex ); + + maSpriteHelper.checkDrawBitmap( this, xBitmap, viewState, renderState ); + + // and forward to base class, which handles the actual rendering + return BaseType::drawBitmap( xBitmap, + viewState, + renderState ); + } + + // TODO(F3): If somebody uses the XIntegerBitmap methods to + // clear pixel (setting alpha != 1.0 there), or a compositing + // mode results in similar alpha, maSpriteHelper might + // errorneously report fully opaque sprites. Effectively, all + // render methods must be overridden here; or better, + // functionality provided at the baseclass. + + // XSprite + virtual void SAL_CALL setAlpha( double alpha ) throw (::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::uno::RuntimeException) + { + tools::verifyRange( alpha, 0.0, 1.0 ); + + typename BaseType::MutexType aGuard( BaseType::m_aMutex ); + + maSpriteHelper.setAlpha( this, alpha ); + } + + virtual void SAL_CALL move( const ::com::sun::star::geometry::RealPoint2D& aNewPos, + const ::com::sun::star::rendering::ViewState& viewState, + const ::com::sun::star::rendering::RenderState& renderState ) throw (::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::uno::RuntimeException) + { + tools::verifyArgs(aNewPos, viewState, renderState, + BOOST_CURRENT_FUNCTION, + static_cast< typename BaseType::UnambiguousBaseType* >(this)); + + typename BaseType::MutexType aGuard( BaseType::m_aMutex ); + + maSpriteHelper.move( this, aNewPos, viewState, renderState ); + } + + virtual void SAL_CALL transform( const ::com::sun::star::geometry::AffineMatrix2D& aTransformation ) throw (::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::uno::RuntimeException) + { + tools::verifyArgs(aTransformation, + BOOST_CURRENT_FUNCTION, + static_cast< typename BaseType::UnambiguousBaseType* >(this)); + + typename BaseType::MutexType aGuard( BaseType::m_aMutex ); + + maSpriteHelper.transform( this, aTransformation ); + } + + virtual void SAL_CALL clip( const ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XPolyPolygon2D >& aClip ) throw (::com::sun::star::uno::RuntimeException) + { + // NULL xClip explicitely allowed here (to clear clipping) + + typename BaseType::MutexType aGuard( BaseType::m_aMutex ); + + maSpriteHelper.clip( this, aClip ); + } + + virtual void SAL_CALL setPriority( double nPriority ) throw (::com::sun::star::uno::RuntimeException) + { + typename BaseType::MutexType aGuard( BaseType::m_aMutex ); + + maSpriteHelper.setPriority( this, nPriority ); + } + + virtual void SAL_CALL show() throw (::com::sun::star::uno::RuntimeException) + { + typename BaseType::MutexType aGuard( BaseType::m_aMutex ); + + maSpriteHelper.show( this ); + } + + virtual void SAL_CALL hide() throw (::com::sun::star::uno::RuntimeException) + { + typename BaseType::MutexType aGuard( BaseType::m_aMutex ); + + maSpriteHelper.hide( this ); + } + + // XCustomSprite + virtual ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XCanvas > SAL_CALL + getContentCanvas() throw (::com::sun::star::uno::RuntimeException) + { + typename BaseType::MutexType aGuard( BaseType::m_aMutex ); + + return this; + } + + // Sprite + virtual bool isAreaUpdateOpaque( const ::basegfx::B2DRange& rUpdateArea ) const + { + typename BaseType::MutexType aGuard( BaseType::m_aMutex ); + + return maSpriteHelper.isAreaUpdateOpaque( rUpdateArea ); + } + + virtual bool isContentChanged() const + { + typename BaseType::MutexType aGuard( BaseType::m_aMutex ); + + return BaseType::mbSurfaceDirty; + } + + virtual ::basegfx::B2DPoint getPosPixel() const + { + typename BaseType::MutexType aGuard( BaseType::m_aMutex ); + + return maSpriteHelper.getPosPixel(); + } + + virtual ::basegfx::B2DVector getSizePixel() const + { + typename BaseType::MutexType aGuard( BaseType::m_aMutex ); + + return maSpriteHelper.getSizePixel(); + } + + virtual ::basegfx::B2DRange getUpdateArea() const + { + typename BaseType::MutexType aGuard( BaseType::m_aMutex ); + + return maSpriteHelper.getUpdateArea(); + } + + virtual double getPriority() const + { + typename BaseType::MutexType aGuard( BaseType::m_aMutex ); + + return maSpriteHelper.getPriority(); + } + + protected: + SpriteHelperType maSpriteHelper; + }; +} + +#endif /* INCLUDED_CANVAS_CANVASCUSTOMSPRITEBASE_HXX */ + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/canvas/inc/canvas/base/canvascustomspritehelper.hxx b/canvas/inc/canvas/base/canvascustomspritehelper.hxx new file mode 100644 index 000000000000..222be8503ac6 --- /dev/null +++ b/canvas/inc/canvas/base/canvascustomspritehelper.hxx @@ -0,0 +1,296 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef INCLUDED_CANVAS_CANVASCUSTOMSPRITEHELPER_HXX +#define INCLUDED_CANVAS_CANVASCUSTOMSPRITEHELPER_HXX + +#include <com/sun/star/rendering/XCustomSprite.hpp> +#include <com/sun/star/rendering/XPolyPolygon2D.hpp> +#include <basegfx/point/b2dpoint.hxx> +#include <basegfx/vector/b2dvector.hxx> +#include <basegfx/range/b2drange.hxx> +#include <basegfx/matrix/b2dhommatrix.hxx> +#include <canvas/base/spritesurface.hxx> + + +namespace canvas +{ + /* Definition of CanvasCustomSpriteHelper class */ + + /** Base class for an XSprite helper implementation - to be used + in concert with CanvasCustomSpriteBase + */ + class CanvasCustomSpriteHelper + { + public: + CanvasCustomSpriteHelper(); + virtual ~CanvasCustomSpriteHelper() {} + + /** Init helper + + @param rSpriteSize + Requested size of the sprite, as passed to the + XSpriteCanvas::createCustomSprite() method + + @param rOwningSpriteCanvas + The XSpriteCanvas this sprite is displayed on + */ + void init( const ::com::sun::star::geometry::RealSize2D& rSpriteSize, + const SpriteSurface::Reference& rOwningSpriteCanvas ); + + /** Object is being disposed, release all internal references + + @derive when overriding this method in derived classes, + <em>always</em> call the base class' method! + */ + void disposing(); + + // XCanvas + /// need to call this method for XCanvas::clear(), for opacity tracking + void clearingContent( const Sprite::Reference& rSprite ); + + /// need to call this method for XCanvas::drawBitmap(), for opacity tracking + void checkDrawBitmap( const Sprite::Reference& rSprite, + const ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XBitmap >& xBitmap, + const ::com::sun::star::rendering::ViewState& viewState, + const ::com::sun::star::rendering::RenderState& renderState ); + + // XSprite + void setAlpha( const Sprite::Reference& rSprite, + double alpha ); + void move( const Sprite::Reference& rSprite, + const ::com::sun::star::geometry::RealPoint2D& aNewPos, + const ::com::sun::star::rendering::ViewState& viewState, + const ::com::sun::star::rendering::RenderState& renderState ); + void transform( const Sprite::Reference& rSprite, + const ::com::sun::star::geometry::AffineMatrix2D& aTransformation ); + void clip( const Sprite::Reference& rSprite, + const ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XPolyPolygon2D >& aClip ); + void setPriority( const Sprite::Reference& rSprite, + double nPriority ); + void show( const Sprite::Reference& rSprite ); + void hide( const Sprite::Reference& rSprite ); + + // Sprite + bool isAreaUpdateOpaque( const ::basegfx::B2DRange& rUpdateArea ) const; + ::basegfx::B2DPoint getPosPixel() const; + ::basegfx::B2DVector getSizePixel() const; + ::basegfx::B2DRange getUpdateArea() const; + double getPriority() const; + + // redraw must be implemented by derived - non sensible default implementation + // void redraw( const Sprite::Reference& rSprite, + // const ::basegfx::B2DPoint& rPos ) const; + + + // Helper methods for derived classes + // ---------------------------------- + + /// Calc sprite update area from given raw sprite bounds + ::basegfx::B2DRange getUpdateArea( const ::basegfx::B2DRange& rUntransformedSpriteBounds ) const; + + /// Calc update area for unclipped sprite content + ::basegfx::B2DRange getFullSpriteRect() const; + + /** Returns true, if sprite content bitmap is fully opaque. + + This does not take clipping or transformation into + account, but only denotes that the sprite bitmap's alpha + channel is all 1.0 + */ + bool isContentFullyOpaque() const { return mbIsContentFullyOpaque; } + + /// Returns true, if transformation has changed since last transformUpdated() call + bool hasAlphaChanged() const { return mbAlphaDirty; } + + /// Returns true, if transformation has changed since last transformUpdated() call + bool hasPositionChanged() const { return mbPositionDirty; } + + /// Returns true, if transformation has changed since last transformUpdated() call + bool hasTransformChanged() const { return mbTransformDirty; } + + /// Returns true, if transformation has changed since last transformUpdated() call + bool hasClipChanged() const { return mbClipDirty; } + + /// Returns true, if transformation has changed since last transformUpdated() call + bool hasPrioChanged() const { return mbPrioDirty; } + + /// Returns true, if transformation has changed since last transformUpdated() call + bool hasVisibilityChanged() const { return mbVisibilityDirty; } + + /// Retrieve current alpha value + double getAlpha() const { return mfAlpha; } + + /// Retrieve current clip + const ::com::sun::star::uno::Reference< + ::com::sun::star::rendering::XPolyPolygon2D >& getClip() const { return mxClipPoly; } + + const ::basegfx::B2DHomMatrix& getTransformation() const { return maTransform; } + + /// Retrieve current activation state + bool isActive() const { return mbActive; } + + protected: + /** Notifies that caller is again in sync with current alph + + const, but modifies state visible to derived + classes. beware of passing this information to the + outside! + */ + void alphaUpdated() const { mbAlphaDirty=false; } + + /** Notifies that caller is again in sync with current position + + const, but modifies state visible to derived + classes. beware of passing this information to the + outside! + */ + void positionUpdated() const { mbPositionDirty=false; } + + /** Notifies that caller is again in sync with current transformation + + const, but modifies state visible to derived + classes. beware of passing this information to the + outside! + */ + void transformUpdated() const { mbTransformDirty=false; } + + /** Notifies that caller is again in sync with current clip + + const, but modifies state visible to derived + classes. beware of passing this information to the + outside! + */ + void clipUpdated() const { mbClipDirty=false; } + + /** Notifies that caller is again in sync with current priority + + const, but modifies state visible to derived + classes. beware of passing this information to the + outside! + */ + void prioUpdated() const { mbPrioDirty=false; } + + /** Notifies that caller is again in sync with current visibility + + const, but modifies state visible to derived + classes. beware of passing this information to the + outside! + */ + void visibilityUpdated() const { mbVisibilityDirty=false; } + + private: + CanvasCustomSpriteHelper( const CanvasCustomSpriteHelper& ); + CanvasCustomSpriteHelper& operator=( const CanvasCustomSpriteHelper& ); + + /** Called to convert an API polygon to a basegfx polygon + + @derive Needs to be provided by backend-specific code + */ + virtual ::basegfx::B2DPolyPolygon polyPolygonFromXPolyPolygon2D( + ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XPolyPolygon2D >& xPoly ) const = 0; + + /** Update clip information from current state + + This method recomputes the maCurrClipBounds and + mbIsCurrClipRectangle members from the current clip and + transformation. IFF the clip changed from rectangular to + rectangular again, this method issues a sequence of + optimized SpriteSurface::updateSprite() calls. + + @return true, if SpriteSurface::updateSprite() was already + called within this method. + */ + bool updateClipState( const Sprite::Reference& rSprite ); + + // -------------------------------------------------------------------- + + /// Owning sprite canvas + SpriteSurface::Reference mpSpriteCanvas; + + /** Currently active clip area. + + This member is either empty, denoting that the current + clip shows the full sprite content, or contains a + rectangular subarea of the sprite, outside of which + the sprite content is fully clipped. + + @see mbIsCurrClipRectangle + */ + ::basegfx::B2DRange maCurrClipBounds; + + // sprite state + ::basegfx::B2DPoint maPosition; + ::basegfx::B2DVector maSize; + ::basegfx::B2DHomMatrix maTransform; + ::com::sun::star::uno::Reference< + ::com::sun::star::rendering::XPolyPolygon2D > mxClipPoly; + double mfPriority; + double mfAlpha; + bool mbActive; // true, if not hidden + + /** If true, denotes that the current sprite clip is a true + rectangle, i.e. maCurrClipBounds <em>exactly</em> + describes the visible area of the sprite. + + @see maCurrClipBounds + */ + bool mbIsCurrClipRectangle; + + /** Redraw speedup. + + When true, this flag denotes that the current sprite + content is fully opaque, thus, that blits to the screen do + neither have to take alpha into account, nor prepare any + background for the sprite area. + */ + mutable bool mbIsContentFullyOpaque; + + /// True, iff mfAlpha has changed + mutable bool mbAlphaDirty; + + /// True, iff maPosition has changed + mutable bool mbPositionDirty; + + /// True, iff maTransform has changed + mutable bool mbTransformDirty; + + /// True, iff mxClipPoly has changed + mutable bool mbClipDirty; + + /// True, iff mnPriority has changed + mutable bool mbPrioDirty; + + /// True, iff mbActive has changed + mutable bool mbVisibilityDirty; + }; +} + +#endif /* INCLUDED_CANVAS_CANVASCUSTOMSPRITEHELPER_HXX */ + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/canvas/inc/canvas/base/doublebitmapbase.hxx b/canvas/inc/canvas/base/doublebitmapbase.hxx new file mode 100644 index 000000000000..7059a6e63623 --- /dev/null +++ b/canvas/inc/canvas/base/doublebitmapbase.hxx @@ -0,0 +1,154 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef INCLUDED_CANVAS_DOUBLEBITMAPBASE_HXX +#define INCLUDED_CANVAS_DOUBLEBITMAPBASE_HXX + +#include <com/sun/star/rendering/XIeeeDoubleBitmap.hpp> +#include <canvas/bitmapcanvasbase.hxx> + + +namespace canvas +{ + /** Helper template to handle XIeeeDoubleBitmap method forwarding to + BitmapCanvasHelper + + Use this helper to handle the XIeeeDoubleBitmap part of your + implementation. + + @tpl Base + Base class to use, most probably one of the + WeakComponentImplHelperN templates with the appropriate + interfaces. At least XIeeeDoubleBitmap should be among them (why + else would you use this template, then?). Base class must have + an Base( const Mutex& ) constructor (like the + WeakComponentImplHelperN templates have). + + @tpl CanvasHelper + Canvas helper implementation for the backend in question + + @tpl Mutex + Lock strategy to use. Defaults to using the + OBaseMutex-provided lock. Everytime one of the methods is + entered, an object of type Mutex is created with m_aMutex as + the sole parameter, and destroyed again when the method scope + is left. + + @tpl UnambiguousBase + Optional unambiguous base class for XInterface of Base. It's + sometimes necessary to specify this parameter, e.g. if Base + derives from multiple UNO interface (were each provides its + own version of XInterface, making the conversion ambiguous) + + @see CanvasBase for further contractual requirements towards + the CanvasHelper type, and some examples. + */ + template< class Base, + class CanvasHelper, + class Mutex=::osl::MutexGuard, + class UnambiguousBase=::com::sun::star::uno::XInterface > class DoubleBitmapBase : + public BitmapCanvasBase< Base, CanvasHelper, Mutex, UnambiguousBase > + { + public: + typedef BitmapCanvasBase< Base, CanvasHelper, Mutex, UnambiguousBase > BaseType; + + // XIeeeDoubleBitmap + virtual ::com::sun::star::uno::Sequence< double > SAL_CALL getData( ::com::sun::star::rendering::FloatingPointBitmapLayout& bitmapLayout, + const ::com::sun::star::geometry::IntegerRectangle2D& rect ) throw (::com::sun::star::lang::IndexOutOfBoundsException, + ::com::sun::star::rendering::VolatileContentDestroyedException, + ::com::sun::star::uno::RuntimeException) + { + verifyInput(rect, this); + verifyIndexRange(rect, getSize() ); + + typename BaseType::MutexType aGuard( BaseType::m_aMutex ); + + return BaseType::maCanvasHelper.getData( bitmapLayout, + rect ); + } + + virtual void SAL_CALL setData( const ::com::sun::star::uno::Sequence< double >& data, + const ::com::sun::star::rendering::FloatingPointBitmapLayout& bitmapLayout, + const ::com::sun::star::geometry::IntegerRectangle2D& rect ) throw (::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::lang::IndexOutOfBoundsException, + ::com::sun::star::uno::RuntimeException) + { + verifyInput(bitmapLayout, rect, this); + verifyIndexRange(rect, getSize() ); + + typename BaseType::MutexType aGuard( BaseType::m_aMutex ); + + BaseType::mbSurfaceDirty = true; + BaseType::maCanvasHelper.modifying(); + + BaseType::maCanvasHelper.setData( data, bitmapLayout, rect ); + } + + virtual void SAL_CALL setPixel( const ::com::sun::star::uno::Sequence< double >& color, + const ::com::sun::star::rendering::FloatingPointBitmapLayout& bitmapLayout, + const ::com::sun::star::geometry::IntegerPoint2D& pos ) throw (::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::lang::IndexOutOfBoundsException, + ::com::sun::star::uno::RuntimeException) + { + verifyInput(bitmapLayout, pos, this); + verifyIndexRange(pos, getSize() ); + + typename BaseType::MutexType aGuard( BaseType::m_aMutex ); + + BaseType::mbSurfaceDirty = true; + BaseType::maCanvasHelper.modifying(); + + BaseType::maCanvasHelper.setPixel( color, bitmapLayout, pos ); + } + + virtual ::com::sun::star::uno::Sequence< double > SAL_CALL getPixel( ::com::sun::star::rendering::FloatingPointBitmapLayout& bitmapLayout, + const ::com::sun::star::geometry::IntegerPoint2D& pos ) throw (::com::sun::star::lang::IndexOutOfBoundsException, + ::com::sun::star::rendering::VolatileContentDestroyedException, + ::com::sun::star::uno::RuntimeException) + { + verifyInput(pos, this); + verifyIndexRange(pos, getSize() ); + + typename BaseType::MutexType aGuard( BaseType::m_aMutex ); + + return BaseType::maCanvasHelper.getPixel( bitmapLayout, + pos ); + } + + virtual ::com::sun::star::rendering::FloatingPointBitmapLayout SAL_CALL getMemoryLayout( ) throw (::com::sun::star::uno::RuntimeException) + { + typename BaseType::MutexType aGuard( BaseType::m_aMutex ); + + return BaseType::maCanvasHelper.getMemoryLayout(); + } + }; +} + +#endif /* INCLUDED_CANVAS_DOUBLEBITMAPBASE_HXX */ + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/canvas/inc/canvas/base/floatbitmapbase.hxx b/canvas/inc/canvas/base/floatbitmapbase.hxx new file mode 100644 index 000000000000..cafcdf5dc8b6 --- /dev/null +++ b/canvas/inc/canvas/base/floatbitmapbase.hxx @@ -0,0 +1,158 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef INCLUDED_CANVAS_FLOATBITMAPBASE_HXX +#define INCLUDED_CANVAS_FLOATBITMAPBASE_HXX + +#include <com/sun/star/rendering/XIeeeFloatBitmap.hpp> +#include <canvas/bitmapcanvasbase.hxx> + + +namespace canvas +{ + /** Helper template to handle XIeeeFloatBitmap method forwarding to + BitmapCanvasHelper + + Use this helper to handle the XIeeeFloatBitmap part of your + implementation. + + @tpl Base + Base class to use, most probably one of the + WeakComponentImplHelperN templates with the appropriate + interfaces. At least XIeeeFloatBitmap should be among them (why + else would you use this template, then?). Base class must have + an Base( const Mutex& ) constructor (like the + WeakComponentImplHelperN templates have). + + @tpl CanvasHelper + Canvas helper implementation for the backend in question + + @tpl Mutex + Lock strategy to use. Defaults to using the + OBaseMutex-provided lock. Everytime one of the methods is + entered, an object of type Mutex is created with m_aMutex as + the sole parameter, and destroyed again when the method scope + is left. + + @tpl UnambiguousBase + Optional unambiguous base class for XInterface of Base. It's + sometimes necessary to specify this parameter, e.g. if Base + derives from multiple UNO interface (were each provides its + own version of XInterface, making the conversion ambiguous) + + @see CanvasBase for further contractual requirements towards + the CanvasHelper type, and some examples. + */ + template< class Base, + class CanvasHelper, + class Mutex=::osl::MutexGuard, + class UnambiguousBase=::com::sun::star::uno::XInterface > class FloatBitmapBase : + public BitmapCanvasBase< Base, CanvasHelper, Mutex, UnambiguousBase > + { + public: + typedef BitmapCanvasBase< Base, CanvasHelper, Mutex, UnambiguousBase > BaseType; + + // XIeeeFloatBitmap + virtual ::com::sun::star::uno::Sequence< float > SAL_CALL getData( ::com::sun::star::rendering::FloatingPointBitmapLayout& bitmapLayout, + const ::com::sun::star::geometry::IntegerRectangle2D& rect ) throw (::com::sun::star::lang::IndexOutOfBoundsException, + ::com::sun::star::rendering::VolatileContentDestroyedException, + ::com::sun::star::uno::RuntimeException) + { + verifyInput(rect, + static_cast< typename BaseType::UnambiguousBaseType* >(this)); + verifyIndexRange(rect, getSize() ); + + typename BaseType::MutexType aGuard( BaseType::m_aMutex ); + + return BaseType::maCanvasHelper.getData( bitmapLayout, + rect ); + } + + virtual void SAL_CALL setData( const ::com::sun::star::uno::Sequence< float >& data, + const ::com::sun::star::rendering::FloatingPointBitmapLayout& bitmapLayout, + const ::com::sun::star::geometry::IntegerRectangle2D& rect ) throw (::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::lang::IndexOutOfBoundsException, + ::com::sun::star::uno::RuntimeException) + { + verifyInput(bitmapLayout, rect, + static_cast< typename BaseType::UnambiguousBaseType* >(this)); + verifyIndexRange(rect, getSize() ); + + typename BaseType::MutexType aGuard( BaseType::m_aMutex ); + + BaseType::mbSurfaceDirty = true; + BaseType::maCanvasHelper.modifying(); + + BaseType::maCanvasHelper.setData( data, bitmapLayout, rect ); + } + + virtual void SAL_CALL setPixel( const ::com::sun::star::uno::Sequence< float >& color, + const ::com::sun::star::rendering::FloatingPointBitmapLayout& bitmapLayout, + const ::com::sun::star::geometry::IntegerPoint2D& pos ) throw (::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::lang::IndexOutOfBoundsException, + ::com::sun::star::uno::RuntimeException) + { + verifyInput(bitmapLayout, pos, + static_cast< typename BaseType::UnambiguousBaseType* >(this)); + verifyIndexRange(pos, getSize() ); + + typename BaseType::MutexType aGuard( BaseType::m_aMutex ); + + BaseType::mbSurfaceDirty = true; + BaseType::maCanvasHelper.modifying(); + + BaseType::maCanvasHelper.setPixel( color, bitmapLayout, pos ); + } + + virtual ::com::sun::star::uno::Sequence< float > SAL_CALL getPixel( ::com::sun::star::rendering::FloatingPointBitmapLayout& bitmapLayout, + const ::com::sun::star::geometry::IntegerPoint2D& pos ) throw (::com::sun::star::lang::IndexOutOfBoundsException, + ::com::sun::star::rendering::VolatileContentDestroyedException, + ::com::sun::star::uno::RuntimeException) + { + verifyInput(pos, + static_cast< typename BaseType::UnambiguousBaseType* >(this)); + verifyIndexRange(pos, getSize() ); + + typename BaseType::MutexType aGuard( BaseType::m_aMutex ); + + return BaseType::maCanvasHelper.getPixel( bitmapLayout, + pos ); + } + + virtual ::com::sun::star::rendering::FloatingPointBitmapLayout SAL_CALL getMemoryLayout( ) throw (::com::sun::star::uno::RuntimeException) + { + typename BaseType::MutexType aGuard( BaseType::m_aMutex ); + + return BaseType::maCanvasHelper.getMemoryLayout(); + } + }; +} + +#endif /* INCLUDED_CANVAS_FLOATBITMAPBASE_HXX */ + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/canvas/inc/canvas/base/graphicdevicebase.hxx b/canvas/inc/canvas/base/graphicdevicebase.hxx new file mode 100644 index 000000000000..62424e4cdabd --- /dev/null +++ b/canvas/inc/canvas/base/graphicdevicebase.hxx @@ -0,0 +1,394 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef INCLUDED_CANVAS_GRAPHICDEVICEBASE_HXX +#define INCLUDED_CANVAS_GRAPHICDEVICEBASE_HXX + +#include <rtl/ref.hxx> +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/lang/XMultiServiceFactory.hpp> +#include <com/sun/star/beans/XPropertySet.hpp> +#include <com/sun/star/util/XUpdatable.hpp> +#include <com/sun/star/rendering/XGraphicDevice.hpp> +#include <com/sun/star/rendering/XColorSpace.hpp> + +#include <canvas/parametricpolypolygon.hxx> +#include <canvas/propertysethelper.hxx> + + +/* Definition of GraphicDeviceBase class */ + +namespace canvas +{ + /** Helper template base class for XGraphicDevice implementations. + + This base class provides partial implementations of the + XGraphicDevice-related interface, such as XColorSpace. + + This template basically interposes itself between the full + interface you implement (i.e. not restricted to XGraphicDevice + etc.). The problem with UNO partial interface implementation + actually is, that you cannot do it the plain way, since + deriving from a common base subclass always introduces the + whole set of pure virtuals, that your baseclass helper just + overrided) and your implementation class. You then only have + to implement the functionality <em>besides</em> + XGraphicDevice. If you want to support the optional debug + XUpdatable interface, also add that to the base classes + (client code will call the corresponding update() method, + whenever a burst of animations is over). + + <pre> + Example: + typedef ::cppu::WeakComponentImplHelper5< ::com::sun::star::rendering::XGraphicDevice, + ::com::sun::star::rendering::XColorSpace, + ::com::sun::star::rendering::XPropertySet, + ::com::sun::star::lang::XServiceInfo, + ::com::sun::star::lang::XServiceName > GraphicDeviceBase_Base; + typedef ::canvas::internal::GraphicDeviceBase< GraphicDeviceBase, DeviceHelper > ExampleDevice_Base; + + class ExampleDevice : public ExampleDevice_Base + { + }; + </pre> + + @tpl Base + Base class to use, most probably one of the + WeakComponentImplHelperN templates with the appropriate + interfaces. At least XGraphicDevice should be among them (why else + would you use this template, then?). Base class must have an + Base( const Mutex& ) constructor (like the + WeakComponentImplHelperN templates have). As the very least, + the base class must be derived from uno::XInterface, as some + error reporting mechanisms rely on that. + + @tpl DeviceHelper + Device helper implementation for the backend in question. This + object will be held as a member of this template class, and + basically gets forwarded all XGraphicDevice API calls that + could not be handled generically. + + @tpl Mutex + Lock strategy to use. Defaults to using the + BaseMutexHelper-provided lock. Everytime one of the methods is + entered, an object of type Mutex is created with m_aMutex as + the sole parameter, and destroyed again when the method scope + is left. + + @tpl UnambiguousBase + Optional unambiguous base class for XInterface of Base. It's + sometimes necessary to specify this parameter, e.g. if Base + derives from multiple UNO interface (were each provides its + own version of XInterface, making the conversion ambiguous) + */ + template< class Base, + class DeviceHelper, + class Mutex=::osl::MutexGuard, + class UnambiguousBase=::com::sun::star::uno::XInterface > class GraphicDeviceBase : + public Base + { + public: + typedef Base BaseType; + typedef DeviceHelper DeviceHelperType; + typedef Mutex MutexType; + typedef UnambiguousBase UnambiguousBaseType; + typedef GraphicDeviceBase ThisType; + + typedef ::rtl::Reference< GraphicDeviceBase > Reference; + + GraphicDeviceBase() : + maDeviceHelper(), + maPropHelper(), + mbDumpScreenContent(false) + { + maPropHelper.initProperties( PropertySetHelper::MakeMap + ("HardwareAcceleration", + boost::bind(&DeviceHelper::isAccelerated, + boost::ref(maDeviceHelper))) + ("DeviceHandle", + boost::bind(&DeviceHelper::getDeviceHandle, + boost::ref(maDeviceHelper))) + ("SurfaceHandle", + boost::bind(&DeviceHelper::getSurfaceHandle, + boost::ref(maDeviceHelper))) + ("DumpScreenContent", + boost::bind(&ThisType::getDumpScreenContent, + this), + boost::bind(&ThisType::setDumpScreenContent, + this, + _1))); + } + +#if defined __SUNPRO_CC + using Base::disposing; +#endif + virtual void SAL_CALL disposing() + { + MutexType aGuard( BaseType::m_aMutex ); + + maDeviceHelper.disposing(); + + // pass on to base class + cppu::WeakComponentImplHelperBase::disposing(); + } + + // XGraphicDevice + virtual ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XBufferController > SAL_CALL getBufferController( ) throw (::com::sun::star::uno::RuntimeException) + { + return ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XBufferController >(); + } + + virtual ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XColorSpace > SAL_CALL getDeviceColorSpace( ) throw (::com::sun::star::uno::RuntimeException) + { + MutexType aGuard( BaseType::m_aMutex ); + + return maDeviceHelper.getColorSpace(); + } + + virtual ::com::sun::star::geometry::RealSize2D SAL_CALL getPhysicalResolution( ) throw (::com::sun::star::uno::RuntimeException) + { + MutexType aGuard( BaseType::m_aMutex ); + + return maDeviceHelper.getPhysicalResolution(); + } + + virtual ::com::sun::star::geometry::RealSize2D SAL_CALL getPhysicalSize( ) throw (::com::sun::star::uno::RuntimeException) + { + MutexType aGuard( BaseType::m_aMutex ); + + return maDeviceHelper.getPhysicalSize(); + } + + virtual ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XLinePolyPolygon2D > SAL_CALL createCompatibleLinePolyPolygon( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::com::sun::star::geometry::RealPoint2D > >& points ) throw (::com::sun::star::uno::RuntimeException) + { + MutexType aGuard( BaseType::m_aMutex ); + + return maDeviceHelper.createCompatibleLinePolyPolygon( this, points ); + } + + virtual ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XBezierPolyPolygon2D > SAL_CALL createCompatibleBezierPolyPolygon( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::com::sun::star::geometry::RealBezierSegment2D > >& points ) throw (::com::sun::star::uno::RuntimeException) + { + MutexType aGuard( BaseType::m_aMutex ); + + return maDeviceHelper.createCompatibleBezierPolyPolygon( this, points ); + } + + virtual ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XBitmap > SAL_CALL createCompatibleBitmap( const ::com::sun::star::geometry::IntegerSize2D& size ) throw (::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::uno::RuntimeException) + { + tools::verifyBitmapSize(size, + BOOST_CURRENT_FUNCTION, + static_cast< UnambiguousBaseType* >(this)); + + MutexType aGuard( BaseType::m_aMutex ); + + return maDeviceHelper.createCompatibleBitmap( this, size ); + } + + virtual ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XVolatileBitmap > SAL_CALL createVolatileBitmap( const ::com::sun::star::geometry::IntegerSize2D& size ) throw (::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::uno::RuntimeException) + { + tools::verifyBitmapSize(size, + BOOST_CURRENT_FUNCTION, + static_cast< UnambiguousBaseType* >(this)); + + MutexType aGuard( BaseType::m_aMutex ); + + return maDeviceHelper.createVolatileBitmap( this, size ); + } + + virtual ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XBitmap > SAL_CALL createCompatibleAlphaBitmap( const ::com::sun::star::geometry::IntegerSize2D& size ) throw (::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::uno::RuntimeException) + { + tools::verifyBitmapSize(size, + BOOST_CURRENT_FUNCTION, + static_cast< UnambiguousBaseType* >(this)); + + MutexType aGuard( BaseType::m_aMutex ); + + return maDeviceHelper.createCompatibleAlphaBitmap( this, size ); + } + + virtual ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XVolatileBitmap > SAL_CALL createVolatileAlphaBitmap( const ::com::sun::star::geometry::IntegerSize2D& size ) throw (::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::uno::RuntimeException) + { + tools::verifyBitmapSize(size, + BOOST_CURRENT_FUNCTION, + static_cast< UnambiguousBaseType* >(this)); + + MutexType aGuard( BaseType::m_aMutex ); + + return maDeviceHelper.createVolatileAlphaBitmap( this, size ); + } + + virtual ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > SAL_CALL getParametricPolyPolygonFactory( ) throw (::com::sun::star::uno::RuntimeException) + { + return this; + } + + virtual ::sal_Bool SAL_CALL hasFullScreenMode( ) throw (::com::sun::star::uno::RuntimeException) + { + MutexType aGuard( BaseType::m_aMutex ); + + return maDeviceHelper.hasFullScreenMode(); + } + + virtual ::sal_Bool SAL_CALL enterFullScreenMode( ::sal_Bool bEnter ) throw (::com::sun::star::uno::RuntimeException) + { + MutexType aGuard( BaseType::m_aMutex ); + + return maDeviceHelper.enterFullScreenMode( bEnter ); + } + + // XMultiServiceFactory + virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL createInstance( const ::rtl::OUString& aServiceSpecifier ) throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException) + { + return ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XParametricPolyPolygon2D >( + ParametricPolyPolygon::create(this, + aServiceSpecifier, + ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >())); + } + + virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL createInstanceWithArguments( const ::rtl::OUString& aServiceSpecifier, const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& Arguments ) throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException) + { + return ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XParametricPolyPolygon2D >( + ParametricPolyPolygon::create(this, + aServiceSpecifier, + Arguments)); + } + + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getAvailableServiceNames( ) throw (::com::sun::star::uno::RuntimeException) + { + return ParametricPolyPolygon::getAvailableServiceNames(); + } + + + // XUpdatable + virtual void SAL_CALL update() throw (com::sun::star::uno::RuntimeException) + { + MutexType aGuard( BaseType::m_aMutex ); + + if( mbDumpScreenContent ) + maDeviceHelper.dumpScreenContent(); + } + + + // XPropertySet + virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() throw (::com::sun::star::uno::RuntimeException) + { + MutexType aGuard( BaseType::m_aMutex ); + return maPropHelper.getPropertySetInfo(); + } + + virtual void SAL_CALL setPropertyValue( const ::rtl::OUString& aPropertyName, + const ::com::sun::star::uno::Any& aValue ) throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::beans::PropertyVetoException, + ::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException) + { + MutexType aGuard( BaseType::m_aMutex ); + maPropHelper.setPropertyValue( aPropertyName, aValue ); + } + + virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue( const ::rtl::OUString& aPropertyName ) throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException) + { + MutexType aGuard( BaseType::m_aMutex ); + return maPropHelper.getPropertyValue( aPropertyName ); + } + + virtual void SAL_CALL addPropertyChangeListener( const ::rtl::OUString& aPropertyName, + const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& xListener ) throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException) + { + MutexType aGuard( BaseType::m_aMutex ); + maPropHelper.addPropertyChangeListener( aPropertyName, + xListener ); + } + + virtual void SAL_CALL removePropertyChangeListener( const ::rtl::OUString& aPropertyName, + const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& xListener ) throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException) + { + MutexType aGuard( BaseType::m_aMutex ); + maPropHelper.removePropertyChangeListener( aPropertyName, + xListener ); + } + + virtual void SAL_CALL addVetoableChangeListener( const ::rtl::OUString& aPropertyName, + const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& xListener ) throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException) + { + MutexType aGuard( BaseType::m_aMutex ); + maPropHelper.addVetoableChangeListener( aPropertyName, + xListener ); + } + + virtual void SAL_CALL removeVetoableChangeListener( const ::rtl::OUString& aPropertyName, + const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& xListener ) throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException) + { + MutexType aGuard( BaseType::m_aMutex ); + maPropHelper.removeVetoableChangeListener( aPropertyName, + xListener ); + } + + protected: + ~GraphicDeviceBase() {} // we're a ref-counted UNO class. _We_ destroy ourselves. + + ::com::sun::star::uno::Any getDumpScreenContent() const + { + return ::com::sun::star::uno::makeAny( mbDumpScreenContent ); + } + + void setDumpScreenContent( const ::com::sun::star::uno::Any& rAny ) + { + // TODO(Q1): this was mbDumpScreenContent = + // rAny.get<bool>(), only that gcc3.3 wouldn't eat it + rAny >>= mbDumpScreenContent; + } + + DeviceHelperType maDeviceHelper; + PropertySetHelper maPropHelper; + bool mbDumpScreenContent; + + private: + GraphicDeviceBase( const GraphicDeviceBase& ); + GraphicDeviceBase& operator=( const GraphicDeviceBase& ); + }; +} + +#endif /* INCLUDED_CANVAS_GRAPHICDEVICEBASE_HXX */ + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/canvas/inc/canvas/base/integerbitmapbase.hxx b/canvas/inc/canvas/base/integerbitmapbase.hxx new file mode 100644 index 000000000000..bf5476c2085f --- /dev/null +++ b/canvas/inc/canvas/base/integerbitmapbase.hxx @@ -0,0 +1,154 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef INCLUDED_CANVAS_INTEGERBITMAPBASE_HXX +#define INCLUDED_CANVAS_INTEGERBITMAPBASE_HXX + +#include <com/sun/star/rendering/XIntegerBitmap.hpp> +#include <canvas/base/bitmapcanvasbase.hxx> + + +namespace canvas +{ + /** Helper template to handle XIntegerBitmap method forwarding to + BitmapCanvasHelper + + Use this helper to handle the XIntegerBitmap part of your + implementation. + + @tpl Base + Base class to use, most probably one of the + WeakComponentImplHelperN templates with the appropriate + interfaces. At least XIntegerBitmap should be among them (why + else would you use this template, then?). Base class must have + an Base( const Mutex& ) constructor (like the + WeakComponentImplHelperN templates have). + + @tpl CanvasHelper + Canvas helper implementation for the backend in question + + @tpl Mutex + Lock strategy to use. Defaults to using the + OBaseMutex-provided lock. Everytime one of the methods is + entered, an object of type Mutex is created with m_aMutex as + the sole parameter, and destroyed again when the method scope + is left. + + @tpl UnambiguousBase + Optional unambiguous base class for XInterface of Base. It's + sometimes necessary to specify this parameter, e.g. if Base + derives from multiple UNO interface (were each provides its + own version of XInterface, making the conversion ambiguous) + + @see CanvasBase for further contractual requirements towards + the CanvasHelper type, and some examples. + */ + template< class Base, + class CanvasHelper, + class Mutex=::osl::MutexGuard, + class UnambiguousBase=::com::sun::star::uno::XInterface > class IntegerBitmapBase : + public BitmapCanvasBase< Base, CanvasHelper, Mutex, UnambiguousBase > + { + public: + typedef BitmapCanvasBase< Base, CanvasHelper, Mutex, UnambiguousBase > BaseType; + + // XIntegerBitmap + virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getData( ::com::sun::star::rendering::IntegerBitmapLayout& bitmapLayout, + const ::com::sun::star::geometry::IntegerRectangle2D& rect ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::rendering::VolatileContentDestroyedException, ::com::sun::star::uno::RuntimeException) + { + tools::verifyArgs(rect, + BOOST_CURRENT_FUNCTION, + static_cast< typename BaseType::UnambiguousBaseType* >(this)); + tools::verifyIndexRange(rect, BaseType::getSize() ); + + typename BaseType::MutexType aGuard( BaseType::m_aMutex ); + + return BaseType::maCanvasHelper.getData( bitmapLayout, + rect ); + } + + virtual void SAL_CALL setData( const ::com::sun::star::uno::Sequence< sal_Int8 >& data, + const ::com::sun::star::rendering::IntegerBitmapLayout& bitmapLayout, + const ::com::sun::star::geometry::IntegerRectangle2D& rect ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException) + { + tools::verifyArgs(bitmapLayout, rect, + BOOST_CURRENT_FUNCTION, + static_cast< typename BaseType::UnambiguousBaseType* >(this)); + tools::verifyIndexRange(rect, BaseType::getSize() ); + + typename BaseType::MutexType aGuard( BaseType::m_aMutex ); + + BaseType::mbSurfaceDirty = true; + BaseType::maCanvasHelper.modifying(); + + BaseType::maCanvasHelper.setData( data, bitmapLayout, rect ); + } + + virtual void SAL_CALL setPixel( const ::com::sun::star::uno::Sequence< sal_Int8 >& color, + const ::com::sun::star::rendering::IntegerBitmapLayout& bitmapLayout, + const ::com::sun::star::geometry::IntegerPoint2D& pos ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException) + { + tools::verifyArgs(bitmapLayout, pos, + BOOST_CURRENT_FUNCTION, + static_cast< typename BaseType::UnambiguousBaseType* >(this)); + tools::verifyIndexRange(pos, BaseType::getSize() ); + + typename BaseType::MutexType aGuard( BaseType::m_aMutex ); + + BaseType::mbSurfaceDirty = true; + BaseType::maCanvasHelper.modifying(); + + BaseType::maCanvasHelper.setPixel( color, bitmapLayout, pos ); + } + + virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getPixel( ::com::sun::star::rendering::IntegerBitmapLayout& bitmapLayout, + const ::com::sun::star::geometry::IntegerPoint2D& pos ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::rendering::VolatileContentDestroyedException, ::com::sun::star::uno::RuntimeException) + { + tools::verifyArgs(pos, + BOOST_CURRENT_FUNCTION, + static_cast< typename BaseType::UnambiguousBaseType* >(this)); + tools::verifyIndexRange(pos, BaseType::getSize() ); + + typename BaseType::MutexType aGuard( BaseType::m_aMutex ); + + return BaseType::maCanvasHelper.getPixel( bitmapLayout, + pos ); + } + + virtual ::com::sun::star::rendering::IntegerBitmapLayout SAL_CALL getMemoryLayout( ) throw (::com::sun::star::uno::RuntimeException) + { + typename BaseType::MutexType aGuard( BaseType::m_aMutex ); + + return BaseType::maCanvasHelper.getMemoryLayout(); + } + }; +} + +#endif /* INCLUDED_CANVAS_INTEGERBITMAPBASE_HXX */ + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/canvas/inc/canvas/base/sprite.hxx b/canvas/inc/canvas/base/sprite.hxx new file mode 100644 index 000000000000..bb3d655bb2e7 --- /dev/null +++ b/canvas/inc/canvas/base/sprite.hxx @@ -0,0 +1,122 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef INCLUDED_CANVAS_SPRITE_HXX +#define INCLUDED_CANVAS_SPRITE_HXX + +#include <rtl/ref.hxx> +#include <com/sun/star/lang/XComponent.hpp> +#include <com/sun/star/rendering/XCanvas.hpp> +#include <basegfx/point/b2dpoint.hxx> +#include <basegfx/vector/b2dsize.hxx> + +namespace basegfx +{ + class B2DPoint; + class B2DVector; + class B2DRange; +} + +namespace canvas +{ + /* Definition of Sprite interface (as we mix with UNO here, has to + be XInterface - reference holders to a Sprite must be able to + control lifetime of reference target) + */ + + /** Helper interface to connect SpriteCanvas with various + sprite implementations. + + This interface should be implemented from every sprite class, + as it provides essential repaint and update area facilitates. + + @derive typically, each canvas implementation will derive + another interface from this one, that adds rendering + functionality (which, of course, is impossible here in a + generic way) + */ + class Sprite : public ::com::sun::star::lang::XComponent + { + public: + typedef ::rtl::Reference< Sprite > Reference; + + /** Query whether sprite update will fully cover the given area. + + Use this method to determine whether any background + content (regardless of static or sprite) needs an update + before rendering this sprite. + + @return true, if sprite redraw will fully overwrite given + area (and thus, the background need not be redrawn + beforehand). + */ + virtual bool isAreaUpdateOpaque( const ::basegfx::B2DRange& rUpdateArea ) const = 0; + + /** Query whether content has changed + */ + virtual bool isContentChanged() const = 0; + + /** Query position of the left, top pixel of the sprite + */ + virtual ::basegfx::B2DPoint getPosPixel() const = 0; + + /** Query size of the sprite in pixel. + */ + virtual ::basegfx::B2DVector getSizePixel() const = 0; + + /** Get area that is currently covered by the sprite + + This area is already adapted to clipping, alpha and + transformation state of this sprite. + */ + virtual ::basegfx::B2DRange getUpdateArea() const = 0; + + /** Query sprite priority + */ + virtual double getPriority() const = 0; + }; + + /** Functor providing a StrictWeakOrdering for sprite references + */ + struct SpriteComparator + { + bool operator()( const Sprite::Reference& rLHS, + const Sprite::Reference& rRHS ) + { + const double nPrioL( rLHS->getPriority() ); + const double nPrioR( rRHS->getPriority() ); + + // if prios are equal, tie-break on ptr value + return nPrioL == nPrioR ? rLHS.get() < rRHS.get() : nPrioL < nPrioR; + } + }; +} + +#endif /* INCLUDED_CANVAS_SPRITE_HXX */ + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/canvas/inc/canvas/base/spritecanvasbase.hxx b/canvas/inc/canvas/base/spritecanvasbase.hxx new file mode 100644 index 000000000000..1cf255fe5579 --- /dev/null +++ b/canvas/inc/canvas/base/spritecanvasbase.hxx @@ -0,0 +1,205 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef INCLUDED_CANVAS_SPRITECANVASBASE_HXX +#define INCLUDED_CANVAS_SPRITECANVASBASE_HXX + +#include <rtl/ref.hxx> +#include <com/sun/star/rendering/XSpriteCanvas.hpp> +#include <com/sun/star/rendering/InterpolationMode.hpp> +#include <canvas/base/integerbitmapbase.hxx> +#include <canvas/spriteredrawmanager.hxx> + + +namespace canvas +{ + /** Helper template to handle XIntegerBitmap method forwarding to + BitmapCanvasHelper + + Use this helper to handle the XIntegerBitmap part of your + implementation. + + @tpl Base + Base class to use, most probably one of the + WeakComponentImplHelperN templates with the appropriate + interfaces. At least XSpriteCanvas and SpriteSurface should be + among them (why else would you use this template, then?). Base + class must have an Base( const Mutex& ) constructor (like the + WeakComponentImplHelperN templates have). + + @tpl CanvasHelper + Canvas helper implementation for the backend in question + + @tpl Mutex + Lock strategy to use. Defaults to using the + OBaseMutex-provided lock. Everytime one of the methods is + entered, an object of type Mutex is created with m_aMutex as + the sole parameter, and destroyed again when the method scope + is left. + + @tpl UnambiguousBase + Optional unambiguous base class for XInterface of Base. It's + sometimes necessary to specify this parameter, e.g. if Base + derives from multiple UNO interface (were each provides its + own version of XInterface, making the conversion ambiguous) + + @see CanvasBase for further contractual requirements towards + the CanvasHelper type, and some examples. + */ + template< class Base, + class CanvasHelper, + class Mutex=::osl::MutexGuard, + class UnambiguousBase=::com::sun::star::uno::XInterface > class SpriteCanvasBase : + public IntegerBitmapBase< Base, CanvasHelper, Mutex, UnambiguousBase > + { + public: + typedef IntegerBitmapBase< Base, CanvasHelper, Mutex, UnambiguousBase > BaseType; + typedef ::rtl::Reference< SpriteCanvasBase > Reference; + + SpriteCanvasBase() : + maRedrawManager() + { + } + +#if defined __SUNPRO_CC + using Base::disposing; +#endif + virtual void SAL_CALL disposing() + { + typename BaseType::MutexType aGuard( BaseType::m_aMutex ); + + maRedrawManager.disposing(); + + // pass on to base class + BaseType::disposing(); + } + + // XSpriteCanvas + virtual ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XAnimatedSprite > SAL_CALL createSpriteFromAnimation( const ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XAnimation >& animation ) throw (::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::uno::RuntimeException) + { + tools::verifyArgs(animation, + BOOST_CURRENT_FUNCTION, + static_cast< typename BaseType::UnambiguousBaseType* >(this)); + + typename BaseType::MutexType aGuard( BaseType::m_aMutex ); + + return BaseType::maCanvasHelper.createSpriteFromAnimation(animation); + } + + virtual ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XAnimatedSprite > SAL_CALL createSpriteFromBitmaps( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XBitmap > >& animationBitmaps, + sal_Int8 interpolationMode ) throw (::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::rendering::VolatileContentDestroyedException, + ::com::sun::star::uno::RuntimeException) + { + tools::verifyArgs(animationBitmaps, + BOOST_CURRENT_FUNCTION, + static_cast< typename BaseType::UnambiguousBaseType* >(this)); + tools::verifyRange( interpolationMode, + ::com::sun::star::rendering::InterpolationMode::NEAREST_NEIGHBOR, + ::com::sun::star::rendering::InterpolationMode::BEZIERSPLINE4 ); + + typename BaseType::MutexType aGuard( BaseType::m_aMutex ); + + return BaseType::maCanvasHelper.createSpriteFromBitmaps(animationBitmaps, interpolationMode); + } + + virtual ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XCustomSprite > SAL_CALL createCustomSprite( const ::com::sun::star::geometry::RealSize2D& spriteSize ) throw (::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::uno::RuntimeException) + { + tools::verifySpriteSize(spriteSize, + BOOST_CURRENT_FUNCTION, + static_cast< typename BaseType::UnambiguousBaseType* >(this)); + + typename BaseType::MutexType aGuard( BaseType::m_aMutex ); + + return BaseType::maCanvasHelper.createCustomSprite(spriteSize); + } + + virtual ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XSprite > SAL_CALL createClonedSprite( const ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XSprite >& original ) throw (::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::uno::RuntimeException) + { + tools::verifyArgs(original, + BOOST_CURRENT_FUNCTION, + static_cast< typename BaseType::UnambiguousBaseType* >(this)); + + typename BaseType::MutexType aGuard( BaseType::m_aMutex ); + + return BaseType::maCanvasHelper.createClonedSprite(original); + } + + // SpriteSurface + virtual void showSprite( const Sprite::Reference& rSprite ) + { + OSL_ASSERT( rSprite.is() ); + + typename BaseType::MutexType aGuard( BaseType::m_aMutex ); + + maRedrawManager.showSprite( rSprite ); + } + + virtual void hideSprite( const Sprite::Reference& rSprite ) + { + OSL_ASSERT( rSprite.is() ); + + typename BaseType::MutexType aGuard( BaseType::m_aMutex ); + + maRedrawManager.hideSprite( rSprite ); + } + + virtual void moveSprite( const Sprite::Reference& rSprite, + const ::basegfx::B2DPoint& rOldPos, + const ::basegfx::B2DPoint& rNewPos, + const ::basegfx::B2DVector& rSpriteSize ) + { + OSL_ASSERT( rSprite.is() ); + + typename BaseType::MutexType aGuard( BaseType::m_aMutex ); + + maRedrawManager.moveSprite( rSprite, rOldPos, rNewPos, rSpriteSize ); + } + + virtual void updateSprite( const Sprite::Reference& rSprite, + const ::basegfx::B2DPoint& rPos, + const ::basegfx::B2DRange& rUpdateArea ) + { + OSL_ASSERT( rSprite.is() ); + + typename BaseType::MutexType aGuard( BaseType::m_aMutex ); + + maRedrawManager.updateSprite( rSprite, rPos, rUpdateArea ); + } + + protected: + SpriteRedrawManager maRedrawManager; + }; +} + +#endif /* INCLUDED_CANVAS_SPRITECANVASBASE_HXX */ + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/canvas/inc/canvas/base/spritesurface.hxx b/canvas/inc/canvas/base/spritesurface.hxx new file mode 100644 index 000000000000..c60099f1563b --- /dev/null +++ b/canvas/inc/canvas/base/spritesurface.hxx @@ -0,0 +1,76 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef INCLUDED_CANVAS_SPRITESURFACE_HXX +#define INCLUDED_CANVAS_SPRITESURFACE_HXX + +#include <canvas/base/sprite.hxx> + +namespace canvas +{ + /* Definition of the SpriteSurface interface */ + + /** Canvas surface containing sprites + + Every canvas surface that contains sprites must implement this + interface, when employing the canvas base framework. The + methods provided here are used from the individual sprites to + notify the canvas about necessary screen updates. + */ + class SpriteSurface : public ::com::sun::star::uno::XInterface + { + public: + typedef ::rtl::Reference< SpriteSurface > Reference; + + /// Sprites should call this from XSprite::show() + virtual void showSprite( const Sprite::Reference& rSprite ) = 0; + + /// Sprites should call this from XSprite::hide() + virtual void hideSprite( const Sprite::Reference& rSprite ) = 0; + + /// Sprites should call this from XSprite::move() + virtual void moveSprite( const Sprite::Reference& rSprite, + const ::basegfx::B2DPoint& rOldPos, + const ::basegfx::B2DPoint& rNewPos, + const ::basegfx::B2DVector& rSpriteSize ) = 0; + + /** Sprites should call this when some part of the content has + changed. + + That includes show/hide, i.e. for show, both showSprite() + and updateSprite() must be called. + */ + virtual void updateSprite( const Sprite::Reference& rSprite, + const ::basegfx::B2DPoint& rPos, + const ::basegfx::B2DRange& rUpdateArea ) = 0; + }; +} + +#endif /* INCLUDED_CANVAS_SPRITESURFACE_HXX */ + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |