1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef INCLUDED_CANVAS_SOURCE_VCL_SPRITECANVASHELPER_HXX
21 #define INCLUDED_CANVAS_SOURCE_VCL_SPRITECANVASHELPER_HXX
23 #include <com/sun/star/rendering/XSpriteCanvas.hpp>
24 #include <com/sun/star/rendering/XIntegerBitmap.hpp>
26 #include <vcl/vclptr.hxx>
27 #include <vcl/virdev.hxx>
29 #include <canvas/spriteredrawmanager.hxx>
30 #include <canvas/elapsedtime.hxx>
31 #include <canvas/vclwrapper.hxx>
32 #include "canvashelper.hxx"
33 #include "impltools.hxx"
40 class SpriteCanvasHelper
: public CanvasHelper
44 ~SpriteCanvasHelper();
46 void init( const OutDevProviderSharedPtr
& rOutDev
,
47 SpriteCanvas
& rOwningSpriteCanvas
,
48 ::canvas::SpriteRedrawManager
& rManager
,
52 /// Dispose all internal references
56 ::com::sun::star::uno::Reference
<
57 ::com::sun::star::rendering::XAnimatedSprite
> createSpriteFromAnimation(
58 const ::com::sun::star::uno::Reference
< ::com::sun::star::rendering::XAnimation
>& animation
);
60 ::com::sun::star::uno::Reference
<
61 ::com::sun::star::rendering::XAnimatedSprite
> createSpriteFromBitmaps(
62 const ::com::sun::star::uno::Sequence
<
63 ::com::sun::star::uno::Reference
<
64 ::com::sun::star::rendering::XBitmap
> >& animationBitmaps
,
65 sal_Int8 interpolationMode
);
67 ::com::sun::star::uno::Reference
<
68 ::com::sun::star::rendering::XCustomSprite
> createCustomSprite(
69 const ::com::sun::star::geometry::RealSize2D
& spriteSize
);
71 ::com::sun::star::uno::Reference
<
72 ::com::sun::star::rendering::XSprite
> createClonedSprite(
73 const ::com::sun::star::uno::Reference
< ::com::sun::star::rendering::XSprite
>& original
);
75 /** Actually perform the screen update
78 sal_True, if everything must be updated, not only changed
81 @param io_bSurfaceDirty
82 In/out parameter, whether backbuffer surface is dirty (if
83 yes, we're performing a full update, anyway)
85 bool updateScreen( bool bUpdateAll
,
86 bool& io_bSurfaceDirty
);
88 // SpriteRedrawManager functor calls
91 /** Gets called for simple background repaints
93 void backgroundPaint( const ::basegfx::B2DRange
& rUpdateRect
);
95 /** Gets called when area can be handled by scrolling.
97 Called method must copy screen content from rMoveStart to
98 rMoveEnd, and restore the background in the uncovered
102 Source rect of the scroll
105 Dest rect of the scroll
108 All info necessary, should rMoveStart be partially or
109 fully outside the outdev
111 void scrollUpdate( const ::basegfx::B2DRange
& rMoveStart
,
112 const ::basegfx::B2DRange
& rMoveEnd
,
113 const ::canvas::SpriteRedrawManager::UpdateArea
& rUpdateArea
);
115 void opaqueUpdate( const ::basegfx::B2DRange
& rTotalArea
,
116 const ::std::vector
< ::canvas::Sprite::Reference
>& rSortedUpdateSprites
);
118 void genericUpdate( const ::basegfx::B2DRange
& rTotalArea
,
119 const ::std::vector
< ::canvas::Sprite::Reference
>& rSortedUpdateSprites
);
121 ::com::sun::star::uno::Any
isUnsafeScrolling() const
123 return ::com::sun::star::uno::makeAny(mbIsUnsafeScrolling
);
125 void enableUnsafeScrolling( const ::com::sun::star::uno::Any
& rAny
)
127 mbIsUnsafeScrolling
= rAny
.get
<bool>();
130 ::com::sun::star::uno::Any
isSpriteBounds() const
132 return ::com::sun::star::uno::makeAny(mbShowSpriteBounds
);
134 void enableSpriteBounds( const ::com::sun::star::uno::Any
& rAny
)
136 mbShowSpriteBounds
= rAny
.get
<bool>();
140 void renderFrameCounter( OutputDevice
& rOutDev
);
141 void renderSpriteCount( OutputDevice
& rOutDev
);
142 void renderMemUsage( OutputDevice
& rOutDev
);
144 /// Set from the SpriteCanvas: instance coordinating sprite redraw
145 ::canvas::SpriteRedrawManager
* mpRedrawManager
;
147 /// Set from the init method. used to generate sprites
148 SpriteCanvas
* mpOwningSpriteCanvas
;
150 /** Background compositing surface.
152 Typically, sprites will be composited in the background,
153 before pushing them to screen. This happens here.
155 VclPtr
< VirtualDevice
> maVDev
;
157 /// For the frame counter timings
158 ::canvas::tools::ElapsedTime maLastUpdate
;
160 /// When true, canvas displays debug info on each frame
161 bool mbShowFrameInfo
;
163 /// When true, canvas creates all new sprites with red lines in the corners
164 bool mbShowSpriteBounds
;
166 /// When true, canvas uses the scroll optimization (direct scrolls in front buffer)
167 bool mbIsUnsafeScrolling
;
171 #endif // INCLUDED_CANVAS_SOURCE_VCL_SPRITECANVASHELPER_HXX
173 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */