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