1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef _CAIROCANVAS_SPRITECANVASHELPER_HXX_
25 #define _CAIROCANVAS_SPRITECANVASHELPER_HXX_
26 
27 #include <com/sun/star/rendering/XSpriteCanvas.hpp>
28 #include <com/sun/star/rendering/XIntegerBitmap.hpp>
29 
30 #include <canvas/spriteredrawmanager.hxx>
31 
32 #include "cairo_cairo.hxx"
33 #include "cairo_canvashelper.hxx"
34 
35 namespace basegfx
36 {
37     class B2IRange;
38 }
39 
40 namespace cairocanvas
41 {
42     class SpriteCanvas;
43 
44     class SpriteCanvasHelper : public CanvasHelper
45     {
46     public:
47         SpriteCanvasHelper();
48 
49         void init( ::canvas::SpriteRedrawManager& rManager,
50                    SpriteCanvas&                  rOwningSpriteCanvas,
51                    const ::basegfx::B2ISize&      rSize );
52 
53         /// Dispose all internal references
54         void disposing();
55 
56         // XSpriteCanvas
57         ::com::sun::star::uno::Reference<
58   			::com::sun::star::rendering::XAnimatedSprite > 		createSpriteFromAnimation(
59                 const ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XAnimation >& animation );
60 
61         ::com::sun::star::uno::Reference<
62   			::com::sun::star::rendering::XAnimatedSprite > 		createSpriteFromBitmaps(
63                 const ::com::sun::star::uno::Sequence<
64                 	  ::com::sun::star::uno::Reference<
65                 			::com::sun::star::rendering::XBitmap > >& animationBitmaps,
66                 sal_Int8                                              interpolationMode );
67 
68         ::com::sun::star::uno::Reference<
69   			::com::sun::star::rendering::XCustomSprite > 		createCustomSprite(
70                 const ::com::sun::star::geometry::RealSize2D& spriteSize );
71 
72         ::com::sun::star::uno::Reference<
73   			::com::sun::star::rendering::XSprite > 				createClonedSprite(
74                 const ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XSprite >& original );
75 
76         /** Actually perform the screen update
77 
78             @param rCurrArea
79             Current window area in absolute screen coordinates
80 
81         	@param bUpdateAll
82             sal_True, if everything must be updated, not only changed
83             sprites
84 
85             @param io_bSurfaceDirty
86             In/out parameter, whether backbuffer surface is dirty (if
87             yes, we're performing a full update, anyway)
88          */
89         sal_Bool updateScreen( const ::basegfx::B2IRange& rCurrArea,
90                                sal_Bool                   bUpdateAll,
91                                bool&                      io_bSurfaceDirty );
92 
93 
94         // SpriteRedrawManager functor calls
95         // -------------------------------------------------
96 
97         /** Gets called for simple background repaints
98          */
99         void backgroundPaint( const ::basegfx::B2DRange& rUpdateRect );
100 
101         /** Gets called when area can be handled by scrolling.
102 
103         	Called method must copy screen content from rMoveStart to
104         	rMoveEnd, and restore the background in the uncovered
105         	areas.
106 
107             @param rMoveStart
108             Source rect of the scroll
109 
110             @param rMoveEnd
111             Dest rect of the scroll
112 
113             @param rUpdateArea
114             All info necessary, should rMoveStart be partially or
115             fully outside the outdev
116          */
117         void scrollUpdate( const ::basegfx::B2DRange& 							rMoveStart,
118                            const ::basegfx::B2DRange& 							rMoveEnd,
119                            const ::canvas::SpriteRedrawManager::UpdateArea& 	rUpdateArea );
120 
121         void opaqueUpdate( const ::basegfx::B2DRange&                          rTotalArea,
122                            const ::std::vector< ::canvas::Sprite::Reference >& rSortedUpdateSprites );
123 
124         void genericUpdate( const ::basegfx::B2DRange&                          rTotalArea,
125                             const ::std::vector< ::canvas::Sprite::Reference >& rSortedUpdateSprites );
126 
127     private:
128         ::cairo::SurfaceSharedPtr getCompositingSurface( const ::basegfx::B2ISize& rNeededSize );
129 
130         /// Set from the SpriteCanvas: instance coordinating sprite redraw
131     	::canvas::SpriteRedrawManager*	mpRedrawManager;
132 
133         /// Set from the init method. used to generate sprites
134         SpriteCanvas*                   mpOwningSpriteCanvas;
135 
136         /// a temporary surface used to composite the frontbuffer image
137         ::cairo::SurfaceSharedPtr           mpCompositingSurface;
138         ::basegfx::B2ISize               maCompositingSurfaceSize;
139     };
140 }
141 
142 #endif /* _CAIROCANVAS_SPRITECANVASHELPER_HXX_ */
143 
144