LibreOffice Module slideshow (master) 1
Classes | Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
slideshow::internal::LayerManager Class Reference

This class manages all of a slide's layers (and shapes) More...

#include <layermanager.hxx>

Collaboration diagram for slideshow::internal::LayerManager:
[legend]

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...
 
LayerManageroperator= (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 XShapeToShapeMapgetXShapeToShapeMap () 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, ShapeComparatorLayerShapeMap
 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 UnoViewContainermrViews
 Registered views. More...
 
::std::vector< LayerSharedPtrmaLayers
 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< ShapeSharedPtrmaUpdateShapes
 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...
 

Detailed Description

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.

See also
Layer
Shape

Definition at line 63 of file layermanager.hxx.

Member Typedef Documentation

◆ LayerShapeMap

Set of all shapes.

Definition at line 249 of file layermanager.hxx.

Constructor & Destructor Documentation

◆ LayerManager() [1/2]

slideshow::internal::LayerManager::LayerManager ( const UnoViewContainer rViews,
bool  bDisableAnimationZOrder 
)

Create a new layer manager for the given page bounds.

Parameters
rViewsViews currently registered
bDisableAnimationZOrderWhen 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().

◆ LayerManager() [2/2]

slideshow::internal::LayerManager::LayerManager ( const LayerManager )
delete

Forbid copy construction.

Member Function Documentation

◆ activate()

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().

◆ addShape()

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.

◆ addUpdateArea()

void slideshow::internal::LayerManager::addUpdateArea ( ShapeSharedPtr const &  rShape)
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().

◆ commitLayerChanges()

void slideshow::internal::LayerManager::commitLayerChanges ( std::size_t  nCurrLayerIndex,
LayerShapeMap::const_iterator  aFirstLayerShape,
const LayerShapeMap::const_iterator &  aEndLayerShapes 
)
private

Push changes from updateShapeLayerAssociations() to current layer.

Factored-out method that resizes layer, if necessary, assigns correct layer priority, and repaints contained shapes.

Parameters
nCurrLayerIndexIndex of current layer in maLayers
aFirstLayerShapeValid iterator out of maAllShapes, denoting the first shape from nCurrLayerIndex
aEndLayerShapesValid 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().

◆ createForegroundLayer()

LayerSharedPtr slideshow::internal::LayerManager::createForegroundLayer ( ) const
private

Definition at line 692 of file layermanager.cxx.

References slideshow::internal::Layer::createLayer(), mbActive, and mrViews.

Referenced by updateShapeLayers().

◆ deactivate()

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.

◆ enterAnimationMode()

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.

◆ getSubsetShape()

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().

◆ getXShapeToShapeMap()

const XShapeToShapeMap & slideshow::internal::LayerManager::getXShapeToShapeMap ( ) const

Get a map that maps all Shapes with their XShape reference as the key.

Returns
an unordered map that contains all shapes in the current page with their XShape reference as the key

Definition at line 345 of file layermanager.cxx.

References maXShapeHash.

◆ implAddShape()

void slideshow::internal::LayerManager::implAddShape ( const ShapeSharedPtr rShape)
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().

◆ implRemoveShape()

void slideshow::internal::LayerManager::implRemoveShape ( const ShapeSharedPtr rShape)
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().

◆ isUpdatePending()

bool slideshow::internal::LayerManager::isUpdatePending ( ) const

Check whether any update operations are pending.

Returns
true, if this LayerManager has any updates pending, i.e. needs to repaint something for the next frame.

Definition at line 439 of file layermanager.cxx.

References slideshow::internal::Layer::isUpdatePending(), maLayers, maUpdateShapes, mbActive, and mbLayerAssociationDirty.

◆ leaveAnimationMode()

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().

◆ lookupShape()

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.

Parameters
xShapeThe 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.

◆ manageViews()

template<typename LayerFunc , typename ShapeFunc >
void slideshow::internal::LayerManager::manageViews ( LayerFunc  layerFunc,
ShapeFunc  shapeFunc 
)
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().

◆ notifyShapeUpdate()

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.

Parameters
rShapeShape 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().

◆ operator=()

LayerManager & slideshow::internal::LayerManager::operator= ( const LayerManager )
delete

Forbid copy assignment.

◆ putShape2BackgroundLayer()

void slideshow::internal::LayerManager::putShape2BackgroundLayer ( LayerShapeMap::value_type &  rShapeEntry)
private

Init Shape layers with background layer.

Definition at line 225 of file layermanager.cxx.

References maLayers.

Referenced by implAddShape().

◆ removeShape()

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.

◆ renderTo()

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.

Parameters
rTargetCanvasTarget canvas to output onto.

Definition at line 615 of file layermanager.cxx.

References maAllShapes, and TOOLS_WARN_EXCEPTION.

◆ revokeSubset()

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.

Parameters
rOrigShapeThe shape the subset was created from
rSubsetShapeThe subset created from rOrigShape

Definition at line 350 of file layermanager.cxx.

References implRemoveShape(), maAllShapes, maLayers, and notifyShapeUpdate().

◆ update()

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().

See also
LayerManager::updateScreen()
Returns
whether the update finished successfully.

Definition at line 488 of file layermanager.cxx.

References slideshow::internal::Layer::isUpdatePending(), maAllShapes, maLayers, mbActive, updateShapeLayers(), and updateSprites().

◆ updateShapeLayers()

void slideshow::internal::LayerManager::updateShapeLayers ( bool  bBackgroundLayerPainted)
private

Commits any pending layer reorg, due to shapes either entering or leaving animation mode.

Parameters
bBackgroundLayerPaintedWhen 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().

◆ updateSprites()

bool slideshow::internal::LayerManager::updateSprites ( )
private

Definition at line 452 of file layermanager.cxx.

References addUpdateArea(), and maUpdateShapes.

Referenced by update().

◆ viewAdded()

void slideshow::internal::LayerManager::viewAdded ( const UnoViewSharedPtr rView)

◆ viewChanged()

void slideshow::internal::LayerManager::viewChanged ( const UnoViewSharedPtr rView)

◆ viewRemoved()

void slideshow::internal::LayerManager::viewRemoved ( const UnoViewSharedPtr rView)

◆ viewsChanged()

void slideshow::internal::LayerManager::viewsChanged ( )

Definition at line 192 of file layermanager.cxx.

References maAllShapes, mbActive, and mrViews.

Referenced by viewChanged().

Member Data Documentation

◆ maAllShapes

LayerShapeMap slideshow::internal::LayerManager::maAllShapes
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().

◆ maLayers

::std::vector< LayerSharedPtr > slideshow::internal::LayerManager::maLayers
private

◆ maUpdateShapes

::std::set< ShapeSharedPtr > slideshow::internal::LayerManager::maUpdateShapes
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().

◆ maXShapeHash

XShapeToShapeMap slideshow::internal::LayerManager::maXShapeHash
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().

◆ mbActive

bool slideshow::internal::LayerManager::mbActive
private

◆ mbDisableAnimationZOrder

bool slideshow::internal::LayerManager::mbDisableAnimationZOrder
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().

◆ mbLayerAssociationDirty

bool slideshow::internal::LayerManager::mbLayerAssociationDirty
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().

◆ mnActiveSprites

sal_Int32 slideshow::internal::LayerManager::mnActiveSprites
private

Number of shape sprites currently active on this LayerManager.

Definition at line 342 of file layermanager.hxx.

Referenced by deactivate(), enterAnimationMode(), and leaveAnimationMode().

◆ mrViews

const UnoViewContainer& slideshow::internal::LayerManager::mrViews
private

The documentation for this class was generated from the following files: