1*91c99ff4SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*91c99ff4SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*91c99ff4SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*91c99ff4SAndrew Rist * distributed with this work for additional information 6*91c99ff4SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*91c99ff4SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*91c99ff4SAndrew Rist * "License"); you may not use this file except in compliance 9*91c99ff4SAndrew Rist * with the License. You may obtain a copy of the License at 10*91c99ff4SAndrew Rist * 11*91c99ff4SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*91c99ff4SAndrew Rist * 13*91c99ff4SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*91c99ff4SAndrew Rist * software distributed under the License is distributed on an 15*91c99ff4SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*91c99ff4SAndrew Rist * KIND, either express or implied. See the License for the 17*91c99ff4SAndrew Rist * specific language governing permissions and limitations 18*91c99ff4SAndrew Rist * under the License. 19*91c99ff4SAndrew Rist * 20*91c99ff4SAndrew Rist *************************************************************/ 21*91c99ff4SAndrew Rist 22*91c99ff4SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir #ifndef _DXCANVAS_SPRITEHELPER_HXX 25cdf0e10cSrcweir #define _DXCANVAS_SPRITEHELPER_HXX 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include <com/sun/star/rendering/XCustomSprite.hpp> 28cdf0e10cSrcweir 29cdf0e10cSrcweir #include <canvas/base/canvascustomspritehelper.hxx> 30cdf0e10cSrcweir 31cdf0e10cSrcweir #include <basegfx/point/b2dpoint.hxx> 32cdf0e10cSrcweir #include <basegfx/vector/b2isize.hxx> 33cdf0e10cSrcweir #include <basegfx/matrix/b2dhommatrix.hxx> 34cdf0e10cSrcweir 35cdf0e10cSrcweir #include "dx_spritecanvas.hxx" 36cdf0e10cSrcweir #include "dx_surfacebitmap.hxx" 37cdf0e10cSrcweir 38cdf0e10cSrcweir namespace dxcanvas 39cdf0e10cSrcweir { 40cdf0e10cSrcweir /* Definition of SpriteHelper class */ 41cdf0e10cSrcweir 42cdf0e10cSrcweir /** Helper class for canvas sprites. 43cdf0e10cSrcweir 44cdf0e10cSrcweir This class implements all sprite-related functionality, like 45cdf0e10cSrcweir that available on the XSprite interface. 46cdf0e10cSrcweir */ 47cdf0e10cSrcweir class SpriteHelper : public ::canvas::CanvasCustomSpriteHelper 48cdf0e10cSrcweir { 49cdf0e10cSrcweir public: 50cdf0e10cSrcweir /** Create sprite helper 51cdf0e10cSrcweir */ 52cdf0e10cSrcweir SpriteHelper(); 53cdf0e10cSrcweir 54cdf0e10cSrcweir /** Late-init the sprite helper 55cdf0e10cSrcweir 56cdf0e10cSrcweir @param rSpriteSize 57cdf0e10cSrcweir Size of the sprite 58cdf0e10cSrcweir 59cdf0e10cSrcweir @param rSpriteCanvas 60cdf0e10cSrcweir Sprite canvas this sprite is part of. Object stores 61cdf0e10cSrcweir ref-counted reference to it, thus, don't forget to pass on 62cdf0e10cSrcweir disposing()! 63cdf0e10cSrcweir 64cdf0e10cSrcweir @param rRenderModule 65cdf0e10cSrcweir rendermodule to use 66cdf0e10cSrcweir 67cdf0e10cSrcweir @param rSpriteSurface 68cdf0e10cSrcweir The surface of the sprite (not the DX texture, but the 69cdf0e10cSrcweir persistent target of content rendering) 70cdf0e10cSrcweir 71cdf0e10cSrcweir @param bShowSpriteBounds 72cdf0e10cSrcweir When true, little debug bound rects for sprites are shown 73cdf0e10cSrcweir */ 74cdf0e10cSrcweir void init( const ::com::sun::star::geometry::RealSize2D& rSpriteSize, 75cdf0e10cSrcweir const SpriteCanvasRef& rSpriteCanvas, 76cdf0e10cSrcweir const IDXRenderModuleSharedPtr& rRenderModule, 77cdf0e10cSrcweir const DXSurfaceBitmapSharedPtr rBitmap, 78cdf0e10cSrcweir bool bShowSpriteBounds ); 79cdf0e10cSrcweir 80cdf0e10cSrcweir void disposing(); 81cdf0e10cSrcweir 82cdf0e10cSrcweir /** Repaint sprite content via hardware to associated sprite 83cdf0e10cSrcweir canvas 84cdf0e10cSrcweir 85cdf0e10cSrcweir @param io_bSurfaceDirty 86cdf0e10cSrcweir Input/output parameter, whether the sprite content is 87cdf0e10cSrcweir dirty or not. If texture was updated, set to false 88cdf0e10cSrcweir 89cdf0e10cSrcweir */ 90cdf0e10cSrcweir void redraw( bool& io_bSurfaceDirty ) const; 91cdf0e10cSrcweir 92cdf0e10cSrcweir private: 93cdf0e10cSrcweir virtual ::basegfx::B2DPolyPolygon polyPolygonFromXPolyPolygon2D( 94cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XPolyPolygon2D >& xPoly ) const; 95cdf0e10cSrcweir 96cdf0e10cSrcweir /// Returns true, if the sprite _really_ needs redraw 97cdf0e10cSrcweir bool needRedraw() const; 98cdf0e10cSrcweir 99cdf0e10cSrcweir SpriteCanvasRef mpSpriteCanvas; 100cdf0e10cSrcweir 101cdf0e10cSrcweir DXSurfaceBitmapSharedPtr mpBitmap; 102cdf0e10cSrcweir mutable bool mbTextureDirty; // when true, texture needs update 103cdf0e10cSrcweir bool mbShowSpriteBounds; // when true, debug bound rect for sprites is shown 104cdf0e10cSrcweir }; 105cdf0e10cSrcweir } 106cdf0e10cSrcweir 107cdf0e10cSrcweir #endif /* _DXCANVAS_SPRITEHELPER_HXX */ 108