From: Heeyong Song Date: Tue, 28 Jul 2020 08:01:23 +0000 (+0900) Subject: [Tizen] Change ownership of Context from Scene to RenderManager X-Git-Tag: accepted/tizen/unified/20200731.145729^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F44%2F239844%2F1;p=platform%2Fcore%2Fuifw%2Fdali-core.git [Tizen] Change ownership of Context from Scene to RenderManager Change-Id: Idf787e1a582d111e29b92a02a23bd06512c22609 --- diff --git a/dali/internal/render/common/render-manager.cpp b/dali/internal/render/common/render-manager.cpp index 5725d0f..6143824 100755 --- a/dali/internal/render/common/render-manager.cpp +++ b/dali/internal/render/common/render-manager.cpp @@ -151,22 +151,33 @@ struct RenderManager::Impl Context* CreateSceneContext() { - sceneContextContainer.push_back( new Context( glAbstraction ) ); - return sceneContextContainer[ sceneContextContainer.size() - 1 ]; + Context* context = new Context( glAbstraction ); + + //TODO: Need eglMakeCurrent first + context->GlContextCreated(); + + sceneContextContainer.PushBack( context ); + return context; } 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() ) { - sceneContextContainer.erase( iter ); + ( *iter )->GlContextDestroyed(); + 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; } @@ -183,7 +194,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 - std::vector< Context* > sceneContextContainer; ///< List of owned contexts holding the GL state per scene + OwnerContainer< 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 @@ -287,10 +298,10 @@ void RenderManager::ContextDestroyed() renderer->GlContextDestroyed(); } - // inform scenes - for( auto&& scene : mImpl->sceneContainer ) + // inform context + for( auto&& context : mImpl->sceneContextContainer ) { - scene->GlContextDestroyed(); + context->GlContextDestroyed(); } } diff --git a/dali/internal/render/gl-resources/context.cpp b/dali/internal/render/gl-resources/context.cpp index ead1be3..e045136 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, std::vector< Context* >* contexts ) +Context::Context( Integration::GlAbstraction& glAbstraction, OwnerContainer< 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 be2db89..378ee31 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, std::vector< Context* >* contexts ); + Context( Integration::GlAbstraction& glAbstraction, OwnerContainer< Context* >* contexts ); /** * Destructor @@ -1829,7 +1829,7 @@ private: // Data FrameBufferStateCache mFrameBufferStateCache; ///< frame buffer state cache - std::vector< Context* >* mSceneContexts; ///< The pointer of the container of contexts for surface rendering + OwnerContainer< 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 7f9bf31..9b7ddcc 100644 --- a/dali/internal/update/common/scene-graph-scene.cpp +++ b/dali/internal/update/common/scene-graph-scene.cpp @@ -17,7 +17,9 @@ // CLASS HEADER #include +// INTERNAL INCLUDES #include +#include namespace Dali { @@ -35,39 +37,13 @@ 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 ) { - if ( mContext != &context ) - { - if ( mContext ) - { - mContext->GlContextDestroyed(); - delete mContext; - } - - mContext = &context; - mContext->GlContextCreated(); - } + mContext = &context; } Context* Scene::GetContext() diff --git a/dali/internal/update/common/scene-graph-scene.h b/dali/internal/update/common/scene-graph-scene.h index a94becc..89d4da1 100644 --- a/dali/internal/update/common/scene-graph-scene.h +++ b/dali/internal/update/common/scene-graph-scene.h @@ -19,10 +19,8 @@ // INTERNAL INCLUDES #include -#include #include #include -#include #include #include @@ -60,11 +58,6 @@ 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 */ @@ -124,7 +117,7 @@ public: private: - Context* mContext; ///< The context holding the GL state of rendering for the scene + Context* mContext; ///< The context holding the GL state of rendering for the scene, not owned // Render instructions describe what should be rendered during RenderManager::RenderScene() // Update manager updates instructions for the next frame while we render the current one