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.
19 #include <dali/integration-api/adaptors/adaptor.h>
20 #include <dali/integration-api/adaptors/scene-holder.h>
22 #include <dali/public-api/object/base-object.h>
24 #include <toolkit-adaptor-impl.h>
25 #include <dali/integration-api/debug.h>
26 #include <test-application.h>
27 #include <test-render-surface.h>
37 bool Adaptor::mAvailable = false;
38 Vector<CallbackBase*> Adaptor::mCallbacks = Vector<CallbackBase*>();
40 Dali::Adaptor& Adaptor::Get()
42 Dali::Adaptor* adaptor = new Dali::Adaptor;
43 Adaptor::mAvailable = true;
47 Dali::RenderSurfaceInterface& Adaptor::GetSurface()
49 Dali::RenderSurfaceInterface* renderSurface = reinterpret_cast <Dali::RenderSurfaceInterface*>( new Dali::TestRenderSurface( Dali::PositionSize( 0, 0, 480, 800 ) ) );
50 return *renderSurface;
53 Dali::Adaptor::AdaptorSignalType& Adaptor::AdaptorSignal()
55 Dali::Adaptor::AdaptorSignalType* signal = new Dali::Adaptor::AdaptorSignalType;
59 } // namespace Adaptor
60 } // namespace Internal
62 Adaptor& Adaptor::New( Window window )
64 return Internal::Adaptor::Adaptor::Get();
67 Adaptor& Adaptor::New( Window window, Configuration::ContextLoss configuration )
69 return Internal::Adaptor::Adaptor::Get();
72 Adaptor& Adaptor::New( Window window, const Dali::RenderSurfaceInterface& surface )
74 return Internal::Adaptor::Adaptor::Get();
77 Adaptor& Adaptor::New( Window window, const Dali::RenderSurfaceInterface& surface, Configuration::ContextLoss configuration )
79 return Internal::Adaptor::Adaptor::Get();
82 Adaptor& Adaptor::New( Dali::Integration::SceneHolder window )
84 return Internal::Adaptor::Adaptor::Get();
87 Adaptor& Adaptor::New( Dali::Integration::SceneHolder window, Configuration::ContextLoss configuration )
89 return Internal::Adaptor::Adaptor::Get();
92 Adaptor& Adaptor::New( Dali::Integration::SceneHolder window, const Dali::RenderSurfaceInterface& surface )
94 return Internal::Adaptor::Adaptor::Get();
97 Adaptor& Adaptor::New( Dali::Integration::SceneHolder window, const Dali::RenderSurfaceInterface& surface, Configuration::ContextLoss configuration )
99 return Internal::Adaptor::Adaptor::Get();
106 void Adaptor::Start()
110 void Adaptor::Pause()
114 void Adaptor::Resume()
122 bool Adaptor::AddIdle( CallbackBase* callback, bool hasReturnValue )
124 const bool isAvailable = IsAvailable();
128 Internal::Adaptor::Adaptor::mCallbacks.PushBack( callback );
134 void Adaptor::RemoveIdle( CallbackBase* callback )
136 const bool isAvailable = IsAvailable();
140 for( Vector<CallbackBase*>::Iterator it = Internal::Adaptor::Adaptor::mCallbacks.Begin(),
141 endIt = Internal::Adaptor::Adaptor::mCallbacks.End();
145 if( callback == *it )
147 Internal::Adaptor::Adaptor::mCallbacks.Remove( it );
154 void Adaptor::ReplaceSurface( Window window, Dali::RenderSurfaceInterface& surface )
158 void Adaptor::ReplaceSurface( Dali::Integration::SceneHolder window, Dali::RenderSurfaceInterface& surface )
162 Adaptor::AdaptorSignalType& Adaptor::ResizedSignal()
164 return Internal::Adaptor::Adaptor::AdaptorSignal();
167 Adaptor::AdaptorSignalType& Adaptor::LanguageChangedSignal()
169 return Internal::Adaptor::Adaptor::AdaptorSignal();
172 Dali::RenderSurfaceInterface& Adaptor::GetSurface()
174 return Internal::Adaptor::Adaptor::GetSurface();
177 Any Adaptor::GetNativeWindowHandle()
183 void Adaptor::ReleaseSurfaceLock()
187 void Adaptor::SetRenderRefreshRate( unsigned int numberOfVSyncsPerRender )
191 void Adaptor::SetUseHardwareVSync(bool useHardware)
195 Adaptor& Adaptor::Get()
197 return Internal::Adaptor::Adaptor::Get();
200 bool Adaptor::IsAvailable()
202 return Internal::Adaptor::Adaptor::mAvailable;
205 void Adaptor::NotifySceneCreated()
209 void Adaptor::NotifyLanguageChanged()
213 void Adaptor::FeedTouchPoint( TouchPoint& point, int timeStamp )
217 void Adaptor::FeedWheelEvent( WheelEvent& wheelEvent )
221 void Adaptor::FeedKeyEvent( KeyEvent& keyEvent )
225 void Adaptor::SceneCreated()
229 class LogFactory : public LogFactoryInterface
232 virtual void InstallLogFunction() const
234 Dali::Integration::Log::LogFunction logFunction(&TestApplication::LogMessage);
235 Dali::Integration::Log::InstallLogFunction(logFunction);
241 virtual ~LogFactory()
246 LogFactory* gLogFactory = NULL;
247 const LogFactoryInterface& Adaptor::GetLogFactory()
249 if( gLogFactory == NULL )
251 gLogFactory = new LogFactory;