LibreOffice Module slideshow (master) 1
|
This class manages all of a slide's layers (and shapes) More...
#include <layermanager.hxx>
Classes | |
class | ShapeComparator |
Public Member Functions | |
LayerManager (const UnoViewContainer &rViews, bool bDisableAnimationZOrder) | |
Create a new layer manager for the given page bounds. More... | |
LayerManager (const LayerManager &)=delete | |
Forbid copy construction. More... | |
LayerManager & | operator= (const LayerManager &)=delete |
Forbid copy assignment. More... | |
void | activate () |
Activate the LayerManager. More... | |
void | deactivate () |
Deactivate the LayerManager. More... | |
void | viewAdded (const UnoViewSharedPtr &rView) |
Notify new view added to UnoViewContainer. More... | |
void | viewRemoved (const UnoViewSharedPtr &rView) |
Notify view removed from UnoViewContainer. More... | |
void | viewChanged (const UnoViewSharedPtr &rView) |
void | viewsChanged () |
void | addShape (const ShapeSharedPtr &rShape) |
Add the shape to this object. More... | |
bool | removeShape (const ShapeSharedPtr &rShape) |
Remove shape from this object. More... | |
ShapeSharedPtr | lookupShape (const css::uno::Reference< css::drawing::XShape > &xShape) const |
Lookup a Shape from an XShape model object. More... | |
AttributableShapeSharedPtr | getSubsetShape (const AttributableShapeSharedPtr &rOrigShape, const DocTreeNode &rTreeNode) |
Query a subset of the given original shape. More... | |
const XShapeToShapeMap & | getXShapeToShapeMap () const |
Get a map that maps all Shapes with their XShape reference as the key. More... | |
void | revokeSubset (const AttributableShapeSharedPtr &rOrigShape, const AttributableShapeSharedPtr &rSubsetShape) |
Revoke a previously queried subset shape. More... | |
void | enterAnimationMode (const AnimatableShapeSharedPtr &rShape) |
Notify the LayerManager that the given Shape starts an animation now. More... | |
void | leaveAnimationMode (const AnimatableShapeSharedPtr &rShape) |
Notify the LayerManager that the given Shape is no longer animated. More... | |
void | notifyShapeUpdate (const ShapeSharedPtr &rShape) |
Notify that a shape needs an update. More... | |
bool | isUpdatePending () const |
Check whether any update operations are pending. More... | |
bool | update () |
Update the content. More... | |
bool | renderTo (const ::cppcanvas::CanvasSharedPtr &rTargetCanvas) const |
Render the content to given canvas. More... | |
Private Types | |
typedef ::std::map< ShapeSharedPtr, LayerWeakPtr, ShapeComparator > | LayerShapeMap |
Set of all shapes. More... | |
Private Member Functions | |
void | addUpdateArea (ShapeSharedPtr const &rShape) |
Adds shape area to containing layer's damage area. More... | |
LayerSharedPtr | createForegroundLayer () const |
void | commitLayerChanges (std::size_t nCurrLayerIndex, LayerShapeMap::const_iterator aFirstLayerShape, const LayerShapeMap::const_iterator &aEndLayerShapes) |
Push changes from updateShapeLayerAssociations() to current layer. More... | |
void | putShape2BackgroundLayer (LayerShapeMap::value_type &rShapeEntry) |
Init Shape layers with background layer. More... | |
void | updateShapeLayers (bool bBackgroundLayerPainted) |
Commits any pending layer reorg, due to shapes either entering or leaving animation mode. More... | |
void | implAddShape (const ShapeSharedPtr &rShape) |
Common stuff when adding a shape. More... | |
void | implRemoveShape (const ShapeSharedPtr &rShape) |
Common stuff when removing a shape. More... | |
template<typename LayerFunc , typename ShapeFunc > | |
void | manageViews (LayerFunc layerFunc, ShapeFunc shapeFunc) |
Add or remove views. More... | |
bool | updateSprites () |
Private Attributes | |
const UnoViewContainer & | mrViews |
Registered views. More... | |
::std::vector< LayerSharedPtr > | maLayers |
All layers of this object. Vector owns the layers. More... | |
XShapeToShapeMap | maXShapeHash |
Contains all shapes with their XShape reference as the key. More... | |
LayerShapeMap | maAllShapes |
Set of shapes this LayerManager own. More... | |
::std::set< ShapeSharedPtr > | maUpdateShapes |
Set of shapes that have requested an update. More... | |
sal_Int32 | mnActiveSprites |
Number of shape sprites currently active on this LayerManager. More... | |
bool | mbLayerAssociationDirty |
sal_True, if shapes might need to move to different layer More... | |
bool | mbActive |
sal_False when deactivated More... | |
bool | mbDisableAnimationZOrder |
When true, all sprite animations run in the foreground. More... | |
This class manages all of a slide's layers (and shapes)
Since layer content changes when animations start or end, the layer manager keeps track of this and also handles starting/stopping of Shape animations. Note that none of the methods actually perform a screen update, this is always delayed until the ActivitiesQueue explicitly performs it.
Definition at line 63 of file layermanager.hxx.
|
private |
Set of all shapes.
Definition at line 249 of file layermanager.hxx.
slideshow::internal::LayerManager::LayerManager | ( | const UnoViewContainer & | rViews, |
bool | bDisableAnimationZOrder | ||
) |
Create a new layer manager for the given page bounds.
rViews | Views currently registered |
bDisableAnimationZOrder | When true, all sprite animations run in the foreground. That is, no extra layers are created, and the slideshow runs potentially faster. |
Definition at line 67 of file layermanager.cxx.
References slideshow::internal::Layer::createBackgroundLayer(), maLayers, mrViews, and viewAdded().
|
delete |
Forbid copy construction.
void slideshow::internal::LayerManager::activate | ( | ) |
Activate the LayerManager.
This method activates the LayerManager. Prior to activation, this instance will be passive, i.e. won't render anything to any view.
Definition at line 91 of file layermanager.cxx.
References maLayers, maUpdateShapes, mbActive, and updateShapeLayers().
void slideshow::internal::LayerManager::addShape | ( | const ShapeSharedPtr & | rShape | ) |
Add the shape to this object.
This method adds a shape to the page.
Definition at line 208 of file layermanager.cxx.
References ENSURE_OR_THROW, implAddShape(), maLayers, and maXShapeHash.
|
private |
Adds shape area to containing layer's damage area.
Definition at line 648 of file layermanager.cxx.
References ENSURE_OR_THROW, maAllShapes, and maLayers.
Referenced by enterAnimationMode(), notifyShapeUpdate(), and updateSprites().
|
private |
Push changes from updateShapeLayerAssociations() to current layer.
Factored-out method that resizes layer, if necessary, assigns correct layer priority, and repaints contained shapes.
nCurrLayerIndex | Index of current layer in maLayers |
aFirstLayerShape | Valid iterator out of maAllShapes, denoting the first shape from nCurrLayerIndex |
aEndLayerShapes | Valid iterator or end iterator out of maAllShapes, denoting one-behind-the-last shape of nCurrLayerIndex |
Definition at line 663 of file layermanager.cxx.
References maLayers, and maUpdateShapes.
Referenced by updateShapeLayers().
|
private |
Definition at line 692 of file layermanager.cxx.
References slideshow::internal::Layer::createLayer(), mbActive, and mrViews.
Referenced by updateShapeLayers().
void slideshow::internal::LayerManager::deactivate | ( | ) |
Deactivate the LayerManager.
This method deactivates the LayerManager. After deactivation, this instance will be passive, i.e. don't render anything to any view. Furthermore, if there's currently more than one Layer active, this method also removes all but one.
Definition at line 105 of file layermanager.cxx.
References maAllShapes, maLayers, mbActive, mbLayerAssociationDirty, and mnActiveSprites.
void slideshow::internal::LayerManager::enterAnimationMode | ( | const AnimatableShapeSharedPtr & | rShape | ) |
Notify the LayerManager that the given Shape starts an animation now.
This method enters animation mode for the Shape on all registered views.
Definition at line 368 of file layermanager.cxx.
References addUpdateArea(), ENSURE_OR_THROW, maLayers, mbLayerAssociationDirty, and mnActiveSprites.
AttributableShapeSharedPtr slideshow::internal::LayerManager::getSubsetShape | ( | const AttributableShapeSharedPtr & | rOrigShape, |
const DocTreeNode & | rTreeNode | ||
) |
Query a subset of the given original shape.
This method queries a new (but not necessarily unique) shape, which displays only the given subset of the original one.
Definition at line 314 of file layermanager.cxx.
References implAddShape(), maLayers, and notifyShapeUpdate().
const XShapeToShapeMap & slideshow::internal::LayerManager::getXShapeToShapeMap | ( | ) | const |
Get a map that maps all Shapes with their XShape reference as the key.
Definition at line 345 of file layermanager.cxx.
References maXShapeHash.
|
private |
Common stuff when adding a shape.
Definition at line 232 of file layermanager.cxx.
References ENSURE_OR_THROW, maAllShapes, maLayers, mbDisableAnimationZOrder, mbLayerAssociationDirty, notifyShapeUpdate(), and putShape2BackgroundLayer().
Referenced by addShape(), and getSubsetShape().
|
private |
Common stuff when removing a shape.
Definition at line 266 of file layermanager.cxx.
References ENSURE_OR_THROW, maAllShapes, maLayers, maUpdateShapes, and mbLayerAssociationDirty.
Referenced by removeShape(), and revokeSubset().
bool slideshow::internal::LayerManager::isUpdatePending | ( | ) | const |
Check whether any update operations are pending.
Definition at line 439 of file layermanager.cxx.
References slideshow::internal::Layer::isUpdatePending(), maLayers, maUpdateShapes, mbActive, and mbLayerAssociationDirty.
void slideshow::internal::LayerManager::leaveAnimationMode | ( | const AnimatableShapeSharedPtr & | rShape | ) |
Notify the LayerManager that the given Shape is no longer animated.
This methods ends animation mode for the given Shape on all registered views.
Definition at line 398 of file layermanager.cxx.
References ENSURE_OR_THROW, maLayers, mbLayerAssociationDirty, mnActiveSprites, and notifyShapeUpdate().
ShapeSharedPtr slideshow::internal::LayerManager::lookupShape | ( | const css::uno::Reference< css::drawing::XShape > & | xShape | ) | const |
Lookup a Shape from an XShape model object.
This method looks up the internal shape map for one representing the given XShape.
xShape | The XShape object, for which the representing Shape should be looked up. |
Definition at line 302 of file layermanager.cxx.
References ENSURE_OR_THROW, and maXShapeHash.
|
private |
Add or remove views.
Sharing duplicate code from viewAdded and viewRemoved method. The only point of variation at those places are removal vs. adding.
Definition at line 47 of file layermanager.cxx.
References maAllShapes.
Referenced by viewAdded(), and viewRemoved().
void slideshow::internal::LayerManager::notifyShapeUpdate | ( | const ShapeSharedPtr & | rShape | ) |
Notify that a shape needs an update.
This method notifies the layer manager that a shape update is necessary. This is useful if, during animation playback, changes occur to shapes which make an update necessary on an update() call. Otherwise, update() will not render anything, which is not triggered by calling one of the other LayerManager methods.
rShape | Shape which needs an update |
Definition at line 427 of file layermanager.cxx.
References addUpdateArea(), slideshow::internal::UnoViewContainer::empty(), maUpdateShapes, mbActive, and mrViews.
Referenced by getSubsetShape(), implAddShape(), leaveAnimationMode(), and revokeSubset().
|
delete |
Forbid copy assignment.
|
private |
Init Shape layers with background layer.
Definition at line 225 of file layermanager.cxx.
References maLayers.
Referenced by implAddShape().
bool slideshow::internal::LayerManager::removeShape | ( | const ShapeSharedPtr & | rShape | ) |
Remove shape from this object.
This method removes a shape from the shape.
Definition at line 253 of file layermanager.cxx.
References implRemoveShape(), maAllShapes, and maXShapeHash.
bool slideshow::internal::LayerManager::renderTo | ( | const ::cppcanvas::CanvasSharedPtr & | rTargetCanvas | ) | const |
Render the content to given canvas.
This is a one-shot operation, which simply draws all shapes onto the given canvas, without any caching or other fuzz. Don't use that for repeated output onto the same canvas, the View concept is more optimal then.
rTargetCanvas | Target canvas to output onto. |
Definition at line 615 of file layermanager.cxx.
References maAllShapes, and TOOLS_WARN_EXCEPTION.
void slideshow::internal::LayerManager::revokeSubset | ( | const AttributableShapeSharedPtr & | rOrigShape, |
const AttributableShapeSharedPtr & | rSubsetShape | ||
) |
Revoke a previously queried subset shape.
With this method, a previously requested subset shape is revoked again. If the last client revokes a given subset, it will cease to be displayed, and the original shape will again show the subset data.
rOrigShape | The shape the subset was created from |
rSubsetShape | The subset created from rOrigShape |
Definition at line 350 of file layermanager.cxx.
References implRemoveShape(), maAllShapes, maLayers, and notifyShapeUpdate().
bool slideshow::internal::LayerManager::update | ( | ) |
Update the content.
This method updates the content on all layers on all registered views. It does not issues a View::updateScreen() call on registered views. Please note that this method only takes into account changes to shapes induced directly by calling methods of the LayerManager. If a shape needs an update, because of some external event unknown to the LayerManager (most notably running animations), you have to notify the LayerManager via notifyShapeUpdate().
Definition at line 488 of file layermanager.cxx.
References slideshow::internal::Layer::isUpdatePending(), maAllShapes, maLayers, mbActive, updateShapeLayers(), and updateSprites().
|
private |
Commits any pending layer reorg, due to shapes either entering or leaving animation mode.
bBackgroundLayerPainted | When true, LayerManager does not render anything on the background layer. Use this, if background has been updated by other means (e.g. slide transition) |
Definition at line 706 of file layermanager.cxx.
References commitLayerChanges(), createForegroundLayer(), maAllShapes, maLayers, maUpdateShapes, mbActive, mbDisableAnimationZOrder, and mbLayerAssociationDirty.
Referenced by activate(), and update().
|
private |
Definition at line 452 of file layermanager.cxx.
References addUpdateArea(), and maUpdateShapes.
Referenced by update().
void slideshow::internal::LayerManager::viewAdded | ( | const UnoViewSharedPtr & | rView | ) |
Notify new view added to UnoViewContainer.
Definition at line 137 of file layermanager.cxx.
References slideshow::internal::UnoViewContainer::begin(), slideshow::internal::UnoViewContainer::end(), maLayers, manageViews(), mbActive, and mrViews.
Referenced by LayerManager().
void slideshow::internal::LayerManager::viewChanged | ( | const UnoViewSharedPtr & | rView | ) |
Definition at line 181 of file layermanager.cxx.
References slideshow::internal::UnoViewContainer::begin(), slideshow::internal::UnoViewContainer::end(), mrViews, and viewsChanged().
void slideshow::internal::LayerManager::viewRemoved | ( | const UnoViewSharedPtr & | rView | ) |
Notify view removed from UnoViewContainer.
Definition at line 161 of file layermanager.cxx.
References slideshow::internal::UnoViewContainer::begin(), slideshow::internal::UnoViewContainer::end(), maLayers, manageViews(), and mrViews.
void slideshow::internal::LayerManager::viewsChanged | ( | ) |
Definition at line 192 of file layermanager.cxx.
References maAllShapes, mbActive, and mrViews.
Referenced by viewChanged().
|
private |
Set of shapes this LayerManager own.
Contains the same set of shapes as XShapeHash, but is sorted in z order, for painting and layer association. Set entries are enriched with two flags for buffering animation enable/disable changes, and shape update requests.
Definition at line 330 of file layermanager.hxx.
Referenced by addUpdateArea(), deactivate(), implAddShape(), implRemoveShape(), manageViews(), removeShape(), renderTo(), revokeSubset(), update(), updateShapeLayers(), and viewsChanged().
|
private |
All layers of this object. Vector owns the layers.
Definition at line 316 of file layermanager.hxx.
Referenced by activate(), addShape(), addUpdateArea(), commitLayerChanges(), deactivate(), enterAnimationMode(), getSubsetShape(), implAddShape(), implRemoveShape(), isUpdatePending(), LayerManager(), leaveAnimationMode(), putShape2BackgroundLayer(), revokeSubset(), update(), updateShapeLayers(), viewAdded(), and viewRemoved().
|
private |
Set of shapes that have requested an update.
When a shape is member of this set, its maShapes entry has bNeedsUpdate set to true. We maintain this redundant information for faster update processing.
Definition at line 339 of file layermanager.hxx.
Referenced by activate(), commitLayerChanges(), implRemoveShape(), isUpdatePending(), notifyShapeUpdate(), updateShapeLayers(), and updateSprites().
|
private |
Contains all shapes with their XShape reference as the key.
Definition at line 320 of file layermanager.hxx.
Referenced by addShape(), getXShapeToShapeMap(), lookupShape(), and removeShape().
|
private |
sal_False when deactivated
Definition at line 348 of file layermanager.hxx.
Referenced by activate(), createForegroundLayer(), deactivate(), isUpdatePending(), notifyShapeUpdate(), update(), updateShapeLayers(), viewAdded(), and viewsChanged().
|
private |
When true, all sprite animations run in the foreground.
That is, no extra layers are created, and the slideshow runs potentially faster.
Definition at line 354 of file layermanager.hxx.
Referenced by implAddShape(), and updateShapeLayers().
|
private |
sal_True, if shapes might need to move to different layer
Definition at line 345 of file layermanager.hxx.
Referenced by deactivate(), enterAnimationMode(), implAddShape(), implRemoveShape(), isUpdatePending(), leaveAnimationMode(), and updateShapeLayers().
|
private |
Number of shape sprites currently active on this LayerManager.
Definition at line 342 of file layermanager.hxx.
Referenced by deactivate(), enterAnimationMode(), and leaveAnimationMode().
|
private |
Registered views.
Definition at line 312 of file layermanager.hxx.
Referenced by createForegroundLayer(), LayerManager(), notifyShapeUpdate(), viewAdded(), viewChanged(), viewRemoved(), and viewsChanged().