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