1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir #ifndef _VCLCANVAS_SPRITECANVASHELPER_HXX_ 29*cdf0e10cSrcweir #define _VCLCANVAS_SPRITECANVASHELPER_HXX_ 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir #include <com/sun/star/rendering/XSpriteCanvas.hpp> 32*cdf0e10cSrcweir #include <com/sun/star/rendering/XIntegerBitmap.hpp> 33*cdf0e10cSrcweir 34*cdf0e10cSrcweir #include <vcl/virdev.hxx> 35*cdf0e10cSrcweir 36*cdf0e10cSrcweir #include <canvas/spriteredrawmanager.hxx> 37*cdf0e10cSrcweir #include <canvas/elapsedtime.hxx> 38*cdf0e10cSrcweir #include <canvas/vclwrapper.hxx> 39*cdf0e10cSrcweir #include "canvashelper.hxx" 40*cdf0e10cSrcweir #include "impltools.hxx" 41*cdf0e10cSrcweir 42*cdf0e10cSrcweir 43*cdf0e10cSrcweir namespace vclcanvas 44*cdf0e10cSrcweir { 45*cdf0e10cSrcweir class RedrawManager; 46*cdf0e10cSrcweir class SpriteCanvas; 47*cdf0e10cSrcweir 48*cdf0e10cSrcweir class SpriteCanvasHelper : public CanvasHelper 49*cdf0e10cSrcweir { 50*cdf0e10cSrcweir public: 51*cdf0e10cSrcweir SpriteCanvasHelper(); 52*cdf0e10cSrcweir 53*cdf0e10cSrcweir void init( const OutDevProviderSharedPtr& rOutDev, 54*cdf0e10cSrcweir SpriteCanvas& rOwningSpriteCanvas, 55*cdf0e10cSrcweir ::canvas::SpriteRedrawManager& rManager, 56*cdf0e10cSrcweir bool bProtect, 57*cdf0e10cSrcweir bool bHaveAlpha ); 58*cdf0e10cSrcweir 59*cdf0e10cSrcweir /// Dispose all internal references 60*cdf0e10cSrcweir void disposing(); 61*cdf0e10cSrcweir 62*cdf0e10cSrcweir // XSpriteCanvas 63*cdf0e10cSrcweir ::com::sun::star::uno::Reference< 64*cdf0e10cSrcweir ::com::sun::star::rendering::XAnimatedSprite > createSpriteFromAnimation( 65*cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XAnimation >& animation ); 66*cdf0e10cSrcweir 67*cdf0e10cSrcweir ::com::sun::star::uno::Reference< 68*cdf0e10cSrcweir ::com::sun::star::rendering::XAnimatedSprite > createSpriteFromBitmaps( 69*cdf0e10cSrcweir const ::com::sun::star::uno::Sequence< 70*cdf0e10cSrcweir ::com::sun::star::uno::Reference< 71*cdf0e10cSrcweir ::com::sun::star::rendering::XBitmap > >& animationBitmaps, 72*cdf0e10cSrcweir sal_Int8 interpolationMode ); 73*cdf0e10cSrcweir 74*cdf0e10cSrcweir ::com::sun::star::uno::Reference< 75*cdf0e10cSrcweir ::com::sun::star::rendering::XCustomSprite > createCustomSprite( 76*cdf0e10cSrcweir const ::com::sun::star::geometry::RealSize2D& spriteSize ); 77*cdf0e10cSrcweir 78*cdf0e10cSrcweir ::com::sun::star::uno::Reference< 79*cdf0e10cSrcweir ::com::sun::star::rendering::XSprite > createClonedSprite( 80*cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XSprite >& original ); 81*cdf0e10cSrcweir 82*cdf0e10cSrcweir /** Actually perform the screen update 83*cdf0e10cSrcweir 84*cdf0e10cSrcweir @param bUpdateAll 85*cdf0e10cSrcweir sal_True, if everything must be updated, not only changed 86*cdf0e10cSrcweir sprites 87*cdf0e10cSrcweir 88*cdf0e10cSrcweir @param io_bSurfaceDirty 89*cdf0e10cSrcweir In/out parameter, whether backbuffer surface is dirty (if 90*cdf0e10cSrcweir yes, we're performing a full update, anyway) 91*cdf0e10cSrcweir */ 92*cdf0e10cSrcweir sal_Bool updateScreen( sal_Bool bUpdateAll, 93*cdf0e10cSrcweir bool& io_bSurfaceDirty ); 94*cdf0e10cSrcweir 95*cdf0e10cSrcweir // SpriteRedrawManager functor calls 96*cdf0e10cSrcweir // ------------------------------------------------- 97*cdf0e10cSrcweir 98*cdf0e10cSrcweir /** Gets called for simple background repaints 99*cdf0e10cSrcweir */ 100*cdf0e10cSrcweir void backgroundPaint( const ::basegfx::B2DRange& rUpdateRect ); 101*cdf0e10cSrcweir 102*cdf0e10cSrcweir /** Gets called when area can be handled by scrolling. 103*cdf0e10cSrcweir 104*cdf0e10cSrcweir Called method must copy screen content from rMoveStart to 105*cdf0e10cSrcweir rMoveEnd, and restore the background in the uncovered 106*cdf0e10cSrcweir areas. 107*cdf0e10cSrcweir 108*cdf0e10cSrcweir @param rMoveStart 109*cdf0e10cSrcweir Source rect of the scroll 110*cdf0e10cSrcweir 111*cdf0e10cSrcweir @param rMoveEnd 112*cdf0e10cSrcweir Dest rect of the scroll 113*cdf0e10cSrcweir 114*cdf0e10cSrcweir @param rUpdateArea 115*cdf0e10cSrcweir All info necessary, should rMoveStart be partially or 116*cdf0e10cSrcweir fully outside the outdev 117*cdf0e10cSrcweir */ 118*cdf0e10cSrcweir void scrollUpdate( const ::basegfx::B2DRange& rMoveStart, 119*cdf0e10cSrcweir const ::basegfx::B2DRange& rMoveEnd, 120*cdf0e10cSrcweir const ::canvas::SpriteRedrawManager::UpdateArea& rUpdateArea ); 121*cdf0e10cSrcweir 122*cdf0e10cSrcweir void opaqueUpdate( const ::basegfx::B2DRange& rTotalArea, 123*cdf0e10cSrcweir const ::std::vector< ::canvas::Sprite::Reference >& rSortedUpdateSprites ); 124*cdf0e10cSrcweir 125*cdf0e10cSrcweir void genericUpdate( const ::basegfx::B2DRange& rTotalArea, 126*cdf0e10cSrcweir const ::std::vector< ::canvas::Sprite::Reference >& rSortedUpdateSprites ); 127*cdf0e10cSrcweir 128*cdf0e10cSrcweir ::com::sun::star::uno::Any isUnsafeScrolling() const 129*cdf0e10cSrcweir { 130*cdf0e10cSrcweir return ::com::sun::star::uno::makeAny(mbIsUnsafeScrolling); 131*cdf0e10cSrcweir } 132*cdf0e10cSrcweir void enableUnsafeScrolling( const ::com::sun::star::uno::Any& rAny ) 133*cdf0e10cSrcweir { 134*cdf0e10cSrcweir mbIsUnsafeScrolling = rAny.get<bool>(); 135*cdf0e10cSrcweir } 136*cdf0e10cSrcweir 137*cdf0e10cSrcweir ::com::sun::star::uno::Any isSpriteBounds() const 138*cdf0e10cSrcweir { 139*cdf0e10cSrcweir return ::com::sun::star::uno::makeAny(mbShowSpriteBounds); 140*cdf0e10cSrcweir } 141*cdf0e10cSrcweir void enableSpriteBounds( const ::com::sun::star::uno::Any& rAny ) 142*cdf0e10cSrcweir { 143*cdf0e10cSrcweir mbShowSpriteBounds = rAny.get<bool>(); 144*cdf0e10cSrcweir } 145*cdf0e10cSrcweir 146*cdf0e10cSrcweir private: 147*cdf0e10cSrcweir void renderFrameCounter( OutputDevice& rOutDev ); 148*cdf0e10cSrcweir void renderSpriteCount( OutputDevice& rOutDev ); 149*cdf0e10cSrcweir void renderMemUsage( OutputDevice& rOutDev ); 150*cdf0e10cSrcweir 151*cdf0e10cSrcweir /// Set from the SpriteCanvas: instance coordinating sprite redraw 152*cdf0e10cSrcweir ::canvas::SpriteRedrawManager* mpRedrawManager; 153*cdf0e10cSrcweir 154*cdf0e10cSrcweir /// Set from the init method. used to generate sprites 155*cdf0e10cSrcweir SpriteCanvas* mpOwningSpriteCanvas; 156*cdf0e10cSrcweir 157*cdf0e10cSrcweir /** Background compositing surface. 158*cdf0e10cSrcweir 159*cdf0e10cSrcweir Typically, sprites will be composited in the background, 160*cdf0e10cSrcweir before pushing them to screen. This happens here. 161*cdf0e10cSrcweir */ 162*cdf0e10cSrcweir ::canvas::vcltools::VCLObject< VirtualDevice > maVDev; 163*cdf0e10cSrcweir 164*cdf0e10cSrcweir /// For the frame counter timings 165*cdf0e10cSrcweir ::canvas::tools::ElapsedTime maLastUpdate; 166*cdf0e10cSrcweir 167*cdf0e10cSrcweir /// When true, canvas displays debug info on each frame 168*cdf0e10cSrcweir bool mbShowFrameInfo; 169*cdf0e10cSrcweir 170*cdf0e10cSrcweir /// When true, canvas creates all new sprites with red lines in the corners 171*cdf0e10cSrcweir bool mbShowSpriteBounds; 172*cdf0e10cSrcweir 173*cdf0e10cSrcweir /// When true, canvas uses the scroll optimization (direct scrolls in front buffer) 174*cdf0e10cSrcweir bool mbIsUnsafeScrolling; 175*cdf0e10cSrcweir }; 176*cdf0e10cSrcweir } 177*cdf0e10cSrcweir 178*cdf0e10cSrcweir #endif /* _VCLCANVAS_SPRITECANVASHELPER_HXX_ */ 179*cdf0e10cSrcweir 180