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