X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali%2Finternal%2Fevent%2Fsize-negotiation%2Frelayout-controller-impl.cpp;h=0b3ec2cffc14ffb8ab71366a237c3d13b6982fef;hb=091424324901c46a18959bfc0dd52f7ce8a0a811;hp=3deb9e1c427ee8092de4187b12a052baccec267a;hpb=48da56010c22526d2aa19332d7ebfadc22b3967f;p=platform%2Fcore%2Fuifw%2Fdali-core.git diff --git a/dali/internal/event/size-negotiation/relayout-controller-impl.cpp b/dali/internal/event/size-negotiation/relayout-controller-impl.cpp index 3deb9e1..0b3ec2c 100644 --- a/dali/internal/event/size-negotiation/relayout-controller-impl.cpp +++ b/dali/internal/event/size-negotiation/relayout-controller-impl.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Samsung Electronics Co., Ltd. + * Copyright (c) 2015 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. @@ -15,8 +15,7 @@ * */ -// FILE HEADER - +// CLASS HEADER #include "relayout-controller-impl.h" // EXTERNAL INCLUDES @@ -26,12 +25,13 @@ #endif // defined(DEBUG_ENABLED) // INTERNAL INCLUDES -#include -#include #include +#include #include #include #include +#include +#include #include namespace Dali @@ -67,9 +67,9 @@ void PrintChildren( Dali::Actor actor, int level ) 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; @@ -92,7 +92,7 @@ void PrintHierarchy() 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 ); } } @@ -106,18 +106,17 @@ void PrintHierarchy() } // 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 ) ), + mStageSize(), // zero initialized mRelayoutConnection( false ), mRelayoutFlag( false ), - mEnabled( false ) + mEnabled( false ), + mPerformingRelayout( false ), + mProcessingCoreEvents( false ) { // Make space for 32 controls to avoid having to copy construct a lot in the beginning mRelayoutStack->Reserve( 32 ); @@ -128,6 +127,17 @@ RelayoutController::~RelayoutController() delete mRelayoutStack; } +RelayoutController* RelayoutController::Get() +{ + return &ThreadLocalStorage::Get().GetRelayoutController(); +} + +void RelayoutController::SetStageSize( unsigned int width, unsigned int height ) +{ + mStageSize.width = width; + mStageSize.height = height; +} + void RelayoutController::QueueActor( Dali::Actor& actor, RelayoutContainer& actors, Vector2 size ) { if( GetImplementation( actor ).RelayoutRequired() ) @@ -136,51 +146,61 @@ void RelayoutController::QueueActor( Dali::Actor& actor, RelayoutContainer& acto } } -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( unsigned int 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(); + } } void RelayoutController::OnApplicationSceneCreated() @@ -192,9 +212,19 @@ void RelayoutController::OnApplicationSceneCreated() // 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(); + Dali::Stage stage = Dali::Stage::GetCurrent(); + Dali::Actor rootLayer = stage.GetRootLayer(); RequestRelayoutTree( rootLayer ); + // Also add request on the root of system overlay + Dali::Internal::SystemOverlay* systemOverlay = GetImplementation(stage).GetSystemOverlayInternal(); + if( systemOverlay ) + { + Dali::Internal::Actor& systemOverlayInternalRoot = systemOverlay->GetDefaultRootActor(); + Dali::Actor systemOverlayRoot = Dali::Actor(&systemOverlayInternalRoot); + RequestRelayoutTree( systemOverlayRoot ); + } + // Flag request for end of frame Request(); } @@ -212,7 +242,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 ); } @@ -231,7 +261,7 @@ void RelayoutController::RequestRelayoutTree( Dali::Actor& actor ) } } -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 ); @@ -243,9 +273,9 @@ void RelayoutController::PropagateAll( Dali::Actor& actor, Dimension dimension, // 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( unsigned int 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 ) ) @@ -305,7 +335,7 @@ void RelayoutController::PropagateAll( Dali::Actor& actor, Dimension dimension, } -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 ); @@ -317,9 +347,9 @@ void RelayoutController::PropagateFlags( Dali::Actor& actor, Dimension dimension // 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( unsigned int 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 ) ) { @@ -413,13 +443,13 @@ void RelayoutController::Relayout() // Only do something when requested if( mRelayoutFlag ) { + mPerformingRelayout = true; + // Clear the flag as we're now doing the relayout mRelayoutFlag = false; // 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; @@ -434,7 +464,7 @@ void RelayoutController::Relayout() if( actor.OnStage() ) { Dali::Actor parent = actor.GetParent(); - QueueActor( actor, *mRelayoutStack, ( parent ) ? Vector2( parent.GetTargetSize() ) : stageSize ); + QueueActor( actor, *mRelayoutStack, ( parent ) ? Vector2( parent.GetTargetSize() ) : mStageSize ); } } } @@ -460,7 +490,11 @@ void RelayoutController::Relayout() // 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 ); } } @@ -469,6 +503,8 @@ void RelayoutController::Relayout() PRINT_HIERARCHY; } + + mPerformingRelayout = false; } // should not disconnect the signal as that causes some control size negotiations to not work correctly // this algorithm needs more optimization as well @@ -479,6 +515,16 @@ void RelayoutController::SetEnabled( bool enabled ) mEnabled = enabled; } +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