namespace SceneGraph
{
-namespace
-{
-
-void DestroyNodeSet( std::set<Node*>& nodeSet )
-{
- for( std::set<Node*>::iterator iter = nodeSet.begin(); iter != nodeSet.end(); ++iter )
- {
- Node* node( *iter );
-
- // Call Node::OnDestroy as each node is destroyed
- node->OnDestroy();
-
- delete node;
- }
- nodeSet.clear();
-}
-
-} //namespace
-
typedef OwnerContainer< Shader* > ShaderContainer;
typedef ShaderContainer::Iterator ShaderIter;
typedef ShaderContainer::ConstIterator ShaderConstIter;
renderers.SetSceneController( *sceneController );
geometries.SetSceneController( *sceneController );
materials.SetSceneController( *sceneController );
+
+ // create first 'dummy' node
+ nodes.PushBack(0u);
}
~Impl()
}
// UpdateManager owns the Nodes
- DestroyNodeSet( activeDisconnectedNodes );
- DestroyNodeSet( connectedNodes );
- DestroyNodeSet( disconnectedNodes );
+ Vector<Node*>::Iterator iter = nodes.Begin()+1;
+ Vector<Node*>::Iterator endIter = nodes.End();
+ for(;iter!=endIter;++iter)
+ {
+ (*iter)->OnDestroy();
+ delete(*iter);
+ }
// If there is root, reset it, otherwise do nothing as rendering was never started
if( root )
Layer* root; ///< The root node (root is a layer)
Layer* systemLevelRoot; ///< A separate root-node for system-level content
- std::set< Node* > activeDisconnectedNodes; ///< A container of new or modified nodes (without parent) owned by UpdateManager
- std::set< Node* > connectedNodes; ///< A container of connected (with parent) nodes owned by UpdateManager
- std::set< Node* > disconnectedNodes; ///< A container of inactive disconnected nodes (without parent) owned by UpdateManager
+
+ Vector<Node*> nodes; ///< A container of all instantiated nodes
SortedLayerPointers sortedLayers; ///< A container of Layer pointers sorted by depth
SortedLayerPointers systemLevelSortedLayers; ///< A separate container of system-level Layers
DALI_ASSERT_ALWAYS( NULL != node );
DALI_ASSERT_ALWAYS( NULL == node->GetParent() ); // Should not have a parent yet
- mImpl->activeDisconnectedNodes.insert( node ); // Takes ownership of node
+ // Nodes must be sorted by pointer
+ Vector<Node*>::Iterator begin = mImpl->nodes.Begin();
+ for(Vector<Node*>::Iterator iter = mImpl->nodes.End()-1; iter >= begin; --iter)
+ {
+ if(node > (*iter))
+ {
+ mImpl->nodes.Insert((iter+1), node);
+ break;
+ }
+ }
}
void UpdateManager::ConnectNode( Node* parent, Node* node )
DALI_ASSERT_ALWAYS( NULL != node );
DALI_ASSERT_ALWAYS( NULL == node->GetParent() ); // Should not have a parent yet
- // Move from active/disconnectedNodes to connectedNodes
- std::set<Node*>::size_type removed = mImpl->activeDisconnectedNodes.erase( node );
- if( !removed )
- {
- removed = mImpl->disconnectedNodes.erase( node );
- DALI_ASSERT_ALWAYS( removed );
- }
- mImpl->connectedNodes.insert( node );
-
- node->SetActive( true );
-
parent->ConnectChild( node );
}
DALI_ASSERT_ALWAYS( NULL != parent );
parent->SetDirtyFlag( ChildDeletedFlag ); // make parent dirty so that render items dont get reused
- // Move from connectedNodes to activeDisconnectedNodes (reset properties next frame)
- parent->DisconnectChild( mSceneGraphBuffers.GetUpdateBufferIndex(), *node, mImpl->connectedNodes, mImpl->activeDisconnectedNodes );
-}
-
-void UpdateManager::SetNodeActive( Node* node )
-{
- DALI_ASSERT_ALWAYS( NULL != node );
- DALI_ASSERT_ALWAYS( NULL == node->GetParent() ); // Should not have a parent yet
-
- // Move from disconnectedNodes to activeDisconnectedNodes (reset properties next frame)
- std::set<Node*>::size_type removed = mImpl->disconnectedNodes.erase( node );
- DALI_ASSERT_ALWAYS( removed );
- mImpl->activeDisconnectedNodes.insert( node );
-
- node->SetActive( true );
+ parent->DisconnectChild( mSceneGraphBuffers.GetUpdateBufferIndex(), *node );
}
void UpdateManager::DestroyNode( Node* node )
DALI_ASSERT_ALWAYS( NULL != node );
DALI_ASSERT_ALWAYS( NULL == node->GetParent() ); // Should have been disconnected
- // Transfer ownership from new/disconnectedNodes to the discard queue
- // This keeps the nodes alive, until the render-thread has finished with them
- std::set<Node*>::size_type removed = mImpl->activeDisconnectedNodes.erase( node );
- if( !removed )
+ Vector<Node*>::Iterator iter = mImpl->nodes.Begin()+1;
+ Vector<Node*>::Iterator endIter = mImpl->nodes.End();
+ for(;iter!=endIter;++iter)
{
- removed = mImpl->disconnectedNodes.erase( node );
- DALI_ASSERT_ALWAYS( removed );
+ if((*iter) == node)
+ {
+ mImpl->nodes.Erase(iter);
+ break;
+ }
}
+
mImpl->discardQueue.Add( mSceneGraphBuffers.GetUpdateBufferIndex(), node );
// Notify the Node about impending destruction
mImpl->systemLevelRoot->ResetToBaseValues( bufferIndex );
}
- // Reset the Connected Nodes
- const std::set<Node*>::iterator endIter = mImpl->connectedNodes.end();
- for( std::set<Node*>::iterator iter = mImpl->connectedNodes.begin(); endIter != iter; ++iter )
+ // Reset all the nodes
+ Vector<Node*>::Iterator iter = mImpl->nodes.Begin()+1;
+ Vector<Node*>::Iterator endIter = mImpl->nodes.End();
+ for(;iter != endIter; ++iter)
{
(*iter)->ResetToBaseValues( bufferIndex );
}
- // If a Node is disconnected, it may still be "active" (requires a reset in next frame)
- for( std::set<Node*>::iterator iter = mImpl->activeDisconnectedNodes.begin(); mImpl->activeDisconnectedNodes.end() != iter; iter = mImpl->activeDisconnectedNodes.begin() )
- {
- Node* node = *iter;
- node->ResetToBaseValues( bufferIndex );
- node->SetActive( false );
-
- // Move everything from activeDisconnectedNodes to disconnectedNodes (no need to reset again)
- mImpl->activeDisconnectedNodes.erase( iter );
- mImpl->disconnectedNodes.insert( node );
- }
-
// Reset system-level render-task list properties to base values
const RenderTaskList::RenderTaskContainer& systemLevelTasks = mImpl->systemLevelTaskList.GetTasks();
mImpl->geometries.ResetToBaseValues( bufferIndex );
mImpl->renderers.ResetToBaseValues( bufferIndex );
-
// Reset animatable shader properties to base values
for (ShaderIter iter = mImpl->shaders.Begin(); iter != mImpl->shaders.End(); ++iter)
{
mIsRoot( false ),
mInheritOrientation( true ),
mInheritScale( true ),
- mIsActive( true ),
mDrawMode( DrawMode::NORMAL ),
mPositionInheritanceMode( DEFAULT_POSITION_INHERITANCE_MODE ),
mColorMode( DEFAULT_COLOR_MODE )
mAttachment = &object;
SetAllDirtyFlags();
- if( mIsActive )
- {
- mAttachment->ConnectedToSceneGraph();
- }
+ mAttachment->ConnectedToSceneGraph();
}
void Node::SetRoot(bool isRoot)
}
}
-void Node::DisconnectChild( BufferIndex updateBufferIndex, Node& childNode, std::set<Node*>& connectedNodes, std::set<Node*>& disconnectedNodes )
+void Node::DisconnectChild( BufferIndex updateBufferIndex, Node& childNode )
{
DALI_ASSERT_ALWAYS( this != &childNode );
DALI_ASSERT_ALWAYS( childNode.GetParent() == this );
}
DALI_ASSERT_ALWAYS( NULL != found );
- found->RecursiveDisconnectFromSceneGraph( updateBufferIndex, connectedNodes, disconnectedNodes );
+ found->RecursiveDisconnectFromSceneGraph( updateBufferIndex );
}
void Node::RemoveRenderer( Renderer* renderer )
mDepth = mParent->GetDepth() + 1u;
}
-void Node::RecursiveDisconnectFromSceneGraph( BufferIndex updateBufferIndex, std::set<Node*>& connectedNodes, std::set<Node*>& disconnectedNodes )
+void Node::RecursiveDisconnectFromSceneGraph( BufferIndex updateBufferIndex )
{
DALI_ASSERT_ALWAYS(!mIsRoot);
DALI_ASSERT_ALWAYS(mParent != NULL);
const NodeIter endIter = mChildren.End();
for ( NodeIter iter = mChildren.Begin(); iter != endIter; ++iter )
{
- (*iter)->RecursiveDisconnectFromSceneGraph( updateBufferIndex, connectedNodes, disconnectedNodes );
+ (*iter)->RecursiveDisconnectFromSceneGraph( updateBufferIndex );
}
// Animators, Constraints etc. should be disconnected from the child's properties.
mAttachment->DisconnectedFromSceneGraph();
}
- // Move into disconnectedNodes
- std::set<Node*>::size_type removed = connectedNodes.erase( this );
- DALI_ASSERT_ALWAYS( removed );
- disconnectedNodes.insert( this );
}
} // namespace SceneGraph
void operator delete( void* ptr );
/**
- * When a Node is marked "active" it has been disconnected, but its properties have been modified.
- * @note An inactive Node will be skipped during the UpdateManager ResetProperties stage.
- * @param[in] isActive True if the Node is active.
- */
- void SetActive( bool isActive )
- {
- mIsActive = isActive;
- }
-
- /**
- * Query whether the Node is active.
- * @return True if the Node is active.
- */
- bool IsActive() const
- {
- return mIsActive;
- }
-
- /**
* Called during UpdateManager::DestroyNode shortly before Node is destroyed.
*/
void OnDestroy();
* @pre childNode is a child of this Node.
* @param[in] updateBufferIndex The current update buffer index.
* @param[in] childNode The node to disconnect.
- * @param[in] connectedNodes Disconnected Node attachments should be removed from here.
- * @param[in] disconnectedNodes Disconnected Node attachments should be added here.
*/
- void DisconnectChild( BufferIndex updateBufferIndex, Node& childNode, std::set<Node*>& connectedNodes, std::set<Node*>& disconnectedNodes );
+ void DisconnectChild( BufferIndex updateBufferIndex, Node& childNode );
/**
* Retrieve the children a Node.
* Recursive helper to disconnect a Node and its children.
* Disconnected Nodes have no parent or children.
* @param[in] updateBufferIndex The current update buffer index.
- * @param[in] connectedNodes Disconnected Node attachments should be removed from here.
- * @param[in] disconnectedNodes Disconnected Node attachments should be added here.
*/
- void RecursiveDisconnectFromSceneGraph( BufferIndex updateBufferIndex, std::set<Node*>& connectedNodes, std::set<Node*>& disconnectedNodes );
+ void RecursiveDisconnectFromSceneGraph( BufferIndex updateBufferIndex );
public: // Default properties
bool mIsRoot:1; ///< True if the node cannot have a parent
bool mInheritOrientation:1; ///< Whether the parent's orientation should be inherited.
bool mInheritScale:1; ///< Whether the parent's scale should be inherited.
- bool mIsActive:1; ///< When a Node is marked "active" it has been disconnected, and its properties have not been modified
DrawMode::Type mDrawMode:2; ///< How the Node and its children should be drawn
PositionInheritanceMode mPositionInheritanceMode:2;///< Determines how position is inherited, 2 bits is enough