-
- SetDepthIndicesMessage( GetEventThreadServices().GetUpdateManager(), sceneGraphNodeDepths );
- DALI_LOG_TIMER_END(depthTimer, gLogFilter, Debug::Concise, "Depth tree create time: ");
-}
-
-/**
- * Structure to store the actor's associated node in the depth tree for child
- * traversal
- */
-struct ActorNodePair
-{
- Actor* actor;
- ActorDepthTreeNode* node;
- ActorNodePair( Actor* actor, ActorDepthTreeNode* node )
- : actor(actor),
- node(node)
- {
- }
-};
-
-/*
- * Descend actor tree, building a depth tree based on actor's sibling order.
- * Actors with the same sibling order share the same depth tree. Siblings
- * in the depth tree are ordered by actor's sibling order.
- *
- * An actor tree like this:
- *
- * Root (SO:0)
- * _/ | \_
- * _/ | \_
- * _/ | \_
- * / | \
- * A(SO:1) B(SO:2) C(SO:1)
- * _/\_ | _/ \_
- * / \ | / \
- * D(SO:0) E(SO:0) F(SO:0) G(SO:1) H(SO:0)
- *
- * will end up as a depth tree like this:
- *
- * RootNode [ Root ] -> NULL
- * |(mFC)
- * V (mNS)
- * Node [ A, C ] ------------------------> Node [ B ] -> NULL
- * | |
- * V V
- * Node [ D, E, H ] -> Node [ G ] -> NULL Node [ F ] -> NULL
- * | | |
- * V V V
- * NULL NULL NULL
- *
- * (All nodes also point to their parents to enable storage free traversal)
- */
-int Actor::BuildDepthTree( DepthNodeMemoryPool& nodeMemoryPool, ActorDepthTreeNode* node )
-{
- int treeCount=1; // Count self and children
-
- // Create/add to children of this node
- if( mChildren )
- {
- std::vector<ActorNodePair> storedChildren;
- storedChildren.reserve( mChildren->size() );
-
- for( ActorContainer::iterator it = mChildren->begin(); it != mChildren->end(); ++it )
- {
- Actor* childActor = (*it).Get();
- if( childActor->IsLayer() )
- {
- Layer* layer = static_cast<Layer*>(childActor);
- if( layer->GetBehavior() == Dali::Layer::LAYER_3D )
- {
- // Ignore this actor and children.
- continue;
- }
- }
-
- // If no existing depth node children
- if( node->mFirstChildNode == NULL )
- {
- node->mFirstChildNode = new (nodeMemoryPool.AllocateRaw()) ActorDepthTreeNode( childActor, childActor->mSiblingOrder );
- node->mFirstChildNode->mParentNode = node;
- storedChildren.push_back(ActorNodePair( childActor, node->mFirstChildNode ));
- }
- else // find child node with matching sibling order (insertion sort)
- {
- bool addedChildActor = false;
-
- // depth tree child nodes ordered by sibling order
- ActorDepthTreeNode* lastNode = NULL;
- for( ActorDepthTreeNode* childNode = node->mFirstChildNode; childNode != NULL; childNode = childNode->mNextSiblingNode )
- {
- uint16_t actorSiblingOrder = childActor->mSiblingOrder;
- uint16_t currentSiblingOrder = childNode->GetSiblingOrder();
-
- if( actorSiblingOrder == currentSiblingOrder )
- {
- // Don't need a new depth node, add to existing node
- childNode->AddActor( childActor );
- storedChildren.push_back(ActorNodePair( childActor, childNode ));
- addedChildActor = true;
- break;
- }
- else if( actorSiblingOrder < currentSiblingOrder )
- {
- break;
- }
- lastNode = childNode;
- }
-
- // No matching sibling order - create new node and insert into sibling list
- if( !addedChildActor )
- {
- ActorDepthTreeNode* newNode = new (nodeMemoryPool.AllocateRaw()) ActorDepthTreeNode( childActor, childActor->mSiblingOrder );
-
- newNode->mParentNode = node;
- storedChildren.push_back(ActorNodePair( childActor, newNode ));
-
- if( lastNode == NULL ) // Insert at start of siblings
- {
- ActorDepthTreeNode* nextNode = node->mFirstChildNode;
- node->mFirstChildNode = newNode;
- newNode->mNextSiblingNode = nextNode;
- }
- else // insert into siblings after last node
- {
- newNode->mNextSiblingNode = lastNode->mNextSiblingNode;
- lastNode->mNextSiblingNode = newNode;
- }
- }
- }
- }
-
- // Order of descent doesn't matter; we're using insertion to sort.
- for( std::vector<ActorNodePair>::iterator iter = storedChildren.begin(); iter != storedChildren.end(); ++iter )
- {
- treeCount += iter->actor->BuildDepthTree( nodeMemoryPool, iter->node );
- }
- }
- return treeCount;
-}
-
-unsigned int Actor::GetDefaultPropertyCount() const
-{
- return DEFAULT_PROPERTY_COUNT;
-}
-
-void Actor::GetDefaultPropertyIndices( Property::IndexContainer& indices ) const
-{
- indices.Reserve( DEFAULT_PROPERTY_COUNT );
-
- for( int i = 0; i < DEFAULT_PROPERTY_COUNT; ++i )
- {
- indices.PushBack( i );
- }
-}
-
-const char* Actor::GetDefaultPropertyName( Property::Index index ) const
-{
- if( index < DEFAULT_PROPERTY_COUNT )
- {
- return DEFAULT_PROPERTY_DETAILS[ index ].name;
- }
-
- return NULL;
-}
-
-Property::Index Actor::GetDefaultPropertyIndex( const std::string& name ) const
-{
- Property::Index index = Property::INVALID_INDEX;
-
- // Look for name in default properties
- for( int i = 0; i < DEFAULT_PROPERTY_COUNT; ++i )
- {
- const Internal::PropertyDetails* property = &DEFAULT_PROPERTY_DETAILS[ i ];
- if( 0 == name.compare( property->name ) )
- {
- index = i;
- break;
- }
- }
-
- return index;
-}
-
-bool Actor::IsDefaultPropertyWritable( Property::Index index ) const
-{
- if( index < DEFAULT_PROPERTY_COUNT )
- {
- return DEFAULT_PROPERTY_DETAILS[ index ].writable;
- }
-
- return false;
-}
-
-bool Actor::IsDefaultPropertyAnimatable( Property::Index index ) const
-{
- if( index < DEFAULT_PROPERTY_COUNT )
- {
- return DEFAULT_PROPERTY_DETAILS[ index ].animatable;
- }
-
- return false;
-}
-
-bool Actor::IsDefaultPropertyAConstraintInput( Property::Index index ) const
-{
- if( index < DEFAULT_PROPERTY_COUNT )
- {
- return DEFAULT_PROPERTY_DETAILS[ index ].constraintInput;
- }
-
- return false;
-}
-
-Property::Type Actor::GetDefaultPropertyType( Property::Index index ) const
-{
- if( index < DEFAULT_PROPERTY_COUNT )
- {
- return DEFAULT_PROPERTY_DETAILS[ index ].type;
- }
-
- // index out of range...return Property::NONE
- return Property::NONE;