1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 #ifndef _DXCANVAS_SPRITECANVASHELPER_HXX_ 25 #define _DXCANVAS_SPRITECANVASHELPER_HXX_ 26 27 #include <com/sun/star/rendering/XSpriteCanvas.hpp> 28 #include <com/sun/star/rendering/XIntegerBitmap.hpp> 29 30 #include <canvas/spriteredrawmanager.hxx> 31 #include <canvas/rendering/isurfaceproxy.hxx> 32 #include <canvas/rendering/isurfaceproxymanager.hxx> 33 34 #include "dx_bitmapcanvashelper.hxx" 35 #include "dx_impltools.hxx" 36 #include "dx_rendermodule.hxx" 37 #include "dx_surfacebitmap.hxx" 38 39 #include <basegfx/range/b2irectangle.hxx> 40 41 namespace dxcanvas 42 { 43 class SpriteCanvas; 44 45 class SpriteCanvasHelper : public BitmapCanvasHelper 46 { 47 public: 48 SpriteCanvasHelper(); 49 50 void init( SpriteCanvas& rParent, 51 ::canvas::SpriteRedrawManager& rManager, 52 const IDXRenderModuleSharedPtr& rRenderModule, 53 const ::canvas::ISurfaceProxyManagerSharedPtr& rSurfaceProxy, 54 const DXSurfaceBitmapSharedPtr& rBackBuffer, 55 const ::basegfx::B2ISize& rOutputOffset ); 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::B2IRectangle& 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 /// For generating sprites 133 SpriteCanvas* mpSpriteSurface; 134 135 /// Set from the SpriteCanvas: instance coordinating sprite redraw 136 ::canvas::SpriteRedrawManager* mpRedrawManager; 137 138 /// DX device, handling all low-level rendering 139 IDXRenderModuleSharedPtr mpRenderModule; 140 141 ::canvas::ISurfaceProxyManagerSharedPtr mpSurfaceProxy; 142 143 /// Backbuffer, contains the static canvas render output 144 DXSurfaceBitmapSharedPtr mpBackBuffer; 145 146 /// Completely temporary rect storage (used by sprite repaint) 147 mutable ::basegfx::B2IRange maUpdateRect; 148 149 /// Completely temporary rect storage (used by sprite repaint) 150 mutable ::basegfx::B2IRange maScrapRect; 151 152 /// When true, show small bound rects around each sprite 153 bool mbShowSpriteBounds; 154 }; 155 } 156 157 #endif /* _DXCANVAS_SPRITECANVASHELPER_HXX_ */ 158