From 7fb98272307d90f6bc2791952c65f1b83fa80458 Mon Sep 17 00:00:00 2001 From: Wonsik Jung Date: Mon, 10 Aug 2020 14:27:54 +0900 Subject: [PATCH] Revert "[Tizen] Change ownership of Context from Scene to RenderManager" This reverts commit aac522d7c1630db61aa7db6e6edd50f9a72e010b. --- dali/internal/render/common/render-manager.cpp | 29 +++++++--------------- dali/internal/render/gl-resources/context.cpp | 2 +- dali/internal/render/gl-resources/context.h | 4 +-- dali/internal/update/common/scene-graph-scene.cpp | 30 ++++++++++++++++++++--- dali/internal/update/common/scene-graph-scene.h | 9 ++++++- 5 files changed, 47 insertions(+), 27 deletions(-) diff --git a/dali/internal/render/common/render-manager.cpp b/dali/internal/render/common/render-manager.cpp index 6143824..5725d0f 100755 --- a/dali/internal/render/common/render-manager.cpp +++ b/dali/internal/render/common/render-manager.cpp @@ -151,33 +151,22 @@ struct RenderManager::Impl Context* CreateSceneContext() { - Context* context = new Context( glAbstraction ); - - //TODO: Need eglMakeCurrent first - context->GlContextCreated(); - - sceneContextContainer.PushBack( context ); - return context; + sceneContextContainer.push_back( new Context( glAbstraction ) ); + return sceneContextContainer[ sceneContextContainer.size() - 1 ]; } void DestroySceneContext( Context* sceneContext ) { - auto iter = std::find( sceneContextContainer.Begin(), sceneContextContainer.End(), sceneContext ); - if( iter != sceneContextContainer.End() ) + auto iter = std::find( sceneContextContainer.begin(), sceneContextContainer.end(), sceneContext ); + if( iter != sceneContextContainer.end() ) { - ( *iter )->GlContextDestroyed(); - sceneContextContainer.Erase( iter ); + sceneContextContainer.erase( iter ); } } Context* ReplaceSceneContext( Context* oldSceneContext ) { Context* newContext = new Context( glAbstraction ); - - oldSceneContext->GlContextDestroyed(); - //TODO: Need eglMakeCurrent first - newContext->GlContextCreated(); - std::replace( sceneContextContainer.begin(), sceneContextContainer.end(), oldSceneContext, newContext ); return newContext; } @@ -194,7 +183,7 @@ struct RenderManager::Impl // programs are owned by context at the moment. Context context; ///< Holds the GL state of the share resource context Context* currentContext; ///< Holds the GL state of the current context for rendering - OwnerContainer< Context* > sceneContextContainer; ///< List of owned contexts holding the GL state per scene + std::vector< Context* > sceneContextContainer; ///< List of owned contexts holding the GL state per scene Integration::GlAbstraction& glAbstraction; ///< GL abstraction Integration::GlSyncAbstraction& glSyncAbstraction; ///< GL sync abstraction Integration::GlContextHelperAbstraction& glContextHelperAbstraction; ///< GL context helper abstraction @@ -298,10 +287,10 @@ void RenderManager::ContextDestroyed() renderer->GlContextDestroyed(); } - // inform context - for( auto&& context : mImpl->sceneContextContainer ) + // inform scenes + for( auto&& scene : mImpl->sceneContainer ) { - context->GlContextDestroyed(); + scene->GlContextDestroyed(); } } diff --git a/dali/internal/render/gl-resources/context.cpp b/dali/internal/render/gl-resources/context.cpp index e045136..ead1be3 100644 --- a/dali/internal/render/gl-resources/context.cpp +++ b/dali/internal/render/gl-resources/context.cpp @@ -69,7 +69,7 @@ Context::Context( Integration::GlAbstraction& glAbstraction ) { } -Context::Context( Integration::GlAbstraction& glAbstraction, OwnerContainer< Context* >* contexts ) +Context::Context( Integration::GlAbstraction& glAbstraction, std::vector< Context* >* contexts ) : mGlAbstraction(glAbstraction), mGlContextCreated(false), mColorMask(true), diff --git a/dali/internal/render/gl-resources/context.h b/dali/internal/render/gl-resources/context.h index 378ee31..be2db89 100644 --- a/dali/internal/render/gl-resources/context.h +++ b/dali/internal/render/gl-resources/context.h @@ -81,7 +81,7 @@ public: * @param glAbstraction the gl abstraction. * @param contexts The list of scene contexts (for surface rendering) */ - Context( Integration::GlAbstraction& glAbstraction, OwnerContainer< Context* >* contexts ); + Context( Integration::GlAbstraction& glAbstraction, std::vector< Context* >* contexts ); /** * Destructor @@ -1829,7 +1829,7 @@ private: // Data FrameBufferStateCache mFrameBufferStateCache; ///< frame buffer state cache - OwnerContainer< Context* >* mSceneContexts; ///< The pointer of the container of contexts for surface rendering + std::vector< Context* >* mSceneContexts; ///< The pointer of the container of contexts for surface rendering }; } // namespace Internal diff --git a/dali/internal/update/common/scene-graph-scene.cpp b/dali/internal/update/common/scene-graph-scene.cpp index 9b7ddcc..7f9bf31 100644 --- a/dali/internal/update/common/scene-graph-scene.cpp +++ b/dali/internal/update/common/scene-graph-scene.cpp @@ -17,9 +17,7 @@ // CLASS HEADER #include -// INTERNAL INCLUDES #include -#include namespace Dali { @@ -37,13 +35,39 @@ Scene::Scene() Scene::~Scene() { + if ( mContext ) + { + mContext->GlContextDestroyed(); + + delete mContext; + mContext = nullptr; + } + mFrameRenderedCallbacks.clear(); mFramePresentedCallbacks.clear(); } +void Scene::GlContextDestroyed() +{ + if ( mContext ) + { + mContext->GlContextDestroyed(); + } +} + void Scene::Initialize( Context& context ) { - mContext = &context; + if ( mContext != &context ) + { + if ( mContext ) + { + mContext->GlContextDestroyed(); + delete mContext; + } + + mContext = &context; + mContext->GlContextCreated(); + } } Context* Scene::GetContext() diff --git a/dali/internal/update/common/scene-graph-scene.h b/dali/internal/update/common/scene-graph-scene.h index 89d4da1..a94becc 100644 --- a/dali/internal/update/common/scene-graph-scene.h +++ b/dali/internal/update/common/scene-graph-scene.h @@ -19,8 +19,10 @@ // INTERNAL INCLUDES #include +#include #include #include +#include #include #include @@ -58,6 +60,11 @@ public: void Initialize( Context& context ); /** + * Called by RenderManager to inform the scene that the context has been destroyed + */ + void GlContextDestroyed(); + + /** * Gets the context holding the GL state of rendering for the scene * @return the context */ @@ -117,7 +124,7 @@ public: private: - Context* mContext; ///< The context holding the GL state of rendering for the scene, not owned + Context* mContext; ///< The context holding the GL state of rendering for the scene // Render instructions describe what should be rendered during RenderManager::RenderScene() // Update manager updates instructions for the next frame while we render the current one -- 2.7.4