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 _VCLCANVAS_SPRITEHELPER_HXX
25 #define _VCLCANVAS_SPRITEHELPER_HXX
26 
27 #include <com/sun/star/rendering/XCustomSprite.hpp>
28 
29 #include <vcl/virdev.hxx>
30 
31 #include <canvas/base/canvascustomspritehelper.hxx>
32 #include <canvas/base/spritesurface.hxx>
33 #include <canvas/vclwrapper.hxx>
34 
35 #include "backbuffer.hxx"
36 #include "impltools.hxx"
37 #include "spritecanvas.hxx"
38 
39 
40 namespace vclcanvas
41 {
42 	/* Definition of SpriteHelper class */
43 
44     /** Helper class for canvas sprites.
45 
46     	This class implements all sprite-related functionality, like
47     	that available on the XSprite interface.
48      */
49     class SpriteHelper : public ::canvas::CanvasCustomSpriteHelper
50     {
51     public:
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 rBackBuffer
68             Buffer of the sprite content (non-alpha part)
69 
70             @param rBackBufferMask
71             Buffer of the sprite content (alpha part)
72          */
73         void init( const ::com::sun::star::geometry::RealSize2D& rSpriteSize,
74                    const ::canvas::SpriteSurface::Reference&     rOwningSpriteCanvas,
75                    const BackBufferSharedPtr&					 rBackBuffer,
76                    const BackBufferSharedPtr&					 rBackBufferMask,
77                    bool											 bShowSpriteBounds );
78 
79         void disposing();
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( OutputDevice&              rOutDev,
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         // for the redraw
105         BackBufferSharedPtr									mpBackBuffer;
106         BackBufferSharedPtr									mpBackBufferMask;
107 
108         /// Cached bitmap for the current sprite content
109         mutable ::canvas::vcltools::VCLObject<BitmapEx>		maContent;
110 
111         /// When true, line sprite corners in red
112         bool                                                mbShowSpriteBounds;
113 
114     };
115 }
116 
117 #endif /* _VCLCANVAS_SPRITEHELPER_HXX */
118