/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
// CLASS HEADER
#include <dali/internal/update/common/scene-graph-scene.h>
+// INTERNAL INCLUDES
+#include <dali/internal/render/gl-resources/context.h>
#include <dali/internal/update/render-tasks/scene-graph-render-task-list.h>
namespace Dali
{
namespace SceneGraph
{
-
Scene::Scene()
-: mContext( nullptr )
+: mContext(nullptr),
+ mFrameRenderedCallbacks(),
+ mFramePresentedCallbacks(),
+ mSkipRendering(false),
+ mSurfaceRect(),
+ mSurfaceOrientation(0),
+ mSurfaceRectChanged(false)
{
}
Scene::~Scene()
{
- if ( mContext )
- {
- mContext->GlContextDestroyed();
+ mFrameRenderedCallbacks.clear();
+ mFramePresentedCallbacks.clear();
+}
- delete mContext;
- mContext = nullptr;
- }
+void Scene::Initialize(Context& context, Graphics::Controller& graphicsController)
+{
+ mContext = &context;
+
+ // Create the render pass for the surface
+ std::vector<Graphics::AttachmentDescription> attachmentDescriptions;
+
+ // Default behaviour for color attachments is to CLEAR and STORE
+ mClearValues.clear();
+ Graphics::AttachmentDescription desc{};
+ desc.SetLoadOp(Graphics::AttachmentLoadOp::CLEAR);
+ desc.SetStoreOp(Graphics::AttachmentStoreOp::STORE);
+ attachmentDescriptions.push_back(desc);
+ mClearValues.emplace_back();
+
+ Graphics::RenderPassCreateInfo rpInfo{};
+ rpInfo.SetAttachments(attachmentDescriptions);
+
+ // Add default render pass (loadOp = clear)
+ mRenderPass = graphicsController.CreateRenderPass(rpInfo, nullptr);
+
+ desc.SetLoadOp( Graphics::AttachmentLoadOp::LOAD );
+ attachmentDescriptions[0] = desc;
+ mRenderPassNoClear = graphicsController.CreateRenderPass(rpInfo, nullptr);
+}
+
+Context* Scene::GetContext()
+{
+ return mContext;
+}
+
+RenderInstructionContainer& Scene::GetRenderInstructions()
+{
+ return mInstructions;
+}
+
+void Scene::AddFrameRenderedCallback(CallbackBase* callback, int32_t frameId)
+{
+ mFrameRenderedCallbacks.push_back(std::make_pair(std::unique_ptr<CallbackBase>(callback), frameId));
+}
+
+void Scene::AddFramePresentedCallback(CallbackBase* callback, int32_t frameId)
+{
+ mFramePresentedCallbacks.push_back(std::make_pair(std::unique_ptr<CallbackBase>(callback), frameId));
}
-void Scene::GlContextDestroyed()
+void Scene::GetFrameRenderedCallback(Dali::Integration::Scene::FrameCallbackContainer& callbacks)
{
- if ( mContext )
+ // Transfer owership of the callbacks
+ for(auto&& iter : mFrameRenderedCallbacks)
{
- mContext->GlContextDestroyed();
+ callbacks.push_back(std::make_pair(std::move(iter.first), iter.second));
}
+
+ mFrameRenderedCallbacks.clear();
}
-void Scene::Initialize( Context& context )
+void Scene::GetFramePresentedCallback(Dali::Integration::Scene::FrameCallbackContainer& callbacks)
{
- if ( mContext != &context )
+ // Transfer owership of the callbacks
+ for(auto&& iter : mFramePresentedCallbacks)
{
- if ( mContext )
- {
- mContext->GlContextDestroyed();
- delete mContext;
- }
-
- mContext = &context;
- mContext->GlContextCreated();
+ callbacks.push_back(std::make_pair(std::move(iter.first), iter.second));
}
+
+ mFramePresentedCallbacks.clear();
}
-Context* Scene::GetContext()
+void Scene::SetSkipRendering(bool skip)
{
- return mContext;
+ mSkipRendering = skip;
}
-RenderInstructionContainer& Scene::GetRenderInstructions()
+bool Scene::IsRenderingSkipped() const
{
- return mInstructions;
+ return mSkipRendering;
+}
+
+void Scene::SetSurfaceRect(const Rect<int32_t>& rect)
+{
+ mSurfaceRect = rect;
+ mSurfaceRectChanged = true;
+}
+
+const Rect<int32_t>& Scene::GetSurfaceRect() const
+{
+ return mSurfaceRect;
+}
+
+void Scene::SetSurfaceOrientation(int32_t orientation)
+{
+ mSurfaceOrientation = orientation;
+}
+
+int32_t Scene::GetSurfaceOrientation() const
+{
+ return mSurfaceOrientation;
+}
+
+bool Scene::IsSurfaceRectChanged()
+{
+ bool surfaceRectChanged = mSurfaceRectChanged;
+ mSurfaceRectChanged = false;
+
+ return surfaceRectChanged;
}
-} //SceneGraph
+} // namespace SceneGraph
-} //Internal
+} // namespace Internal
-} //Dali
+} // namespace Dali