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 _VCLCANVAS_SPRITECANVASHELPER_HXX_ 25cdf0e10cSrcweir #define _VCLCANVAS_SPRITECANVASHELPER_HXX_ 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include <com/sun/star/rendering/XSpriteCanvas.hpp> 28cdf0e10cSrcweir #include <com/sun/star/rendering/XIntegerBitmap.hpp> 29cdf0e10cSrcweir 30cdf0e10cSrcweir #include <vcl/virdev.hxx> 31cdf0e10cSrcweir 32cdf0e10cSrcweir #include <canvas/spriteredrawmanager.hxx> 33cdf0e10cSrcweir #include <canvas/elapsedtime.hxx> 34cdf0e10cSrcweir #include <canvas/vclwrapper.hxx> 35cdf0e10cSrcweir #include "canvashelper.hxx" 36cdf0e10cSrcweir #include "impltools.hxx" 37cdf0e10cSrcweir 38cdf0e10cSrcweir 39cdf0e10cSrcweir namespace vclcanvas 40cdf0e10cSrcweir { 41cdf0e10cSrcweir class RedrawManager; 42cdf0e10cSrcweir class SpriteCanvas; 43cdf0e10cSrcweir 44cdf0e10cSrcweir class SpriteCanvasHelper : public CanvasHelper 45cdf0e10cSrcweir { 46cdf0e10cSrcweir public: 47cdf0e10cSrcweir SpriteCanvasHelper(); 48cdf0e10cSrcweir 49cdf0e10cSrcweir void init( const OutDevProviderSharedPtr& rOutDev, 50cdf0e10cSrcweir SpriteCanvas& rOwningSpriteCanvas, 51cdf0e10cSrcweir ::canvas::SpriteRedrawManager& rManager, 52cdf0e10cSrcweir bool bProtect, 53cdf0e10cSrcweir bool bHaveAlpha ); 54cdf0e10cSrcweir 55cdf0e10cSrcweir /// Dispose all internal references 56cdf0e10cSrcweir void disposing(); 57cdf0e10cSrcweir 58cdf0e10cSrcweir // XSpriteCanvas 59cdf0e10cSrcweir ::com::sun::star::uno::Reference< 60cdf0e10cSrcweir ::com::sun::star::rendering::XAnimatedSprite > createSpriteFromAnimation( 61cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XAnimation >& animation ); 62cdf0e10cSrcweir 63cdf0e10cSrcweir ::com::sun::star::uno::Reference< 64cdf0e10cSrcweir ::com::sun::star::rendering::XAnimatedSprite > createSpriteFromBitmaps( 65cdf0e10cSrcweir const ::com::sun::star::uno::Sequence< 66cdf0e10cSrcweir ::com::sun::star::uno::Reference< 67cdf0e10cSrcweir ::com::sun::star::rendering::XBitmap > >& animationBitmaps, 68cdf0e10cSrcweir sal_Int8 interpolationMode ); 69cdf0e10cSrcweir 70cdf0e10cSrcweir ::com::sun::star::uno::Reference< 71cdf0e10cSrcweir ::com::sun::star::rendering::XCustomSprite > createCustomSprite( 72cdf0e10cSrcweir const ::com::sun::star::geometry::RealSize2D& spriteSize ); 73cdf0e10cSrcweir 74cdf0e10cSrcweir ::com::sun::star::uno::Reference< 75cdf0e10cSrcweir ::com::sun::star::rendering::XSprite > createClonedSprite( 76cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XSprite >& original ); 77cdf0e10cSrcweir 78cdf0e10cSrcweir /** Actually perform the screen update 79cdf0e10cSrcweir 80cdf0e10cSrcweir @param bUpdateAll 81cdf0e10cSrcweir sal_True, if everything must be updated, not only changed 82cdf0e10cSrcweir sprites 83cdf0e10cSrcweir 84cdf0e10cSrcweir @param io_bSurfaceDirty 85cdf0e10cSrcweir In/out parameter, whether backbuffer surface is dirty (if 86cdf0e10cSrcweir yes, we're performing a full update, anyway) 87cdf0e10cSrcweir */ 88cdf0e10cSrcweir sal_Bool updateScreen( sal_Bool bUpdateAll, 89cdf0e10cSrcweir bool& io_bSurfaceDirty ); 90cdf0e10cSrcweir 91cdf0e10cSrcweir // SpriteRedrawManager functor calls 92cdf0e10cSrcweir // ------------------------------------------------- 93cdf0e10cSrcweir 94cdf0e10cSrcweir /** Gets called for simple background repaints 95cdf0e10cSrcweir */ 96cdf0e10cSrcweir void backgroundPaint( const ::basegfx::B2DRange& rUpdateRect ); 97cdf0e10cSrcweir 98cdf0e10cSrcweir /** Gets called when area can be handled by scrolling. 99cdf0e10cSrcweir 100cdf0e10cSrcweir Called method must copy screen content from rMoveStart to 101cdf0e10cSrcweir rMoveEnd, and restore the background in the uncovered 102cdf0e10cSrcweir areas. 103cdf0e10cSrcweir 104cdf0e10cSrcweir @param rMoveStart 105cdf0e10cSrcweir Source rect of the scroll 106cdf0e10cSrcweir 107cdf0e10cSrcweir @param rMoveEnd 108cdf0e10cSrcweir Dest rect of the scroll 109cdf0e10cSrcweir 110cdf0e10cSrcweir @param rUpdateArea 111cdf0e10cSrcweir All info necessary, should rMoveStart be partially or 112cdf0e10cSrcweir fully outside the outdev 113cdf0e10cSrcweir */ 114cdf0e10cSrcweir void scrollUpdate( const ::basegfx::B2DRange& rMoveStart, 115cdf0e10cSrcweir const ::basegfx::B2DRange& rMoveEnd, 116cdf0e10cSrcweir const ::canvas::SpriteRedrawManager::UpdateArea& rUpdateArea ); 117cdf0e10cSrcweir 118cdf0e10cSrcweir void opaqueUpdate( const ::basegfx::B2DRange& rTotalArea, 119cdf0e10cSrcweir const ::std::vector< ::canvas::Sprite::Reference >& rSortedUpdateSprites ); 120cdf0e10cSrcweir 121cdf0e10cSrcweir void genericUpdate( const ::basegfx::B2DRange& rTotalArea, 122cdf0e10cSrcweir const ::std::vector< ::canvas::Sprite::Reference >& rSortedUpdateSprites ); 123cdf0e10cSrcweir isUnsafeScrolling() const124cdf0e10cSrcweir ::com::sun::star::uno::Any isUnsafeScrolling() const 125cdf0e10cSrcweir { 126cdf0e10cSrcweir return ::com::sun::star::uno::makeAny(mbIsUnsafeScrolling); 127cdf0e10cSrcweir } enableUnsafeScrolling(const::com::sun::star::uno::Any & rAny)128cdf0e10cSrcweir void enableUnsafeScrolling( const ::com::sun::star::uno::Any& rAny ) 129cdf0e10cSrcweir { 130cdf0e10cSrcweir mbIsUnsafeScrolling = rAny.get<bool>(); 131cdf0e10cSrcweir } 132cdf0e10cSrcweir isSpriteBounds() const133cdf0e10cSrcweir ::com::sun::star::uno::Any isSpriteBounds() const 134cdf0e10cSrcweir { 135cdf0e10cSrcweir return ::com::sun::star::uno::makeAny(mbShowSpriteBounds); 136cdf0e10cSrcweir } enableSpriteBounds(const::com::sun::star::uno::Any & rAny)137cdf0e10cSrcweir void enableSpriteBounds( const ::com::sun::star::uno::Any& rAny ) 138cdf0e10cSrcweir { 139cdf0e10cSrcweir mbShowSpriteBounds = rAny.get<bool>(); 140cdf0e10cSrcweir } 141cdf0e10cSrcweir 142cdf0e10cSrcweir private: 143cdf0e10cSrcweir void renderFrameCounter( OutputDevice& rOutDev ); 144cdf0e10cSrcweir void renderSpriteCount( OutputDevice& rOutDev ); 145cdf0e10cSrcweir void renderMemUsage( OutputDevice& rOutDev ); 146cdf0e10cSrcweir 147cdf0e10cSrcweir /// Set from the SpriteCanvas: instance coordinating sprite redraw 148cdf0e10cSrcweir ::canvas::SpriteRedrawManager* mpRedrawManager; 149cdf0e10cSrcweir 150cdf0e10cSrcweir /// Set from the init method. used to generate sprites 151cdf0e10cSrcweir SpriteCanvas* mpOwningSpriteCanvas; 152cdf0e10cSrcweir 153cdf0e10cSrcweir /** Background compositing surface. 154cdf0e10cSrcweir 155cdf0e10cSrcweir Typically, sprites will be composited in the background, 156cdf0e10cSrcweir before pushing them to screen. This happens here. 157cdf0e10cSrcweir */ 158cdf0e10cSrcweir ::canvas::vcltools::VCLObject< VirtualDevice > maVDev; 159cdf0e10cSrcweir 160cdf0e10cSrcweir /// For the frame counter timings 161cdf0e10cSrcweir ::canvas::tools::ElapsedTime maLastUpdate; 162cdf0e10cSrcweir 163cdf0e10cSrcweir /// When true, canvas displays debug info on each frame 164cdf0e10cSrcweir bool mbShowFrameInfo; 165cdf0e10cSrcweir 166cdf0e10cSrcweir /// When true, canvas creates all new sprites with red lines in the corners 167cdf0e10cSrcweir bool mbShowSpriteBounds; 168cdf0e10cSrcweir 169cdf0e10cSrcweir /// When true, canvas uses the scroll optimization (direct scrolls in front buffer) 170cdf0e10cSrcweir bool mbIsUnsafeScrolling; 171cdf0e10cSrcweir }; 172cdf0e10cSrcweir } 173cdf0e10cSrcweir 174cdf0e10cSrcweir #endif /* _VCLCANVAS_SPRITECANVASHELPER_HXX_ */ 175cdf0e10cSrcweir 176