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