c8d17eee7412cdd1d64494409f2725783638c597
[platform/core/uifw/dali-adaptor.git] / dali / internal / adaptor / common / adaptor.cpp
1 /*
2  * Copyright (c) 2023 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/adaptor-framework/adaptor.h>
20
21 // EXTERNAL INCLUDES
22 #include <dali/integration-api/debug.h>
23 #include <dali/public-api/object/object-registry.h>
24
25 // INTERNAL INCLUDES
26 #include <dali/devel-api/adaptor-framework/style-monitor.h>
27 #include <dali/integration-api/adaptor-framework/render-surface-interface.h>
28 #include <dali/integration-api/adaptor-framework/scene-holder.h>
29 #include <dali/internal/adaptor/common/adaptor-impl.h>
30 #include <dali/internal/adaptor/common/thread-controller-interface.h>
31 #include <dali/internal/window-system/common/window-impl.h>
32
33 namespace Dali
34 {
35 Adaptor& Adaptor::New(Window window)
36 {
37   Internal::Adaptor::SceneHolder* sceneHolder = &Dali::GetImplementation(window);
38   Adaptor*                        adaptor     = Internal::Adaptor::Adaptor::New(Dali::Integration::SceneHolder(sceneHolder), NULL);
39   return *adaptor;
40 }
41
42 Adaptor& Adaptor::New(Window window, const Dali::RenderSurfaceInterface& surface)
43 {
44   Internal::Adaptor::SceneHolder* sceneHolder = &Dali::GetImplementation(window);
45   Dali::RenderSurfaceInterface*   pSurface    = const_cast<Dali::RenderSurfaceInterface*>(&surface);
46   Adaptor*                        adaptor     = Internal::Adaptor::Adaptor::New(Dali::Integration::SceneHolder(sceneHolder), pSurface, NULL, Dali::Internal::Adaptor::ThreadMode::NORMAL);
47   return *adaptor;
48 }
49
50 Adaptor& Adaptor::New(Dali::Integration::SceneHolder window)
51 {
52   Adaptor* adaptor = Internal::Adaptor::Adaptor::New(window, NULL);
53   return *adaptor;
54 }
55
56 Adaptor& Adaptor::New(Dali::Integration::SceneHolder window, const Dali::RenderSurfaceInterface& surface)
57 {
58   Dali::RenderSurfaceInterface* pSurface = const_cast<Dali::RenderSurfaceInterface*>(&surface);
59   Adaptor*                      adaptor  = Internal::Adaptor::Adaptor::New(window, pSurface, NULL, Dali::Internal::Adaptor::ThreadMode::NORMAL);
60   return *adaptor;
61 }
62
63 Adaptor::~Adaptor()
64 {
65   delete mImpl;
66 }
67
68 void Adaptor::Start()
69 {
70   mImpl->Start();
71 }
72
73 void Adaptor::Pause()
74 {
75   mImpl->Pause();
76 }
77
78 void Adaptor::Resume()
79 {
80   mImpl->Resume();
81 }
82
83 void Adaptor::Stop()
84 {
85   mImpl->Stop();
86 }
87
88 bool Adaptor::AddIdle(CallbackBase* callback, bool hasReturnValue)
89 {
90   DALI_ASSERT_ALWAYS(IsAvailable() && "Adaptor not instantiated");
91   return mImpl->AddIdle(callback, hasReturnValue);
92 }
93
94 bool Adaptor::AddWindow(Dali::Integration::SceneHolder childWindow)
95 {
96   DALI_ASSERT_ALWAYS(IsAvailable() && "Adaptor not instantiated");
97   return mImpl->AddWindow(childWindow);
98 }
99
100 void Adaptor::RemoveIdle(CallbackBase* callback)
101 {
102   DALI_ASSERT_ALWAYS(IsAvailable() && "Adaptor not instantiated");
103   mImpl->RemoveIdle(callback);
104 }
105
106 void Adaptor::ProcessIdle()
107 {
108   DALI_ASSERT_ALWAYS(IsAvailable() && "Adaptor not instantiated");
109   mImpl->ProcessIdle();
110 }
111
112 void Adaptor::ReplaceSurface(Window window, Dali::RenderSurfaceInterface& surface)
113 {
114   Internal::Adaptor::SceneHolder* sceneHolder = &Dali::GetImplementation(window);
115   mImpl->ReplaceSurface(Dali::Integration::SceneHolder(sceneHolder), surface);
116 }
117
118 void Adaptor::ReplaceSurface(Dali::Integration::SceneHolder window, Dali::RenderSurfaceInterface& surface)
119 {
120   mImpl->ReplaceSurface(window, surface);
121 }
122
123 Adaptor::AdaptorSignalType& Adaptor::ResizedSignal()
124 {
125   return mImpl->ResizedSignal();
126 }
127
128 Adaptor::AdaptorSignalType& Adaptor::LanguageChangedSignal()
129 {
130   return mImpl->LanguageChangedSignal();
131 }
132
133 Adaptor::WindowCreatedSignalType& Adaptor::WindowCreatedSignal()
134 {
135   return mImpl->WindowCreatedSignal();
136 }
137
138 Dali::RenderSurfaceInterface& Adaptor::GetSurface()
139 {
140   return mImpl->GetSurface();
141 }
142
143 Any Adaptor::GetNativeWindowHandle()
144 {
145   return mImpl->GetNativeWindowHandle();
146 }
147
148 Any Adaptor::GetNativeWindowHandle(Actor actor)
149 {
150   return mImpl->GetNativeWindowHandle(actor);
151 }
152
153 Any Adaptor::GetGraphicsDisplay()
154 {
155   return mImpl->GetGraphicsDisplay();
156 }
157
158 void Adaptor::ReleaseSurfaceLock()
159 {
160   mImpl->ReleaseSurfaceLock();
161 }
162
163 void Adaptor::SetRenderRefreshRate(unsigned int numberOfVSyncsPerRender)
164 {
165   mImpl->SetRenderRefreshRate(numberOfVSyncsPerRender);
166 }
167
168 void Adaptor::SetPreRenderCallback(CallbackBase* callback)
169 {
170   mImpl->SetPreRenderCallback(callback);
171 }
172
173 Adaptor& Adaptor::Get()
174 {
175   return Internal::Adaptor::Adaptor::Get();
176 }
177
178 bool Adaptor::IsAvailable()
179 {
180   return Internal::Adaptor::Adaptor::IsAvailable();
181 }
182
183 void Adaptor::NotifySceneCreated()
184 {
185   mImpl->NotifySceneCreated();
186 }
187
188 void Adaptor::NotifyLanguageChanged()
189 {
190   mImpl->NotifyLanguageChanged();
191 }
192
193 void Adaptor::FeedTouchPoint(TouchPoint& point, int timeStamp)
194 {
195   mImpl->FeedTouchPoint(point, timeStamp);
196 }
197
198 void Adaptor::FeedWheelEvent(WheelEvent& wheelEvent)
199 {
200   mImpl->FeedWheelEvent(wheelEvent);
201 }
202
203 void Adaptor::FeedKeyEvent(KeyEvent& keyEvent)
204 {
205   mImpl->FeedKeyEvent(keyEvent);
206 }
207
208 void Adaptor::SceneCreated()
209 {
210   mImpl->SceneCreated();
211 }
212
213 void Adaptor::SurfaceResizePrepare(Dali::RenderSurfaceInterface* surface, SurfaceSize surfaceSize)
214 {
215   mImpl->SurfaceResizePrepare(surface, surfaceSize);
216 }
217
218 void Adaptor::SurfaceResizeComplete(Dali::RenderSurfaceInterface* surface, SurfaceSize surfaceSize)
219 {
220   mImpl->SurfaceResizeComplete(surface, surfaceSize);
221 }
222
223 void Adaptor::RenderOnce()
224 {
225   mImpl->RenderOnce();
226 }
227
228 void Adaptor::FlushUpdateMessages()
229 {
230   mImpl->FlushUpdateMessages();
231 }
232
233 void Adaptor::RequestProcessEventsOnIdle()
234 {
235   mImpl->RequestProcessEventsOnIdle();
236 }
237
238 const LogFactoryInterface& Adaptor::GetLogFactory()
239 {
240   return mImpl->GetLogFactory();
241 }
242
243 const TraceFactoryInterface& Adaptor::GetTraceFactory()
244 {
245   return mImpl->GetTraceFactory();
246 }
247
248 void Adaptor::RegisterProcessor(Integration::Processor& processor, bool postProcessor)
249 {
250   mImpl->RegisterProcessor(processor, postProcessor);
251 }
252
253 void Adaptor::UnregisterProcessor(Integration::Processor& processor, bool postProcessor)
254 {
255   mImpl->UnregisterProcessor(processor, postProcessor);
256 }
257
258 Dali::WindowContainer Adaptor::GetWindows() const
259 {
260   return mImpl->GetWindows();
261 }
262
263 SceneHolderList Adaptor::GetSceneHolders() const
264 {
265   return mImpl->GetSceneHolders();
266 }
267
268 Dali::ObjectRegistry Adaptor::GetObjectRegistry() const
269 {
270   return mImpl->GetObjectRegistry();
271 }
272
273 void Adaptor::OnWindowShown()
274 {
275   mImpl->OnWindowShown();
276 }
277
278 void Adaptor::OnWindowHidden()
279 {
280   mImpl->OnWindowHidden();
281 }
282
283 Adaptor::Adaptor()
284 : mImpl(NULL)
285 {
286 }
287
288 } // namespace Dali