2 * Copyright (c) 2019 Samsung Electronics Co., Ltd.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
18 #include <toolkit-window.h>
20 // Don't want to include the actual window.h which otherwise will be indirectly included by adaptor.h.
22 #include <dali/integration-api/adaptors/adaptor.h>
24 #include <dali/integration-api/adaptors/scene-holder.h>
26 #include <dali/public-api/object/base-object.h>
28 #include <toolkit-adaptor-impl.h>
29 #include <dali/integration-api/debug.h>
30 #include <test-application.h>
31 #include <test-render-surface.h>
41 bool Adaptor::mAvailable = false;
42 Vector<CallbackBase*> Adaptor::mCallbacks = Vector<CallbackBase*>();
43 Dali::WindowContainer Adaptor::mWindows;
44 Dali::Adaptor::WindowCreatedSignalType* Adaptor::mWindowCreatedSignal = nullptr;
46 Dali::Adaptor& Adaptor::Get()
48 Dali::Adaptor* adaptor = new Dali::Adaptor;
49 Adaptor::mAvailable = true;
53 Dali::RenderSurfaceInterface& Adaptor::GetSurface()
55 Dali::RenderSurfaceInterface* renderSurface = reinterpret_cast <Dali::RenderSurfaceInterface*>( new Dali::TestRenderSurface( Dali::PositionSize( 0, 0, 480, 800 ) ) );
56 return *renderSurface;
59 Dali::WindowContainer Adaptor::GetWindows()
61 return Adaptor::mWindows;
64 Dali::Adaptor::AdaptorSignalType& Adaptor::AdaptorSignal()
66 Dali::Adaptor::AdaptorSignalType* signal = new Dali::Adaptor::AdaptorSignalType;
70 Dali::Adaptor::WindowCreatedSignalType& Adaptor::WindowCreatedSignal()
72 if ( !Adaptor::mWindowCreatedSignal )
74 Adaptor::mWindowCreatedSignal = new Dali::Adaptor::WindowCreatedSignalType;
77 return *Adaptor::mWindowCreatedSignal;
80 } // namespace Adaptor
81 } // namespace Internal
83 Adaptor& Adaptor::New( Window window )
85 return Internal::Adaptor::Adaptor::Get();
88 Adaptor& Adaptor::New( Window window, Configuration::ContextLoss configuration )
90 return Internal::Adaptor::Adaptor::Get();
93 Adaptor& Adaptor::New( Window window, const Dali::RenderSurfaceInterface& surface )
95 return Internal::Adaptor::Adaptor::Get();
98 Adaptor& Adaptor::New( Window window, const Dali::RenderSurfaceInterface& surface, Configuration::ContextLoss configuration )
100 return Internal::Adaptor::Adaptor::Get();
103 Adaptor& Adaptor::New( Dali::Integration::SceneHolder window )
105 return Internal::Adaptor::Adaptor::Get();
108 Adaptor& Adaptor::New( Dali::Integration::SceneHolder window, Configuration::ContextLoss configuration )
110 return Internal::Adaptor::Adaptor::Get();
113 Adaptor& Adaptor::New( Dali::Integration::SceneHolder window, const Dali::RenderSurfaceInterface& surface )
115 return Internal::Adaptor::Adaptor::Get();
118 Adaptor& Adaptor::New( Dali::Integration::SceneHolder window, const Dali::RenderSurfaceInterface& surface, Configuration::ContextLoss configuration )
120 return Internal::Adaptor::Adaptor::Get();
127 void Adaptor::Start()
131 void Adaptor::Pause()
135 void Adaptor::Resume()
143 bool Adaptor::AddIdle( CallbackBase* callback, bool hasReturnValue )
145 const bool isAvailable = IsAvailable();
149 Internal::Adaptor::Adaptor::mCallbacks.PushBack( callback );
155 void Adaptor::RemoveIdle( CallbackBase* callback )
157 const bool isAvailable = IsAvailable();
161 for( Vector<CallbackBase*>::Iterator it = Internal::Adaptor::Adaptor::mCallbacks.Begin(),
162 endIt = Internal::Adaptor::Adaptor::mCallbacks.End();
166 if( callback == *it )
168 Internal::Adaptor::Adaptor::mCallbacks.Remove( it );
175 void Adaptor::ReplaceSurface( Window window, Dali::RenderSurfaceInterface& surface )
179 void Adaptor::ReplaceSurface( Dali::Integration::SceneHolder window, Dali::RenderSurfaceInterface& surface )
183 Adaptor::AdaptorSignalType& Adaptor::ResizedSignal()
185 return Internal::Adaptor::Adaptor::AdaptorSignal();
188 Adaptor::AdaptorSignalType& Adaptor::LanguageChangedSignal()
190 return Internal::Adaptor::Adaptor::AdaptorSignal();
193 Adaptor::WindowCreatedSignalType& Adaptor::WindowCreatedSignal()
195 return Internal::Adaptor::Adaptor::WindowCreatedSignal();
198 Dali::RenderSurfaceInterface& Adaptor::GetSurface()
200 return Internal::Adaptor::Adaptor::GetSurface();
203 Dali::WindowContainer Adaptor::GetWindows() const
205 return Internal::Adaptor::Adaptor::GetWindows();
208 Any Adaptor::GetNativeWindowHandle()
214 void Adaptor::ReleaseSurfaceLock()
218 void Adaptor::SetRenderRefreshRate( unsigned int numberOfVSyncsPerRender )
222 void Adaptor::SetUseHardwareVSync(bool useHardware)
226 Adaptor& Adaptor::Get()
228 return Internal::Adaptor::Adaptor::Get();
231 bool Adaptor::IsAvailable()
233 return Internal::Adaptor::Adaptor::mAvailable;
236 void Adaptor::NotifySceneCreated()
240 void Adaptor::NotifyLanguageChanged()
244 void Adaptor::FeedTouchPoint( TouchPoint& point, int timeStamp )
248 void Adaptor::FeedWheelEvent( WheelEvent& wheelEvent )
252 void Adaptor::FeedKeyEvent( KeyEvent& keyEvent )
256 void Adaptor::SceneCreated()
260 class LogFactory : public LogFactoryInterface
263 virtual void InstallLogFunction() const
265 Dali::Integration::Log::LogFunction logFunction(&TestApplication::LogMessage);
266 Dali::Integration::Log::InstallLogFunction(logFunction);
272 virtual ~LogFactory()
277 LogFactory* gLogFactory = NULL;
278 const LogFactoryInterface& Adaptor::GetLogFactory()
280 if( gLogFactory == NULL )
282 gLogFactory = new LogFactory;
290 Dali::PositionSize win_size;
291 win_size.width = 640;
292 win_size.height = 800;
294 Dali::Window window = Dali::Window::New( win_size, "" );
295 Internal::Adaptor::Adaptor::mWindows.push_back( window );