2 * Copyright (c) 2017 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>
21 #include <dali/public-api/object/base-object.h>
23 #include <toolkit-adaptor-impl.h>
24 #include <dali/integration-api/debug.h>
25 #include <test-application.h>
26 #include <test-render-surface.h>
36 bool Adaptor::mAvailable = false;
37 Vector<CallbackBase*> Adaptor::mCallbacks = Vector<CallbackBase*>();
39 Dali::Adaptor& Adaptor::Get()
41 Dali::Adaptor* adaptor = new Dali::Adaptor;
42 Adaptor::mAvailable = true;
46 Dali::RenderSurfaceInterface& Adaptor::GetSurface()
48 Dali::RenderSurfaceInterface* renderSurface = reinterpret_cast <Dali::RenderSurfaceInterface*>( new Dali::TestRenderSurface( Dali::PositionSize( 0, 0, 480, 800 ) ) );
49 return *renderSurface;
52 Dali::Adaptor::AdaptorSignalType& Adaptor::AdaptorSignal()
54 Dali::Adaptor::AdaptorSignalType* signal = new Dali::Adaptor::AdaptorSignalType;
58 } // namespace Adaptor
59 } // namespace Internal
61 Adaptor& Adaptor::New( Window window )
63 return Internal::Adaptor::Adaptor::Get();
66 Adaptor& Adaptor::New( Window window, Configuration::ContextLoss configuration )
68 return Internal::Adaptor::Adaptor::Get();
71 Adaptor& Adaptor::New( Any nativeWindow, const Dali::RenderSurfaceInterface& surface )
73 return Internal::Adaptor::Adaptor::Get();
76 Adaptor& Adaptor::New( Any nativeWindow, const Dali::RenderSurfaceInterface& surface, Configuration::ContextLoss configuration )
78 return Internal::Adaptor::Adaptor::Get();
93 void Adaptor::Resume()
101 bool Adaptor::AddIdle( CallbackBase* callback, bool hasReturnValue )
103 const bool isAvailable = IsAvailable();
107 Internal::Adaptor::Adaptor::mCallbacks.PushBack( callback );
113 void Adaptor::RemoveIdle( CallbackBase* callback )
115 const bool isAvailable = IsAvailable();
119 for( Vector<CallbackBase*>::Iterator it = Internal::Adaptor::Adaptor::mCallbacks.Begin(),
120 endIt = Internal::Adaptor::Adaptor::mCallbacks.End();
124 if( callback == *it )
126 Internal::Adaptor::Adaptor::mCallbacks.Remove( it );
133 void Adaptor::ReplaceSurface( Any nativeWindow, Dali::RenderSurfaceInterface& surface )
137 Adaptor::AdaptorSignalType& Adaptor::ResizedSignal()
139 return Internal::Adaptor::Adaptor::AdaptorSignal();
142 Adaptor::AdaptorSignalType& Adaptor::LanguageChangedSignal()
144 return Internal::Adaptor::Adaptor::AdaptorSignal();
147 Dali::RenderSurfaceInterface& Adaptor::GetSurface()
149 return Internal::Adaptor::Adaptor::GetSurface();
152 Any Adaptor::GetNativeWindowHandle()
158 void Adaptor::ReleaseSurfaceLock()
162 void Adaptor::SetRenderRefreshRate( unsigned int numberOfVSyncsPerRender )
166 void Adaptor::SetUseHardwareVSync(bool useHardware)
170 Adaptor& Adaptor::Get()
172 return Internal::Adaptor::Adaptor::Get();
175 bool Adaptor::IsAvailable()
177 return Internal::Adaptor::Adaptor::mAvailable;
180 void Adaptor::NotifySceneCreated()
184 void Adaptor::NotifyLanguageChanged()
188 void Adaptor::SetMinimumPinchDistance(float distance)
192 void Adaptor::FeedTouchPoint( TouchPoint& point, int timeStamp )
196 void Adaptor::FeedWheelEvent( WheelEvent& wheelEvent )
200 void Adaptor::FeedKeyEvent( KeyEvent& keyEvent )
204 void Adaptor::SceneCreated()
208 class LogFactory : public LogFactoryInterface
211 virtual void InstallLogFunction() const
213 Dali::Integration::Log::LogFunction logFunction(&TestApplication::LogMessage);
214 Dali::Integration::Log::InstallLogFunction(logFunction);
220 virtual ~LogFactory()
225 LogFactory* gLogFactory = NULL;
226 const LogFactoryInterface& Adaptor::GetLogFactory()
228 if( gLogFactory == NULL )
230 gLogFactory = new LogFactory;