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 _NULLCANVAS_SPRITEHELPER_HXX
29 #define _NULLCANVAS_SPRITEHELPER_HXX
30 
31 #include <com/sun/star/rendering/XCustomSprite.hpp>
32 
33 #include <canvas/base/canvascustomspritehelper.hxx>
34 
35 #include <basegfx/point/b2dpoint.hxx>
36 #include <basegfx/vector/b2isize.hxx>
37 #include <basegfx/matrix/b2dhommatrix.hxx>
38 
39 #include "null_spritecanvas.hxx"
40 
41 
42 namespace nullcanvas
43 {
44 	/* Definition of SpriteHelper class */
45 
46     /** Helper class for canvas sprites.
47 
48     	This class implements all sprite-related functionality, like
49     	that available on the XSprite interface.
50      */
51     class SpriteHelper : public ::canvas::CanvasCustomSpriteHelper
52     {
53     public:
54         /** Create sprite helper
55          */
56         SpriteHelper();
57 
58         // make CanvasCustomSpriteHelper::init visible for name lookup
59         using ::canvas::CanvasCustomSpriteHelper::init;
60 
61         /** Late-init the sprite helper
62 
63         	@param rSpriteSize
64             Size of the sprite
65 
66             @param rSpriteCanvas
67             Sprite canvas this sprite is part of. Object stores
68             ref-counted reference to it, thus, don't forget to pass on
69             disposing()!
70 
71             @param rDevice
72             DX device to use
73 
74             @param rSpriteSurface
75             The surface of the sprite (not the DX texture, but the
76             persistent target of content rendering)
77 
78             @param bShowSpriteBounds
79             When true, little debug bound rects for sprites are shown
80          */
81         void init( const ::com::sun::star::geometry::RealSize2D&	rSpriteSize,
82                    const SpriteCanvasRef&							rSpriteCanvas );
83 
84         void disposing();
85 
86         /** Repaint sprite content via hardware to associated sprite
87             canvas
88 
89             @param io_bSurfaceDirty
90             Input/output parameter, whether the sprite content is
91             dirty or not. If texture was updated, set to false
92          */
93         void redraw( bool& io_bSurfaceDirty ) const;
94 
95     private:
96         virtual ::basegfx::B2DPolyPolygon polyPolygonFromXPolyPolygon2D(
97             ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XPolyPolygon2D >& xPoly ) const;
98 
99 
100         SpriteCanvasRef				mpSpriteCanvas;
101         mutable bool                mbTextureDirty;  // when true, texture needs update
102     };
103 }
104 
105 #endif /* _NULLCANVAS_SPRITEHELPER_HXX */
106