1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: cairo_spritecanvas.hxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef _CAIROCANVAS_SPRITECANVAS_HXX_
32 #define _CAIROCANVAS_SPRITECANVAS_HXX_
34 #include <com/sun/star/uno/XComponentContext.hpp>
35 #include <com/sun/star/beans/XPropertySet.hpp>
36 #include <com/sun/star/lang/XInitialization.hpp>
37 #include <com/sun/star/lang/XServiceInfo.hpp>
38 #include <com/sun/star/lang/XServiceName.hpp>
39 #include <com/sun/star/awt/XWindowListener.hpp>
40 #include <com/sun/star/util/XUpdatable.hpp>
41 #include <com/sun/star/rendering/XSpriteCanvas.hpp>
42 #include <com/sun/star/rendering/XIntegerBitmap.hpp>
43 #include <com/sun/star/rendering/XGraphicDevice.hpp>
44 #include <com/sun/star/rendering/XBufferController.hpp>
45 #include <com/sun/star/rendering/XParametricPolyPolygon2DFactory.hpp>
47 #include <cppuhelper/compbase9.hxx>
48 #include <comphelper/uno3.hxx>
50 #include <canvas/base/spritecanvasbase.hxx>
51 #include <canvas/base/basemutexhelper.hxx>
52 #include <canvas/base/bufferedgraphicdevicebase.hxx>
54 #include <basegfx/vector/b2isize.hxx>
56 #include "cairo_spritedevicehelper.hxx"
57 #include "cairo_repainttarget.hxx"
58 #include "cairo_surfaceprovider.hxx"
59 #include "cairo_spritecanvashelper.hxx"
61 #define SPRITECANVAS_SERVICE_NAME "com.sun.star.rendering.SpriteCanvas.Cairo"
62 #define SPRITECANVAS_IMPLEMENTATION_NAME "com.sun.star.comp.rendering.SpriteCanvas.Cairo"
66 typedef ::cppu::WeakComponentImplHelper9
< ::com::sun::star::rendering::XSpriteCanvas
,
67 ::com::sun::star::rendering::XIntegerBitmap
,
68 ::com::sun::star::rendering::XGraphicDevice
,
69 ::com::sun::star::rendering::XParametricPolyPolygon2DFactory
,
70 ::com::sun::star::rendering::XBufferController
,
71 ::com::sun::star::awt::XWindowListener
,
72 ::com::sun::star::util::XUpdatable
,
73 ::com::sun::star::beans::XPropertySet
,
74 ::com::sun::star::lang::XServiceName
> WindowGraphicDeviceBase_Base
;
75 typedef ::canvas::BufferedGraphicDeviceBase
< ::canvas::BaseMutexHelper
< WindowGraphicDeviceBase_Base
>,
78 ::cppu::OWeakObject
> SpriteCanvasBase_Base
;
79 /** Mixin SpriteSurface
81 Have to mixin the SpriteSurface before deriving from
82 ::canvas::SpriteCanvasBase, as this template should already
83 implement some of those interface methods.
85 The reason why this appears kinda convoluted is the fact that
86 we cannot specify non-IDL types as WeakComponentImplHelperN
87 template args, and furthermore, don't want to derive
88 ::canvas::SpriteCanvasBase directly from
89 ::canvas::SpriteSurface (because derivees of
90 ::canvas::SpriteCanvasBase have to explicitely forward the
91 XInterface methods (e.g. via DECLARE_UNO3_AGG_DEFAULTS)
92 anyway). Basically, ::canvas::CanvasCustomSpriteBase should
93 remain a base class that provides implementation, not to
94 enforce any specific interface on its derivees.
96 class SpriteCanvasBaseSpriteSurface_Base
: public SpriteCanvasBase_Base
,
97 public ::canvas::SpriteSurface
,
98 public SurfaceProvider
102 typedef ::canvas::SpriteCanvasBase
< SpriteCanvasBaseSpriteSurface_Base
,
105 ::cppu::OWeakObject
> SpriteCanvasBaseT
;
107 /** Product of this component's factory.
109 The SpriteCanvas object combines the actual Window canvas with
110 the XGraphicDevice interface. This is because there's a
111 one-to-one relation between them, anyway, since each window
112 can have exactly one canvas and one associated
113 XGraphicDevice. And to avoid messing around with circular
114 references, this is implemented as one single object.
116 class SpriteCanvas
: public SpriteCanvasBaseT
,
120 SpriteCanvas( const ::com::sun::star::uno::Sequence
<
121 ::com::sun::star::uno::Any
>& aArguments
,
122 const ::com::sun::star::uno::Reference
<
123 ::com::sun::star::uno::XComponentContext
>& rxContext
);
127 #if defined __SUNPRO_CC
128 using SpriteCanvasBaseT::disposing
;
131 /// Dispose all internal references
132 virtual void SAL_CALL
disposing();
134 // Forwarding the XComponent implementation to the
135 // cppu::ImplHelper templated base
136 // Classname Base doing refcounting Base implementing the XComponent interface
139 DECLARE_UNO3_XCOMPONENT_AGG_DEFAULTS( SpriteCanvas
, WindowGraphicDeviceBase_Base
, ::cppu::WeakComponentImplHelperBase
);
141 // XBufferController (partial)
142 virtual ::sal_Bool SAL_CALL
showBuffer( ::sal_Bool bUpdateAll
) throw (::com::sun::star::uno::RuntimeException
);
143 virtual ::sal_Bool SAL_CALL
switchBuffer( ::sal_Bool bUpdateAll
) throw (::com::sun::star::uno::RuntimeException
);
145 // XSpriteCanvas (partial)
146 virtual sal_Bool SAL_CALL
updateScreen( sal_Bool bUpdateAll
) throw (::com::sun::star::uno::RuntimeException
);
149 virtual ::rtl::OUString SAL_CALL
getServiceName( ) throw (::com::sun::star::uno::RuntimeException
);
152 virtual SurfaceSharedPtr
getSurface();
153 virtual SurfaceSharedPtr
createSurface( const ::basegfx::B2ISize
& rSize
, Content aContent
= CAIRO_CONTENT_COLOR_ALPHA
);
154 virtual SurfaceSharedPtr
createSurface( ::Bitmap
& rBitmap
);
155 virtual SurfaceSharedPtr
changeSurface( bool bHasAlpha
, bool bCopyContent
);
156 virtual OutputDevice
* getOutputDevice();
159 virtual bool repaint( const ::cairo::SurfaceSharedPtr
& pSurface
,
160 const ::com::sun::star::rendering::ViewState
& viewState
,
161 const ::com::sun::star::rendering::RenderState
& renderState
);
163 SurfaceSharedPtr
getWindowSurface();
164 SurfaceSharedPtr
getBufferSurface();
166 const ::basegfx::B2ISize
& getSizePixel();
167 void setSizePixel( const ::basegfx::B2ISize
& rSize
);
171 ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Any
> maArguments
;
172 ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XComponentContext
> mxComponentContext
;
175 typedef ::rtl::Reference
< SpriteCanvas
> SpriteCanvasRef
;