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 10cdf0e10cSrcweir * 11*91c99ff4SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 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. 19cdf0e10cSrcweir * 20*91c99ff4SAndrew Rist *************************************************************/ 21*91c99ff4SAndrew Rist 22*91c99ff4SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir #ifndef _DXCANVAS_SPRITECANVASHELPER_HXX_ 25cdf0e10cSrcweir #define _DXCANVAS_SPRITECANVASHELPER_HXX_ 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include <com/sun/star/rendering/XSpriteCanvas.hpp> 28cdf0e10cSrcweir #include <com/sun/star/rendering/XIntegerBitmap.hpp> 29cdf0e10cSrcweir 30cdf0e10cSrcweir #include <canvas/spriteredrawmanager.hxx> 31cdf0e10cSrcweir #include <canvas/rendering/isurfaceproxy.hxx> 32cdf0e10cSrcweir #include <canvas/rendering/isurfaceproxymanager.hxx> 33cdf0e10cSrcweir 34cdf0e10cSrcweir #include "dx_bitmapcanvashelper.hxx" 35cdf0e10cSrcweir #include "dx_impltools.hxx" 36cdf0e10cSrcweir #include "dx_rendermodule.hxx" 37cdf0e10cSrcweir #include "dx_surfacebitmap.hxx" 38cdf0e10cSrcweir 39cdf0e10cSrcweir #include <basegfx/range/b2irectangle.hxx> 40cdf0e10cSrcweir 41cdf0e10cSrcweir namespace dxcanvas 42cdf0e10cSrcweir { 43cdf0e10cSrcweir class SpriteCanvas; 44cdf0e10cSrcweir 45cdf0e10cSrcweir class SpriteCanvasHelper : public BitmapCanvasHelper 46cdf0e10cSrcweir { 47cdf0e10cSrcweir public: 48cdf0e10cSrcweir SpriteCanvasHelper(); 49cdf0e10cSrcweir 50cdf0e10cSrcweir void init( SpriteCanvas& rParent, 51cdf0e10cSrcweir ::canvas::SpriteRedrawManager& rManager, 52cdf0e10cSrcweir const IDXRenderModuleSharedPtr& rRenderModule, 53cdf0e10cSrcweir const ::canvas::ISurfaceProxyManagerSharedPtr& rSurfaceProxy, 54cdf0e10cSrcweir const DXSurfaceBitmapSharedPtr& rBackBuffer, 55cdf0e10cSrcweir const ::basegfx::B2ISize& rOutputOffset ); 56cdf0e10cSrcweir 57cdf0e10cSrcweir /// Dispose all internal references 58cdf0e10cSrcweir void disposing(); 59cdf0e10cSrcweir 60cdf0e10cSrcweir // XSpriteCanvas 61cdf0e10cSrcweir ::com::sun::star::uno::Reference< 62cdf0e10cSrcweir ::com::sun::star::rendering::XAnimatedSprite > createSpriteFromAnimation( 63cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XAnimation >& animation ); 64cdf0e10cSrcweir 65cdf0e10cSrcweir ::com::sun::star::uno::Reference< 66cdf0e10cSrcweir ::com::sun::star::rendering::XAnimatedSprite > createSpriteFromBitmaps( 67cdf0e10cSrcweir const ::com::sun::star::uno::Sequence< 68cdf0e10cSrcweir ::com::sun::star::uno::Reference< 69cdf0e10cSrcweir ::com::sun::star::rendering::XBitmap > >& animationBitmaps, 70cdf0e10cSrcweir sal_Int8 interpolationMode ); 71cdf0e10cSrcweir 72cdf0e10cSrcweir ::com::sun::star::uno::Reference< 73cdf0e10cSrcweir ::com::sun::star::rendering::XCustomSprite > createCustomSprite( 74cdf0e10cSrcweir const ::com::sun::star::geometry::RealSize2D& spriteSize ); 75cdf0e10cSrcweir 76cdf0e10cSrcweir ::com::sun::star::uno::Reference< 77cdf0e10cSrcweir ::com::sun::star::rendering::XSprite > createClonedSprite( 78cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XSprite >& original ); 79cdf0e10cSrcweir 80cdf0e10cSrcweir /** Actually perform the screen update 81cdf0e10cSrcweir 82cdf0e10cSrcweir @param rCurrArea 83cdf0e10cSrcweir Current window area in absolute screen coordinates 84cdf0e10cSrcweir 85cdf0e10cSrcweir @param bUpdateAll 86cdf0e10cSrcweir sal_True, if everything must be updated, not only changed 87cdf0e10cSrcweir sprites 88cdf0e10cSrcweir 89cdf0e10cSrcweir @param io_bSurfaceDirty 90cdf0e10cSrcweir In/out parameter, whether backbuffer surface is dirty (if 91cdf0e10cSrcweir yes, we're performing a full update, anyway) 92cdf0e10cSrcweir */ 93cdf0e10cSrcweir sal_Bool updateScreen( const ::basegfx::B2IRectangle& rCurrArea, 94cdf0e10cSrcweir sal_Bool bUpdateAll, 95cdf0e10cSrcweir bool& io_bSurfaceDirty ); 96cdf0e10cSrcweir 97cdf0e10cSrcweir 98cdf0e10cSrcweir // SpriteRedrawManager functor calls 99cdf0e10cSrcweir // ------------------------------------------------- 100cdf0e10cSrcweir 101cdf0e10cSrcweir /** Gets called for simple background repaints 102cdf0e10cSrcweir */ 103cdf0e10cSrcweir void backgroundPaint( const ::basegfx::B2DRange& rUpdateRect ); 104cdf0e10cSrcweir 105cdf0e10cSrcweir /** Gets called when area can be handled by scrolling. 106cdf0e10cSrcweir 107cdf0e10cSrcweir Called method must copy screen content from rMoveStart to 108cdf0e10cSrcweir rMoveEnd, and restore the background in the uncovered 109cdf0e10cSrcweir areas. 110cdf0e10cSrcweir 111cdf0e10cSrcweir @param rMoveStart 112cdf0e10cSrcweir Source rect of the scroll 113cdf0e10cSrcweir 114cdf0e10cSrcweir @param rMoveEnd 115cdf0e10cSrcweir Dest rect of the scroll 116cdf0e10cSrcweir 117cdf0e10cSrcweir @param rUpdateArea 118cdf0e10cSrcweir All info necessary, should rMoveStart be partially or 119cdf0e10cSrcweir fully outside the outdev 120cdf0e10cSrcweir */ 121cdf0e10cSrcweir void scrollUpdate( const ::basegfx::B2DRange& rMoveStart, 122cdf0e10cSrcweir const ::basegfx::B2DRange& rMoveEnd, 123cdf0e10cSrcweir const ::canvas::SpriteRedrawManager::UpdateArea& rUpdateArea ); 124cdf0e10cSrcweir 125cdf0e10cSrcweir void opaqueUpdate( const ::basegfx::B2DRange& rTotalArea, 126cdf0e10cSrcweir const ::std::vector< ::canvas::Sprite::Reference >& rSortedUpdateSprites ); 127cdf0e10cSrcweir 128cdf0e10cSrcweir void genericUpdate( const ::basegfx::B2DRange& rTotalArea, 129cdf0e10cSrcweir const ::std::vector< ::canvas::Sprite::Reference >& rSortedUpdateSprites ); 130cdf0e10cSrcweir 131cdf0e10cSrcweir private: 132cdf0e10cSrcweir /// For generating sprites 133cdf0e10cSrcweir SpriteCanvas* mpSpriteSurface; 134cdf0e10cSrcweir 135cdf0e10cSrcweir /// Set from the SpriteCanvas: instance coordinating sprite redraw 136cdf0e10cSrcweir ::canvas::SpriteRedrawManager* mpRedrawManager; 137cdf0e10cSrcweir 138cdf0e10cSrcweir /// DX device, handling all low-level rendering 139cdf0e10cSrcweir IDXRenderModuleSharedPtr mpRenderModule; 140cdf0e10cSrcweir 141cdf0e10cSrcweir ::canvas::ISurfaceProxyManagerSharedPtr mpSurfaceProxy; 142cdf0e10cSrcweir 143cdf0e10cSrcweir /// Backbuffer, contains the static canvas render output 144cdf0e10cSrcweir DXSurfaceBitmapSharedPtr mpBackBuffer; 145cdf0e10cSrcweir 146cdf0e10cSrcweir /// Completely temporary rect storage (used by sprite repaint) 147cdf0e10cSrcweir mutable ::basegfx::B2IRange maUpdateRect; 148cdf0e10cSrcweir 149cdf0e10cSrcweir /// Completely temporary rect storage (used by sprite repaint) 150cdf0e10cSrcweir mutable ::basegfx::B2IRange maScrapRect; 151cdf0e10cSrcweir 152cdf0e10cSrcweir /// When true, show small bound rects around each sprite 153cdf0e10cSrcweir bool mbShowSpriteBounds; 154cdf0e10cSrcweir }; 155cdf0e10cSrcweir } 156cdf0e10cSrcweir 157cdf0e10cSrcweir #endif /* _DXCANVAS_SPRITECANVASHELPER_HXX_ */ 158