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_SPRITEHELPER_HXX
25 #define _CAIROCANVAS_SPRITEHELPER_HXX
26 
27 #include <com/sun/star/rendering/XCustomSprite.hpp>
28 
29 #include <canvas/base/canvascustomspritehelper.hxx>
30 
31 #include <basegfx/point/b2dpoint.hxx>
32 #include <basegfx/vector/b2isize.hxx>
33 #include <basegfx/matrix/b2dhommatrix.hxx>
34 
35 #include "cairo_spritecanvas.hxx"
36 
37 
38 namespace cairocanvas
39 {
40 	/* Definition of SpriteHelper class */
41 
42     /** Helper class for canvas sprites.
43 
44     	This class implements all sprite-related functionality, like
45     	that available on the XSprite interface.
46      */
47     class SpriteHelper : public ::canvas::CanvasCustomSpriteHelper
48     {
49     public:
50         /** Create sprite helper
51          */
52         SpriteHelper();
53 
54         /** Late-init the sprite helper
55 
56         	@param rSpriteSize
57             Size of the sprite
58 
59             @param rSpriteCanvas
60             Sprite canvas this sprite is part of. Object stores
61             ref-counted reference to it, thus, don't forget to pass on
62             disposing()!
63 
64             @param rDevice
65             DX device to use
66 
67             @param rSpriteSurface
68             The surface of the sprite (not the DX texture, but the
69             persistent target of content rendering)
70 
71             @param bShowSpriteBounds
72             When true, little debug bound rects for sprites are shown
73          */
74         void init( const ::com::sun::star::geometry::RealSize2D& rSpriteSize,
75                    const SpriteCanvasRef&					     rSpriteCanvas );
76 
77         void disposing();
78 
79 		void setSurface( const ::cairo::SurfaceSharedPtr& pBufferSurface );
80 
81         /** Repaint sprite content to associated sprite canvas
82 
83         	@param rPos
84             Output position (sprite's own position is disregarded)
85 
86             @param io_bSurfacesDirty
87             When true, the referenced sprite surfaces (backBuffer and
88             backBufferMask) have been modified since last call.
89 
90             @param bBufferedUpdate
91             When true, the redraw does <em>not</em> happen directly on
92             the front buffer, but within a VDev. Used to speed up
93             drawing.
94          */
95         void redraw( const ::cairo::CairoSharedPtr& pCairo,
96                      const ::basegfx::B2DPoint&     rPos,
97                      bool& 						    bSurfacesDirty,
98                      bool                           bBufferedUpdate ) const;
99 
100     private:
101         virtual ::basegfx::B2DPolyPolygon polyPolygonFromXPolyPolygon2D(
102             ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XPolyPolygon2D >& xPoly ) const;
103 
104 
105         SpriteCanvasRef           mpSpriteCanvas;
106         ::cairo::SurfaceSharedPtr mpBufferSurface;
107         mutable bool              mbTextureDirty;  // when true, texture needs update
108     };
109 }
110 
111 #endif /* _CAIROCANVAS_SPRITEHELPER_HXX */
112