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 _DXCANVAS_CANVASCUSTOMSPRITE_HXX
25cdf0e10cSrcweir #define _DXCANVAS_CANVASCUSTOMSPRITE_HXX
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include <cppuhelper/compbase4.hxx>
28cdf0e10cSrcweir #include <comphelper/uno3.hxx>
29cdf0e10cSrcweir 
30cdf0e10cSrcweir #include <com/sun/star/lang/XServiceInfo.hpp>
31cdf0e10cSrcweir #include <com/sun/star/lang/XComponent.hpp>
32cdf0e10cSrcweir #include <com/sun/star/rendering/XCustomSprite.hpp>
33cdf0e10cSrcweir #include <com/sun/star/rendering/XIntegerBitmap.hpp>
34cdf0e10cSrcweir #include <com/sun/star/rendering/XPolyPolygon2D.hpp>
35cdf0e10cSrcweir 
36cdf0e10cSrcweir #include <basegfx/point/b2dpoint.hxx>
37cdf0e10cSrcweir #include <basegfx/vector/b2isize.hxx>
38cdf0e10cSrcweir #include <basegfx/matrix/b2dhommatrix.hxx>
39cdf0e10cSrcweir 
40cdf0e10cSrcweir #include <canvas/base/basemutexhelper.hxx>
41cdf0e10cSrcweir #include <canvas/base/canvascustomspritebase.hxx>
42cdf0e10cSrcweir 
43cdf0e10cSrcweir #include "dx_sprite.hxx"
44cdf0e10cSrcweir #include "dx_surfacebitmap.hxx"
45cdf0e10cSrcweir #include "dx_bitmapcanvashelper.hxx"
46cdf0e10cSrcweir #include "dx_spritehelper.hxx"
47cdf0e10cSrcweir #include "dx_spritecanvas.hxx"
48cdf0e10cSrcweir 
49cdf0e10cSrcweir 
50cdf0e10cSrcweir namespace dxcanvas
51cdf0e10cSrcweir {
52cdf0e10cSrcweir     typedef ::cppu::WeakComponentImplHelper4< ::com::sun::star::rendering::XCustomSprite,
53cdf0e10cSrcweir 									 		  ::com::sun::star::rendering::XBitmapCanvas,
54cdf0e10cSrcweir 											  ::com::sun::star::rendering::XIntegerBitmap,
55cdf0e10cSrcweir                          			 		  ::com::sun::star::lang::XServiceInfo >	CanvasCustomSpriteBase_Base;
56cdf0e10cSrcweir 	/** Mixin Sprite
57cdf0e10cSrcweir 
58cdf0e10cSrcweir     	Have to mixin the Sprite interface before deriving from
59cdf0e10cSrcweir     	::canvas::CanvasCustomSpriteBase, as this template should
60cdf0e10cSrcweir     	already implement some of those interface methods.
61cdf0e10cSrcweir 
62cdf0e10cSrcweir         The reason why this appears kinda convoluted is the fact that
63cdf0e10cSrcweir         we cannot specify non-IDL types as WeakComponentImplHelperN
64cdf0e10cSrcweir         template args, and furthermore, don't want to derive
65cdf0e10cSrcweir         ::canvas::CanvasCustomSpriteBase directly from
66cdf0e10cSrcweir         ::canvas::Sprite (because derivees of
67*6d53c851Smseidel         ::canvas::CanvasCustomSpriteBase have to explicitly forward
68cdf0e10cSrcweir         the XInterface methods (e.g. via DECLARE_UNO3_AGG_DEFAULTS)
69cdf0e10cSrcweir         anyway). Basically, ::canvas::CanvasCustomSpriteBase should
70cdf0e10cSrcweir         remain a base class that provides implementation, not to
71cdf0e10cSrcweir         enforce any specific interface on its derivees.
72cdf0e10cSrcweir      */
73cdf0e10cSrcweir 	class CanvasCustomSpriteSpriteBase_Base : public ::canvas::BaseMutexHelper< CanvasCustomSpriteBase_Base >,
74cdf0e10cSrcweir     									   	  public Sprite
75cdf0e10cSrcweir     {
76cdf0e10cSrcweir     };
77cdf0e10cSrcweir 
78cdf0e10cSrcweir 	typedef ::canvas::CanvasCustomSpriteBase< CanvasCustomSpriteSpriteBase_Base,
79cdf0e10cSrcweir                                               SpriteHelper,
80cdf0e10cSrcweir                                               BitmapCanvasHelper,
81cdf0e10cSrcweir                                               ::osl::MutexGuard,
82cdf0e10cSrcweir                                               ::cppu::OWeakObject > 					CanvasCustomSpriteBaseT;
83cdf0e10cSrcweir 
84cdf0e10cSrcweir 	/* Definition of CanvasCustomSprite class */
85cdf0e10cSrcweir 
86cdf0e10cSrcweir     class CanvasCustomSprite : public CanvasCustomSpriteBaseT
87cdf0e10cSrcweir     {
88cdf0e10cSrcweir     public:
89cdf0e10cSrcweir         /** Create a custom sprite
90cdf0e10cSrcweir 
91cdf0e10cSrcweir 			@param rSpriteSize
92cdf0e10cSrcweir             Size of the sprite in pixel
93cdf0e10cSrcweir 
94cdf0e10cSrcweir             @param rRefDevice
95cdf0e10cSrcweir             Associated output device
96cdf0e10cSrcweir 
97cdf0e10cSrcweir             @param rSpriteCanvas
98cdf0e10cSrcweir             Target canvas
99cdf0e10cSrcweir 
100cdf0e10cSrcweir             @param rDevice
101cdf0e10cSrcweir             Target DX device
102cdf0e10cSrcweir          */
103cdf0e10cSrcweir         CanvasCustomSprite( const ::com::sun::star::geometry::RealSize2D& 	rSpriteSize,
104cdf0e10cSrcweir                             const SpriteCanvasRef&                          rRefDevice,
105cdf0e10cSrcweir                             const IDXRenderModuleSharedPtr&					rRenderModule,
106cdf0e10cSrcweir 							const ::canvas::ISurfaceProxyManagerSharedPtr&	rSurfaceProxy,
107cdf0e10cSrcweir                             bool											bShowSpriteBounds );
108cdf0e10cSrcweir 
109cdf0e10cSrcweir         virtual void SAL_CALL disposing();
110cdf0e10cSrcweir 
111cdf0e10cSrcweir 		// Forwarding the XComponent implementation to the
112cdf0e10cSrcweir         // cppu::ImplHelper templated base
113cdf0e10cSrcweir         //                                    Classname           Base doing refcount          Base implementing the XComponent interface
114cdf0e10cSrcweir         //                                          |                    |                         |
115cdf0e10cSrcweir         //                                          V                    V                         V
116cdf0e10cSrcweir         DECLARE_UNO3_XCOMPONENT_AGG_DEFAULTS( CanvasCustomSprite, CanvasCustomSpriteBase_Base, ::cppu::WeakComponentImplHelperBase );
117cdf0e10cSrcweir 
118cdf0e10cSrcweir         // XServiceInfo
119cdf0e10cSrcweir         virtual ::rtl::OUString SAL_CALL getImplementationName() throw( ::com::sun::star::uno::RuntimeException );
120cdf0e10cSrcweir         virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw( ::com::sun::star::uno::RuntimeException );
121cdf0e10cSrcweir         virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames()  throw( ::com::sun::star::uno::RuntimeException );
122cdf0e10cSrcweir 
123cdf0e10cSrcweir         // Sprite
124cdf0e10cSrcweir         virtual void redraw() const;
125cdf0e10cSrcweir 
126cdf0e10cSrcweir     private:
127cdf0e10cSrcweir         /** MUST hold here, too, since BitmapCanvasHelper only contains a
128cdf0e10cSrcweir             raw pointer (without refcounting)
129cdf0e10cSrcweir         */
130cdf0e10cSrcweir         SpriteCanvasRef          mpSpriteCanvas;
131cdf0e10cSrcweir         DXSurfaceBitmapSharedPtr mpSurface;
132cdf0e10cSrcweir     };
133cdf0e10cSrcweir }
134cdf0e10cSrcweir 
135cdf0e10cSrcweir #endif /* _DXCANVAS_CANVASCUSTOMSPRITE_HXX */
136