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 _CAIROCANVAS_SPRITEHELPER_HXX 29 #define _CAIROCANVAS_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 "cairo_spritecanvas.hxx" 40 41 42 namespace cairocanvas 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 rDevice 69 DX device 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 81 void disposing(); 82 83 void setSurface( const ::cairo::SurfaceSharedPtr& pBufferSurface ); 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( const ::cairo::CairoSharedPtr& pCairo, 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 109 SpriteCanvasRef mpSpriteCanvas; 110 ::cairo::SurfaceSharedPtr mpBufferSurface; 111 mutable bool mbTextureDirty; // when true, texture needs update 112 }; 113 } 114 115 #endif /* _CAIROCANVAS_SPRITEHELPER_HXX */ 116