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>
62 #include <dali/internal/imaging/common/image-loader-plugin-proxy.h>
64 using Dali::TextAbstraction::FontClient;
77 thread_local Adaptor* gThreadLocalAdaptor = NULL; // raw thread specific pointer to allow Adaptor::Get
78 } // unnamed namespace
80 Dali::Adaptor* Adaptor::New( Any nativeWindow, RenderSurface *surface, Dali::Configuration::ContextLoss configuration, EnvironmentOptions* environmentOptions )
82 Dali::Adaptor* adaptor = new Dali::Adaptor;
83 Adaptor* impl = new Adaptor( nativeWindow, *adaptor, surface, environmentOptions );
84 adaptor->mImpl = impl;
86 impl->Initialize(configuration);
91 Dali::Adaptor* Adaptor::New( Dali::Window window, Dali::Configuration::ContextLoss configuration, EnvironmentOptions* environmentOptions )
93 Any winId = window.GetNativeHandle();
95 Window& windowImpl = Dali::GetImplementation(window);
96 Dali::Adaptor* adaptor = New( winId, windowImpl.GetSurface(), configuration, environmentOptions );
97 windowImpl.SetAdaptor(*adaptor);
101 void Adaptor::Initialize( Dali::Configuration::ContextLoss configuration )
103 // all threads here (event, update, and render) will send their logs to TIZEN Platform's LogMessage handler.
104 Dali::Integration::Log::LogFunction logFunction( Dali::TizenPlatform::LogMessage );
105 mEnvironmentOptions->SetLogFunction( logFunction );
106 mEnvironmentOptions->InstallLogFunction(); // install logging for main thread
108 mPlatformAbstraction = new TizenPlatform::TizenPlatformAbstraction;
111 GetDataStoragePath( path );
112 mPlatformAbstraction->SetDataStoragePath( path );
114 ResourcePolicy::DataRetention dataRetentionPolicy = ResourcePolicy::DALI_DISCARDS_ALL_DATA;
115 if( configuration == Dali::Configuration::APPLICATION_DOES_NOT_HANDLE_CONTEXT_LOSS )
117 dataRetentionPolicy = ResourcePolicy::DALI_DISCARDS_ALL_DATA;
119 // Note, Tizen does not use DALI_RETAINS_ALL_DATA, as it can reload images from
120 // files automatically.
122 if( mEnvironmentOptions->PerformanceServerRequired() )
124 mPerformanceInterface = PerformanceInterfaceFactory::CreateInterface( *this, *mEnvironmentOptions );
127 mEnvironmentOptions->CreateTraceManager( mPerformanceInterface );
128 mEnvironmentOptions->InstallTraceFunction(); // install tracing for main thread
130 mCallbackManager = CallbackManager::New();
132 PositionSize size = mSurface->GetPositionSize();
134 mGestureManager = new GestureManager(*this, Vector2(size.width, size.height), mCallbackManager, *mEnvironmentOptions);
136 if( mEnvironmentOptions->GetGlesCallTime() > 0 )
138 mGLES = new GlProxyImplementation( *mEnvironmentOptions );
142 mGLES = new GlImplementation();
145 const Integration::DepthBufferAvailable depthBufferAvailable = static_cast< Integration::DepthBufferAvailable >( mEnvironmentOptions->DepthBufferRequired() );
146 const Integration::StencilBufferAvailable stencilBufferAvailable = static_cast< Integration::StencilBufferAvailable >( mEnvironmentOptions->StencilBufferRequired() );
148 mEglFactory = new EglFactory( mEnvironmentOptions->GetMultiSamplingLevel(), depthBufferAvailable, stencilBufferAvailable );
150 EglSyncImplementation* eglSyncImpl = mEglFactory->GetSyncImplementation();
152 mCore = Integration::Core::New( *this,
153 *mPlatformAbstraction,
157 dataRetentionPolicy ,
158 ( 0u != mEnvironmentOptions->GetRenderToFboInterval() ) ? Integration::RenderToFrameBuffer::TRUE : Integration::RenderToFrameBuffer::FALSE,
159 depthBufferAvailable,
160 stencilBufferAvailable );
162 const unsigned int timeInterval = mEnvironmentOptions->GetObjectProfilerInterval();
163 if( 0u < timeInterval )
165 mObjectProfiler = new ObjectProfiler( timeInterval );
168 mNotificationTrigger = mTriggerEventFactory.CreateTriggerEvent( MakeCallback( this, &Adaptor::ProcessCoreEvents ), TriggerEventInterface::KEEP_ALIVE_AFTER_TRIGGER);
170 mVSyncMonitor = new VSyncMonitor;
172 mThreadController = new ThreadController( *this, *mEnvironmentOptions );
174 // Should be called after Core creation
175 if( mEnvironmentOptions->GetPanGestureLoggingLevel() )
177 Integration::EnableProfiling( Dali::Integration::PROFILING_TYPE_PAN_GESTURE );
179 if( mEnvironmentOptions->GetPanGesturePredictionMode() >= 0 )
181 Integration::SetPanGesturePredictionMode(mEnvironmentOptions->GetPanGesturePredictionMode());
183 if( mEnvironmentOptions->GetPanGesturePredictionAmount() >= 0 )
185 Integration::SetPanGesturePredictionAmount(mEnvironmentOptions->GetPanGesturePredictionAmount());
187 if( mEnvironmentOptions->GetPanGestureMaximumPredictionAmount() >= 0 )
189 Integration::SetPanGestureMaximumPredictionAmount(mEnvironmentOptions->GetPanGestureMaximumPredictionAmount());
191 if( mEnvironmentOptions->GetPanGestureMinimumPredictionAmount() >= 0 )
193 Integration::SetPanGestureMinimumPredictionAmount(mEnvironmentOptions->GetPanGestureMinimumPredictionAmount());
195 if( mEnvironmentOptions->GetPanGesturePredictionAmountAdjustment() >= 0 )
197 Integration::SetPanGesturePredictionAmountAdjustment(mEnvironmentOptions->GetPanGesturePredictionAmountAdjustment());
199 if( mEnvironmentOptions->GetPanGestureSmoothingMode() >= 0 )
201 Integration::SetPanGestureSmoothingMode(mEnvironmentOptions->GetPanGestureSmoothingMode());
203 if( mEnvironmentOptions->GetPanGestureSmoothingAmount() >= 0.0f )
205 Integration::SetPanGestureSmoothingAmount(mEnvironmentOptions->GetPanGestureSmoothingAmount());
207 if( mEnvironmentOptions->GetPanGestureUseActualTimes() >= 0 )
209 Integration::SetPanGestureUseActualTimes( mEnvironmentOptions->GetPanGestureUseActualTimes() == 0 ? true : false );
211 if( mEnvironmentOptions->GetPanGestureInterpolationTimeRange() >= 0 )
213 Integration::SetPanGestureInterpolationTimeRange( mEnvironmentOptions->GetPanGestureInterpolationTimeRange() );
215 if( mEnvironmentOptions->GetPanGestureScalarOnlyPredictionEnabled() >= 0 )
217 Integration::SetPanGestureScalarOnlyPredictionEnabled( mEnvironmentOptions->GetPanGestureScalarOnlyPredictionEnabled() == 0 ? true : false );
219 if( mEnvironmentOptions->GetPanGestureTwoPointPredictionEnabled() >= 0 )
221 Integration::SetPanGestureTwoPointPredictionEnabled( mEnvironmentOptions->GetPanGestureTwoPointPredictionEnabled() == 0 ? true : false );
223 if( mEnvironmentOptions->GetPanGestureTwoPointInterpolatePastTime() >= 0 )
225 Integration::SetPanGestureTwoPointInterpolatePastTime( mEnvironmentOptions->GetPanGestureTwoPointInterpolatePastTime() );
227 if( mEnvironmentOptions->GetPanGestureTwoPointVelocityBias() >= 0.0f )
229 Integration::SetPanGestureTwoPointVelocityBias( mEnvironmentOptions->GetPanGestureTwoPointVelocityBias() );
231 if( mEnvironmentOptions->GetPanGestureTwoPointAccelerationBias() >= 0.0f )
233 Integration::SetPanGestureTwoPointAccelerationBias( mEnvironmentOptions->GetPanGestureTwoPointAccelerationBias() );
235 if( mEnvironmentOptions->GetPanGestureMultitapSmoothingRange() >= 0 )
237 Integration::SetPanGestureMultitapSmoothingRange( mEnvironmentOptions->GetPanGestureMultitapSmoothingRange() );
240 // Set max texture size
241 if( mEnvironmentOptions->GetMaxTextureSize() > 0 )
243 Dali::SetMaxTextureSize( mEnvironmentOptions->GetMaxTextureSize() );
246 SetupSystemInformation();
251 // Ensure stop status
254 // set to NULL first as we do not want any access to Adaptor as it is being destroyed.
255 gThreadLocalAdaptor = NULL;
257 for ( ObserverContainer::iterator iter = mObservers.begin(), endIter = mObservers.end(); iter != endIter; ++iter )
259 (*iter)->OnDestroy();
262 delete mThreadController; // this will shutdown render thread, which will call Core::ContextDestroyed before exit
263 delete mVSyncMonitor;
264 delete mEventHandler;
265 delete mObjectProfiler;
270 delete mGestureManager;
271 delete mPlatformAbstraction;
272 delete mCallbackManager;
273 delete mPerformanceInterface;
275 // uninstall it on this thread (main actor thread)
276 Dali::Integration::Log::UninstallLogFunction();
278 // Delete environment options if we own it
279 if( mEnvironmentOptionsOwned )
281 delete mEnvironmentOptions;
285 void Adaptor::Start()
287 // it doesn't support restart after stop at this moment
288 // to support restarting, need more testing
289 if( READY != mState )
294 // Start the callback manager
295 mCallbackManager->Start();
297 // create event handler
298 mEventHandler = new EventHandler( mSurface, *this, *mGestureManager, *this, mDragAndDropDetector );
300 if( mDeferredRotationObserver != NULL )
302 mEventHandler->SetRotationObserver(mDeferredRotationObserver);
303 mDeferredRotationObserver = NULL;
306 unsigned int dpiHor, dpiVer;
308 mSurface->GetDpi( dpiHor, dpiVer );
310 // tell core about the DPI value
311 mCore->SetDpi(dpiHor, dpiVer);
313 // set the DPI value for font rendering
314 FontClient fontClient = FontClient::Get();
315 fontClient.SetDpi( dpiHor, dpiVer );
317 // Tell the core the size of the surface just before we start the render-thread
318 PositionSize size = mSurface->GetPositionSize();
319 mCore->SurfaceResized( size.width, size.height );
321 // Initialize the thread controller
322 mThreadController->Initialize();
324 ProcessCoreEvents(); // Ensure any startup messages are processed.
326 // Initialize the image loader plugin
327 Internal::Adaptor::ImageLoaderPluginProxy::Initialize();
329 for ( ObserverContainer::iterator iter = mObservers.begin(), endIter = mObservers.end(); iter != endIter; ++iter )
335 // Dali::Internal::Adaptor::Adaptor::Pause
336 void Adaptor::Pause()
338 // Only pause the adaptor if we're actually running.
339 if( RUNNING == mState )
341 // Inform observers that we are about to be paused.
342 for( ObserverContainer::iterator iter = mObservers.begin(), endIter = mObservers.end(); iter != endIter; ++iter )
347 // Reset the event handler when adaptor paused
350 mEventHandler->Pause();
353 mThreadController->Pause();
356 // Ensure any messages queued during pause callbacks are processed by doing another update.
361 // Dali::Internal::Adaptor::Adaptor::Resume
362 void Adaptor::Resume()
364 // Only resume the adaptor if we are in the suspended state.
365 if( PAUSED == mState )
369 // Reset the event handler when adaptor resumed
372 mEventHandler->Resume();
375 // Inform observers that we have resumed.
376 for( ObserverContainer::iterator iter = mObservers.begin(), endIter = mObservers.end(); iter != endIter; ++iter )
381 // trigger processing of events queued up while paused
382 mCore->ProcessEvents();
384 // Do at end to ensure our first update/render after resumption includes the processed messages as well
385 mThreadController->Resume();
391 if( RUNNING == mState ||
393 PAUSED_WHILE_HIDDEN == mState )
395 for( ObserverContainer::iterator iter = mObservers.begin(), endIter = mObservers.end(); iter != endIter; ++iter )
400 mThreadController->Stop();
402 // Delete the TTS player
403 for(int i =0; i < Dali::TtsPlayer::MODE_NUM; i++)
407 mTtsPlayers[i].Reset();
411 // Destroy the image loader plugin
412 Internal::Adaptor::ImageLoaderPluginProxy::Destroy();
414 delete mEventHandler;
415 mEventHandler = NULL;
417 delete mNotificationTrigger;
418 mNotificationTrigger = NULL;
420 mCallbackManager->Stop();
426 void Adaptor::ContextLost()
428 mCore->GetContextNotifier()->NotifyContextLost(); // Inform stage
431 void Adaptor::ContextRegained()
433 // Inform core, so that texture resources can be reloaded
434 mCore->RecoverFromContextLoss();
436 mCore->GetContextNotifier()->NotifyContextRegained(); // Inform stage
439 void Adaptor::FeedTouchPoint( TouchPoint& point, int timeStamp )
441 mEventHandler->FeedTouchPoint( point, timeStamp );
444 void Adaptor::FeedWheelEvent( WheelEvent& wheelEvent )
446 mEventHandler->FeedWheelEvent( wheelEvent );
449 void Adaptor::FeedKeyEvent( KeyEvent& keyEvent )
451 mEventHandler->FeedKeyEvent( keyEvent );
454 void Adaptor::ReplaceSurface( Any nativeWindow, RenderSurface& surface )
456 PositionSize positionSize = surface.GetPositionSize();
458 // let the core know the surface size has changed
459 mCore->SurfaceResized( positionSize.width, positionSize.height );
461 mResizedSignal.Emit( mAdaptor );
463 mNativeWindow = nativeWindow;
466 // flush the event queue to give the update-render thread chance
467 // to start processing messages for new camera setup etc as soon as possible
470 // this method blocks until the render thread has completed the replace.
471 mThreadController->ReplaceSurface(mSurface);
474 RenderSurface& Adaptor::GetSurface() const
479 void Adaptor::ReleaseSurfaceLock()
481 mSurface->ReleaseLock();
484 Dali::TtsPlayer Adaptor::GetTtsPlayer(Dali::TtsPlayer::Mode mode)
486 if(!mTtsPlayers[mode])
488 // Create the TTS player when it needed, because it can reduce launching time.
489 mTtsPlayers[mode] = TtsPlayer::New(mode);
492 return mTtsPlayers[mode];
495 bool Adaptor::AddIdle( CallbackBase* callback, bool hasReturnValue, bool forceAdd )
497 bool idleAdded(false);
499 // Only add an idle if the Adaptor is actually running
500 if( RUNNING == mState || READY == mState || forceAdd )
502 idleAdded = mCallbackManager->AddIdleCallback( callback, hasReturnValue );
508 void Adaptor::RemoveIdle( CallbackBase* callback )
510 mCallbackManager->RemoveIdleCallback( callback );
513 void Adaptor::SetPreRenderCallback( CallbackBase* callback )
515 mThreadController->SetPreRenderCallback( callback );
518 Dali::Adaptor& Adaptor::Get()
520 DALI_ASSERT_ALWAYS( IsAvailable() && "Adaptor not instantiated" );
521 return gThreadLocalAdaptor->mAdaptor;
524 bool Adaptor::IsAvailable()
526 return gThreadLocalAdaptor != NULL;
529 void Adaptor::SceneCreated()
531 mCore->SceneCreated();
534 Dali::Integration::Core& Adaptor::GetCore()
539 void Adaptor::SetRenderRefreshRate( unsigned int numberOfVSyncsPerRender )
541 mThreadController->SetRenderRefreshRate( numberOfVSyncsPerRender );
544 void Adaptor::SetUseHardwareVSync( bool useHardware )
546 mVSyncMonitor->SetUseHardwareVSync( useHardware );
549 EglFactory& Adaptor::GetEGLFactory() const
551 DALI_ASSERT_DEBUG( mEglFactory && "EGL Factory not created" );
555 EglFactoryInterface& Adaptor::GetEGLFactoryInterface() const
560 Integration::GlAbstraction& Adaptor::GetGlAbstraction() const
562 DALI_ASSERT_DEBUG( mGLES && "GLImplementation not created" );
566 Dali::Integration::PlatformAbstraction& Adaptor::GetPlatformAbstractionInterface()
568 return *mPlatformAbstraction;
571 Dali::Integration::GlAbstraction& Adaptor::GetGlesInterface()
576 TriggerEventInterface& Adaptor::GetProcessCoreEventsTrigger()
578 return *mNotificationTrigger;
581 TriggerEventFactoryInterface& Adaptor::GetTriggerEventFactoryInterface()
583 return mTriggerEventFactory;
586 SocketFactoryInterface& Adaptor::GetSocketFactoryInterface()
588 return mSocketFactory;
591 RenderSurface* Adaptor::GetRenderSurfaceInterface()
596 VSyncMonitorInterface* Adaptor::GetVSyncMonitorInterface()
598 return mVSyncMonitor;
601 TraceInterface& Adaptor::GetKernelTraceInterface()
603 return mKernelTracer;
606 TraceInterface& Adaptor::GetSystemTraceInterface()
608 return mSystemTracer;
611 PerformanceInterface* Adaptor::GetPerformanceInterface()
613 return mPerformanceInterface;
616 Integration::PlatformAbstraction& Adaptor::GetPlatformAbstraction() const
618 DALI_ASSERT_DEBUG( mPlatformAbstraction && "PlatformAbstraction not created" );
619 return *mPlatformAbstraction;
622 void Adaptor::SetDragAndDropDetector( DragAndDropDetectorPtr detector )
624 mDragAndDropDetector = detector;
628 mEventHandler->SetDragAndDropDetector( detector );
632 void Adaptor::SetRotationObserver( RotationObserver* observer )
636 mEventHandler->SetRotationObserver( observer );
638 else if( mState == READY )
640 // Set once event handler exists
641 mDeferredRotationObserver = observer;
645 void Adaptor::DestroyTtsPlayer(Dali::TtsPlayer::Mode mode)
647 if(mTtsPlayers[mode])
649 mTtsPlayers[mode].Reset();
653 void Adaptor::SetMinimumPinchDistance(float distance)
655 if( mGestureManager )
657 mGestureManager->SetMinimumPinchDistance(distance);
661 Any Adaptor::GetNativeWindowHandle()
663 return mNativeWindow;
666 Any Adaptor::GetGraphicsDisplay()
672 EglInterface* egl = mEglFactory->GetImplementation();
675 auto eglImpl = static_cast<EglImplementation*>(egl);
676 display = eglImpl->GetDisplay();
682 void Adaptor::SetUseRemoteSurface(bool useRemoteSurface)
684 mUseRemoteSurface = useRemoteSurface;
687 void Adaptor::AddObserver( LifeCycleObserver& observer )
689 ObserverContainer::iterator match ( find(mObservers.begin(), mObservers.end(), &observer) );
691 if ( match == mObservers.end() )
693 mObservers.push_back( &observer );
697 void Adaptor::RemoveObserver( LifeCycleObserver& observer )
699 ObserverContainer::iterator match ( find(mObservers.begin(), mObservers.end(), &observer) );
701 if ( match != mObservers.end() )
703 mObservers.erase( match );
707 void Adaptor::QueueCoreEvent(const Dali::Integration::Event& event)
711 mCore->QueueEvent(event);
715 void Adaptor::ProcessCoreEvents()
719 if( mPerformanceInterface )
721 mPerformanceInterface->AddMarker( PerformanceInterface::PROCESS_EVENTS_START );
724 mCore->ProcessEvents();
726 if( mPerformanceInterface )
728 mPerformanceInterface->AddMarker( PerformanceInterface::PROCESS_EVENTS_END );
733 void Adaptor::RequestUpdate( bool forceUpdate )
739 mThreadController->RequestUpdate();
743 case PAUSED_WHILE_HIDDEN:
745 // When Dali applications are partially visible behind the lock-screen,
746 // the indicator must be updated (therefore allow updates in the PAUSED state)
749 mThreadController->RequestUpdateOnce();
761 void Adaptor::RequestProcessEventsOnIdle( bool forceProcess )
763 // Only request a notification if the Adaptor is actually running
764 // and we haven't installed the idle notification
765 if( ( ! mNotificationOnIdleInstalled ) && ( RUNNING == mState || READY == mState || forceProcess ) )
767 mNotificationOnIdleInstalled = AddIdleEnterer( MakeCallback( this, &Adaptor::ProcessCoreEventsFromIdle ), forceProcess );
771 void Adaptor::OnWindowShown()
773 if ( PAUSED_WHILE_HIDDEN == mState )
775 // Adaptor can now be resumed
780 // Force a render task
785 void Adaptor::OnWindowHidden()
787 if ( RUNNING == mState )
791 // Adaptor cannot be resumed until the window is shown
792 mState = PAUSED_WHILE_HIDDEN;
796 // Dali::Internal::Adaptor::Adaptor::OnDamaged
797 void Adaptor::OnDamaged( const DamageArea& area )
799 // This is needed for the case where Dali window is partially obscured
800 RequestUpdate( false );
803 void Adaptor::SurfaceResizePrepare( SurfaceSize surfaceSize )
805 // let the core know the surface size has changed
806 mCore->SurfaceResized( surfaceSize.GetWidth(), surfaceSize.GetHeight() );
808 mResizedSignal.Emit( mAdaptor );
811 void Adaptor::SurfaceResizeComplete( SurfaceSize surfaceSize )
813 // flush the event queue to give the update-render thread chance
814 // to start processing messages for new camera setup etc as soon as possible
817 mThreadController->ResizeSurface();
820 void Adaptor::NotifySceneCreated()
822 GetCore().SceneCreated();
824 // Start thread controller after the scene has been created
825 mThreadController->Start();
827 // process after surface is created (registering to remote surface provider if required)
828 SurfaceInitialized();
833 void Adaptor::NotifyLanguageChanged()
835 mLanguageChangedSignal.Emit( mAdaptor );
838 void Adaptor::RenderOnce()
843 const LogFactoryInterface& Adaptor::GetLogFactory()
845 return *mEnvironmentOptions;
848 void Adaptor::RequestUpdateOnce()
850 if( mThreadController )
852 mThreadController->RequestUpdateOnce();
856 void Adaptor::IndicatorSizeChanged(int height)
858 // let the core know the indicator height is changed
859 mCore->SetTopMargin(height);
862 bool Adaptor::ProcessCoreEventsFromIdle()
866 // the idle handle automatically un-installs itself
867 mNotificationOnIdleInstalled = false;
872 Adaptor::Adaptor(Any nativeWindow, Dali::Adaptor& adaptor, RenderSurface* surface, EnvironmentOptions* environmentOptions)
874 mLanguageChangedSignal(),
878 mThreadController( NULL ),
879 mVSyncMonitor( NULL ),
883 mNativeWindow( nativeWindow ),
885 mPlatformAbstraction( NULL ),
886 mEventHandler( NULL ),
887 mCallbackManager( NULL ),
888 mNotificationOnIdleInstalled( false ),
889 mNotificationTrigger( NULL ),
890 mGestureManager( NULL ),
891 mDaliFeedbackPlugin(),
892 mFeedbackController( NULL ),
895 mDragAndDropDetector(),
896 mDeferredRotationObserver( NULL ),
897 mEnvironmentOptions( environmentOptions ? environmentOptions : new EnvironmentOptions /* Create the options if not provided */),
898 mPerformanceInterface( NULL ),
901 mTriggerEventFactory(),
902 mObjectProfiler( NULL ),
904 mEnvironmentOptionsOwned( environmentOptions ? false : true /* If not provided then we own the object */ ),
905 mUseRemoteSurface( false )
907 DALI_ASSERT_ALWAYS( !IsAvailable() && "Cannot create more than one Adaptor per thread" );
908 gThreadLocalAdaptor = this;
913 void Adaptor::SetViewMode( ViewMode viewMode )
915 mSurface->SetViewMode( viewMode );
916 mCore->SetViewMode( viewMode );
919 ViewMode Adaptor::GetViewMode() const
921 return mCore->GetViewMode();
924 void Adaptor::SetStereoBase( float stereoBase )
926 mCore->SetStereoBase( stereoBase );
929 float Adaptor::GetStereoBase() const
931 return mCore->GetStereoBase();
934 void Adaptor::SetRootLayoutDirection( std::string locale )
936 Dali::Stage stage = Dali::Stage::GetCurrent();
938 stage.GetRootLayer().SetProperty( Dali::Actor::Property::LAYOUT_DIRECTION,
939 static_cast< LayoutDirection::Type >( Internal::Adaptor::Locale::GetDirection( std::string( locale ) ) ) );
942 bool Adaptor::AddIdleEnterer( CallbackBase* callback, bool forceAdd )
944 bool idleAdded( false );
946 // Only add an idle if the Adaptor is actually running
947 if( RUNNING == mState || READY == mState || forceAdd )
949 idleAdded = mCallbackManager->AddIdleEntererCallback( callback );
955 void Adaptor::RemoveIdleEnterer( CallbackBase* callback )
957 mCallbackManager->RemoveIdleEntererCallback( callback );
960 } // namespace Adaptor
962 } // namespace Internal