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 _VCLCANVAS_SPRITEHELPER_HXX 29 #define _VCLCANVAS_SPRITEHELPER_HXX 30 31 #include <com/sun/star/rendering/XCustomSprite.hpp> 32 33 #include <vcl/virdev.hxx> 34 35 #include <canvas/base/canvascustomspritehelper.hxx> 36 #include <canvas/base/spritesurface.hxx> 37 #include <canvas/vclwrapper.hxx> 38 39 #include "backbuffer.hxx" 40 #include "impltools.hxx" 41 #include "spritecanvas.hxx" 42 43 44 namespace vclcanvas 45 { 46 /* Definition of SpriteHelper class */ 47 48 /** Helper class for canvas sprites. 49 50 This class implements all sprite-related functionality, like 51 that available on the XSprite interface. 52 */ 53 class SpriteHelper : public ::canvas::CanvasCustomSpriteHelper 54 { 55 public: 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 rBackBuffer 72 Buffer of the sprite content (non-alpha part) 73 74 @param rBackBufferMask 75 Buffer of the sprite content (alpha part) 76 */ 77 void init( const ::com::sun::star::geometry::RealSize2D& rSpriteSize, 78 const ::canvas::SpriteSurface::Reference& rOwningSpriteCanvas, 79 const BackBufferSharedPtr& rBackBuffer, 80 const BackBufferSharedPtr& rBackBufferMask, 81 bool bShowSpriteBounds ); 82 83 void disposing(); 84 85 /** Repaint sprite content to associated sprite canvas 86 87 @param rPos 88 Output position (sprite's own position is disregarded) 89 90 @param io_bSurfacesDirty 91 When true, the referenced sprite surfaces (backBuffer and 92 backBufferMask) have been modified since last call. 93 94 @param bBufferedUpdate 95 When true, the redraw does <em>not</em> happen directly on 96 the front buffer, but within a VDev. Used to speed up 97 drawing. 98 */ 99 void redraw( OutputDevice& rOutDev, 100 const ::basegfx::B2DPoint& rPos, 101 bool& bSurfacesDirty, 102 bool bBufferedUpdate ) const; 103 104 private: 105 virtual ::basegfx::B2DPolyPolygon polyPolygonFromXPolyPolygon2D( 106 ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XPolyPolygon2D >& xPoly ) const; 107 108 // for the redraw 109 BackBufferSharedPtr mpBackBuffer; 110 BackBufferSharedPtr mpBackBufferMask; 111 112 /// Cached bitmap for the current sprite content 113 mutable ::canvas::vcltools::VCLObject<BitmapEx> maContent; 114 115 /// When true, line sprite corners in red 116 bool mbShowSpriteBounds; 117 118 }; 119 } 120 121 #endif /* _VCLCANVAS_SPRITEHELPER_HXX */ 122