40 return rLHS.lock().get() != rRHS.lock().get();
46 template<
typename LayerFunc,
56 if( pLayer && pLayer != pCurrLayer )
59 pCurrViewLayer = layerFunc(pCurrLayer);
63 shapeFunc(rShape.first,pCurrViewLayer);
68 bool bDisableAnimationZOrder ) :
75 mbLayerAssociationDirty(false),
77 mbDisableAnimationZOrder(bDisableAnimationZOrder)
87 for(
const auto& rView :
mrViews )
100 pLayer->clearUpdateRanges();
113 const bool bMoreThanOneLayer(
maLayers.size() > 1);
120 rShape.first->clearAllViewLayers();
123 rShape.second.reset();
125 if (bMoreThanOneLayer)
134 OSL_ASSERT(
maLayers.size() == 1 &&
maLayers.front()->isBackgroundLayer() );
151 {
return pLayer->addView( rView ); },
153 {
return pShape->addViewLayer( pLayer,
true ); } );
157 for(
const auto& pLayer :
maLayers )
158 pLayer->addView( rView );
171 {
return pLayer->removeView( rView ); },
173 {
return pShape->removeViewLayer( pLayer ); } );
177 for(
const auto& pLayer :
maLayers )
178 pLayer->removeView( rView );
198 for(
const auto& pView :
mrViews )
205 rShape.first->render();
228 rBgLayer->setShapeViews(rShapeEntry.first);
229 rShapeEntry.second = rBgLayer;
235 ENSURE_OR_THROW( rShape,
"LayerManager::implAddShape(): invalid Shape" );
237 LayerShapeMap::value_type aValue (rShape,
LayerWeakPtr());
249 if( rShape->isVisible() )
269 ENSURE_OR_THROW( rShape,
"LayerManager::implRemoveShape(): invalid Shape" );
271 const LayerShapeMap::iterator aShapeEntry(
maAllShapes.find(rShape) );
276 const bool bShapeUpdateNotified =
maUpdateShapes.erase( rShape ) != 0;
283 if( bShapeUpdateNotified ||
284 (rShape->isVisible() &&
285 !rShape->isBackgroundDetached()) )
292 pLayer->addUpdateRange( rShape->getUpdateArea() );
296 rShape->clearAllViewLayers();
304 ENSURE_OR_THROW( xShape.is(),
"LayerManager::lookupShape(): invalid Shape" );
306 const XShapeToShapeMap::const_iterator aIter(
maXShapeHash.find( xShape ));
311 return aIter->second;
322 if( rOrigShape->createSubset( pSubset,
325 OSL_ENSURE( pSubset,
"LayerManager::getSubsetShape(): failed to create subset" );
338 if( rOrigShape->isVisible() )
355 if( rOrigShape->revokeSubset( rSubsetShape ) )
363 if( rOrigShape->isVisible() )
371 ENSURE_OR_THROW( rShape,
"LayerManager::enterAnimationMode(): invalid Shape" );
373 const bool bPrevAnimState( rShape->isBackgroundDetached() );
375 rShape->enterAnimationMode();
381 if( bPrevAnimState != rShape->isBackgroundDetached() )
389 if( rShape->isVisible() )
401 ENSURE_OR_THROW( rShape,
"LayerManager::leaveAnimationMode(): invalid Shape" );
403 const bool bPrevAnimState( rShape->isBackgroundDetached() );
405 rShape->leaveAnimationMode();
411 if( bPrevAnimState != rShape->isBackgroundDetached() )
418 if( rShape->isVisible() )
433 if( rShape->isVisible() || rShape->isBackgroundDetached() )
447 return std::any_of(
maLayers.begin(),
461 if( pShape->isBackgroundDetached() )
466 if( !pShape->update() )
510 bool bIsCurrLayerUpdating(
false);
516 if( pLayer != pCurrLayer )
519 bIsCurrLayerUpdating = pCurrLayer->isUpdatePending();
521 if( bIsCurrLayerUpdating )
522 aEndUpdater = pCurrLayer->beginUpdate();
525 if( bIsCurrLayerUpdating &&
526 !rShape.first->isBackgroundDetached() &&
527 pCurrLayer->isInsideUpdateArea(rShape.first) )
529 if( !rShape.first->render() )
555 virtual ::cppcanvas::CanvasSharedPtr getCanvas()
const override
560 virtual void clear()
const override
565 virtual void clearAll()
const override
570 virtual ::cppcanvas::CustomSpriteSharedPtr createSprite( const ::basegfx::B2DSize& ,
571 double )
const override
574 "DummyLayer::createSprite(): This method is not supposed to be called!" );
575 return ::cppcanvas::CustomSpriteSharedPtr();
580 OSL_FAIL(
"BitmapView::setPriority(): This method is not supposed to be called!" );
583 virtual css::geometry::IntegerSize2D getTranslationOffset()
const override
585 return geometry::IntegerSize2D(0,0);
588 virtual ::basegfx::B2DHomMatrix getTransformation()
const override
590 return mpCanvas->getTransformation();
595 OSL_FAIL(
"BitmapView::getSpriteTransformation(): This method is not supposed to be called!" );
596 return ::basegfx::B2DHomMatrix();
599 virtual void setClip( const ::basegfx::B2DPolyPolygon& )
override
601 OSL_FAIL(
"BitmapView::setClip(): This method is not supposed to be called!" );
604 virtual bool resize( const ::basegfx::B2DRange& )
override
606 OSL_FAIL(
"BitmapView::resize(): This method is not supposed to be called!" );
629 rShape.first->addViewLayer( pTmpLayer,
633 rShape.first->removeViewLayer( pTmpLayer );
635 catch( uno::Exception& )
651 ENSURE_OR_THROW( rShape,
"LayerManager::addUpdateArea(): invalid Shape" );
653 const LayerShapeMap::const_iterator aShapeEntry(
maAllShapes.find(rShape) );
660 pLayer->addUpdateRange( rShape->getUpdateArea() );
664 LayerShapeMap::const_iterator aFirstLayerShape,
665 const LayerShapeMap::const_iterator& aEndLayerShapes )
667 const bool bLayerExists(
maLayers.size() > nCurrLayerIndex );
672 const bool bLayerResized( rLayer->commitBounds() );
674 nCurrLayerIndex+1) );
681 rLayer->clearContent();
684 while( aFirstLayerShape != aEndLayerShapes )
687 aFirstLayerShape->first->render();
700 for(
const auto& rView :
mrViews )
701 pLayer->addView( rView );
733 std::size_t nCurrLayerIndex(0);
734 bool bIsBackgroundLayer(
true);
735 bool bLastWasBackgroundDetached(
false);
736 LayerShapeMap::iterator aCurrShapeEntry(
maAllShapes.begin() );
737 LayerShapeMap::iterator aCurrLayerFirstShapeEntry(
maAllShapes.begin() );
738 const LayerShapeMap::iterator aEndShapeEntry (
maAllShapes.end() );
739 while( aCurrShapeEntry != aEndShapeEntry )
742 const bool bThisIsBackgroundDetached(
743 pCurrShape->isBackgroundDetached() );
745 if( bLastWasBackgroundDetached &&
746 !bThisIsBackgroundDetached )
754 aCurrLayerFirstShapeEntry,
756 aCurrLayerFirstShapeEntry=aCurrShapeEntry;
758 bIsBackgroundLayer =
false;
760 if( aWeakLayers.size() <= nCurrLayerIndex ||
761 notEqual(aWeakLayers.at(nCurrLayerIndex), aCurrShapeEntry->second) )
767 aWeakLayers.insert( aWeakLayers.begin()+nCurrLayerIndex,
772 OSL_ASSERT(
maLayers.size() == aWeakLayers.size() );
777 LayerWeakPtr& rCurrWeakLayer( aWeakLayers.at(nCurrLayerIndex) );
778 if( notEqual(rCurrWeakLayer, aCurrShapeEntry->second) )
782 maLayers.at(nCurrLayerIndex)->setShapeViews(
787 if( !bThisIsBackgroundDetached && pCurrShape->isVisible() )
794 pOldLayer->addUpdateRange(
795 pCurrShape->getUpdateArea() );
800 if( !(bBackgroundLayerPainted && bIsBackgroundLayer) )
804 aCurrShapeEntry->second = rCurrWeakLayer;
813 if( !bThisIsBackgroundDetached && !bIsBackgroundLayer )
814 rCurrLayer->updateBounds( pCurrShape );
816 bLastWasBackgroundDetached = bThisIsBackgroundDetached;
822 aCurrLayerFirstShapeEntry,
826 if(
maLayers.size() > nCurrLayerIndex+1 )
This class represents kind of a DOM tree node for shape text.
void implRemoveShape(const ShapeSharedPtr &rShape)
Common stuff when removing a shape.
bool mbDisableAnimationZOrder
When true, all sprite animations run in the foreground.
void viewAdded(const UnoViewSharedPtr &rView)
Notify new view added to UnoViewContainer.
bool renderTo(const ::cppcanvas::CanvasSharedPtr &rTargetCanvas) const
Render the content to given canvas.
void updateShapeLayers(bool bBackgroundLayerPainted)
Commits any pending layer reorg, due to shapes either entering or leaving animation mode.
void deactivate()
Deactivate the LayerManager.
void commitLayerChanges(std::size_t nCurrLayerIndex, LayerShapeMap::const_iterator aFirstLayerShape, const LayerShapeMap::const_iterator &aEndLayerShapes)
Push changes from updateShapeLayerAssociations() to current layer.
const UnoViewContainer & mrViews
Registered views.
ShapeSharedPtr lookupShape(const css::uno::Reference< css::drawing::XShape > &xShape) const
Lookup a Shape from an XShape model object.
LayerShapeMap maAllShapes
Set of shapes this LayerManager own.
AttributableShapeSharedPtr getSubsetShape(const AttributableShapeSharedPtr &rOrigShape, const DocTreeNode &rTreeNode)
Query a subset of the given original shape.
void notifyShapeUpdate(const ShapeSharedPtr &rShape)
Notify that a shape needs an update.
void revokeSubset(const AttributableShapeSharedPtr &rOrigShape, const AttributableShapeSharedPtr &rSubsetShape)
Revoke a previously queried subset shape.
void manageViews(LayerFunc layerFunc, ShapeFunc shapeFunc)
Add or remove views.
void activate()
Activate the LayerManager.
void leaveAnimationMode(const AnimatableShapeSharedPtr &rShape)
Notify the LayerManager that the given Shape is no longer animated.
void addUpdateArea(ShapeSharedPtr const &rShape)
Adds shape area to containing layer's damage area.
void implAddShape(const ShapeSharedPtr &rShape)
Common stuff when adding a shape.
void enterAnimationMode(const AnimatableShapeSharedPtr &rShape)
Notify the LayerManager that the given Shape starts an animation now.
bool mbLayerAssociationDirty
sal_True, if shapes might need to move to different layer
LayerSharedPtr createForegroundLayer() const
::std::vector< LayerSharedPtr > maLayers
All layers of this object. Vector owns the layers.
const XShapeToShapeMap & getXShapeToShapeMap() const
Get a map that maps all Shapes with their XShape reference as the key.
bool update()
Update the content.
LayerManager(const UnoViewContainer &rViews, bool bDisableAnimationZOrder)
Create a new layer manager for the given page bounds.
bool isUpdatePending() const
Check whether any update operations are pending.
void addShape(const ShapeSharedPtr &rShape)
Add the shape to this object.
void viewRemoved(const UnoViewSharedPtr &rView)
Notify view removed from UnoViewContainer.
void putShape2BackgroundLayer(LayerShapeMap::value_type &rShapeEntry)
Init Shape layers with background layer.
XShapeToShapeMap maXShapeHash
Contains all shapes with their XShape reference as the key.
bool mbActive
sal_False when deactivated
::std::set< ShapeSharedPtr > maUpdateShapes
Set of shapes that have requested an update.
sal_Int32 mnActiveSprites
Number of shape sprites currently active on this LayerManager.
void viewChanged(const UnoViewSharedPtr &rView)
bool removeShape(const ShapeSharedPtr &rShape)
Remove shape from this object.
bool isUpdatePending() const
Whether any update ranges have been added.
static LayerSharedPtr createBackgroundLayer()
Create background layer.
std::shared_ptr< LayerEndUpdate > EndUpdater
static LayerSharedPtr createLayer()
Create non-background layer.
UnoViewVector::iterator begin()
UnoViewVector::iterator end()
#define TOOLS_WARN_EXCEPTION(area, stream)
#define ENSURE_OR_THROW(c, m)
::cppcanvas::CanvasSharedPtr mpCanvas
std::shared_ptr< Canvas > CanvasSharedPtr
::std::shared_ptr< AnimatableShape > AnimatableShapeSharedPtr
std::shared_ptr< View > ViewSharedPtr
std::shared_ptr< ViewLayer > ViewLayerSharedPtr
::std::weak_ptr< Layer > LayerWeakPtr
::std::shared_ptr< Layer > LayerSharedPtr
::std::shared_ptr< AttributableShape > AttributableShapeSharedPtr
std::unordered_map< css::uno::Reference< css::drawing::XShape >, ShapeSharedPtr, hash< css::uno::Reference< css::drawing::XShape > > > XShapeToShapeMap
A hash map which maps the XShape to the corresponding Shape object.
::std::shared_ptr< Shape > ShapeSharedPtr
std::shared_ptr< UnoView > UnoViewSharedPtr
::basegfx::B2DHomMatrix getSpriteTransformation(const ::basegfx::B2DVector &rPixelSize, const ::basegfx::B2DVector &rOrigSize, const ShapeAttributeLayerSharedPtr &pAttr)
bool mbActive
When true, show() was called. Slide hidden otherwise.