Fix for SizeNegotiation.
[platform/core/uifw/dali-core.git] / dali / internal / event / size-negotiation / relayout-controller-impl.cpp
index 81d0310..9c2120a 100644 (file)
@@ -29,6 +29,7 @@
 #include <dali/public-api/actors/layer.h>
 #include <dali/public-api/common/stage.h>
 #include <dali/integration-api/debug.h>
+#include <dali/integration-api/render-controller.h>
 #include <dali/public-api/object/type-registry.h>
 #include <dali/public-api/object/object-registry.h>
 #include <dali/internal/event/actors/actor-impl.h>
@@ -69,7 +70,7 @@ void PrintChildren( Dali::Actor actor, int level )
 
   output << ", Dirty: (" << ( GetImplementation( actor ).IsLayoutDirty( Dimension::WIDTH ) ? "TRUE" : "FALSE" ) << "," << ( GetImplementation( actor ).IsLayoutDirty( Dimension::HEIGHT ) ? "TRUE" : "FALSE" ) << ")";
   output << ", Negotiated: (" << ( GetImplementation( actor ).IsLayoutNegotiated( Dimension::WIDTH ) ? "TRUE" : "FALSE" ) << "," << ( GetImplementation( actor ).IsLayoutNegotiated( Dimension::HEIGHT ) ? "TRUE" : "FALSE" ) << ")";
-  output << ", Enabled: " << ( actor.IsRelayoutEnabled() ? "TRUE" : "FALSE" );
+  output << ", Enabled: " << ( GetImplementation( actor ).IsRelayoutEnabled() ? "TRUE" : "FALSE" );
 
   output << ", (" << actor.GetObjectPtr() << ")" << std::endl;
 
@@ -111,14 +112,16 @@ RelayoutController* RelayoutController::Get()
   return &ThreadLocalStorage::Get().GetRelayoutController();
 }
 
-RelayoutController::RelayoutController()
-: mRelayoutInfoAllocator(),
+RelayoutController::RelayoutController( Integration::RenderController& controller )
+: mRenderController( controller ),
+  mRelayoutInfoAllocator(),
   mSlotDelegate( this ),
   mRelayoutStack( new MemoryPoolRelayoutContainer( mRelayoutInfoAllocator ) ),
   mRelayoutConnection( false ),
   mRelayoutFlag( false ),
   mEnabled( false ),
-  mPerformingRelayout( false )
+  mPerformingRelayout( false ),
+  mProcessingCoreEvents( false )
 {
   // Make space for 32 controls to avoid having to copy construct a lot in the beginning
   mRelayoutStack->Reserve( 32 );
@@ -144,8 +147,8 @@ void RelayoutController::RequestRelayout( Dali::Actor& actor, Dimension::Type di
     return;
   }
 
-  Dali::ActorContainer potentialRedundantSubRoots;
-  Dali::ActorContainer topOfSubTreeStack;
+  std::vector< Dali::Actor > potentialRedundantSubRoots;
+  std::vector< Dali::Actor > topOfSubTreeStack;
 
   topOfSubTreeStack.push_back( actor );
 
@@ -159,29 +162,39 @@ void RelayoutController::RequestRelayout( Dali::Actor& actor, Dimension::Type di
     }
   }
 
-  // Request this actor as head of sub-tree if it is not dependent on a parent that is dirty
-  Dali::Actor subTreeActor = topOfSubTreeStack.back();
-  Dali::Actor parent = subTreeActor.GetParent();
-  if( !parent || !( GetImplementation( subTreeActor ).RelayoutDependentOnParent() && GetImplementation( parent ).RelayoutRequired() ) )
+  while( !topOfSubTreeStack.empty() )
   {
-    // Add sub tree root to relayout list
-    AddRequest( subTreeActor );
+    // Request this actor as head of sub-tree if it is not dependent on a parent that is dirty
+    Dali::Actor subTreeActor = topOfSubTreeStack.back();
+    topOfSubTreeStack.pop_back();
 
-    // Flag request for end of frame
-    Request();
-  }
-  else
-  {
-    potentialRedundantSubRoots.push_back( subTreeActor );
+    Dali::Actor parent = subTreeActor.GetParent();
+    if( !parent || !( GetImplementation( subTreeActor ).RelayoutDependentOnParent() && GetImplementation( parent ).RelayoutRequired() ) )
+    {
+      // Add sub tree root to relayout list
+      AddRequest( subTreeActor );
+
+      // Flag request for end of frame
+      Request();
+    }
+    else
+    {
+      potentialRedundantSubRoots.push_back( subTreeActor );
+    }
   }
 
   // Remove any redundant sub-tree heads
-  for( ActorContainer::iterator it = potentialRedundantSubRoots.begin(), itEnd = potentialRedundantSubRoots.end(); it != itEnd; ++it )
+  for( std::vector< Dali::Actor >::iterator it = potentialRedundantSubRoots.begin(), itEnd = potentialRedundantSubRoots.end(); it != itEnd; ++it )
   {
     Dali::Actor subRoot = *it;
 
     RemoveRequest( subRoot );
   }
+
+  if ( !mProcessingCoreEvents )
+  {
+    mRenderController.RequestProcessEventsOnIdle();
+  }
 }
 
 void RelayoutController::OnApplicationSceneCreated()
@@ -213,7 +226,7 @@ void RelayoutController::RequestRelayoutTree( Dali::Actor& actor )
   {
     // If parent is not in relayout we are at the top of a new sub-tree
     Dali::Actor parent = actor.GetParent();
-    if( !parent || !parent.IsRelayoutEnabled() )
+    if( !parent || !GetImplementation( parent ).IsRelayoutEnabled() )
     {
       AddRequest( actor );
     }
@@ -232,7 +245,7 @@ void RelayoutController::RequestRelayoutTree( Dali::Actor& actor )
   }
 }
 
-void RelayoutController::PropagateAll( Dali::Actor& actor, Dimension::Type dimension, Dali::ActorContainer& topOfSubTreeStack, Dali::ActorContainer& potentialRedundantSubRoots )
+void RelayoutController::PropagateAll( Dali::Actor& actor, Dimension::Type dimension, std::vector< Dali::Actor >& topOfSubTreeStack, std::vector< Dali::Actor >& potentialRedundantSubRoots )
 {
   // Only set dirty flag if doing relayout and not already marked as dirty
   Actor& actorImpl = GetImplementation( actor );
@@ -489,6 +502,11 @@ bool RelayoutController::IsPerformingRelayout() const
   return mPerformingRelayout;
 }
 
+void RelayoutController::SetProcessingCoreEvents( bool processingEvents )
+{
+  mProcessingCoreEvents = processingEvents;
+}
+
 void RelayoutController::FindAndZero( const RawActorList& list, const Dali::RefObject* object )
 {
   // Object has been destroyed so clear it from this list