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