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 _NULLCANVAS_SPRITEHELPER_HXX
25 #define _NULLCANVAS_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 "null_spritecanvas.hxx"
36 
37 
38 namespace nullcanvas
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         // make CanvasCustomSpriteHelper::init visible for name lookup
55         using ::canvas::CanvasCustomSpriteHelper::init;
56 
57         /** Late-init the sprite helper
58 
59         	@param rSpriteSize
60             Size of the sprite
61 
62             @param rSpriteCanvas
63             Sprite canvas this sprite is part of. Object stores
64             ref-counted reference to it, thus, don't forget to pass on
65             disposing()!
66 
67             @param rDevice
68             DX device to use
69 
70             @param rSpriteSurface
71             The surface of the sprite (not the DX texture, but the
72             persistent target of content rendering)
73 
74             @param bShowSpriteBounds
75             When true, little debug bound rects for sprites are shown
76          */
77         void init( const ::com::sun::star::geometry::RealSize2D&	rSpriteSize,
78                    const SpriteCanvasRef&							rSpriteCanvas );
79 
80         void disposing();
81 
82         /** Repaint sprite content via hardware to associated sprite
83             canvas
84 
85             @param io_bSurfaceDirty
86             Input/output parameter, whether the sprite content is
87             dirty or not. If texture was updated, set to false
88          */
89         void redraw( bool& io_bSurfaceDirty ) const;
90 
91     private:
92         virtual ::basegfx::B2DPolyPolygon polyPolygonFromXPolyPolygon2D(
93             ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XPolyPolygon2D >& xPoly ) const;
94 
95 
96         SpriteCanvasRef				mpSpriteCanvas;
97         mutable bool                mbTextureDirty;  // when true, texture needs update
98     };
99 }
100 
101 #endif /* _NULLCANVAS_SPRITEHELPER_HXX */
102