xref: /trunk/main/canvas/source/vcl/spritecanvas.hxx (revision 56b8eddc)
191c99ff4SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
391c99ff4SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
491c99ff4SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
591c99ff4SAndrew Rist  * distributed with this work for additional information
691c99ff4SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
791c99ff4SAndrew Rist  * to you under the Apache License, Version 2.0 (the
891c99ff4SAndrew Rist  * "License"); you may not use this file except in compliance
991c99ff4SAndrew Rist  * with the License.  You may obtain a copy of the License at
1091c99ff4SAndrew Rist  *
1191c99ff4SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
1291c99ff4SAndrew Rist  *
1391c99ff4SAndrew Rist  * Unless required by applicable law or agreed to in writing,
1491c99ff4SAndrew Rist  * software distributed under the License is distributed on an
1591c99ff4SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
1691c99ff4SAndrew Rist  * KIND, either express or implied.  See the License for the
1791c99ff4SAndrew Rist  * specific language governing permissions and limitations
1891c99ff4SAndrew Rist  * under the License.
1991c99ff4SAndrew Rist  *
2091c99ff4SAndrew Rist  *************************************************************/
2191c99ff4SAndrew Rist 
2291c99ff4SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #ifndef _VCLCANVAS_SPRITECANVAS_HXX_
25cdf0e10cSrcweir #define _VCLCANVAS_SPRITECANVAS_HXX_
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include <rtl/ref.hxx>
28cdf0e10cSrcweir 
29cdf0e10cSrcweir #include <com/sun/star/uno/XComponentContext.hpp>
30cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp>
31cdf0e10cSrcweir #include <com/sun/star/lang/XServiceName.hpp>
32cdf0e10cSrcweir #include <com/sun/star/awt/XWindowListener.hpp>
33cdf0e10cSrcweir #include <com/sun/star/util/XUpdatable.hpp>
34cdf0e10cSrcweir #include <com/sun/star/rendering/XSpriteCanvas.hpp>
35cdf0e10cSrcweir #include <com/sun/star/rendering/XIntegerBitmap.hpp>
36cdf0e10cSrcweir #include <com/sun/star/rendering/XGraphicDevice.hpp>
37cdf0e10cSrcweir #include <com/sun/star/rendering/XBufferController.hpp>
38cdf0e10cSrcweir 
39cdf0e10cSrcweir #include <cppuhelper/compbase9.hxx>
40cdf0e10cSrcweir #include <comphelper/uno3.hxx>
41cdf0e10cSrcweir 
42cdf0e10cSrcweir #include <canvas/base/spritecanvasbase.hxx>
43cdf0e10cSrcweir #include <canvas/base/basemutexhelper.hxx>
44cdf0e10cSrcweir #include <canvas/base/bufferedgraphicdevicebase.hxx>
45cdf0e10cSrcweir 
46cdf0e10cSrcweir #include "spritecanvashelper.hxx"
47cdf0e10cSrcweir #include "impltools.hxx"
48cdf0e10cSrcweir #include "spritedevicehelper.hxx"
49cdf0e10cSrcweir #include "repainttarget.hxx"
50cdf0e10cSrcweir 
51cdf0e10cSrcweir 
52cdf0e10cSrcweir #define SPRITECANVAS_SERVICE_NAME        "com.sun.star.rendering.SpriteCanvas.VCL"
53cdf0e10cSrcweir #define SPRITECANVAS_IMPLEMENTATION_NAME "com.sun.star.comp.rendering.SpriteCanvas.VCL"
54cdf0e10cSrcweir 
55cdf0e10cSrcweir namespace vclcanvas
56cdf0e10cSrcweir {
57cdf0e10cSrcweir     typedef ::cppu::WeakComponentImplHelper9< ::com::sun::star::rendering::XSpriteCanvas,
58cdf0e10cSrcweir                                               ::com::sun::star::rendering::XIntegerBitmap,
59cdf0e10cSrcweir                                               ::com::sun::star::rendering::XGraphicDevice,
60cdf0e10cSrcweir                                               ::com::sun::star::lang::XMultiServiceFactory,
61cdf0e10cSrcweir                                               ::com::sun::star::rendering::XBufferController,
62cdf0e10cSrcweir                                               ::com::sun::star::awt::XWindowListener,
63cdf0e10cSrcweir                                               ::com::sun::star::util::XUpdatable,
64cdf0e10cSrcweir                                               ::com::sun::star::beans::XPropertySet,
65cdf0e10cSrcweir                                               ::com::sun::star::lang::XServiceName >	WindowGraphicDeviceBase_Base;
66cdf0e10cSrcweir     typedef ::canvas::BufferedGraphicDeviceBase< ::canvas::BaseMutexHelper< WindowGraphicDeviceBase_Base >,
67cdf0e10cSrcweir                                                  SpriteDeviceHelper,
68cdf0e10cSrcweir                                                  tools::LocalGuard,
69cdf0e10cSrcweir                                                  ::cppu::OWeakObject > 	SpriteCanvasBase_Base;
70cdf0e10cSrcweir 
71cdf0e10cSrcweir 	/** Mixin SpriteSurface
72cdf0e10cSrcweir 
73cdf0e10cSrcweir     	Have to mixin the SpriteSurface before deriving from
74cdf0e10cSrcweir     	::canvas::SpriteCanvasBase, as this template should already
75cdf0e10cSrcweir     	implement some of those interface methods.
76cdf0e10cSrcweir 
77cdf0e10cSrcweir         The reason why this appears kinda convoluted is the fact that
78cdf0e10cSrcweir         we cannot specify non-IDL types as WeakComponentImplHelperN
79cdf0e10cSrcweir         template args, and furthermore, don't want to derive
80cdf0e10cSrcweir         ::canvas::SpriteCanvasBase directly from
81cdf0e10cSrcweir         ::canvas::SpriteSurface (because derivees of
82*56b8eddcSmseidel         ::canvas::SpriteCanvasBase have to explicitly forward the
83cdf0e10cSrcweir         XInterface methods (e.g. via DECLARE_UNO3_AGG_DEFAULTS)
84cdf0e10cSrcweir         anyway). Basically, ::canvas::CanvasCustomSpriteBase should
85cdf0e10cSrcweir         remain a base class that provides implementation, not to
86cdf0e10cSrcweir         enforce any specific interface on its derivees.
87cdf0e10cSrcweir      */
88cdf0e10cSrcweir 	class SpriteCanvasBaseSpriteSurface_Base : public SpriteCanvasBase_Base,
89cdf0e10cSrcweir     										   public ::canvas::SpriteSurface
90cdf0e10cSrcweir     {
91cdf0e10cSrcweir     };
92cdf0e10cSrcweir 
93cdf0e10cSrcweir 	typedef ::canvas::SpriteCanvasBase< SpriteCanvasBaseSpriteSurface_Base,
94cdf0e10cSrcweir                                         SpriteCanvasHelper,
95cdf0e10cSrcweir                                         tools::LocalGuard,
96cdf0e10cSrcweir                                         ::cppu::OWeakObject >			SpriteCanvasBaseT;
97cdf0e10cSrcweir 
98cdf0e10cSrcweir     /** Product of this component's factory.
99cdf0e10cSrcweir 
100cdf0e10cSrcweir 		The SpriteCanvas object combines the actual Window canvas with
101cdf0e10cSrcweir 		the XGraphicDevice interface. This is because there's a
102cdf0e10cSrcweir 		one-to-one relation between them, anyway, since each window
103cdf0e10cSrcweir 		can have exactly one canvas and one associated
104cdf0e10cSrcweir 		XGraphicDevice. And to avoid messing around with circular
105cdf0e10cSrcweir 		references, this is implemented as one single object.
106cdf0e10cSrcweir      */
107cdf0e10cSrcweir     class SpriteCanvas : public SpriteCanvasBaseT,
108cdf0e10cSrcweir                          public RepaintTarget
109cdf0e10cSrcweir     {
110cdf0e10cSrcweir     public:
111cdf0e10cSrcweir         SpriteCanvas( const ::com::sun::star::uno::Sequence<
112cdf0e10cSrcweir                             ::com::sun::star::uno::Any >&               aArguments,
113cdf0e10cSrcweir                       const ::com::sun::star::uno::Reference<
114cdf0e10cSrcweir                             ::com::sun::star::uno::XComponentContext >& rxContext );
115cdf0e10cSrcweir 
116cdf0e10cSrcweir         void initialize();
117cdf0e10cSrcweir 
118cdf0e10cSrcweir         /// For resource tracking
119cdf0e10cSrcweir         ~SpriteCanvas();
120cdf0e10cSrcweir 
121cdf0e10cSrcweir #if defined __SUNPRO_CC
122cdf0e10cSrcweir         using SpriteCanvasBaseT::disposing;
123cdf0e10cSrcweir #endif
124cdf0e10cSrcweir 
125cdf0e10cSrcweir         /// Dispose all internal references
126cdf0e10cSrcweir         virtual void SAL_CALL disposing();
127cdf0e10cSrcweir 
128cdf0e10cSrcweir 		// Forwarding the XComponent implementation to the
129cdf0e10cSrcweir         // cppu::ImplHelper templated base
130cdf0e10cSrcweir         //                                    Classname     Base doing refcounting        Base implementing the XComponent interface
131cdf0e10cSrcweir         //                                       |                 |                            |
132cdf0e10cSrcweir         //                                       V                 V                            V
133cdf0e10cSrcweir         DECLARE_UNO3_XCOMPONENT_AGG_DEFAULTS( SpriteCanvas, WindowGraphicDeviceBase_Base, ::cppu::WeakComponentImplHelperBase );
134cdf0e10cSrcweir 
135cdf0e10cSrcweir         // XBufferController (partial)
136cdf0e10cSrcweir         virtual ::sal_Bool SAL_CALL showBuffer( ::sal_Bool bUpdateAll ) throw (::com::sun::star::uno::RuntimeException);
137cdf0e10cSrcweir         virtual ::sal_Bool SAL_CALL switchBuffer( ::sal_Bool bUpdateAll ) throw (::com::sun::star::uno::RuntimeException);
138cdf0e10cSrcweir 
139cdf0e10cSrcweir         // XSpriteCanvas (partial)
140cdf0e10cSrcweir         virtual sal_Bool SAL_CALL updateScreen( sal_Bool bUpdateAll ) throw (::com::sun::star::uno::RuntimeException);
141cdf0e10cSrcweir 
142cdf0e10cSrcweir         // XServiceName
143cdf0e10cSrcweir         virtual ::rtl::OUString SAL_CALL getServiceName(  ) throw (::com::sun::star::uno::RuntimeException);
144cdf0e10cSrcweir 
145cdf0e10cSrcweir         // RepaintTarget
146cdf0e10cSrcweir         virtual bool repaint( const GraphicObjectSharedPtr&                   rGrf,
147cdf0e10cSrcweir                               const ::com::sun::star::rendering::ViewState&   viewState,
148cdf0e10cSrcweir                               const ::com::sun::star::rendering::RenderState& renderState,
149cdf0e10cSrcweir                               const ::Point&                                  rPt,
150cdf0e10cSrcweir                               const ::Size&                                   rSz,
151cdf0e10cSrcweir                               const GraphicAttr&                              rAttr ) const;
152cdf0e10cSrcweir 
153cdf0e10cSrcweir         /// Get backbuffer for this canvas
getFrontBuffer() const154cdf0e10cSrcweir         OutDevProviderSharedPtr getFrontBuffer() const { return maDeviceHelper.getOutDev(); }
155cdf0e10cSrcweir         /// Get window for this canvas
getBackBuffer() const156cdf0e10cSrcweir         BackBufferSharedPtr getBackBuffer() const { return maDeviceHelper.getBackBuffer(); }
157cdf0e10cSrcweir 
158cdf0e10cSrcweir     private:
159cdf0e10cSrcweir         ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > maArguments;
160cdf0e10cSrcweir         ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > mxComponentContext;
161cdf0e10cSrcweir     };
162cdf0e10cSrcweir 
163cdf0e10cSrcweir     typedef ::rtl::Reference< SpriteCanvas > SpriteCanvasRef;
164cdf0e10cSrcweir     typedef ::rtl::Reference< SpriteCanvas > DeviceRef;
165cdf0e10cSrcweir 
166cdf0e10cSrcweir }
167cdf0e10cSrcweir 
168cdf0e10cSrcweir #endif
169