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/public-api/object/any.h>
25 #include <dali/devel-api/actors/actor-devel.h>
26 #include <dali/integration-api/debug.h>
27 #include <dali/integration-api/core.h>
28 #include <dali/integration-api/context-notifier.h>
29 #include <dali/integration-api/profiling.h>
30 #include <dali/integration-api/input-options.h>
31 #include <dali/integration-api/events/touch-event-integ.h>
34 #include <dali/public-api/dali-adaptor-common.h>
35 #include <dali/internal/system/common/thread-controller.h>
36 #include <dali/internal/system/common/performance-interface-factory.h>
37 #include <dali/internal/adaptor/common/lifecycle-observer.h>
39 #include <dali/devel-api/text-abstraction/font-client.h>
41 #include <dali/internal/system/common/callback-manager.h>
42 #include <dali/internal/accessibility/common/tts-player-impl.h>
43 #include <dali/internal/accessibility/common/accessibility-adaptor-impl.h>
44 #include <dali/internal/input/common/gesture-manager.h>
45 #include <dali/internal/window-system/common/event-handler.h>
46 #include <dali/internal/graphics/gles20/gl-proxy-implementation.h>
47 #include <dali/internal/graphics/gles20/gl-implementation.h>
48 #include <dali/internal/graphics/gles20/egl-sync-implementation.h>
49 #include <dali/internal/graphics/common/egl-image-extensions.h>
50 #include <dali/internal/graphics/gles20/egl-factory.h>
51 #include <dali/internal/clipboard/common/clipboard-impl.h>
52 #include <dali/internal/graphics/common/vsync-monitor.h>
53 #include <dali/internal/system/common/object-profiler.h>
54 #include <dali/internal/window-system/common/display-connection.h>
55 #include <dali/internal/window-system/common/window-impl.h>
56 #include <dali/internal/window-system/common/window-render-surface.h>
58 #include <dali/internal/system/common/logging.h>
59 #include <dali/devel-api/adaptor-framework/image-loading.h>
61 #include <dali/internal/system/common/locale-utils.h>
63 using Dali::TextAbstraction::FontClient;
76 thread_local Adaptor* gThreadLocalAdaptor = NULL; // raw thread specific pointer to allow Adaptor::Get
77 } // unnamed namespace
79 Dali::Adaptor* Adaptor::New( Any nativeWindow, RenderSurface *surface, Dali::Configuration::ContextLoss configuration, EnvironmentOptions* environmentOptions )
81 Dali::Adaptor* adaptor = new Dali::Adaptor;
82 Adaptor* impl = new Adaptor( nativeWindow, *adaptor, surface, environmentOptions );
83 adaptor->mImpl = impl;
85 impl->Initialize(configuration);
90 Dali::Adaptor* Adaptor::New( Dali::Window window, Dali::Configuration::ContextLoss configuration, EnvironmentOptions* environmentOptions )
92 Any winId = window.GetNativeHandle();
94 Window& windowImpl = Dali::GetImplementation(window);
95 Dali::Adaptor* adaptor = New( winId, windowImpl.GetSurface(), configuration, environmentOptions );
96 windowImpl.SetAdaptor(*adaptor);
100 void Adaptor::Initialize( Dali::Configuration::ContextLoss configuration )
102 // all threads here (event, update, and render) will send their logs to TIZEN Platform's LogMessage handler.
103 Dali::Integration::Log::LogFunction logFunction( Dali::TizenPlatform::LogMessage );
104 mEnvironmentOptions->SetLogFunction( logFunction );
105 mEnvironmentOptions->InstallLogFunction(); // install logging for main thread
107 mPlatformAbstraction = new TizenPlatform::TizenPlatformAbstraction;
110 GetDataStoragePath( path );
111 mPlatformAbstraction->SetDataStoragePath( path );
113 ResourcePolicy::DataRetention dataRetentionPolicy = ResourcePolicy::DALI_DISCARDS_ALL_DATA;
114 if( configuration == Dali::Configuration::APPLICATION_DOES_NOT_HANDLE_CONTEXT_LOSS )
116 dataRetentionPolicy = ResourcePolicy::DALI_DISCARDS_ALL_DATA;
118 // Note, Tizen does not use DALI_RETAINS_ALL_DATA, as it can reload images from
119 // files automatically.
121 if( mEnvironmentOptions->PerformanceServerRequired() )
123 mPerformanceInterface = PerformanceInterfaceFactory::CreateInterface( *this, *mEnvironmentOptions );
126 mEnvironmentOptions->CreateTraceManager( mPerformanceInterface );
127 mEnvironmentOptions->InstallTraceFunction(); // install tracing for main thread
129 mCallbackManager = CallbackManager::New();
131 PositionSize size = mSurface->GetPositionSize();
133 mGestureManager = new GestureManager(*this, Vector2(size.width, size.height), mCallbackManager, *mEnvironmentOptions);
135 if( mEnvironmentOptions->GetGlesCallTime() > 0 )
137 mGLES = new GlProxyImplementation( *mEnvironmentOptions );
141 mGLES = new GlImplementation();
144 const Integration::DepthBufferAvailable depthBufferAvailable = static_cast< Integration::DepthBufferAvailable >( mEnvironmentOptions->DepthBufferRequired() );
145 const Integration::StencilBufferAvailable stencilBufferAvailable = static_cast< Integration::StencilBufferAvailable >( mEnvironmentOptions->StencilBufferRequired() );
147 mEglFactory = new EglFactory( mEnvironmentOptions->GetMultiSamplingLevel(), depthBufferAvailable, stencilBufferAvailable );
149 EglSyncImplementation* eglSyncImpl = mEglFactory->GetSyncImplementation();
151 mCore = Integration::Core::New( *this,
152 *mPlatformAbstraction,
156 dataRetentionPolicy ,
157 ( 0u != mEnvironmentOptions->GetRenderToFboInterval() ) ? Integration::RenderToFrameBuffer::TRUE : Integration::RenderToFrameBuffer::FALSE,
158 depthBufferAvailable,
159 stencilBufferAvailable );
161 const unsigned int timeInterval = mEnvironmentOptions->GetObjectProfilerInterval();
162 if( 0u < timeInterval )
164 mObjectProfiler = new ObjectProfiler( timeInterval );
167 mNotificationTrigger = mTriggerEventFactory.CreateTriggerEvent( MakeCallback( this, &Adaptor::ProcessCoreEvents ), TriggerEventInterface::KEEP_ALIVE_AFTER_TRIGGER);
169 mVSyncMonitor = new VSyncMonitor;
171 mThreadController = new ThreadController( *this, *mEnvironmentOptions );
173 // Should be called after Core creation
174 if( mEnvironmentOptions->GetPanGestureLoggingLevel() )
176 Integration::EnableProfiling( Dali::Integration::PROFILING_TYPE_PAN_GESTURE );
178 if( mEnvironmentOptions->GetPanGesturePredictionMode() >= 0 )
180 Integration::SetPanGesturePredictionMode(mEnvironmentOptions->GetPanGesturePredictionMode());
182 if( mEnvironmentOptions->GetPanGesturePredictionAmount() >= 0 )
184 Integration::SetPanGesturePredictionAmount(mEnvironmentOptions->GetPanGesturePredictionAmount());
186 if( mEnvironmentOptions->GetPanGestureMaximumPredictionAmount() >= 0 )
188 Integration::SetPanGestureMaximumPredictionAmount(mEnvironmentOptions->GetPanGestureMaximumPredictionAmount());
190 if( mEnvironmentOptions->GetPanGestureMinimumPredictionAmount() >= 0 )
192 Integration::SetPanGestureMinimumPredictionAmount(mEnvironmentOptions->GetPanGestureMinimumPredictionAmount());
194 if( mEnvironmentOptions->GetPanGesturePredictionAmountAdjustment() >= 0 )
196 Integration::SetPanGesturePredictionAmountAdjustment(mEnvironmentOptions->GetPanGesturePredictionAmountAdjustment());
198 if( mEnvironmentOptions->GetPanGestureSmoothingMode() >= 0 )
200 Integration::SetPanGestureSmoothingMode(mEnvironmentOptions->GetPanGestureSmoothingMode());
202 if( mEnvironmentOptions->GetPanGestureSmoothingAmount() >= 0.0f )
204 Integration::SetPanGestureSmoothingAmount(mEnvironmentOptions->GetPanGestureSmoothingAmount());
206 if( mEnvironmentOptions->GetPanGestureUseActualTimes() >= 0 )
208 Integration::SetPanGestureUseActualTimes( mEnvironmentOptions->GetPanGestureUseActualTimes() == 0 ? true : false );
210 if( mEnvironmentOptions->GetPanGestureInterpolationTimeRange() >= 0 )
212 Integration::SetPanGestureInterpolationTimeRange( mEnvironmentOptions->GetPanGestureInterpolationTimeRange() );
214 if( mEnvironmentOptions->GetPanGestureScalarOnlyPredictionEnabled() >= 0 )
216 Integration::SetPanGestureScalarOnlyPredictionEnabled( mEnvironmentOptions->GetPanGestureScalarOnlyPredictionEnabled() == 0 ? true : false );
218 if( mEnvironmentOptions->GetPanGestureTwoPointPredictionEnabled() >= 0 )
220 Integration::SetPanGestureTwoPointPredictionEnabled( mEnvironmentOptions->GetPanGestureTwoPointPredictionEnabled() == 0 ? true : false );
222 if( mEnvironmentOptions->GetPanGestureTwoPointInterpolatePastTime() >= 0 )
224 Integration::SetPanGestureTwoPointInterpolatePastTime( mEnvironmentOptions->GetPanGestureTwoPointInterpolatePastTime() );
226 if( mEnvironmentOptions->GetPanGestureTwoPointVelocityBias() >= 0.0f )
228 Integration::SetPanGestureTwoPointVelocityBias( mEnvironmentOptions->GetPanGestureTwoPointVelocityBias() );
230 if( mEnvironmentOptions->GetPanGestureTwoPointAccelerationBias() >= 0.0f )
232 Integration::SetPanGestureTwoPointAccelerationBias( mEnvironmentOptions->GetPanGestureTwoPointAccelerationBias() );
234 if( mEnvironmentOptions->GetPanGestureMultitapSmoothingRange() >= 0 )
236 Integration::SetPanGestureMultitapSmoothingRange( mEnvironmentOptions->GetPanGestureMultitapSmoothingRange() );
239 // Set max texture size
240 if( mEnvironmentOptions->GetMaxTextureSize() > 0 )
242 Dali::SetMaxTextureSize( mEnvironmentOptions->GetMaxTextureSize() );
245 SetupSystemInformation();
250 // Ensure stop status
253 // set to NULL first as we do not want any access to Adaptor as it is being destroyed.
254 gThreadLocalAdaptor = NULL;
256 for ( ObserverContainer::iterator iter = mObservers.begin(), endIter = mObservers.end(); iter != endIter; ++iter )
258 (*iter)->OnDestroy();
261 delete mThreadController; // this will shutdown render thread, which will call Core::ContextDestroyed before exit
262 delete mVSyncMonitor;
263 delete mEventHandler;
264 delete mObjectProfiler;
269 delete mGestureManager;
270 delete mPlatformAbstraction;
271 delete mCallbackManager;
272 delete mPerformanceInterface;
274 // uninstall it on this thread (main actor thread)
275 Dali::Integration::Log::UninstallLogFunction();
277 // Delete environment options if we own it
278 if( mEnvironmentOptionsOwned )
280 delete mEnvironmentOptions;
284 void Adaptor::Start()
286 // it doesn't support restart after stop at this moment
287 // to support restarting, need more testing
288 if( READY != mState )
293 // Start the callback manager
294 mCallbackManager->Start();
296 // create event handler
297 mEventHandler = new EventHandler( mSurface, *this, *mGestureManager, *this, mDragAndDropDetector );
299 if( mDeferredRotationObserver != NULL )
301 mEventHandler->SetRotationObserver(mDeferredRotationObserver);
302 mDeferredRotationObserver = NULL;
305 unsigned int dpiHor, dpiVer;
307 mSurface->GetDpi( dpiHor, dpiVer );
309 // tell core about the DPI value
310 mCore->SetDpi(dpiHor, dpiVer);
312 // set the DPI value for font rendering
313 FontClient fontClient = FontClient::Get();
314 fontClient.SetDpi( dpiHor, dpiVer );
316 // Tell the core the size of the surface just before we start the render-thread
317 PositionSize size = mSurface->GetPositionSize();
318 mCore->SurfaceResized( size.width, size.height );
320 // Initialize the thread controller
321 mThreadController->Initialize();
323 ProcessCoreEvents(); // Ensure any startup messages are processed.
325 for ( ObserverContainer::iterator iter = mObservers.begin(), endIter = mObservers.end(); iter != endIter; ++iter )
331 // Dali::Internal::Adaptor::Adaptor::Pause
332 void Adaptor::Pause()
334 // Only pause the adaptor if we're actually running.
335 if( RUNNING == mState )
337 // Inform observers that we are about to be paused.
338 for( ObserverContainer::iterator iter = mObservers.begin(), endIter = mObservers.end(); iter != endIter; ++iter )
343 // Reset the event handler when adaptor paused
346 mEventHandler->Pause();
349 mThreadController->Pause();
352 // Ensure any messages queued during pause callbacks are processed by doing another update.
357 // Dali::Internal::Adaptor::Adaptor::Resume
358 void Adaptor::Resume()
360 // Only resume the adaptor if we are in the suspended state.
361 if( PAUSED == mState )
365 // Reset the event handler when adaptor resumed
368 mEventHandler->Resume();
371 // Inform observers that we have resumed.
372 for( ObserverContainer::iterator iter = mObservers.begin(), endIter = mObservers.end(); iter != endIter; ++iter )
377 // trigger processing of events queued up while paused
378 mCore->ProcessEvents();
380 // Do at end to ensure our first update/render after resumption includes the processed messages as well
381 mThreadController->Resume();
387 if( RUNNING == mState ||
389 PAUSED_WHILE_HIDDEN == mState )
391 for( ObserverContainer::iterator iter = mObservers.begin(), endIter = mObservers.end(); iter != endIter; ++iter )
396 mThreadController->Stop();
398 // Delete the TTS player
399 for(int i =0; i < Dali::TtsPlayer::MODE_NUM; i++)
403 mTtsPlayers[i].Reset();
407 delete mEventHandler;
408 mEventHandler = NULL;
410 delete mNotificationTrigger;
411 mNotificationTrigger = NULL;
413 mCallbackManager->Stop();
419 void Adaptor::ContextLost()
421 mCore->GetContextNotifier()->NotifyContextLost(); // Inform stage
424 void Adaptor::ContextRegained()
426 // Inform core, so that texture resources can be reloaded
427 mCore->RecoverFromContextLoss();
429 mCore->GetContextNotifier()->NotifyContextRegained(); // Inform stage
432 void Adaptor::FeedTouchPoint( TouchPoint& point, int timeStamp )
434 mEventHandler->FeedTouchPoint( point, timeStamp );
437 void Adaptor::FeedWheelEvent( WheelEvent& wheelEvent )
439 mEventHandler->FeedWheelEvent( wheelEvent );
442 void Adaptor::FeedKeyEvent( KeyEvent& keyEvent )
444 mEventHandler->FeedKeyEvent( keyEvent );
447 void Adaptor::ReplaceSurface( Any nativeWindow, RenderSurface& surface )
449 PositionSize positionSize = surface.GetPositionSize();
451 // let the core know the surface size has changed
452 mCore->SurfaceResized( positionSize.width, positionSize.height );
454 mResizedSignal.Emit( mAdaptor );
456 mNativeWindow = nativeWindow;
459 // flush the event queue to give the update-render thread chance
460 // to start processing messages for new camera setup etc as soon as possible
463 // this method blocks until the render thread has completed the replace.
464 mThreadController->ReplaceSurface(mSurface);
467 RenderSurface& Adaptor::GetSurface() const
472 void Adaptor::ReleaseSurfaceLock()
474 mSurface->ReleaseLock();
477 Dali::TtsPlayer Adaptor::GetTtsPlayer(Dali::TtsPlayer::Mode mode)
479 if(!mTtsPlayers[mode])
481 // Create the TTS player when it needed, because it can reduce launching time.
482 mTtsPlayers[mode] = TtsPlayer::New(mode);
485 return mTtsPlayers[mode];
488 bool Adaptor::AddIdle( CallbackBase* callback, bool hasReturnValue, bool forceAdd )
490 bool idleAdded(false);
492 // Only add an idle if the Adaptor is actually running
493 if( RUNNING == mState || READY == mState || forceAdd )
495 idleAdded = mCallbackManager->AddIdleCallback( callback, hasReturnValue );
501 void Adaptor::RemoveIdle( CallbackBase* callback )
503 mCallbackManager->RemoveIdleCallback( callback );
506 void Adaptor::SetPreRenderCallback( CallbackBase* callback )
508 mThreadController->SetPreRenderCallback( callback );
511 Dali::Adaptor& Adaptor::Get()
513 DALI_ASSERT_ALWAYS( IsAvailable() && "Adaptor not instantiated" );
514 return gThreadLocalAdaptor->mAdaptor;
517 bool Adaptor::IsAvailable()
519 return gThreadLocalAdaptor != NULL;
522 void Adaptor::SceneCreated()
524 mCore->SceneCreated();
527 Dali::Integration::Core& Adaptor::GetCore()
532 void Adaptor::SetRenderRefreshRate( unsigned int numberOfVSyncsPerRender )
534 mThreadController->SetRenderRefreshRate( numberOfVSyncsPerRender );
537 void Adaptor::SetUseHardwareVSync( bool useHardware )
539 mVSyncMonitor->SetUseHardwareVSync( useHardware );
542 EglFactory& Adaptor::GetEGLFactory() const
544 DALI_ASSERT_DEBUG( mEglFactory && "EGL Factory not created" );
548 EglFactoryInterface& Adaptor::GetEGLFactoryInterface() const
553 Integration::GlAbstraction& Adaptor::GetGlAbstraction() const
555 DALI_ASSERT_DEBUG( mGLES && "GLImplementation not created" );
559 Dali::Integration::PlatformAbstraction& Adaptor::GetPlatformAbstractionInterface()
561 return *mPlatformAbstraction;
564 Dali::Integration::GlAbstraction& Adaptor::GetGlesInterface()
569 TriggerEventInterface& Adaptor::GetProcessCoreEventsTrigger()
571 return *mNotificationTrigger;
574 TriggerEventFactoryInterface& Adaptor::GetTriggerEventFactoryInterface()
576 return mTriggerEventFactory;
579 SocketFactoryInterface& Adaptor::GetSocketFactoryInterface()
581 return mSocketFactory;
584 RenderSurface* Adaptor::GetRenderSurfaceInterface()
589 VSyncMonitorInterface* Adaptor::GetVSyncMonitorInterface()
591 return mVSyncMonitor;
594 TraceInterface& Adaptor::GetKernelTraceInterface()
596 return mKernelTracer;
599 TraceInterface& Adaptor::GetSystemTraceInterface()
601 return mSystemTracer;
604 PerformanceInterface* Adaptor::GetPerformanceInterface()
606 return mPerformanceInterface;
609 Integration::PlatformAbstraction& Adaptor::GetPlatformAbstraction() const
611 DALI_ASSERT_DEBUG( mPlatformAbstraction && "PlatformAbstraction not created" );
612 return *mPlatformAbstraction;
615 void Adaptor::SetDragAndDropDetector( DragAndDropDetectorPtr detector )
617 mDragAndDropDetector = detector;
621 mEventHandler->SetDragAndDropDetector( detector );
625 void Adaptor::SetRotationObserver( RotationObserver* observer )
629 mEventHandler->SetRotationObserver( observer );
631 else if( mState == READY )
633 // Set once event handler exists
634 mDeferredRotationObserver = observer;
638 void Adaptor::DestroyTtsPlayer(Dali::TtsPlayer::Mode mode)
640 if(mTtsPlayers[mode])
642 mTtsPlayers[mode].Reset();
646 void Adaptor::SetMinimumPinchDistance(float distance)
648 if( mGestureManager )
650 mGestureManager->SetMinimumPinchDistance(distance);
654 Any Adaptor::GetNativeWindowHandle()
656 return mNativeWindow;
659 Any Adaptor::GetGraphicsDisplay()
665 EglInterface* egl = mEglFactory->GetImplementation();
668 auto eglImpl = static_cast<EglImplementation*>(egl);
669 display = eglImpl->GetDisplay();
675 void Adaptor::SetUseRemoteSurface(bool useRemoteSurface)
677 mUseRemoteSurface = useRemoteSurface;
680 void Adaptor::AddObserver( LifeCycleObserver& observer )
682 ObserverContainer::iterator match ( find(mObservers.begin(), mObservers.end(), &observer) );
684 if ( match == mObservers.end() )
686 mObservers.push_back( &observer );
690 void Adaptor::RemoveObserver( LifeCycleObserver& observer )
692 ObserverContainer::iterator match ( find(mObservers.begin(), mObservers.end(), &observer) );
694 if ( match != mObservers.end() )
696 mObservers.erase( match );
700 void Adaptor::QueueCoreEvent(const Dali::Integration::Event& event)
704 mCore->QueueEvent(event);
708 void Adaptor::ProcessCoreEvents()
712 if( mPerformanceInterface )
714 mPerformanceInterface->AddMarker( PerformanceInterface::PROCESS_EVENTS_START );
717 mCore->ProcessEvents();
719 if( mPerformanceInterface )
721 mPerformanceInterface->AddMarker( PerformanceInterface::PROCESS_EVENTS_END );
726 void Adaptor::RequestUpdate( bool forceUpdate )
732 mThreadController->RequestUpdate();
736 case PAUSED_WHILE_HIDDEN:
738 // When Dali applications are partially visible behind the lock-screen,
739 // the indicator must be updated (therefore allow updates in the PAUSED state)
742 mThreadController->RequestUpdateOnce();
754 void Adaptor::RequestProcessEventsOnIdle( bool forceProcess )
756 // Only request a notification if the Adaptor is actually running
757 // and we haven't installed the idle notification
758 if( ( ! mNotificationOnIdleInstalled ) && ( RUNNING == mState || READY == mState || forceProcess ) )
760 mNotificationOnIdleInstalled = AddIdleEnterer( MakeCallback( this, &Adaptor::ProcessCoreEventsFromIdle ), forceProcess );
764 void Adaptor::OnWindowShown()
766 if ( PAUSED_WHILE_HIDDEN == mState )
768 // Adaptor can now be resumed
773 // Force a render task
778 void Adaptor::OnWindowHidden()
780 if ( RUNNING == mState )
784 // Adaptor cannot be resumed until the window is shown
785 mState = PAUSED_WHILE_HIDDEN;
789 // Dali::Internal::Adaptor::Adaptor::OnDamaged
790 void Adaptor::OnDamaged( const DamageArea& area )
792 // This is needed for the case where Dali window is partially obscured
793 RequestUpdate( false );
796 void Adaptor::SurfaceResizePrepare( SurfaceSize surfaceSize )
798 // let the core know the surface size has changed
799 mCore->SurfaceResized( surfaceSize.GetWidth(), surfaceSize.GetHeight() );
801 mResizedSignal.Emit( mAdaptor );
804 void Adaptor::SurfaceResizeComplete( SurfaceSize surfaceSize )
806 // flush the event queue to give the update-render thread chance
807 // to start processing messages for new camera setup etc as soon as possible
810 mThreadController->ResizeSurface();
813 void Adaptor::NotifySceneCreated()
815 GetCore().SceneCreated();
817 // Start thread controller after the scene has been created
818 mThreadController->Start();
820 // process after surface is created (registering to remote surface provider if required)
821 SurfaceInitialized();
826 void Adaptor::NotifyLanguageChanged()
828 mLanguageChangedSignal.Emit( mAdaptor );
831 void Adaptor::RenderOnce()
836 const LogFactoryInterface& Adaptor::GetLogFactory()
838 return *mEnvironmentOptions;
841 void Adaptor::RequestUpdateOnce()
843 if( mThreadController )
845 mThreadController->RequestUpdateOnce();
849 void Adaptor::IndicatorSizeChanged(int height)
851 // let the core know the indicator height is changed
852 mCore->SetTopMargin(height);
855 bool Adaptor::ProcessCoreEventsFromIdle()
859 // the idle handle automatically un-installs itself
860 mNotificationOnIdleInstalled = false;
865 Adaptor::Adaptor(Any nativeWindow, Dali::Adaptor& adaptor, RenderSurface* surface, EnvironmentOptions* environmentOptions)
867 mLanguageChangedSignal(),
871 mThreadController( NULL ),
872 mVSyncMonitor( NULL ),
876 mNativeWindow( nativeWindow ),
878 mPlatformAbstraction( NULL ),
879 mEventHandler( NULL ),
880 mCallbackManager( NULL ),
881 mNotificationOnIdleInstalled( false ),
882 mNotificationTrigger( NULL ),
883 mGestureManager( NULL ),
884 mDaliFeedbackPlugin(),
885 mFeedbackController( NULL ),
888 mDragAndDropDetector(),
889 mDeferredRotationObserver( NULL ),
890 mEnvironmentOptions( environmentOptions ? environmentOptions : new EnvironmentOptions /* Create the options if not provided */),
891 mPerformanceInterface( NULL ),
894 mTriggerEventFactory(),
895 mObjectProfiler( NULL ),
897 mEnvironmentOptionsOwned( environmentOptions ? false : true /* If not provided then we own the object */ ),
898 mUseRemoteSurface( false )
900 DALI_ASSERT_ALWAYS( !IsAvailable() && "Cannot create more than one Adaptor per thread" );
901 gThreadLocalAdaptor = this;
906 void Adaptor::SetViewMode( ViewMode viewMode )
908 mSurface->SetViewMode( viewMode );
909 mCore->SetViewMode( viewMode );
912 ViewMode Adaptor::GetViewMode() const
914 return mCore->GetViewMode();
917 void Adaptor::SetStereoBase( float stereoBase )
919 mCore->SetStereoBase( stereoBase );
922 float Adaptor::GetStereoBase() const
924 return mCore->GetStereoBase();
927 void Adaptor::SetRootLayoutDirection( std::string locale )
929 Dali::Stage stage = Dali::Stage::GetCurrent();
931 stage.GetRootLayer().SetProperty( Dali::Actor::Property::LAYOUT_DIRECTION,
932 static_cast< LayoutDirection::Type >( Internal::Adaptor::Locale::GetDirection( std::string( locale ) ) ) );
935 bool Adaptor::AddIdleEnterer( CallbackBase* callback, bool forceAdd )
937 bool idleAdded( false );
939 // Only add an idle if the Adaptor is actually running
940 if( RUNNING == mState || READY == mState || forceAdd )
942 idleAdded = mCallbackManager->AddIdleEntererCallback( callback );
948 void Adaptor::RemoveIdleEnterer( CallbackBase* callback )
950 mCallbackManager->RemoveIdleEntererCallback( callback );
953 } // namespace Adaptor
955 } // namespace Internal