xref: /AOO41X/main/canvas/source/directx/dx_spritecanvashelper.hxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir #ifndef _DXCANVAS_SPRITECANVASHELPER_HXX_
29*cdf0e10cSrcweir #define _DXCANVAS_SPRITECANVASHELPER_HXX_
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir #include <com/sun/star/rendering/XSpriteCanvas.hpp>
32*cdf0e10cSrcweir #include <com/sun/star/rendering/XIntegerBitmap.hpp>
33*cdf0e10cSrcweir 
34*cdf0e10cSrcweir #include <canvas/spriteredrawmanager.hxx>
35*cdf0e10cSrcweir #include <canvas/rendering/isurfaceproxy.hxx>
36*cdf0e10cSrcweir #include <canvas/rendering/isurfaceproxymanager.hxx>
37*cdf0e10cSrcweir 
38*cdf0e10cSrcweir #include "dx_bitmapcanvashelper.hxx"
39*cdf0e10cSrcweir #include "dx_impltools.hxx"
40*cdf0e10cSrcweir #include "dx_rendermodule.hxx"
41*cdf0e10cSrcweir #include "dx_surfacebitmap.hxx"
42*cdf0e10cSrcweir 
43*cdf0e10cSrcweir #include <basegfx/range/b2irectangle.hxx>
44*cdf0e10cSrcweir 
45*cdf0e10cSrcweir namespace dxcanvas
46*cdf0e10cSrcweir {
47*cdf0e10cSrcweir     class SpriteCanvas;
48*cdf0e10cSrcweir 
49*cdf0e10cSrcweir     class SpriteCanvasHelper : public BitmapCanvasHelper
50*cdf0e10cSrcweir     {
51*cdf0e10cSrcweir     public:
52*cdf0e10cSrcweir         SpriteCanvasHelper();
53*cdf0e10cSrcweir 
54*cdf0e10cSrcweir         void init( SpriteCanvas&                                    rParent,
55*cdf0e10cSrcweir                    ::canvas::SpriteRedrawManager&					rManager,
56*cdf0e10cSrcweir                    const IDXRenderModuleSharedPtr&					rRenderModule,
57*cdf0e10cSrcweir 				   const ::canvas::ISurfaceProxyManagerSharedPtr&	rSurfaceProxy,
58*cdf0e10cSrcweir                    const DXSurfaceBitmapSharedPtr&					rBackBuffer,
59*cdf0e10cSrcweir                    const ::basegfx::B2ISize&						rOutputOffset );
60*cdf0e10cSrcweir 
61*cdf0e10cSrcweir         /// Dispose all internal references
62*cdf0e10cSrcweir         void disposing();
63*cdf0e10cSrcweir 
64*cdf0e10cSrcweir         // XSpriteCanvas
65*cdf0e10cSrcweir         ::com::sun::star::uno::Reference<
66*cdf0e10cSrcweir   			::com::sun::star::rendering::XAnimatedSprite > 		createSpriteFromAnimation(
67*cdf0e10cSrcweir                 const ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XAnimation >& animation );
68*cdf0e10cSrcweir 
69*cdf0e10cSrcweir         ::com::sun::star::uno::Reference<
70*cdf0e10cSrcweir   			::com::sun::star::rendering::XAnimatedSprite > 		createSpriteFromBitmaps(
71*cdf0e10cSrcweir                 const ::com::sun::star::uno::Sequence<
72*cdf0e10cSrcweir                 	  ::com::sun::star::uno::Reference<
73*cdf0e10cSrcweir                 			::com::sun::star::rendering::XBitmap > >& animationBitmaps,
74*cdf0e10cSrcweir                 sal_Int8                                              interpolationMode );
75*cdf0e10cSrcweir 
76*cdf0e10cSrcweir         ::com::sun::star::uno::Reference<
77*cdf0e10cSrcweir   			::com::sun::star::rendering::XCustomSprite > 		createCustomSprite(
78*cdf0e10cSrcweir                 const ::com::sun::star::geometry::RealSize2D& spriteSize );
79*cdf0e10cSrcweir 
80*cdf0e10cSrcweir         ::com::sun::star::uno::Reference<
81*cdf0e10cSrcweir   			::com::sun::star::rendering::XSprite > 				createClonedSprite(
82*cdf0e10cSrcweir                 const ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XSprite >& original );
83*cdf0e10cSrcweir 
84*cdf0e10cSrcweir         /** Actually perform the screen update
85*cdf0e10cSrcweir 
86*cdf0e10cSrcweir             @param rCurrArea
87*cdf0e10cSrcweir             Current window area in absolute screen coordinates
88*cdf0e10cSrcweir 
89*cdf0e10cSrcweir         	@param bUpdateAll
90*cdf0e10cSrcweir             sal_True, if everything must be updated, not only changed
91*cdf0e10cSrcweir             sprites
92*cdf0e10cSrcweir 
93*cdf0e10cSrcweir             @param io_bSurfaceDirty
94*cdf0e10cSrcweir             In/out parameter, whether backbuffer surface is dirty (if
95*cdf0e10cSrcweir             yes, we're performing a full update, anyway)
96*cdf0e10cSrcweir          */
97*cdf0e10cSrcweir         sal_Bool updateScreen( const ::basegfx::B2IRectangle& rCurrArea,
98*cdf0e10cSrcweir                                sal_Bool                       bUpdateAll,
99*cdf0e10cSrcweir                                bool&                          io_bSurfaceDirty );
100*cdf0e10cSrcweir 
101*cdf0e10cSrcweir 
102*cdf0e10cSrcweir         // SpriteRedrawManager functor calls
103*cdf0e10cSrcweir         // -------------------------------------------------
104*cdf0e10cSrcweir 
105*cdf0e10cSrcweir         /** Gets called for simple background repaints
106*cdf0e10cSrcweir          */
107*cdf0e10cSrcweir         void backgroundPaint( const ::basegfx::B2DRange& rUpdateRect );
108*cdf0e10cSrcweir 
109*cdf0e10cSrcweir         /** Gets called when area can be handled by scrolling.
110*cdf0e10cSrcweir 
111*cdf0e10cSrcweir         	Called method must copy screen content from rMoveStart to
112*cdf0e10cSrcweir         	rMoveEnd, and restore the background in the uncovered
113*cdf0e10cSrcweir         	areas.
114*cdf0e10cSrcweir 
115*cdf0e10cSrcweir             @param rMoveStart
116*cdf0e10cSrcweir             Source rect of the scroll
117*cdf0e10cSrcweir 
118*cdf0e10cSrcweir             @param rMoveEnd
119*cdf0e10cSrcweir             Dest rect of the scroll
120*cdf0e10cSrcweir 
121*cdf0e10cSrcweir             @param rUpdateArea
122*cdf0e10cSrcweir             All info necessary, should rMoveStart be partially or
123*cdf0e10cSrcweir             fully outside the outdev
124*cdf0e10cSrcweir          */
125*cdf0e10cSrcweir         void scrollUpdate( const ::basegfx::B2DRange& 							rMoveStart,
126*cdf0e10cSrcweir                            const ::basegfx::B2DRange& 							rMoveEnd,
127*cdf0e10cSrcweir                            const ::canvas::SpriteRedrawManager::UpdateArea& 	rUpdateArea );
128*cdf0e10cSrcweir 
129*cdf0e10cSrcweir         void opaqueUpdate( const ::basegfx::B2DRange&                          rTotalArea,
130*cdf0e10cSrcweir                            const ::std::vector< ::canvas::Sprite::Reference >& rSortedUpdateSprites );
131*cdf0e10cSrcweir 
132*cdf0e10cSrcweir         void genericUpdate( const ::basegfx::B2DRange&                          rTotalArea,
133*cdf0e10cSrcweir                             const ::std::vector< ::canvas::Sprite::Reference >& rSortedUpdateSprites );
134*cdf0e10cSrcweir 
135*cdf0e10cSrcweir     private:
136*cdf0e10cSrcweir         /// For generating sprites
137*cdf0e10cSrcweir         SpriteCanvas*                                   mpSpriteSurface;
138*cdf0e10cSrcweir 
139*cdf0e10cSrcweir         /// Set from the SpriteCanvas: instance coordinating sprite redraw
140*cdf0e10cSrcweir     	::canvas::SpriteRedrawManager*					mpRedrawManager;
141*cdf0e10cSrcweir 
142*cdf0e10cSrcweir         /// DX device, handling all low-level rendering
143*cdf0e10cSrcweir         IDXRenderModuleSharedPtr						mpRenderModule;
144*cdf0e10cSrcweir 
145*cdf0e10cSrcweir 		::canvas::ISurfaceProxyManagerSharedPtr			mpSurfaceProxy;
146*cdf0e10cSrcweir 
147*cdf0e10cSrcweir         /// Backbuffer, contains the static canvas render output
148*cdf0e10cSrcweir 		DXSurfaceBitmapSharedPtr						mpBackBuffer;
149*cdf0e10cSrcweir 
150*cdf0e10cSrcweir         /// Completely temporary rect storage (used by sprite repaint)
151*cdf0e10cSrcweir         mutable ::basegfx::B2IRange                     maUpdateRect;
152*cdf0e10cSrcweir 
153*cdf0e10cSrcweir         /// Completely temporary rect storage (used by sprite repaint)
154*cdf0e10cSrcweir         mutable ::basegfx::B2IRange                     maScrapRect;
155*cdf0e10cSrcweir 
156*cdf0e10cSrcweir         /// When true, show small bound rects around each sprite
157*cdf0e10cSrcweir         bool                                            mbShowSpriteBounds;
158*cdf0e10cSrcweir     };
159*cdf0e10cSrcweir }
160*cdf0e10cSrcweir 
161*cdf0e10cSrcweir #endif /* _DXCANVAS_SPRITECANVASHELPER_HXX_ */
162