- 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 );