/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2019 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
*
*/
-// FILE HEADER
-
+// CLASS HEADER
#include "relayout-controller-impl.h"
// EXTERNAL INCLUDES
#if defined(DEBUG_ENABLED)
#include <sstream>
-#include <dali/internal/event/common/system-overlay-impl.h>
#endif // defined(DEBUG_ENABLED)
// INTERNAL INCLUDES
-#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>
+#include <dali/internal/event/common/stage-impl.h>
#include <dali/internal/event/common/thread-local-storage.h>
namespace Dali
output << " - Pos: " << actor.GetCurrentPosition() << " Size: " << actor.GetTargetSize();
- output << ", Dirty: (" << ( GetImplementation( actor ).IsLayoutDirty( WIDTH ) ? "TRUE" : "FALSE" ) << "," << ( GetImplementation( actor ).IsLayoutDirty( HEIGHT ) ? "TRUE" : "FALSE" ) << ")";
- output << ", Negotiated: (" << ( GetImplementation( actor ).IsLayoutNegotiated( WIDTH ) ? "TRUE" : "FALSE" ) << "," << ( GetImplementation( actor ).IsLayoutNegotiated( HEIGHT ) ? "TRUE" : "FALSE" ) << ")";
- output << ", Enabled: " << ( actor.IsRelayoutEnabled() ? "TRUE" : "FALSE" );
+ 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: " << ( GetImplementation( actor ).IsRelayoutEnabled() ? "TRUE" : "FALSE" );
output << ", (" << actor.GetObjectPtr() << ")" << std::endl;
DALI_LOG_INFO( gLogFilter, Debug::Verbose, output.str().c_str() );
++level;
- unsigned int numChildren = actor.GetChildCount();
- for( unsigned int i=0; i<numChildren; ++i )
+ uint32_t numChildren = actor.GetChildCount();
+ for( uint32_t i=0; i<numChildren; ++i )
{
PrintChildren( actor.GetChildAt(i), level );
}
if ( gLogFilter->IsEnabledFor( Debug::Verbose ) )
{
DALI_LOG_INFO( gLogFilter, Debug::Verbose, "---------- ROOT LAYER ----------\n" );
- PrintChildren( Dali::Stage().GetCurrent().GetRootLayer(), 0 );
+
+ PrintChildren( Stage::GetCurrent()->GetRootLayer(), 0 );
}
}
} // unnamed namespace
-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 );
delete mRelayoutStack;
}
-void RelayoutController::QueueActor( Dali::Actor& actor, RelayoutContainer& actors, Vector2 size )
+RelayoutController* RelayoutController::Get()
+{
+ return &ThreadLocalStorage::Get().GetRelayoutController();
+}
+
+void RelayoutController::QueueActor( Internal::Actor* actor, RelayoutContainer& actors, Vector2 size )
{
- if( GetImplementation( actor ).RelayoutRequired() )
+ if( actor && actor->RelayoutRequired() )
{
- actors.Add( actor, size );
+ Dali::Actor actorHandle = Dali::Actor( actor );
+ actors.Add( actorHandle, size );
}
}
-void RelayoutController::RequestRelayout( Dali::Actor& actor, Dimension dimension )
+void RelayoutController::RequestRelayout( Dali::Actor& actor, Dimension::Type dimension )
{
if( !mEnabled )
{
return;
}
- Dali::ActorContainer potentialRedundantSubRoots;
- Dali::ActorContainer topOfSubTreeStack;
+ std::vector< Dali::Actor > potentialRedundantSubRoots;
+ std::vector< Dali::Actor > topOfSubTreeStack;
topOfSubTreeStack.push_back( actor );
// Propagate on all dimensions
- for( unsigned int i = 0; i < DIMENSION_COUNT; ++i )
+ for( uint32_t i = 0; i < Dimension::DIMENSION_COUNT; ++i )
{
if( dimension & ( 1 << i ) )
{
// Do the propagation
- PropagateAll( actor, static_cast< Dimension >( 1 << i ), topOfSubTreeStack, potentialRedundantSubRoots );
+ PropagateAll( actor, static_cast< Dimension::Type >( 1 << i ), topOfSubTreeStack, potentialRedundantSubRoots );
}
}
- // 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( false );
+ }
}
void RelayoutController::OnApplicationSceneCreated()
// Open relayout controller to receive relayout requests
mEnabled = true;
- // Spread the dirty flag through whole tree - don't need to explicity
- // add request on rootLayer as it will automatically be added below.
- Dali::Actor rootLayer = Dali::Stage::GetCurrent().GetRootLayer();
- RequestRelayoutTree( rootLayer );
-
// Flag request for end of frame
Request();
}
{
// 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 );
}
}
// Propagate down to children
- for( unsigned int i = 0; i < actor.GetChildCount(); ++i )
+ for( uint32_t i = 0; i < actor.GetChildCount(); ++i )
{
Dali::Actor child = actor.GetChildAt( i );
}
}
-void RelayoutController::PropagateAll( Dali::Actor& actor, Dimension 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 );
// Check for dimension dependecy: width for height/height for width etc
// Check each possible dimension and see if it is dependent on the input one
- for( unsigned int i = 0; i < DIMENSION_COUNT; ++i )
+ for( uint32_t i = 0; i < Dimension::DIMENSION_COUNT; ++i )
{
- Dimension dimensionToCheck = static_cast< Dimension >( 1 << i );
+ Dimension::Type dimensionToCheck = static_cast< Dimension::Type >( 1 << i );
if( actorImpl.RelayoutDependentOnDimension( dimension, dimensionToCheck ) &&
!actorImpl.IsLayoutDirty( dimensionToCheck ) )
{
// Store the highest parent reached
bool found = false;
- for( unsigned int i = 0, count = topOfSubTreeStack.size(); i < count; ++i )
+ for( auto&& element : topOfSubTreeStack )
{
- if( topOfSubTreeStack[ i ] == parent )
+ if( element == parent )
{
found = true;
break;
}
-void RelayoutController::PropagateFlags( Dali::Actor& actor, Dimension dimension )
+void RelayoutController::PropagateFlags( Dali::Actor& actor, Dimension::Type dimension )
{
// Only set dirty flag if doing relayout and not already marked as dirty
Actor& actorImpl = GetImplementation( actor );
// Check for dimension dependecy: width for height/height for width etc
// Check each possible dimension and see if it is dependent on the input one
- for( unsigned int i = 0; i < DIMENSION_COUNT; ++i )
+ for( uint32_t i = 0; i < Dimension::DIMENSION_COUNT; ++i )
{
- Dimension dimensionToCheck = static_cast< Dimension >( 1 << i );
+ Dimension::Type dimensionToCheck = static_cast< Dimension::Type >( 1 << i );
if( actorImpl.RelayoutDependentOnDimension( dimension, dimensionToCheck ) )
{
}
// Propagate down to children
- for( unsigned int i = 0, childCount = actor.GetChildCount(); i < childCount; ++i )
+ for( uint32_t i = 0, childCount = actor.GetChildCount(); i < childCount; ++i )
{
Dali::Actor child = actor.GetChildAt( i );
Actor& childImpl = GetImplementation( child );
void RelayoutController::AddRequest( Dali::Actor& actor )
{
- BaseObject* actorPtr = &GetImplementation( actor );
+ Internal::Actor* actorPtr = &GetImplementation( actor );
// Only add the rootActor if it is not already recorded
bool found = false;
- for( unsigned int i = 0, count = mDirtyLayoutSubTrees.Size(); i < count; ++i )
+ for( auto&& item : mDirtyLayoutSubTrees )
{
- if( mDirtyLayoutSubTrees[ i ] == actorPtr )
+ if( item == actorPtr )
{
found = true;
break;
void RelayoutController::RemoveRequest( Dali::Actor& actor )
{
- BaseObject* actorPtr = &GetImplementation( actor );
+ Internal::Actor* actorPtr = &GetImplementation( actor );
// Remove actor from dirty sub trees
for( RawActorList::Iterator it = mDirtyLayoutSubTrees.Begin(), itEnd = mDirtyLayoutSubTrees.End(); it != itEnd; ++it )
if( !mRelayoutConnection )
{
- Dali::Stage stage = Dali::Stage::GetCurrent();
- stage.GetObjectRegistry().ObjectDestroyedSignal().Connect( mSlotDelegate, &RelayoutController::OnObjectDestroyed );
+ ThreadLocalStorage::Get().GetObjectRegistry().ObjectDestroyedSignal().Connect( mSlotDelegate, &RelayoutController::OnObjectDestroyed );
mRelayoutConnection = true;
}
// 1. Finds all top-level controls from the dirty list and allocate them the size of the stage
// These controls are paired with the parent/stage size and added to the stack.
- const Vector2 stageSize = Dali::Stage::GetCurrent().GetSize();
-
for( RawActorList::Iterator it = mDirtyLayoutSubTrees.Begin(), itEnd = mDirtyLayoutSubTrees.End(); it != itEnd; ++it )
{
- BaseObject* dirtyActor = *it;
+ Internal::Actor* dirtyActor = *it;
// Need to test if actor is valid (could have been deleted and had the pointer cleared)
if( dirtyActor )
{
- // We know that BaseObject is a base class of Internal::Actor but need to instruct the compiler to do the cast
- Dali::Actor actor = Dali::Actor( reinterpret_cast<Dali::Internal::Actor*>( dirtyActor ) );
-
// Only negotiate actors that are on stage
- if( actor.OnStage() )
+ if( dirtyActor->OnStage() )
{
- Dali::Actor parent = actor.GetParent();
- QueueActor( actor, *mRelayoutStack, ( parent ) ? Vector2( parent.GetTargetSize() ) : stageSize );
+ Internal::Actor* parent = dirtyActor->GetParent();
+ QueueActor( dirtyActor, *mRelayoutStack, ( parent ) ? Vector2( parent->GetTargetSize() ) : dirtyActor->GetScene().GetSize() );
}
}
}
// 3. Negotiate the size with the current actor. Pass it an empty container which the actor
// has to fill with all the actors it has not done any size negotiation for.
+
actorImpl.NegotiateSize( size, *mRelayoutStack );
+
+ // Reset the flag so that size negotiation will respect the actor's original resize policy
+ actorImpl.SetUseAssignedSize( false );
}
}
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