Merge "Protect dereferencing null in Node" into devel/master
[platform/core/uifw/dali-core.git] / dali / integration-api / scene.cpp
1 /*
2  * Copyright (c) 2021 Samsung Electronics Co., Ltd.
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  *
16  */
17
18 // CLASS HEADER
19 #include <dali/integration-api/scene.h>
20
21 // EXTERNAL INCLUDES
22 #include <dali/graphics-api/graphics-render-target.h>
23 #include <dali/public-api/actors/layer.h>
24 #include <dali/public-api/render-tasks/render-task-list.h>
25
26 // INTERNAL INCLUDES
27 #include <dali/internal/event/common/scene-impl.h>
28
29 namespace Dali
30 {
31 namespace Integration
32 {
33 Scene Scene::New(Size size, int32_t orientation)
34 {
35   Internal::ScenePtr internal = Internal::Scene::New(size, orientation);
36   return Scene(internal.Get());
37 }
38
39 Scene Scene::DownCast(BaseHandle handle)
40 {
41   return Scene(dynamic_cast<Dali::Internal::Scene*>(handle.GetObjectPtr()));
42 }
43
44 Scene::Scene() = default;
45
46 Scene::~Scene() = default;
47
48 Scene::Scene(const Scene& handle) = default;
49
50 Scene::Scene(Internal::Scene* internal)
51 : BaseHandle(internal)
52 {
53 }
54
55 Scene& Scene::operator=(const Scene& rhs) = default;
56
57 void Scene::Add(Actor actor)
58 {
59   GetImplementation(*this).Add(GetImplementation(actor));
60 }
61
62 void Scene::Remove(Actor actor)
63 {
64   GetImplementation(*this).Remove(GetImplementation(actor));
65 }
66
67 Size Scene::GetSize() const
68 {
69   return GetImplementation(*this).GetSize();
70 }
71
72 void Scene::SetDpi(Vector2 dpi)
73 {
74   GetImplementation(*this).SetDpi(dpi);
75 }
76
77 Vector2 Scene::GetDpi() const
78 {
79   return GetImplementation(*this).GetDpi();
80 }
81
82 void Scene::SetBackgroundColor(const Vector4& color)
83 {
84   GetImplementation(*this).SetBackgroundColor(color);
85 }
86
87 Vector4 Scene::GetBackgroundColor() const
88 {
89   return GetImplementation(*this).GetBackgroundColor();
90 }
91
92 RenderTaskList Scene::GetRenderTaskList() const
93 {
94   return RenderTaskList(&GetImplementation(*this).GetRenderTaskList());
95 }
96
97 Layer Scene::GetRootLayer() const
98 {
99   return GetImplementation(*this).GetRootLayer();
100 }
101
102 uint32_t Scene::GetLayerCount() const
103 {
104   return GetImplementation(*this).GetLayerCount();
105 }
106
107 Layer Scene::GetLayer(uint32_t depth) const
108 {
109   return GetImplementation(*this).GetLayer(depth);
110 }
111
112 void Scene::SurfaceResized(float width, float height)
113 {
114   GetImplementation(*this).SurfaceResized(width, height);
115 }
116
117 void Scene::SurfaceReplaced()
118 {
119   GetImplementation(*this).SurfaceReplaced();
120 }
121
122 void Scene::Discard()
123 {
124   GetImplementation(*this).Discard();
125 }
126
127 void Scene::SetSurfaceRenderTarget(Graphics::RenderTarget* renderTarget)
128 {
129   GetImplementation(*this).SetSurfaceRenderTarget(renderTarget);
130 }
131
132 Integration::Scene Scene::Get(Actor actor)
133 {
134   return Dali::Integration::Scene(&GetImplementation(actor).GetScene());
135 }
136
137 void Scene::QueueEvent(const Integration::Event& event)
138 {
139   GetImplementation(*this).QueueEvent(event);
140 }
141
142 void Scene::ProcessEvents()
143 {
144   GetImplementation(*this).ProcessEvents();
145 }
146
147 void Scene::AddFrameRenderedCallback(std::unique_ptr<CallbackBase> callback, int32_t frameId)
148 {
149   GetImplementation(*this).AddFrameRenderedCallback(std::move(callback), frameId);
150 }
151
152 void Scene::AddFramePresentedCallback(std::unique_ptr<CallbackBase> callback, int32_t frameId)
153 {
154   GetImplementation(*this).AddFramePresentedCallback(std::move(callback), frameId);
155 }
156
157 void Scene::GetFrameRenderedCallback(FrameCallbackContainer& callbacks)
158 {
159   GetImplementation(*this).GetFrameRenderedCallback(callbacks);
160 }
161
162 void Scene::GetFramePresentedCallback(FrameCallbackContainer& callbacks)
163 {
164   GetImplementation(*this).GetFramePresentedCallback(callbacks);
165 }
166
167 void Scene::SurfaceRotated(float width, float height, int32_t orientation)
168 {
169   GetImplementation(*this).SurfaceRotated(width, height, orientation);
170 }
171
172 int32_t Scene::GetCurrentSurfaceOrientation() const
173 {
174   return GetImplementation(*this).GetCurrentSurfaceOrientation();
175 }
176
177 const Rect<int32_t>& Scene::GetCurrentSurfaceRect() const
178 {
179   return GetImplementation(*this).GetCurrentSurfaceRect();
180 }
181
182 bool Scene::IsSurfaceRectChanged() const
183 {
184   return GetImplementation(*this).IsSurfaceRectChanged();
185 }
186
187 void Scene::SetRotationCompletedAcknowledgement()
188 {
189   GetImplementation(*this).SetRotationCompletedAcknowledgement();
190 }
191
192 bool Scene::IsRotationCompletedAcknowledgementSet() const
193 {
194   return GetImplementation(*this).IsRotationCompletedAcknowledgementSet();
195 }
196
197 Scene::EventProcessingFinishedSignalType& Scene::EventProcessingFinishedSignal()
198 {
199   return GetImplementation(*this).EventProcessingFinishedSignal();
200 }
201
202 Scene::KeyEventSignalType& Scene::KeyEventSignal()
203 {
204   return GetImplementation(*this).KeyEventSignal();
205 }
206
207 Scene::KeyEventGeneratedSignalType& Scene::KeyEventGeneratedSignal()
208 {
209   return GetImplementation(*this).KeyEventGeneratedSignal();
210 }
211
212 Scene::TouchEventSignalType& Scene::TouchedSignal()
213 {
214   return GetImplementation(*this).TouchedSignal();
215 }
216
217 Scene::WheelEventSignalType& Scene::WheelEventSignal()
218 {
219   return GetImplementation(*this).WheelEventSignal();
220 }
221
222 } // namespace Integration
223
224 } // namespace Dali