2 * Copyright (c) 2018 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/internal/adaptor/common/adaptor-impl.h>
22 #include <dali/public-api/common/stage.h>
23 #include <dali/public-api/actors/layer.h>
24 #include <dali/devel-api/actors/actor-devel.h>
25 #include <dali/integration-api/debug.h>
26 #include <dali/integration-api/core.h>
27 #include <dali/integration-api/context-notifier.h>
28 #include <dali/integration-api/profiling.h>
29 #include <dali/integration-api/input-options.h>
30 #include <dali/integration-api/events/touch-event-integ.h>
33 #include <dali/public-api/dali-adaptor-common.h>
34 #include <dali/internal/system/common/thread-controller.h>
35 #include <dali/internal/system/common/performance-interface-factory.h>
36 #include <dali/internal/adaptor/common/lifecycle-observer.h>
38 #include <dali/devel-api/text-abstraction/font-client.h>
40 #include <dali/internal/system/common/callback-manager.h>
41 #include <dali/internal/accessibility/common/tts-player-impl.h>
42 #include <dali/internal/accessibility/common/accessibility-adaptor-impl.h>
43 #include <dali/internal/input/common/gesture-manager.h>
44 #include <dali/internal/window-system/common/event-handler.h>
45 #include <dali/internal/graphics/gles20/gl-proxy-implementation.h>
46 #include <dali/internal/graphics/gles20/gl-implementation.h>
47 #include <dali/internal/graphics/gles20/egl-sync-implementation.h>
48 #include <dali/internal/graphics/common/egl-image-extensions.h>
49 #include <dali/internal/graphics/gles20/egl-factory.h>
50 #include <dali/internal/clipboard/common/clipboard-impl.h>
51 #include <dali/internal/graphics/common/vsync-monitor.h>
52 #include <dali/internal/system/common/object-profiler.h>
53 #include <dali/internal/window-system/common/display-connection.h>
54 #include <dali/internal/window-system/common/window-impl.h>
55 #include <dali/internal/window-system/common/window-render-surface.h>
57 #include <dali/internal/system/common/logging.h>
58 #include <dali/devel-api/adaptor-framework/image-loading.h>
60 #include <dali/internal/system/common/locale-utils.h>
62 using Dali::TextAbstraction::FontClient;
75 thread_local Adaptor* gThreadLocalAdaptor = NULL; // raw thread specific pointer to allow Adaptor::Get
76 } // unnamed namespace
78 Dali::Adaptor* Adaptor::New( Any nativeWindow, RenderSurface *surface, Dali::Configuration::ContextLoss configuration, EnvironmentOptions* environmentOptions )
80 Dali::Adaptor* adaptor = new Dali::Adaptor;
81 Adaptor* impl = new Adaptor( nativeWindow, *adaptor, surface, environmentOptions );
82 adaptor->mImpl = impl;
84 impl->Initialize(configuration);
89 Dali::Adaptor* Adaptor::New( Dali::Window window, Dali::Configuration::ContextLoss configuration, EnvironmentOptions* environmentOptions )
91 Any winId = window.GetNativeHandle();
93 Window& windowImpl = Dali::GetImplementation(window);
94 Dali::Adaptor* adaptor = New( winId, windowImpl.GetSurface(), configuration, environmentOptions );
95 windowImpl.SetAdaptor(*adaptor);
99 void Adaptor::Initialize( Dali::Configuration::ContextLoss configuration )
101 // all threads here (event, update, and render) will send their logs to TIZEN Platform's LogMessage handler.
102 Dali::Integration::Log::LogFunction logFunction( Dali::TizenPlatform::LogMessage );
103 mEnvironmentOptions->SetLogFunction( logFunction );
104 mEnvironmentOptions->InstallLogFunction(); // install logging for main thread
106 mPlatformAbstraction = new TizenPlatform::TizenPlatformAbstraction;
109 GetDataStoragePath( path );
110 mPlatformAbstraction->SetDataStoragePath( path );
112 ResourcePolicy::DataRetention dataRetentionPolicy = ResourcePolicy::DALI_DISCARDS_ALL_DATA;
113 if( configuration == Dali::Configuration::APPLICATION_DOES_NOT_HANDLE_CONTEXT_LOSS )
115 dataRetentionPolicy = ResourcePolicy::DALI_DISCARDS_ALL_DATA;
117 // Note, Tizen does not use DALI_RETAINS_ALL_DATA, as it can reload images from
118 // files automatically.
120 if( mEnvironmentOptions->PerformanceServerRequired() )
122 mPerformanceInterface = PerformanceInterfaceFactory::CreateInterface( *this, *mEnvironmentOptions );
125 mEnvironmentOptions->CreateTraceManager( mPerformanceInterface );
126 mEnvironmentOptions->InstallTraceFunction(); // install tracing for main thread
128 mCallbackManager = CallbackManager::New();
130 PositionSize size = mSurface->GetPositionSize();
132 mGestureManager = new GestureManager(*this, Vector2(size.width, size.height), mCallbackManager, *mEnvironmentOptions);
134 if( mEnvironmentOptions->GetGlesCallTime() > 0 )
136 mGLES = new GlProxyImplementation( *mEnvironmentOptions );
140 mGLES = new GlImplementation();
143 const Integration::DepthBufferAvailable depthBufferAvailable = static_cast< Integration::DepthBufferAvailable >( mEnvironmentOptions->DepthBufferRequired() );
144 const Integration::StencilBufferAvailable stencilBufferAvailable = static_cast< Integration::StencilBufferAvailable >( mEnvironmentOptions->StencilBufferRequired() );
146 mEglFactory = new EglFactory( mEnvironmentOptions->GetMultiSamplingLevel(), depthBufferAvailable, stencilBufferAvailable );
148 EglSyncImplementation* eglSyncImpl = mEglFactory->GetSyncImplementation();
150 mCore = Integration::Core::New( *this,
151 *mPlatformAbstraction,
155 dataRetentionPolicy ,
156 ( 0u != mEnvironmentOptions->GetRenderToFboInterval() ) ? Integration::RenderToFrameBuffer::TRUE : Integration::RenderToFrameBuffer::FALSE,
157 depthBufferAvailable,
158 stencilBufferAvailable );
160 const unsigned int timeInterval = mEnvironmentOptions->GetObjectProfilerInterval();
161 if( 0u < timeInterval )
163 mObjectProfiler = new ObjectProfiler( timeInterval );
166 mNotificationTrigger = mTriggerEventFactory.CreateTriggerEvent( MakeCallback( this, &Adaptor::ProcessCoreEvents ), TriggerEventInterface::KEEP_ALIVE_AFTER_TRIGGER);
168 mVSyncMonitor = new VSyncMonitor;
170 mThreadController = new ThreadController( *this, *mEnvironmentOptions );
172 // Should be called after Core creation
173 if( mEnvironmentOptions->GetPanGestureLoggingLevel() )
175 Integration::EnableProfiling( Dali::Integration::PROFILING_TYPE_PAN_GESTURE );
177 if( mEnvironmentOptions->GetPanGesturePredictionMode() >= 0 )
179 Integration::SetPanGesturePredictionMode(mEnvironmentOptions->GetPanGesturePredictionMode());
181 if( mEnvironmentOptions->GetPanGesturePredictionAmount() >= 0 )
183 Integration::SetPanGesturePredictionAmount(mEnvironmentOptions->GetPanGesturePredictionAmount());
185 if( mEnvironmentOptions->GetPanGestureMaximumPredictionAmount() >= 0 )
187 Integration::SetPanGestureMaximumPredictionAmount(mEnvironmentOptions->GetPanGestureMaximumPredictionAmount());
189 if( mEnvironmentOptions->GetPanGestureMinimumPredictionAmount() >= 0 )
191 Integration::SetPanGestureMinimumPredictionAmount(mEnvironmentOptions->GetPanGestureMinimumPredictionAmount());
193 if( mEnvironmentOptions->GetPanGesturePredictionAmountAdjustment() >= 0 )
195 Integration::SetPanGesturePredictionAmountAdjustment(mEnvironmentOptions->GetPanGesturePredictionAmountAdjustment());
197 if( mEnvironmentOptions->GetPanGestureSmoothingMode() >= 0 )
199 Integration::SetPanGestureSmoothingMode(mEnvironmentOptions->GetPanGestureSmoothingMode());
201 if( mEnvironmentOptions->GetPanGestureSmoothingAmount() >= 0.0f )
203 Integration::SetPanGestureSmoothingAmount(mEnvironmentOptions->GetPanGestureSmoothingAmount());
205 if( mEnvironmentOptions->GetPanGestureUseActualTimes() >= 0 )
207 Integration::SetPanGestureUseActualTimes( mEnvironmentOptions->GetPanGestureUseActualTimes() == 0 ? true : false );
209 if( mEnvironmentOptions->GetPanGestureInterpolationTimeRange() >= 0 )
211 Integration::SetPanGestureInterpolationTimeRange( mEnvironmentOptions->GetPanGestureInterpolationTimeRange() );
213 if( mEnvironmentOptions->GetPanGestureScalarOnlyPredictionEnabled() >= 0 )
215 Integration::SetPanGestureScalarOnlyPredictionEnabled( mEnvironmentOptions->GetPanGestureScalarOnlyPredictionEnabled() == 0 ? true : false );
217 if( mEnvironmentOptions->GetPanGestureTwoPointPredictionEnabled() >= 0 )
219 Integration::SetPanGestureTwoPointPredictionEnabled( mEnvironmentOptions->GetPanGestureTwoPointPredictionEnabled() == 0 ? true : false );
221 if( mEnvironmentOptions->GetPanGestureTwoPointInterpolatePastTime() >= 0 )
223 Integration::SetPanGestureTwoPointInterpolatePastTime( mEnvironmentOptions->GetPanGestureTwoPointInterpolatePastTime() );
225 if( mEnvironmentOptions->GetPanGestureTwoPointVelocityBias() >= 0.0f )
227 Integration::SetPanGestureTwoPointVelocityBias( mEnvironmentOptions->GetPanGestureTwoPointVelocityBias() );
229 if( mEnvironmentOptions->GetPanGestureTwoPointAccelerationBias() >= 0.0f )
231 Integration::SetPanGestureTwoPointAccelerationBias( mEnvironmentOptions->GetPanGestureTwoPointAccelerationBias() );
233 if( mEnvironmentOptions->GetPanGestureMultitapSmoothingRange() >= 0 )
235 Integration::SetPanGestureMultitapSmoothingRange( mEnvironmentOptions->GetPanGestureMultitapSmoothingRange() );
238 // Set max texture size
239 if( mEnvironmentOptions->GetMaxTextureSize() > 0 )
241 Dali::SetMaxTextureSize( mEnvironmentOptions->GetMaxTextureSize() );
244 SetupSystemInformation();
249 // Ensure stop status
252 // set to NULL first as we do not want any access to Adaptor as it is being destroyed.
253 gThreadLocalAdaptor = NULL;
255 for ( ObserverContainer::iterator iter = mObservers.begin(), endIter = mObservers.end(); iter != endIter; ++iter )
257 (*iter)->OnDestroy();
260 delete mThreadController; // this will shutdown render thread, which will call Core::ContextDestroyed before exit
261 delete mVSyncMonitor;
262 delete mEventHandler;
263 delete mObjectProfiler;
268 delete mGestureManager;
269 delete mPlatformAbstraction;
270 delete mCallbackManager;
271 delete mPerformanceInterface;
273 // uninstall it on this thread (main actor thread)
274 Dali::Integration::Log::UninstallLogFunction();
276 // Delete environment options if we own it
277 if( mEnvironmentOptionsOwned )
279 delete mEnvironmentOptions;
283 void Adaptor::Start()
285 // it doesn't support restart after stop at this moment
286 // to support restarting, need more testing
287 if( READY != mState )
292 // Start the callback manager
293 mCallbackManager->Start();
295 // create event handler
296 mEventHandler = new EventHandler( mSurface, *this, *mGestureManager, *this, mDragAndDropDetector );
298 if( mDeferredRotationObserver != NULL )
300 mEventHandler->SetRotationObserver(mDeferredRotationObserver);
301 mDeferredRotationObserver = NULL;
304 unsigned int dpiHor, dpiVer;
306 mSurface->GetDpi( dpiHor, dpiVer );
308 // tell core about the DPI value
309 mCore->SetDpi(dpiHor, dpiVer);
311 // set the DPI value for font rendering
312 FontClient fontClient = FontClient::Get();
313 fontClient.SetDpi( dpiHor, dpiVer );
315 // Tell the core the size of the surface just before we start the render-thread
316 PositionSize size = mSurface->GetPositionSize();
317 mCore->SurfaceResized( size.width, size.height );
319 // Initialize the thread controller
320 mThreadController->Initialize();
322 ProcessCoreEvents(); // Ensure any startup messages are processed.
324 for ( ObserverContainer::iterator iter = mObservers.begin(), endIter = mObservers.end(); iter != endIter; ++iter )
330 // Dali::Internal::Adaptor::Adaptor::Pause
331 void Adaptor::Pause()
333 // Only pause the adaptor if we're actually running.
334 if( RUNNING == mState )
336 // Inform observers that we are about to be paused.
337 for( ObserverContainer::iterator iter = mObservers.begin(), endIter = mObservers.end(); iter != endIter; ++iter )
342 // Reset the event handler when adaptor paused
345 mEventHandler->Pause();
348 mThreadController->Pause();
351 // Ensure any messages queued during pause callbacks are processed by doing another update.
356 // Dali::Internal::Adaptor::Adaptor::Resume
357 void Adaptor::Resume()
359 // Only resume the adaptor if we are in the suspended state.
360 if( PAUSED == mState )
364 // Reset the event handler when adaptor resumed
367 mEventHandler->Resume();
370 // Inform observers that we have resumed.
371 for( ObserverContainer::iterator iter = mObservers.begin(), endIter = mObservers.end(); iter != endIter; ++iter )
376 // trigger processing of events queued up while paused
377 mCore->ProcessEvents();
379 // Do at end to ensure our first update/render after resumption includes the processed messages as well
380 mThreadController->Resume();
386 if( RUNNING == mState ||
388 PAUSED_WHILE_HIDDEN == mState )
390 for( ObserverContainer::iterator iter = mObservers.begin(), endIter = mObservers.end(); iter != endIter; ++iter )
395 mThreadController->Stop();
397 // Delete the TTS player
398 for(int i =0; i < Dali::TtsPlayer::MODE_NUM; i++)
402 mTtsPlayers[i].Reset();
406 delete mEventHandler;
407 mEventHandler = NULL;
409 delete mNotificationTrigger;
410 mNotificationTrigger = NULL;
412 mCallbackManager->Stop();
418 void Adaptor::ContextLost()
420 mCore->GetContextNotifier()->NotifyContextLost(); // Inform stage
423 void Adaptor::ContextRegained()
425 // Inform core, so that texture resources can be reloaded
426 mCore->RecoverFromContextLoss();
428 mCore->GetContextNotifier()->NotifyContextRegained(); // Inform stage
431 void Adaptor::FeedTouchPoint( TouchPoint& point, int timeStamp )
433 mEventHandler->FeedTouchPoint( point, timeStamp );
436 void Adaptor::FeedWheelEvent( WheelEvent& wheelEvent )
438 mEventHandler->FeedWheelEvent( wheelEvent );
441 void Adaptor::FeedKeyEvent( KeyEvent& keyEvent )
443 mEventHandler->FeedKeyEvent( keyEvent );
446 void Adaptor::ReplaceSurface( Any nativeWindow, RenderSurface& surface )
448 PositionSize positionSize = surface.GetPositionSize();
450 // let the core know the surface size has changed
451 mCore->SurfaceResized( positionSize.width, positionSize.height );
453 mResizedSignal.Emit( mAdaptor );
455 mNativeWindow = nativeWindow;
458 // flush the event queue to give the update-render thread chance
459 // to start processing messages for new camera setup etc as soon as possible
462 // this method blocks until the render thread has completed the replace.
463 mThreadController->ReplaceSurface(mSurface);
466 RenderSurface& Adaptor::GetSurface() const
471 void Adaptor::ReleaseSurfaceLock()
473 mSurface->ReleaseLock();
476 Dali::TtsPlayer Adaptor::GetTtsPlayer(Dali::TtsPlayer::Mode mode)
478 if(!mTtsPlayers[mode])
480 // Create the TTS player when it needed, because it can reduce launching time.
481 mTtsPlayers[mode] = TtsPlayer::New(mode);
484 return mTtsPlayers[mode];
487 bool Adaptor::AddIdle( CallbackBase* callback, bool hasReturnValue, bool forceAdd )
489 bool idleAdded(false);
491 // Only add an idle if the Adaptor is actually running
492 if( RUNNING == mState || READY == mState || forceAdd )
494 idleAdded = mCallbackManager->AddIdleCallback( callback, hasReturnValue );
500 void Adaptor::RemoveIdle( CallbackBase* callback )
502 mCallbackManager->RemoveIdleCallback( callback );
505 void Adaptor::SetPreRenderCallback( CallbackBase* callback )
507 mThreadController->SetPreRenderCallback( callback );
510 Dali::Adaptor& Adaptor::Get()
512 DALI_ASSERT_ALWAYS( IsAvailable() && "Adaptor not instantiated" );
513 return gThreadLocalAdaptor->mAdaptor;
516 bool Adaptor::IsAvailable()
518 return gThreadLocalAdaptor != NULL;
521 void Adaptor::SceneCreated()
523 mCore->SceneCreated();
526 Dali::Integration::Core& Adaptor::GetCore()
531 void Adaptor::SetRenderRefreshRate( unsigned int numberOfVSyncsPerRender )
533 mThreadController->SetRenderRefreshRate( numberOfVSyncsPerRender );
536 void Adaptor::SetUseHardwareVSync( bool useHardware )
538 mVSyncMonitor->SetUseHardwareVSync( useHardware );
541 EglFactory& Adaptor::GetEGLFactory() const
543 DALI_ASSERT_DEBUG( mEglFactory && "EGL Factory not created" );
547 EglFactoryInterface& Adaptor::GetEGLFactoryInterface() const
552 Integration::GlAbstraction& Adaptor::GetGlAbstraction() const
554 DALI_ASSERT_DEBUG( mGLES && "GLImplementation not created" );
558 Dali::Integration::PlatformAbstraction& Adaptor::GetPlatformAbstractionInterface()
560 return *mPlatformAbstraction;
563 Dali::Integration::GlAbstraction& Adaptor::GetGlesInterface()
568 TriggerEventInterface& Adaptor::GetProcessCoreEventsTrigger()
570 return *mNotificationTrigger;
573 TriggerEventFactoryInterface& Adaptor::GetTriggerEventFactoryInterface()
575 return mTriggerEventFactory;
578 SocketFactoryInterface& Adaptor::GetSocketFactoryInterface()
580 return mSocketFactory;
583 RenderSurface* Adaptor::GetRenderSurfaceInterface()
588 VSyncMonitorInterface* Adaptor::GetVSyncMonitorInterface()
590 return mVSyncMonitor;
593 TraceInterface& Adaptor::GetKernelTraceInterface()
595 return mKernelTracer;
598 TraceInterface& Adaptor::GetSystemTraceInterface()
600 return mSystemTracer;
603 PerformanceInterface* Adaptor::GetPerformanceInterface()
605 return mPerformanceInterface;
608 Integration::PlatformAbstraction& Adaptor::GetPlatformAbstraction() const
610 DALI_ASSERT_DEBUG( mPlatformAbstraction && "PlatformAbstraction not created" );
611 return *mPlatformAbstraction;
614 void Adaptor::SetDragAndDropDetector( DragAndDropDetectorPtr detector )
616 mDragAndDropDetector = detector;
620 mEventHandler->SetDragAndDropDetector( detector );
624 void Adaptor::SetRotationObserver( RotationObserver* observer )
628 mEventHandler->SetRotationObserver( observer );
630 else if( mState == READY )
632 // Set once event handler exists
633 mDeferredRotationObserver = observer;
637 void Adaptor::DestroyTtsPlayer(Dali::TtsPlayer::Mode mode)
639 if(mTtsPlayers[mode])
641 mTtsPlayers[mode].Reset();
645 void Adaptor::SetMinimumPinchDistance(float distance)
647 if( mGestureManager )
649 mGestureManager->SetMinimumPinchDistance(distance);
653 Any Adaptor::GetNativeWindowHandle()
655 return mNativeWindow;
658 void Adaptor::SetUseRemoteSurface(bool useRemoteSurface)
660 mUseRemoteSurface = useRemoteSurface;
663 void Adaptor::AddObserver( LifeCycleObserver& observer )
665 ObserverContainer::iterator match ( find(mObservers.begin(), mObservers.end(), &observer) );
667 if ( match == mObservers.end() )
669 mObservers.push_back( &observer );
673 void Adaptor::RemoveObserver( LifeCycleObserver& observer )
675 ObserverContainer::iterator match ( find(mObservers.begin(), mObservers.end(), &observer) );
677 if ( match != mObservers.end() )
679 mObservers.erase( match );
683 void Adaptor::QueueCoreEvent(const Dali::Integration::Event& event)
687 mCore->QueueEvent(event);
691 void Adaptor::ProcessCoreEvents()
695 if( mPerformanceInterface )
697 mPerformanceInterface->AddMarker( PerformanceInterface::PROCESS_EVENTS_START );
700 mCore->ProcessEvents();
702 if( mPerformanceInterface )
704 mPerformanceInterface->AddMarker( PerformanceInterface::PROCESS_EVENTS_END );
709 void Adaptor::RequestUpdate( bool forceUpdate )
715 mThreadController->RequestUpdate();
719 case PAUSED_WHILE_HIDDEN:
721 // When Dali applications are partially visible behind the lock-screen,
722 // the indicator must be updated (therefore allow updates in the PAUSED state)
725 mThreadController->RequestUpdateOnce();
737 void Adaptor::RequestProcessEventsOnIdle( bool forceProcess )
739 // Only request a notification if the Adaptor is actually running
740 // and we haven't installed the idle notification
741 if( ( ! mNotificationOnIdleInstalled ) && ( RUNNING == mState || READY == mState || forceProcess ) )
743 mNotificationOnIdleInstalled = AddIdleEnterer( MakeCallback( this, &Adaptor::ProcessCoreEventsFromIdle ), forceProcess );
747 void Adaptor::OnWindowShown()
749 if ( PAUSED_WHILE_HIDDEN == mState )
751 // Adaptor can now be resumed
756 // Force a render task
761 void Adaptor::OnWindowHidden()
763 if ( RUNNING == mState )
767 // Adaptor cannot be resumed until the window is shown
768 mState = PAUSED_WHILE_HIDDEN;
772 // Dali::Internal::Adaptor::Adaptor::OnDamaged
773 void Adaptor::OnDamaged( const DamageArea& area )
775 // This is needed for the case where Dali window is partially obscured
776 RequestUpdate( false );
779 void Adaptor::SurfaceResizePrepare( SurfaceSize surfaceSize )
781 // let the core know the surface size has changed
782 mCore->SurfaceResized( surfaceSize.GetWidth(), surfaceSize.GetHeight() );
784 mResizedSignal.Emit( mAdaptor );
787 void Adaptor::SurfaceResizeComplete( SurfaceSize surfaceSize )
789 // flush the event queue to give the update-render thread chance
790 // to start processing messages for new camera setup etc as soon as possible
793 mThreadController->ResizeSurface();
796 void Adaptor::NotifySceneCreated()
798 GetCore().SceneCreated();
800 // Start thread controller after the scene has been created
801 mThreadController->Start();
803 // process after surface is created (registering to remote surface provider if required)
804 SurfaceInitialized();
809 void Adaptor::NotifyLanguageChanged()
811 mLanguageChangedSignal.Emit( mAdaptor );
814 void Adaptor::RenderOnce()
819 const LogFactoryInterface& Adaptor::GetLogFactory()
821 return *mEnvironmentOptions;
824 void Adaptor::RequestUpdateOnce()
826 if( mThreadController )
828 mThreadController->RequestUpdateOnce();
832 void Adaptor::IndicatorSizeChanged(int height)
834 // let the core know the indicator height is changed
835 mCore->SetTopMargin(height);
838 bool Adaptor::ProcessCoreEventsFromIdle()
842 // the idle handle automatically un-installs itself
843 mNotificationOnIdleInstalled = false;
848 Adaptor::Adaptor(Any nativeWindow, Dali::Adaptor& adaptor, RenderSurface* surface, EnvironmentOptions* environmentOptions)
850 mLanguageChangedSignal(),
854 mThreadController( NULL ),
855 mVSyncMonitor( NULL ),
859 mNativeWindow( nativeWindow ),
861 mPlatformAbstraction( NULL ),
862 mEventHandler( NULL ),
863 mCallbackManager( NULL ),
864 mNotificationOnIdleInstalled( false ),
865 mNotificationTrigger( NULL ),
866 mGestureManager( NULL ),
867 mDaliFeedbackPlugin(),
868 mFeedbackController( NULL ),
871 mDragAndDropDetector(),
872 mDeferredRotationObserver( NULL ),
873 mEnvironmentOptions( environmentOptions ? environmentOptions : new EnvironmentOptions /* Create the options if not provided */),
874 mPerformanceInterface( NULL ),
877 mTriggerEventFactory(),
878 mObjectProfiler( NULL ),
880 mEnvironmentOptionsOwned( environmentOptions ? false : true /* If not provided then we own the object */ ),
881 mUseRemoteSurface( false )
883 DALI_ASSERT_ALWAYS( !IsAvailable() && "Cannot create more than one Adaptor per thread" );
884 gThreadLocalAdaptor = this;
889 void Adaptor::SetViewMode( ViewMode viewMode )
891 mSurface->SetViewMode( viewMode );
892 mCore->SetViewMode( viewMode );
895 ViewMode Adaptor::GetViewMode() const
897 return mCore->GetViewMode();
900 void Adaptor::SetStereoBase( float stereoBase )
902 mCore->SetStereoBase( stereoBase );
905 float Adaptor::GetStereoBase() const
907 return mCore->GetStereoBase();
910 void Adaptor::SetRootLayoutDirection( std::string locale )
912 Dali::Stage stage = Dali::Stage::GetCurrent();
914 stage.GetRootLayer().SetProperty( Dali::Actor::Property::LAYOUT_DIRECTION,
915 static_cast< LayoutDirection::Type >( Internal::Adaptor::Locale::GetDirection( std::string( locale ) ) ) );
918 bool Adaptor::AddIdleEnterer( CallbackBase* callback, bool forceAdd )
920 bool idleAdded( false );
922 // Only add an idle if the Adaptor is actually running
923 if( RUNNING == mState || READY == mState || forceAdd )
925 idleAdded = mCallbackManager->AddIdleEntererCallback( callback );
931 void Adaptor::RemoveIdleEnterer( CallbackBase* callback )
933 mCallbackManager->RemoveIdleEntererCallback( callback );
936 } // namespace Adaptor
938 } // namespace Internal