2 * Copyright (c) 2021 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 #include <dali/internal/update/common/scene-graph-scene.h>
21 #include <dali/integration-api/core-enumerations.h>
22 #include <dali/internal/update/render-tasks/scene-graph-render-task-list.h>
31 : mFrameRenderedCallbacks(),
32 mFramePresentedCallbacks(),
33 mSkipRendering(false),
35 mSurfaceOrientation(0),
36 mSurfaceRectChanged(false)
42 mFrameRenderedCallbacks.clear();
43 mFramePresentedCallbacks.clear();
46 void Scene::Initialize(Graphics::Controller& graphicsController, Integration::DepthBufferAvailable depthBufferAvailable, Integration::StencilBufferAvailable stencilBufferAvailable)
48 // Create the render pass for the surface
49 std::vector<Graphics::AttachmentDescription> attachmentDescriptions;
51 // Default behaviour for color attachments is to CLEAR and STORE
53 mClearValues.emplace_back();
55 // Assume single color attachment
56 Graphics::AttachmentDescription desc{};
57 desc.SetLoadOp(Graphics::AttachmentLoadOp::CLEAR);
58 desc.SetStoreOp(Graphics::AttachmentStoreOp::STORE);
59 attachmentDescriptions.push_back(desc);
61 if(depthBufferAvailable == Integration::DepthBufferAvailable::TRUE ||
62 stencilBufferAvailable == Integration::StencilBufferAvailable::TRUE)
65 desc.SetLoadOp(Graphics::AttachmentLoadOp::CLEAR);
66 desc.SetStoreOp(Graphics::AttachmentStoreOp::STORE);
69 desc.SetStencilLoadOp(Graphics::AttachmentLoadOp::CLEAR);
70 desc.SetStencilStoreOp(Graphics::AttachmentStoreOp::STORE);
71 attachmentDescriptions.push_back(desc);
73 mClearValues.emplace_back();
74 mClearValues.back().depthStencil.depth = 0;
75 mClearValues.back().depthStencil.stencil = 0;
78 Graphics::RenderPassCreateInfo rpInfo{};
79 rpInfo.SetAttachments(attachmentDescriptions);
81 // Add default render pass (loadOp = clear)
82 mRenderPass = graphicsController.CreateRenderPass(rpInfo, nullptr); // Warning: Shallow ptr
84 desc.SetLoadOp(Graphics::AttachmentLoadOp::LOAD);
85 attachmentDescriptions[0] = desc;
86 if(attachmentDescriptions.size() > 1)
88 desc.SetLoadOp(Graphics::AttachmentLoadOp::LOAD);
89 desc.SetStencilLoadOp(Graphics::AttachmentLoadOp::LOAD);
90 attachmentDescriptions.back() = desc;
93 mRenderPassNoClear = graphicsController.CreateRenderPass(rpInfo, nullptr); // Warning: Shallow ptr
96 RenderInstructionContainer& Scene::GetRenderInstructions()
101 void Scene::AddFrameRenderedCallback(CallbackBase* callback, int32_t frameId)
103 mFrameRenderedCallbacks.push_back(std::make_pair(std::unique_ptr<CallbackBase>(callback), frameId));
106 void Scene::AddFramePresentedCallback(CallbackBase* callback, int32_t frameId)
108 mFramePresentedCallbacks.push_back(std::make_pair(std::unique_ptr<CallbackBase>(callback), frameId));
111 void Scene::GetFrameRenderedCallback(Dali::Integration::Scene::FrameCallbackContainer& callbacks)
113 // Transfer owership of the callbacks
114 for(auto&& iter : mFrameRenderedCallbacks)
116 callbacks.push_back(std::make_pair(std::move(iter.first), iter.second));
119 mFrameRenderedCallbacks.clear();
122 void Scene::GetFramePresentedCallback(Dali::Integration::Scene::FrameCallbackContainer& callbacks)
124 // Transfer owership of the callbacks
125 for(auto&& iter : mFramePresentedCallbacks)
127 callbacks.push_back(std::make_pair(std::move(iter.first), iter.second));
130 mFramePresentedCallbacks.clear();
133 void Scene::SetSkipRendering(bool skip)
135 mSkipRendering = skip;
138 bool Scene::IsRenderingSkipped() const
140 return mSkipRendering;
143 void Scene::SetSurfaceRect(const Rect<int32_t>& rect)
146 mSurfaceRectChanged = true;
149 const Rect<int32_t>& Scene::GetSurfaceRect() const
154 void Scene::SetSurfaceOrientation(int32_t orientation)
156 mSurfaceOrientation = orientation;
159 int32_t Scene::GetSurfaceOrientation() const
161 return mSurfaceOrientation;
164 bool Scene::IsSurfaceRectChanged()
166 bool surfaceRectChanged = mSurfaceRectChanged;
167 mSurfaceRectChanged = false;
169 return surfaceRectChanged;
172 } // namespace SceneGraph
174 } // namespace Internal