Change the order of the nodes when actors are moved 82/151082/2
authorAdeel Kazmi <adeel.kazmi@samsung.com>
Tue, 19 Sep 2017 14:33:03 +0000 (15:33 +0100)
committerAdeel Kazmi <adeel.kazmi@samsung.com>
Tue, 19 Sep 2017 15:31:29 +0000 (16:31 +0100)
This is required because certain clipping scenarios stopped working as we only changed the depth
index on the nodes but not the order in which they appear in the container.

Clipping relied on the order of the nodes in the hieararchy.

Change-Id: I7194c35318f55c326fe82886d6b58a865999e7bc

dali/internal/update/manager/update-manager.cpp

index cf23bc2..897573b 100644 (file)
@@ -139,8 +139,25 @@ inline void EraseUsingDiscardQueue( OwnerContainer<T*>& container, T* object, Di
   }
 }
 
+/**
+ * Descends into node's hierarchy and sorts the children of each child according to their depth-index.
+ * @param[in] node The node whose hierarchy to descend
+ */
+void SortSiblingNodesRecursively( Node& node )
+{
+  NodeContainer& container = node.GetChildren();
+  std::sort( container.Begin(), container.End(),
+             []( Node* a, Node* b ) { return a->GetDepthIndex() < b->GetDepthIndex(); } );
+
+  // Descend tree and sort as well
+  for( auto&& iter : container )
+  {
+    SortSiblingNodesRecursively( *iter );
+  }
 }
 
+} // unnamed namespace
+
 /**
  * Structure to contain UpdateManager internal data
  */
@@ -1022,6 +1039,9 @@ void UpdateManager::SetDepthIndices( OwnerPointer< NodeDepths >& nodeDepths )
   {
     iter.node->SetDepthIndex( iter.sortedDepth );
   }
+
+  // Go through node hierarchy and rearrange siblings according to depth-index
+  SortSiblingNodesRecursively( *( mImpl->root ) );
 }
 
 void UpdateManager::AddSampler( OwnerPointer< Render::Sampler >& sampler )