2 * Copyright (c) 2022 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),
37 mRotationCompletedAcknowledgement(false)
43 mFrameRenderedCallbacks.clear();
44 mFramePresentedCallbacks.clear();
47 void Scene::Initialize(Graphics::Controller& graphicsController, Integration::DepthBufferAvailable depthBufferAvailable, Integration::StencilBufferAvailable stencilBufferAvailable)
49 // Create the render pass for the surface
50 std::vector<Graphics::AttachmentDescription> attachmentDescriptions;
52 // Default behaviour for color attachments is to CLEAR and STORE
54 mClearValues.emplace_back();
56 // Assume single color attachment
57 Graphics::AttachmentDescription desc{};
58 desc.SetLoadOp(Graphics::AttachmentLoadOp::CLEAR);
59 desc.SetStoreOp(Graphics::AttachmentStoreOp::STORE);
60 attachmentDescriptions.push_back(desc);
62 if(depthBufferAvailable == Integration::DepthBufferAvailable::TRUE ||
63 stencilBufferAvailable == Integration::StencilBufferAvailable::TRUE)
66 desc.SetLoadOp(Graphics::AttachmentLoadOp::CLEAR);
67 desc.SetStoreOp(Graphics::AttachmentStoreOp::STORE);
70 desc.SetStencilLoadOp(Graphics::AttachmentLoadOp::CLEAR);
71 desc.SetStencilStoreOp(Graphics::AttachmentStoreOp::STORE);
72 attachmentDescriptions.push_back(desc);
74 mClearValues.emplace_back();
75 mClearValues.back().depthStencil.depth = 0;
76 mClearValues.back().depthStencil.stencil = 0;
79 Graphics::RenderPassCreateInfo rpInfo{};
80 rpInfo.SetAttachments(attachmentDescriptions);
82 // Add default render pass (loadOp = clear)
83 mRenderPass = graphicsController.CreateRenderPass(rpInfo, nullptr); // Warning: Shallow ptr
85 desc.SetLoadOp(Graphics::AttachmentLoadOp::LOAD);
86 attachmentDescriptions[0] = desc;
87 if(attachmentDescriptions.size() > 1)
89 desc.SetLoadOp(Graphics::AttachmentLoadOp::LOAD);
90 desc.SetStencilLoadOp(Graphics::AttachmentLoadOp::LOAD);
91 attachmentDescriptions.back() = desc;
94 mRenderPassNoClear = graphicsController.CreateRenderPass(rpInfo, nullptr); // Warning: Shallow ptr
97 RenderInstructionContainer& Scene::GetRenderInstructions()
102 void Scene::AddFrameRenderedCallback(CallbackBase* callback, int32_t frameId)
104 mFrameRenderedCallbacks.push_back(std::make_pair(std::unique_ptr<CallbackBase>(callback), frameId));
107 void Scene::AddFramePresentedCallback(CallbackBase* callback, int32_t frameId)
109 mFramePresentedCallbacks.push_back(std::make_pair(std::unique_ptr<CallbackBase>(callback), frameId));
112 void Scene::GetFrameRenderedCallback(Dali::Integration::Scene::FrameCallbackContainer& callbacks)
114 // Transfer owership of the callbacks
115 for(auto&& iter : mFrameRenderedCallbacks)
117 callbacks.push_back(std::make_pair(std::move(iter.first), iter.second));
120 mFrameRenderedCallbacks.clear();
123 void Scene::GetFramePresentedCallback(Dali::Integration::Scene::FrameCallbackContainer& callbacks)
125 // Transfer owership of the callbacks
126 for(auto&& iter : mFramePresentedCallbacks)
128 callbacks.push_back(std::make_pair(std::move(iter.first), iter.second));
131 mFramePresentedCallbacks.clear();
134 void Scene::SetSkipRendering(bool skip)
136 mSkipRendering = skip;
139 bool Scene::IsRenderingSkipped() const
141 return mSkipRendering;
144 void Scene::SetSurfaceRect(const Rect<int32_t>& rect)
147 mSurfaceRectChanged = true;
151 mRoot->SetUpdated(true);
155 const Rect<int32_t>& Scene::GetSurfaceRect() const
160 void Scene::SetSurfaceOrientation(int32_t orientation)
162 mSurfaceOrientation = orientation;
166 mRoot->SetUpdated(true);
170 int32_t Scene::GetSurfaceOrientation() const
172 return mSurfaceOrientation;
175 bool Scene::IsSurfaceRectChanged()
177 bool surfaceRectChanged = mSurfaceRectChanged;
178 mSurfaceRectChanged = false;
180 return surfaceRectChanged;
183 void Scene::SetRotationCompletedAcknowledgement()
185 mRotationCompletedAcknowledgement = true;
188 bool Scene::IsRotationCompletedAcknowledgementSet()
190 bool setRotationCompletedAcknowledgement = mRotationCompletedAcknowledgement;
191 mRotationCompletedAcknowledgement = false;
192 return setRotationCompletedAcknowledgement;
195 std::vector<DirtyRect>& Scene::GetItemsDirtyRects()
197 return mItemsDirtyRects;
200 } // namespace SceneGraph
202 } // namespace Internal