X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali%2Finternal%2Fcommon%2Fcore-impl.cpp;h=7412b9a81e8b5f8778505bbeb7b81930663a050a;hb=d2bc18872d7b4f316b86a0897e6c9fabf67a1241;hp=7d6f52315d39f47b0b5fd58862deba046abd352a;hpb=c3cc5b3c11dff5a5b0e0cdb7ea929dc2b4314bcc;p=platform%2Fcore%2Fuifw%2Fdali-core.git diff --git a/dali/internal/common/core-impl.cpp b/dali/internal/common/core-impl.cpp index 7d6f523..7412b9a 100644 --- a/dali/internal/common/core-impl.cpp +++ b/dali/internal/common/core-impl.cpp @@ -26,6 +26,7 @@ #include #include #include +#include #include #include @@ -33,6 +34,7 @@ #include #include #include +#include #include #include #include @@ -72,7 +74,6 @@ namespace Internal using Integration::RenderController; using Integration::PlatformAbstraction; using Integration::GlSyncAbstraction; -using Integration::GestureManager; using Integration::GlAbstraction; using Integration::Event; using Integration::UpdateStatus; @@ -82,14 +83,14 @@ Core::Core( RenderController& renderController, PlatformAbstraction& platform, GlAbstraction& glAbstraction, GlSyncAbstraction& glSyncAbstraction, - GestureManager& gestureManager, ResourcePolicy::DataRetention dataRetentionPolicy, Integration::RenderToFrameBuffer renderToFboEnabled, Integration::DepthBufferAvailable depthBufferAvailable, Integration::StencilBufferAvailable stencilBufferAvailable ) : mRenderController( renderController ), mPlatform(platform), - mProcessingEvent(false) + mProcessingEvent(false), + mForceNextUpdate( false ) { // Create the thread local storage CreateThreadLocalStorage(); @@ -122,15 +123,14 @@ Core::Core( RenderController& renderController, mRenderManager->SetShaderSaver( *mUpdateManager ); - mStage = IntrusivePtr( Stage::New( *mAnimationPlaylist, *mPropertyNotificationManager, *mUpdateManager, *mNotificationManager, mRenderController ) ); + mObjectRegistry = ObjectRegistry::New(); + + mStage = IntrusivePtr( Stage::New( *mUpdateManager ) ); // This must be called after stage is created but before stage initialization mRelayoutController = IntrusivePtr< RelayoutController >( new RelayoutController( mRenderController ) ); - mStage->Initialize( renderToFboEnabled == Integration::RenderToFrameBuffer::TRUE ); - - mGestureEventProcessor = new GestureEventProcessor( *mStage, *mUpdateManager, gestureManager, mRenderController ); - mEventProcessor = new EventProcessor( *mStage, *mNotificationManager, *mGestureEventProcessor ); + mGestureEventProcessor = new GestureEventProcessor( *mUpdateManager, mRenderController ); mShaderFactory = new ShaderFactory(); mUpdateManager->SetShaderSaver( *mShaderFactory ); @@ -154,17 +154,21 @@ Core::~Core() delete tls; } + mObjectRegistry.Reset(); + // Stop relayout requests being raised on stage destruction mRelayoutController.Reset(); - // Clean-up stage - remove default camera and root layer - mStage->Uninitialize(); - // remove (last?) reference to stage mStage.Reset(); } +void Core::Initialize() +{ + mStage->Initialize( *mScenes[0] ); +} + Integration::ContextNotifierInterface* Core::GetContextNotifier() { return mStage.Get(); @@ -187,27 +191,27 @@ void Core::ContextDestroyed() mRenderManager->ContextDestroyed(); } -void Core::SurfaceResized( uint32_t width, uint32_t height ) +void Core::SurfaceResized( Integration::RenderSurface* surface, bool forceUpdate ) { - mStage->SurfaceResized( static_cast( width ), static_cast( height ) ); - - // The stage-size may be less than surface-size (reduced by top-margin) - Vector2 size = mStage->GetSize(); - mRelayoutController->SetStageSize( static_cast( size.width ), static_cast( size.height ) ); // values get truncated -} - -void Core::SetTopMargin( uint32_t margin ) -{ - mStage->SetTopMargin( margin ); - - // The stage-size may be less than surface-size (reduced by top-margin) - Vector2 size = mStage->GetSize(); - mRelayoutController->SetStageSize( static_cast( size.width ), static_cast( size.height ) ); // values get truncated + for( auto iter = mScenes.begin(); iter != mScenes.end(); ++iter ) + { + if( (*iter)->GetSurface() == surface ) + { + (*iter)->SurfaceResized( forceUpdate ); + } + } } -void Core::SetDpi( uint32_t dpiHorizontal, uint32_t dpiVertical ) +void Core::SurfaceDeleted( Integration::RenderSurface* surface ) { - mStage->SetDpi( Vector2( static_cast( dpiHorizontal ), static_cast( dpiVertical ) ) ); + for( auto scene : mScenes ) + { + if( scene->GetSurface() == surface ) + { + scene->SurfaceDeleted(); + break; + } + } } void Core::Update( float elapsedSeconds, uint32_t lastVSyncTimeMilliseconds, uint32_t nextVSyncTimeMilliseconds, Integration::UpdateStatus& status, bool renderToFboEnabled, bool isRenderingToFbo ) @@ -244,11 +248,20 @@ void Core::SceneCreated() mStage->EmitSceneCreatedSignal(); mRelayoutController->OnApplicationSceneCreated(); + + for( auto iter = mScenes.begin(); iter != mScenes.end(); ++iter ) + { + Dali::Actor sceneRootLayer = (*iter)->GetRootLayer(); + mRelayoutController->RequestRelayoutTree( sceneRootLayer ); + } } void Core::QueueEvent( const Integration::Event& event ) { - mEventProcessor->QueueEvent( event ); + if (mScenes.size() != 0) + { + mScenes.front()->QueueEvent( event ); + } } void Core::ProcessEvents() @@ -267,12 +280,23 @@ void Core::ProcessEvents() // Signal that any messages received will be flushed soon mUpdateManager->EventProcessingStarted(); - mEventProcessor->ProcessEvents(); + // Scene could be added or removed while processing the events + // Copy the Scene container locally to avoid possibly invalid iterator + SceneContainer scenes = mScenes; + + // process events in all scenes + for( auto scene : scenes ) + { + scene->ProcessEvents(); + } mNotificationManager->ProcessMessages(); // Emit signal here to inform listeners that event processing has finished. - mStage->EmitEventProcessingFinishedSignal(); + for( auto scene : scenes ) + { + scene->EmitEventProcessingFinishedSignal(); + } // Run any registered processors RunProcessors(); @@ -280,9 +304,11 @@ void Core::ProcessEvents() // Run the size negotiation after event processing finished signal mRelayoutController->Relayout(); - // Rebuild depth tree after event processing has finished - mStage->RebuildDepthTree(); + for( auto scene : scenes ) + { + scene->RebuildDepthTree(); + } // Flush any queued messages for the update-thread const bool messagesToProcess = mUpdateManager->FlushQueue(); @@ -290,7 +316,7 @@ void Core::ProcessEvents() // Check if the touch or gestures require updates. const bool gestureNeedsUpdate = mGestureEventProcessor->NeedsUpdate(); // Check if the next update is forced. - const bool forceUpdate = mStage->IsNextUpdateForced(); + const bool forceUpdate = IsNextUpdateForced(); if( messagesToProcess || gestureNeedsUpdate || forceUpdate ) { @@ -377,6 +403,40 @@ RelayoutController& Core::GetRelayoutController() return *(mRelayoutController.Get()); } +ObjectRegistry& Core::GetObjectRegistry() const +{ + return *(mObjectRegistry.Get()); +} + +EventThreadServices& Core::GetEventThreadServices() +{ + return *this; +} + +PropertyNotificationManager& Core::GetPropertyNotificationManager() const +{ + return *(mPropertyNotificationManager); +} + +AnimationPlaylist& Core::GetAnimationPlaylist() const +{ + return *(mAnimationPlaylist); +} + +void Core::AddScene( Scene* scene ) +{ + mScenes.push_back( scene ); +} + +void Core::RemoveScene( Scene* scene ) +{ + auto iter = std::find( mScenes.begin(), mScenes.end(), scene ); + if( iter != mScenes.end() ) + { + mScenes.erase( iter ); + } +} + void Core::CreateThreadLocalStorage() { // a pointer to the ThreadLocalStorage object will be stored in TLS @@ -384,6 +444,45 @@ void Core::CreateThreadLocalStorage() new ThreadLocalStorage(this); } +void Core::RegisterObject( Dali::BaseObject* object ) +{ + mObjectRegistry = &ThreadLocalStorage::Get().GetObjectRegistry(); + mObjectRegistry->RegisterObject( object ); +} + +void Core::UnregisterObject( Dali::BaseObject* object ) +{ + mObjectRegistry = &ThreadLocalStorage::Get().GetObjectRegistry(); + mObjectRegistry->UnregisterObject( object ); +} + +Integration::RenderController& Core::GetRenderController() +{ + return mRenderController; +} + +uint32_t* Core::ReserveMessageSlot( uint32_t size, bool updateScene ) +{ + return mUpdateManager->ReserveMessageSlot( size, updateScene ); +} + +BufferIndex Core::GetEventBufferIndex() const +{ + return mUpdateManager->GetEventBufferIndex(); +} + +void Core::ForceNextUpdate() +{ + mForceNextUpdate = true; +} + +bool Core::IsNextUpdateForced() +{ + bool nextUpdateForced = mForceNextUpdate; + mForceNextUpdate = false; + return nextUpdateForced; +} + } // namespace Internal } // namespace Dali