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 _CAIROCANVAS_SPRITECANVASHELPER_HXX_ 29 #define _CAIROCANVAS_SPRITECANVASHELPER_HXX_ 30 31 #include <com/sun/star/rendering/XSpriteCanvas.hpp> 32 #include <com/sun/star/rendering/XIntegerBitmap.hpp> 33 34 #include <canvas/spriteredrawmanager.hxx> 35 36 #include "cairo_cairo.hxx" 37 #include "cairo_canvashelper.hxx" 38 39 namespace basegfx 40 { 41 class B2IRange; 42 } 43 44 namespace cairocanvas 45 { 46 class SpriteCanvas; 47 48 class SpriteCanvasHelper : public CanvasHelper 49 { 50 public: 51 SpriteCanvasHelper(); 52 53 void init( ::canvas::SpriteRedrawManager& rManager, 54 SpriteCanvas& rOwningSpriteCanvas, 55 const ::basegfx::B2ISize& rSize ); 56 57 /// Dispose all internal references 58 void disposing(); 59 60 // XSpriteCanvas 61 ::com::sun::star::uno::Reference< 62 ::com::sun::star::rendering::XAnimatedSprite > createSpriteFromAnimation( 63 const ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XAnimation >& animation ); 64 65 ::com::sun::star::uno::Reference< 66 ::com::sun::star::rendering::XAnimatedSprite > createSpriteFromBitmaps( 67 const ::com::sun::star::uno::Sequence< 68 ::com::sun::star::uno::Reference< 69 ::com::sun::star::rendering::XBitmap > >& animationBitmaps, 70 sal_Int8 interpolationMode ); 71 72 ::com::sun::star::uno::Reference< 73 ::com::sun::star::rendering::XCustomSprite > createCustomSprite( 74 const ::com::sun::star::geometry::RealSize2D& spriteSize ); 75 76 ::com::sun::star::uno::Reference< 77 ::com::sun::star::rendering::XSprite > createClonedSprite( 78 const ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XSprite >& original ); 79 80 /** Actually perform the screen update 81 82 @param rCurrArea 83 Current window area in absolute screen coordinates 84 85 @param bUpdateAll 86 sal_True, if everything must be updated, not only changed 87 sprites 88 89 @param io_bSurfaceDirty 90 In/out parameter, whether backbuffer surface is dirty (if 91 yes, we're performing a full update, anyway) 92 */ 93 sal_Bool updateScreen( const ::basegfx::B2IRange& rCurrArea, 94 sal_Bool bUpdateAll, 95 bool& io_bSurfaceDirty ); 96 97 98 // SpriteRedrawManager functor calls 99 // ------------------------------------------------- 100 101 /** Gets called for simple background repaints 102 */ 103 void backgroundPaint( const ::basegfx::B2DRange& rUpdateRect ); 104 105 /** Gets called when area can be handled by scrolling. 106 107 Called method must copy screen content from rMoveStart to 108 rMoveEnd, and restore the background in the uncovered 109 areas. 110 111 @param rMoveStart 112 Source rect of the scroll 113 114 @param rMoveEnd 115 Dest rect of the scroll 116 117 @param rUpdateArea 118 All info necessary, should rMoveStart be partially or 119 fully outside the outdev 120 */ 121 void scrollUpdate( const ::basegfx::B2DRange& rMoveStart, 122 const ::basegfx::B2DRange& rMoveEnd, 123 const ::canvas::SpriteRedrawManager::UpdateArea& rUpdateArea ); 124 125 void opaqueUpdate( const ::basegfx::B2DRange& rTotalArea, 126 const ::std::vector< ::canvas::Sprite::Reference >& rSortedUpdateSprites ); 127 128 void genericUpdate( const ::basegfx::B2DRange& rTotalArea, 129 const ::std::vector< ::canvas::Sprite::Reference >& rSortedUpdateSprites ); 130 131 private: 132 ::cairo::SurfaceSharedPtr getCompositingSurface( const ::basegfx::B2ISize& rNeededSize ); 133 134 /// Set from the SpriteCanvas: instance coordinating sprite redraw 135 ::canvas::SpriteRedrawManager* mpRedrawManager; 136 137 /// Set from the init method. used to generate sprites 138 SpriteCanvas* mpOwningSpriteCanvas; 139 140 /// a temporary surface used to composite the frontbuffer image 141 ::cairo::SurfaceSharedPtr mpCompositingSurface; 142 ::basegfx::B2ISize maCompositingSurfaceSize; 143 }; 144 } 145 146 #endif /* _CAIROCANVAS_SPRITECANVASHELPER_HXX_ */ 147 148