[3.0] Bug fix in Transform manager, improve performance 00/84900/1
authorFerran Sole <ferran.sole@samsung.com>
Tue, 9 Aug 2016 15:07:35 +0000 (16:07 +0100)
committerAgnelo Vaz <agnelo.vaz@samsung.com>
Mon, 22 Aug 2016 17:11:32 +0000 (18:11 +0100)
* World matrices where not reordered in the sorting pass causing the
  application to get the wrong value if the world matrix was queried during
  component sorting.
  This bug was causing slider handle and value to jump to an erroneous position
  when panning

* Minor performance improvement to reduce the number of swaps when
  reordering transform components

Change-Id: Ifde6ef4aaa2052c70042ef46c8909c85c407588a

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

index 5415778..b289bf4 100644 (file)
@@ -312,6 +312,7 @@ void TransformManager::SwapComponents( unsigned int i, unsigned int j )
   std::swap( mLocal[i], mLocal[j] );
   std::swap( mComponentDirty[i], mComponentDirty[j] );
   std::swap( mBoundingSpheres[i], mBoundingSpheres[j] );
+  std::swap( mWorld[i], mWorld[j] );
 
   mIds[ mComponentId[i] ] = i;
   mIds[ mComponentId[j] ] = j;
@@ -335,10 +336,15 @@ void TransformManager::ReorderComponents()
     }
   }
 
-  std::sort( mOrderedComponents.Begin(), mOrderedComponents.End());
-  for( size_t i(0); i<mComponentCount-1; ++i )
+  std::stable_sort( mOrderedComponents.Begin(), mOrderedComponents.End());
+  unsigned int previousIndex = 0;
+  for( size_t newIndex(0); newIndex<mComponentCount-1; ++newIndex )
   {
-    SwapComponents( mIds[mOrderedComponents[i].id], i);
+    previousIndex = mIds[mOrderedComponents[newIndex].id];
+    if( previousIndex != newIndex )
+    {
+      SwapComponents( previousIndex, newIndex);
+    }
   }
 }