[dali_2.3.25] Merge branch 'devel/master'
[platform/core/uifw/dali-adaptor.git] / dali / internal / adaptor / common / adaptor.cpp
1 /*
2  * Copyright (c) 2024 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   if(IsAvailable())
91   {
92     return mImpl->AddIdle(callback, hasReturnValue);
93   }
94   else
95   {
96     DALI_LOG_ERROR("Adaptor not instantiated");
97     return false;
98   }
99 }
100
101 bool Adaptor::AddWindow(Dali::Integration::SceneHolder childWindow)
102 {
103   if(IsAvailable())
104   {
105     return mImpl->AddWindow(childWindow);
106   }
107   else
108   {
109     DALI_LOG_ERROR("Adaptor not instantiated");
110     return false;
111   }
112 }
113
114 void Adaptor::RemoveIdle(CallbackBase* callback)
115 {
116   if(IsAvailable())
117   {
118     mImpl->RemoveIdle(callback);
119   }
120   else
121   {
122     DALI_LOG_ERROR("Adaptor not instantiated");
123   }
124 }
125
126 void Adaptor::ProcessIdle()
127 {
128   if(IsAvailable())
129   {
130     mImpl->ProcessIdle();
131   }
132   else
133   {
134     DALI_LOG_ERROR("Adaptor not instantiated");
135   }
136 }
137
138 void Adaptor::ReplaceSurface(Window window, Dali::RenderSurfaceInterface& surface)
139 {
140   Internal::Adaptor::SceneHolder* sceneHolder = &Dali::GetImplementation(window);
141   mImpl->ReplaceSurface(Dali::Integration::SceneHolder(sceneHolder), surface);
142 }
143
144 void Adaptor::ReplaceSurface(Dali::Integration::SceneHolder window, Dali::RenderSurfaceInterface& surface)
145 {
146   mImpl->ReplaceSurface(window, surface);
147 }
148
149 Adaptor::AdaptorSignalType& Adaptor::ResizedSignal()
150 {
151   return mImpl->ResizedSignal();
152 }
153
154 Adaptor::AdaptorSignalType& Adaptor::LanguageChangedSignal()
155 {
156   return mImpl->LanguageChangedSignal();
157 }
158
159 Adaptor::WindowCreatedSignalType& Adaptor::WindowCreatedSignal()
160 {
161   return mImpl->WindowCreatedSignal();
162 }
163
164 Adaptor::LocaleChangedSignalType& Adaptor::LocaleChangedSignal()
165 {
166   return mImpl->LocaleChangedSignal();
167 }
168
169 Dali::RenderSurfaceInterface& Adaptor::GetSurface()
170 {
171   return mImpl->GetSurface();
172 }
173
174 Any Adaptor::GetNativeWindowHandle()
175 {
176   return mImpl->GetNativeWindowHandle();
177 }
178
179 Any Adaptor::GetNativeWindowHandle(Actor actor)
180 {
181   return mImpl->GetNativeWindowHandle(actor);
182 }
183
184 Any Adaptor::GetGraphicsDisplay()
185 {
186   return mImpl->GetGraphicsDisplay();
187 }
188
189 void Adaptor::ReleaseSurfaceLock()
190 {
191   mImpl->ReleaseSurfaceLock();
192 }
193
194 void Adaptor::SetRenderRefreshRate(unsigned int numberOfVSyncsPerRender)
195 {
196   mImpl->SetRenderRefreshRate(numberOfVSyncsPerRender);
197 }
198
199 void Adaptor::SetPreRenderCallback(CallbackBase* callback)
200 {
201   mImpl->SetPreRenderCallback(callback);
202 }
203
204 Adaptor& Adaptor::Get()
205 {
206   return Internal::Adaptor::Adaptor::Get();
207 }
208
209 bool Adaptor::IsAvailable()
210 {
211   return Internal::Adaptor::Adaptor::IsAvailable();
212 }
213
214 void Adaptor::NotifySceneCreated()
215 {
216   mImpl->NotifySceneCreated();
217 }
218
219 void Adaptor::NotifyLanguageChanged()
220 {
221   mImpl->NotifyLanguageChanged();
222 }
223
224 void Adaptor::FeedTouchPoint(TouchPoint& point, int timeStamp)
225 {
226   mImpl->FeedTouchPoint(point, timeStamp);
227 }
228
229 void Adaptor::FeedWheelEvent(WheelEvent& wheelEvent)
230 {
231   mImpl->FeedWheelEvent(wheelEvent);
232 }
233
234 void Adaptor::FeedKeyEvent(KeyEvent& keyEvent)
235 {
236   mImpl->FeedKeyEvent(keyEvent);
237 }
238
239 void Adaptor::SceneCreated()
240 {
241   mImpl->SceneCreated();
242 }
243
244 void Adaptor::SurfaceResizePrepare(Dali::RenderSurfaceInterface* surface, SurfaceSize surfaceSize)
245 {
246   mImpl->SurfaceResizePrepare(surface, surfaceSize);
247 }
248
249 void Adaptor::SurfaceResizeComplete(Dali::RenderSurfaceInterface* surface, SurfaceSize surfaceSize)
250 {
251   mImpl->SurfaceResizeComplete(surface, surfaceSize);
252 }
253
254 void Adaptor::UpdateOnce()
255 {
256   mImpl->RequestUpdateOnce();
257 }
258
259 void Adaptor::RenderOnce()
260 {
261   mImpl->RenderOnce();
262 }
263
264 void Adaptor::FlushUpdateMessages()
265 {
266   mImpl->FlushUpdateMessages();
267 }
268
269 void Adaptor::RequestProcessEventsOnIdle()
270 {
271   mImpl->RequestProcessEventsOnIdle();
272 }
273
274 const LogFactoryInterface& Adaptor::GetLogFactory()
275 {
276   return mImpl->GetLogFactory();
277 }
278
279 const TraceFactoryInterface& Adaptor::GetTraceFactory()
280 {
281   return mImpl->GetTraceFactory();
282 }
283
284 void Adaptor::RegisterProcessor(Integration::Processor& processor, bool postProcessor)
285 {
286   mImpl->RegisterProcessor(processor, postProcessor);
287 }
288
289 void Adaptor::UnregisterProcessor(Integration::Processor& processor, bool postProcessor)
290 {
291   mImpl->UnregisterProcessor(processor, postProcessor);
292 }
293
294 Dali::WindowContainer Adaptor::GetWindows() const
295 {
296   return mImpl->GetWindows();
297 }
298
299 SceneHolderList Adaptor::GetSceneHolders() const
300 {
301   return mImpl->GetSceneHolders();
302 }
303
304 Dali::ObjectRegistry Adaptor::GetObjectRegistry() const
305 {
306   return mImpl->GetObjectRegistry();
307 }
308
309 void Adaptor::OnWindowShown()
310 {
311   mImpl->OnWindowShown();
312 }
313
314 void Adaptor::OnWindowHidden()
315 {
316   mImpl->OnWindowHidden();
317 }
318
319 Adaptor::Adaptor()
320 : mImpl(NULL)
321 {
322 }
323
324 } // namespace Dali