Merge "Check whether the scene-graph RenderTask object is valid" into devel/master
[platform/core/uifw/dali-core.git] / dali / devel-api / common / stage.cpp
1 /*
2  * Copyright (c) 2022 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/devel-api/common/stage.h>
20
21 // INTERNAL INCLUDES
22 #include <dali/internal/common/core-impl.h>
23 #include <dali/internal/event/common/stage-impl.h>
24 #include <dali/public-api/actors/actor.h>
25 #include <dali/public-api/actors/layer.h>
26 #include <dali/public-api/object/object-registry.h>
27 #include <dali/public-api/render-tasks/render-task-list.h>
28
29 namespace Dali
30 {
31 using Internal::Core;
32
33 Stage::Stage() = default;
34
35 Stage::~Stage() = default;
36
37 Stage::Stage(const Stage& handle) = default;
38
39 Stage& Stage::operator=(const Stage& rhs) = default;
40
41 Stage::Stage(Stage&& handle) noexcept = default;
42
43 Stage& Stage::operator=(Stage&& rhs) noexcept = default;
44
45 Stage::Stage(Internal::Stage* internal)
46 : BaseHandle(internal)
47 {
48 }
49
50 Stage Stage::GetCurrent()
51 {
52   Internal::Stage* stage = Internal::Stage::GetCurrent();
53   DALI_ASSERT_ALWAYS(stage && "Stage doesn't exist");
54   return Stage(stage);
55 }
56
57 bool Stage::IsInstalled()
58 {
59   return Internal::Stage::IsInstalled();
60 }
61
62 void Stage::Add(Actor& actor)
63 {
64   GetImplementation(*this).Add(GetImplementation(actor));
65 }
66
67 void Stage::Remove(Actor& actor)
68 {
69   GetImplementation(*this).Remove(GetImplementation(actor));
70 }
71
72 RenderTaskList Stage::GetRenderTaskList() const
73 {
74   return RenderTaskList(&GetImplementation(*this).GetRenderTaskList());
75 }
76
77 Vector2 Stage::GetSize() const
78 {
79   return GetImplementation(*this).GetSize();
80 }
81
82 uint32_t Stage::GetLayerCount() const
83 {
84   return GetImplementation(*this).GetLayerCount();
85 }
86
87 Layer Stage::GetLayer(uint32_t depth) const
88 {
89   return GetImplementation(*this).GetLayer(depth);
90 }
91
92 Layer Stage::GetRootLayer() const
93 {
94   return GetImplementation(*this).GetRootLayer();
95 }
96
97 void Stage::SetBackgroundColor(Vector4 color)
98 {
99   GetImplementation(*this).SetBackgroundColor(color);
100 }
101
102 Vector4 Stage::GetBackgroundColor() const
103 {
104   return GetImplementation(*this).GetBackgroundColor();
105 }
106
107 Vector2 Stage::GetDpi() const
108 {
109   return GetImplementation(*this).GetDpi();
110 }
111
112 ObjectRegistry Stage::GetObjectRegistry() const
113 {
114   Internal::Stage* stage = Internal::Stage::GetCurrent();
115   DALI_ASSERT_ALWAYS(stage && "GetObjectRegistry() : Stage is null");
116
117   Internal::ObjectRegistry& internal = stage->GetObjectRegistry();
118   return ObjectRegistry(&internal);
119 }
120
121 void Stage::KeepRendering(float durationSeconds)
122 {
123   GetImplementation(*this).KeepRendering(durationSeconds);
124 }
125
126 Stage::KeyEventSignalType& Stage::KeyEventSignal()
127 {
128   return GetImplementation(*this).KeyEventSignal();
129 }
130
131 Stage::EventProcessingFinishedSignalType& Stage::EventProcessingFinishedSignal()
132 {
133   return GetImplementation(*this).EventProcessingFinishedSignal();
134 }
135
136 Stage::TouchEventSignalType& Stage::TouchedSignal()
137 {
138   return GetImplementation(*this).TouchedSignal();
139 }
140
141 Stage::WheelEventSignalType& Stage::WheelEventSignal()
142 {
143   return GetImplementation(*this).WheelEventSignal();
144 }
145
146 Stage::ContextStatusSignal& Stage::ContextLostSignal()
147 {
148   return GetImplementation(*this).ContextLostSignal();
149 }
150
151 Stage::ContextStatusSignal& Stage::ContextRegainedSignal()
152 {
153   return GetImplementation(*this).ContextRegainedSignal();
154 }
155
156 Stage::SceneCreatedSignalType& Stage::SceneCreatedSignal()
157 {
158   return GetImplementation(*this).SceneCreatedSignal();
159 }
160
161 } // namespace Dali