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