X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali%2Finternal%2Fcommon%2Fcore-impl.cpp;h=863c7e5b63f340a0e9a0a5da85cff2e7d8d78d34;hb=b43741a90b40ca9dfbd33d6a9d390d3c09230e89;hp=12dbec6b6cdcf363ff0b38b68f493f1b29f6ab0f;hpb=61260bb3612098fca7124f400637237cb3f181d6;p=platform%2Fcore%2Fuifw%2Fdali-core.git diff --git a/dali/internal/common/core-impl.cpp b/dali/internal/common/core-impl.cpp old mode 100644 new mode 100755 index 12dbec6..863c7e5 --- a/dali/internal/common/core-impl.cpp +++ b/dali/internal/common/core-impl.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018 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. @@ -19,13 +19,15 @@ #include // INTERNAL INCLUDES -#include #include #include #include #include +#include #include +#include #include +#include #include #include @@ -33,6 +35,7 @@ #include #include #include +#include #include #include #include @@ -72,8 +75,8 @@ namespace Internal using Integration::RenderController; using Integration::PlatformAbstraction; using Integration::GlSyncAbstraction; -using Integration::GestureManager; using Integration::GlAbstraction; +using Integration::GlContextHelperAbstraction; using Integration::Event; using Integration::UpdateStatus; using Integration::RenderStatus; @@ -82,14 +85,16 @@ Core::Core( RenderController& renderController, PlatformAbstraction& platform, GlAbstraction& glAbstraction, GlSyncAbstraction& glSyncAbstraction, - GestureManager& gestureManager, + GlContextHelperAbstraction& glContextHelperAbstraction, ResourcePolicy::DataRetention dataRetentionPolicy, Integration::RenderToFrameBuffer renderToFboEnabled, Integration::DepthBufferAvailable depthBufferAvailable, - Integration::StencilBufferAvailable stencilBufferAvailable ) + Integration::StencilBufferAvailable stencilBufferAvailable, + Integration::PartialUpdateAvailable partialUpdateAvailable ) : mRenderController( renderController ), mPlatform(platform), - mProcessingEvent(false) + mProcessingEvent(false), + mForceNextUpdate( false ) { // Create the thread local storage CreateThreadLocalStorage(); @@ -105,7 +110,7 @@ Core::Core( RenderController& renderController, mRenderTaskProcessor = new SceneGraph::RenderTaskProcessor(); - mRenderManager = RenderManager::New( glAbstraction, glSyncAbstraction, depthBufferAvailable, stencilBufferAvailable ); + mRenderManager = RenderManager::New( glAbstraction, glSyncAbstraction, glContextHelperAbstraction, depthBufferAvailable, stencilBufferAvailable, partialUpdateAvailable ); RenderQueue& renderQueue = mRenderManager->GetRenderQueue(); @@ -122,15 +127,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 +158,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 +195,16 @@ void Core::ContextDestroyed() mRenderManager->ContextDestroyed(); } -void Core::SurfaceResized( uint32_t width, uint32_t height ) -{ - 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 ) +void Core::SurfaceDeleted( Integration::RenderSurface* surface ) { - 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 -} - -void Core::SetDpi( uint32_t dpiHorizontal, uint32_t dpiVertical ) -{ - 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 +241,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 +273,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 +297,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 +309,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 ) { @@ -309,26 +328,6 @@ uint32_t Core::GetMaximumUpdateCount() const return MAXIMUM_UPDATE_COUNT; } -Integration::SystemOverlay& Core::GetSystemOverlay() -{ - return mStage->GetSystemOverlay(); -} - -void Core::SetViewMode( ViewMode viewMode ) -{ - mStage->SetViewMode( viewMode ); -} - -ViewMode Core::GetViewMode() const -{ - return mStage->GetViewMode(); -} - -void Core::SetStereoBase( float stereoBase ) -{ - mStage->SetStereoBase( stereoBase ); -} - void Core::RegisterProcessor( Integration::Processor& processor ) { mProcessors.PushBack(&processor); @@ -357,11 +356,6 @@ void Core::RunProcessors() } } -float Core::GetStereoBase() const -{ - return mStage->GetStereoBase(); -} - StagePtr Core::GetCurrentStage() { return mStage.Get(); @@ -402,6 +396,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 @@ -409,6 +437,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