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;
}
// 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
renderer->GlContextDestroyed();
}
- // inform scenes
- for( auto&& scene : mImpl->sceneContainer )
+ // inform context
+ for( auto&& context : mImpl->sceneContextContainer )
{
- scene->GlContextDestroyed();
+ context->GlContextDestroyed();
}
}
{
}
-Context::Context( Integration::GlAbstraction& glAbstraction, std::vector< Context* >* contexts )
+Context::Context( Integration::GlAbstraction& glAbstraction, OwnerContainer< Context* >* contexts )
: mGlAbstraction(glAbstraction),
mGlContextCreated(false),
mColorMask(true),
* @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
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
// CLASS HEADER
#include <dali/internal/update/common/scene-graph-scene.h>
+// INTERNAL INCLUDES
#include <dali/internal/update/render-tasks/scene-graph-render-task-list.h>
+#include <dali/internal/render/gl-resources/context.h>
namespace Dali
{
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()
// INTERNAL INCLUDES
#include <dali/integration-api/scene.h>
-#include <dali/integration-api/gl-defines.h>
#include <dali/internal/common/message.h>
#include <dali/internal/event/common/event-thread-services.h>
-#include <dali/internal/render/gl-resources/context.h>
#include <dali/internal/render/common/render-instruction-container.h>
#include <dali/public-api/common/vector-wrapper.h>
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
*/
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