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/internal/render/gl-resources/context.h>
22 #include <dali/internal/update/render-tasks/scene-graph-render-task-list.h>
32 mFrameRenderedCallbacks(),
33 mFramePresentedCallbacks(),
34 mSkipRendering(false),
36 mSurfaceOrientation(0),
37 mSurfaceRectChanged(false)
43 mFrameRenderedCallbacks.clear();
44 mFramePresentedCallbacks.clear();
47 void Scene::Initialize(Context& context, Graphics::Controller& graphicsController)
51 // Create the render pass for the surface
52 std::vector<Graphics::AttachmentDescription> attachmentDescriptions;
54 // Default behaviour for color attachments is to CLEAR and STORE
56 Graphics::AttachmentDescription desc{};
57 desc.SetLoadOp(Graphics::AttachmentLoadOp::CLEAR);
58 desc.SetStoreOp(Graphics::AttachmentStoreOp::STORE);
59 attachmentDescriptions.push_back(desc);
60 mClearValues.emplace_back();
62 Graphics::RenderPassCreateInfo rpInfo{};
63 rpInfo.SetAttachments(attachmentDescriptions);
65 // Add default render pass (loadOp = clear)
66 mRenderPass = graphicsController.CreateRenderPass(rpInfo, nullptr);
69 Context* Scene::GetContext()
74 RenderInstructionContainer& Scene::GetRenderInstructions()
79 void Scene::AddFrameRenderedCallback(CallbackBase* callback, int32_t frameId)
81 mFrameRenderedCallbacks.push_back(std::make_pair(std::unique_ptr<CallbackBase>(callback), frameId));
84 void Scene::AddFramePresentedCallback(CallbackBase* callback, int32_t frameId)
86 mFramePresentedCallbacks.push_back(std::make_pair(std::unique_ptr<CallbackBase>(callback), frameId));
89 void Scene::GetFrameRenderedCallback(Dali::Integration::Scene::FrameCallbackContainer& callbacks)
91 // Transfer owership of the callbacks
92 for(auto&& iter : mFrameRenderedCallbacks)
94 callbacks.push_back(std::make_pair(std::move(iter.first), iter.second));
97 mFrameRenderedCallbacks.clear();
100 void Scene::GetFramePresentedCallback(Dali::Integration::Scene::FrameCallbackContainer& callbacks)
102 // Transfer owership of the callbacks
103 for(auto&& iter : mFramePresentedCallbacks)
105 callbacks.push_back(std::make_pair(std::move(iter.first), iter.second));
108 mFramePresentedCallbacks.clear();
111 void Scene::SetSkipRendering(bool skip)
113 mSkipRendering = skip;
116 bool Scene::IsRenderingSkipped() const
118 return mSkipRendering;
121 void Scene::SetSurfaceRect(const Rect<int32_t>& rect)
124 mSurfaceRectChanged = true;
127 const Rect<int32_t>& Scene::GetSurfaceRect() const
132 void Scene::SetSurfaceOrientation(int32_t orientation)
134 mSurfaceOrientation = orientation;
137 int32_t Scene::GetSurfaceOrientation() const
139 return mSurfaceOrientation;
142 bool Scene::IsSurfaceRectChanged()
144 bool surfaceRectChanged = mSurfaceRectChanged;
145 mSurfaceRectChanged = false;
147 return surfaceRectChanged;
150 } // namespace SceneGraph
152 } // namespace Internal