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 _DXCANVAS_SPRITEHELPER_HXX 29 #define _DXCANVAS_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 "dx_spritecanvas.hxx" 40 #include "dx_surfacebitmap.hxx" 41 42 namespace dxcanvas 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 /** Late-init the sprite helper 59 60 @param rSpriteSize 61 Size of the sprite 62 63 @param rSpriteCanvas 64 Sprite canvas this sprite is part of. Object stores 65 ref-counted reference to it, thus, don't forget to pass on 66 disposing()! 67 68 @param rRenderModule 69 rendermodule to use 70 71 @param rSpriteSurface 72 The surface of the sprite (not the DX texture, but the 73 persistent target of content rendering) 74 75 @param bShowSpriteBounds 76 When true, little debug bound rects for sprites are shown 77 */ 78 void init( const ::com::sun::star::geometry::RealSize2D& rSpriteSize, 79 const SpriteCanvasRef& rSpriteCanvas, 80 const IDXRenderModuleSharedPtr& rRenderModule, 81 const DXSurfaceBitmapSharedPtr rBitmap, 82 bool bShowSpriteBounds ); 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 */ 94 void redraw( bool& io_bSurfaceDirty ) const; 95 96 private: 97 virtual ::basegfx::B2DPolyPolygon polyPolygonFromXPolyPolygon2D( 98 ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XPolyPolygon2D >& xPoly ) const; 99 100 /// Returns true, if the sprite _really_ needs redraw 101 bool needRedraw() const; 102 103 SpriteCanvasRef mpSpriteCanvas; 104 105 DXSurfaceBitmapSharedPtr mpBitmap; 106 mutable bool mbTextureDirty; // when true, texture needs update 107 bool mbShowSpriteBounds; // when true, debug bound rect for sprites is shown 108 }; 109 } 110 111 #endif /* _DXCANVAS_SPRITEHELPER_HXX */ 112