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/dali-common.h>
23 #include <dali/public-api/common/stage.h>
24 #include <dali/public-api/actors/layer.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/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/devel-api/adaptor-framework/render-surface.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/input/common/imf-manager-impl.h>
52 #include <dali/internal/clipboard/common/clipboard-impl.h>
53 #include <dali/internal/graphics/common/vsync-monitor.h>
54 #include <dali/internal/system/common/object-profiler.h>
55 #include <dali/internal/window-system/common/display-connection.h>
56 #include <dali/internal/window-system/common/window-impl.h>
58 #include <dali/devel-api/adaptor-framework/accessibility.h>
59 #include <dali/devel-api/adaptor-framework/image-loading.h>
60 #include <dali/internal/system/common/logging.h>
62 #include <dali/internal/system/common/locale-utils.h>
67 using Dali::TextAbstraction::FontClient;
80 thread_local Adaptor* gThreadLocalAdaptor = NULL; // raw thread specific pointer to allow Adaptor::Get
81 } // unnamed namespace
83 Dali::Adaptor* Adaptor::New( Any nativeWindow, RenderSurface *surface, Dali::Configuration::ContextLoss configuration, EnvironmentOptions* environmentOptions )
85 Dali::Adaptor* adaptor = new Dali::Adaptor;
86 Adaptor* impl = new Adaptor( nativeWindow, *adaptor, surface, environmentOptions );
87 adaptor->mImpl = impl;
89 impl->Initialize(configuration);
94 Dali::Adaptor* Adaptor::New( Dali::Window window, Dali::Configuration::ContextLoss configuration, EnvironmentOptions* environmentOptions )
96 Any winId = window.GetNativeHandle();
98 Window& windowImpl = Dali::GetImplementation(window);
99 Dali::Adaptor* adaptor = New( winId, windowImpl.GetSurface(), configuration, environmentOptions );
100 windowImpl.SetAdaptor(*adaptor);
104 void Adaptor::Initialize( Dali::Configuration::ContextLoss configuration )
106 // all threads here (event, update, and render) will send their logs to TIZEN Platform's LogMessage handler.
107 Dali::Integration::Log::LogFunction logFunction( Dali::TizenPlatform::LogMessage );
108 mEnvironmentOptions->SetLogFunction( logFunction );
109 mEnvironmentOptions->InstallLogFunction(); // install logging for main thread
111 mPlatformAbstraction = new TizenPlatform::TizenPlatformAbstraction;
114 GetDataStoragePath( path );
115 mPlatformAbstraction->SetDataStoragePath( path );
117 ResourcePolicy::DataRetention dataRetentionPolicy = ResourcePolicy::DALI_DISCARDS_ALL_DATA;
118 if( configuration == Dali::Configuration::APPLICATION_DOES_NOT_HANDLE_CONTEXT_LOSS )
120 dataRetentionPolicy = ResourcePolicy::DALI_DISCARDS_ALL_DATA;
122 // Note, Tizen does not use DALI_RETAINS_ALL_DATA, as it can reload images from
123 // files automatically.
125 if( mEnvironmentOptions->PerformanceServerRequired() )
127 mPerformanceInterface = PerformanceInterfaceFactory::CreateInterface( *this, *mEnvironmentOptions );
130 mEnvironmentOptions->CreateTraceManager( mPerformanceInterface );
131 mEnvironmentOptions->InstallTraceFunction(); // install tracing for main thread
133 mCallbackManager = CallbackManager::New();
135 PositionSize size = mSurface->GetPositionSize();
137 mGestureManager = new GestureManager(*this, Vector2(size.width, size.height), mCallbackManager, *mEnvironmentOptions);
139 if( mEnvironmentOptions->GetGlesCallTime() > 0 )
141 mGLES = new GlProxyImplementation( *mEnvironmentOptions );
145 mGLES = new GlImplementation();
148 const Integration::DepthBufferAvailable depthBufferAvailable = static_cast< Integration::DepthBufferAvailable >( mEnvironmentOptions->DepthBufferRequired() );
149 const Integration::StencilBufferAvailable stencilBufferAvailable = static_cast< Integration::StencilBufferAvailable >( mEnvironmentOptions->StencilBufferRequired() );
151 mEglFactory = new EglFactory( mEnvironmentOptions->GetMultiSamplingLevel(), depthBufferAvailable, stencilBufferAvailable );
153 EglSyncImplementation* eglSyncImpl = mEglFactory->GetSyncImplementation();
155 mCore = Integration::Core::New( *this,
156 *mPlatformAbstraction,
160 dataRetentionPolicy ,
161 ( 0u != mEnvironmentOptions->GetRenderToFboInterval() ) ? Integration::RenderToFrameBuffer::TRUE : Integration::RenderToFrameBuffer::FALSE,
162 depthBufferAvailable,
163 stencilBufferAvailable );
165 const unsigned int timeInterval = mEnvironmentOptions->GetObjectProfilerInterval();
166 if( 0u < timeInterval )
168 mObjectProfiler = new ObjectProfiler( timeInterval );
171 mNotificationTrigger = mTriggerEventFactory.CreateTriggerEvent( MakeCallback( this, &Adaptor::ProcessCoreEvents ), TriggerEventInterface::KEEP_ALIVE_AFTER_TRIGGER);
173 mVSyncMonitor = new VSyncMonitor;
175 mThreadController = new ThreadController( *this, *mEnvironmentOptions );
177 // Should be called after Core creation
178 if( mEnvironmentOptions->GetPanGestureLoggingLevel() )
180 Integration::EnableProfiling( Dali::Integration::PROFILING_TYPE_PAN_GESTURE );
182 if( mEnvironmentOptions->GetPanGesturePredictionMode() >= 0 )
184 Integration::SetPanGesturePredictionMode(mEnvironmentOptions->GetPanGesturePredictionMode());
186 if( mEnvironmentOptions->GetPanGesturePredictionAmount() >= 0 )
188 Integration::SetPanGesturePredictionAmount(mEnvironmentOptions->GetPanGesturePredictionAmount());
190 if( mEnvironmentOptions->GetPanGestureMaximumPredictionAmount() >= 0 )
192 Integration::SetPanGestureMaximumPredictionAmount(mEnvironmentOptions->GetPanGestureMaximumPredictionAmount());
194 if( mEnvironmentOptions->GetPanGestureMinimumPredictionAmount() >= 0 )
196 Integration::SetPanGestureMinimumPredictionAmount(mEnvironmentOptions->GetPanGestureMinimumPredictionAmount());
198 if( mEnvironmentOptions->GetPanGesturePredictionAmountAdjustment() >= 0 )
200 Integration::SetPanGesturePredictionAmountAdjustment(mEnvironmentOptions->GetPanGesturePredictionAmountAdjustment());
202 if( mEnvironmentOptions->GetPanGestureSmoothingMode() >= 0 )
204 Integration::SetPanGestureSmoothingMode(mEnvironmentOptions->GetPanGestureSmoothingMode());
206 if( mEnvironmentOptions->GetPanGestureSmoothingAmount() >= 0.0f )
208 Integration::SetPanGestureSmoothingAmount(mEnvironmentOptions->GetPanGestureSmoothingAmount());
210 if( mEnvironmentOptions->GetPanGestureUseActualTimes() >= 0 )
212 Integration::SetPanGestureUseActualTimes( mEnvironmentOptions->GetPanGestureUseActualTimes() == 0 ? true : false );
214 if( mEnvironmentOptions->GetPanGestureInterpolationTimeRange() >= 0 )
216 Integration::SetPanGestureInterpolationTimeRange( mEnvironmentOptions->GetPanGestureInterpolationTimeRange() );
218 if( mEnvironmentOptions->GetPanGestureScalarOnlyPredictionEnabled() >= 0 )
220 Integration::SetPanGestureScalarOnlyPredictionEnabled( mEnvironmentOptions->GetPanGestureScalarOnlyPredictionEnabled() == 0 ? true : false );
222 if( mEnvironmentOptions->GetPanGestureTwoPointPredictionEnabled() >= 0 )
224 Integration::SetPanGestureTwoPointPredictionEnabled( mEnvironmentOptions->GetPanGestureTwoPointPredictionEnabled() == 0 ? true : false );
226 if( mEnvironmentOptions->GetPanGestureTwoPointInterpolatePastTime() >= 0 )
228 Integration::SetPanGestureTwoPointInterpolatePastTime( mEnvironmentOptions->GetPanGestureTwoPointInterpolatePastTime() );
230 if( mEnvironmentOptions->GetPanGestureTwoPointVelocityBias() >= 0.0f )
232 Integration::SetPanGestureTwoPointVelocityBias( mEnvironmentOptions->GetPanGestureTwoPointVelocityBias() );
234 if( mEnvironmentOptions->GetPanGestureTwoPointAccelerationBias() >= 0.0f )
236 Integration::SetPanGestureTwoPointAccelerationBias( mEnvironmentOptions->GetPanGestureTwoPointAccelerationBias() );
238 if( mEnvironmentOptions->GetPanGestureMultitapSmoothingRange() >= 0 )
240 Integration::SetPanGestureMultitapSmoothingRange( mEnvironmentOptions->GetPanGestureMultitapSmoothingRange() );
243 // Set max texture size
244 if( mEnvironmentOptions->GetMaxTextureSize() > 0 )
246 Dali::SetMaxTextureSize( mEnvironmentOptions->GetMaxTextureSize() );
249 SetupSystemInformation();
251 Dali::Stage stage = Dali::Stage::GetCurrent();
253 char appname[4096] = {0};
255 aul_app_get_pkgname_bypid( pid, appname, sizeof( appname ) );
257 accessibilityObserver.atspiBridge = Accessibility::CreateBridge();
258 auto accessible = Accessibility::Accessible::Get( stage.GetRootLayer() );
259 accessibilityObserver.atspiBridge->SetApplicationChild( accessible );
260 accessibilityObserver.atspiBridge->SetApplicationName( appname );
261 accessibilityObserver.atspiBridge->Initialize();
263 Dali::Stage::GetCurrent().KeyEventSignal().Connect( &accessibilityObserver, &AccessibilityObserver::OnAccessibleKeyEvent );
266 void Adaptor::AccessibilityObserver::OnAccessibleKeyEvent( const KeyEvent& event )
268 Accessibility::KeyEventType type;
269 if( event.state == KeyEvent::Down )
271 type = Accessibility::KeyEventType::KeyPressed;
273 else if( event.state == KeyEvent::Up )
275 type = Accessibility::KeyEventType::KeyReleased;
281 atspiBridge->Emit( type, event.keyCode, event.keyPressedName, event.time, !event.keyPressed.empty() );
286 // Ensure stop status
289 // set to NULL first as we do not want any access to Adaptor as it is being destroyed.
290 gThreadLocalAdaptor = NULL;
292 for ( ObserverContainer::iterator iter = mObservers.begin(), endIter = mObservers.end(); iter != endIter; ++iter )
294 (*iter)->OnDestroy();
297 delete mThreadController; // this will shutdown render thread, which will call Core::ContextDestroyed before exit
298 delete mVSyncMonitor;
299 delete mEventHandler;
300 delete mObjectProfiler;
305 delete mGestureManager;
306 delete mPlatformAbstraction;
307 delete mCallbackManager;
308 delete mPerformanceInterface;
310 // uninstall it on this thread (main actor thread)
311 Dali::Integration::Log::UninstallLogFunction();
313 // Delete environment options if we own it
314 if( mEnvironmentOptionsOwned )
316 delete mEnvironmentOptions;
320 void Adaptor::Start()
322 // it doesn't support restart after stop at this moment
323 // to support restarting, need more testing
324 if( READY != mState )
329 // Start the callback manager
330 mCallbackManager->Start();
332 // create event handler
333 mEventHandler = new EventHandler( mSurface, *this, *mGestureManager, *this, mDragAndDropDetector );
335 if( mDeferredRotationObserver != NULL )
337 mEventHandler->SetRotationObserver(mDeferredRotationObserver);
338 mDeferredRotationObserver = NULL;
341 unsigned int dpiHor, dpiVer;
344 Dali::DisplayConnection::GetDpi( mNativeWindow, dpiHor, dpiVer );
346 Dali::DisplayConnection::GetDpi( dpiHor, dpiVer );
349 // tell core about the DPI value
350 mCore->SetDpi(dpiHor, dpiVer);
352 // set the DPI value for font rendering
353 FontClient fontClient = FontClient::Get();
354 fontClient.SetDpi( dpiHor, dpiVer );
356 // Tell the core the size of the surface just before we start the render-thread
357 PositionSize size = mSurface->GetPositionSize();
358 mCore->SurfaceResized( size.width, size.height );
360 // Initialize the thread controller
361 mThreadController->Initialize();
363 ProcessCoreEvents(); // Ensure any startup messages are processed.
365 for ( ObserverContainer::iterator iter = mObservers.begin(), endIter = mObservers.end(); iter != endIter; ++iter )
371 // Dali::Internal::Adaptor::Adaptor::Pause
372 void Adaptor::Pause()
374 // Only pause the adaptor if we're actually running.
375 if( RUNNING == mState )
377 // Inform observers that we are about to be paused.
378 for( ObserverContainer::iterator iter = mObservers.begin(), endIter = mObservers.end(); iter != endIter; ++iter )
383 // Reset the event handler when adaptor paused
386 mEventHandler->Pause();
389 mThreadController->Pause();
392 // Ensure any messages queued during pause callbacks are processed by doing another update.
397 // Dali::Internal::Adaptor::Adaptor::Resume
398 void Adaptor::Resume()
400 // Only resume the adaptor if we are in the suspended state.
401 if( PAUSED == mState )
405 // Reset the event handler when adaptor resumed
408 mEventHandler->Resume();
411 // Inform observers that we have resumed.
412 for( ObserverContainer::iterator iter = mObservers.begin(), endIter = mObservers.end(); iter != endIter; ++iter )
417 // trigger processing of events queued up while paused
418 mCore->ProcessEvents();
420 // Do at end to ensure our first update/render after resumption includes the processed messages as well
421 mThreadController->Resume();
427 if( RUNNING == mState ||
429 PAUSED_WHILE_HIDDEN == mState )
431 for( ObserverContainer::iterator iter = mObservers.begin(), endIter = mObservers.end(); iter != endIter; ++iter )
436 mThreadController->Stop();
438 // Delete the TTS player
439 for(int i =0; i < Dali::TtsPlayer::MODE_NUM; i++)
443 mTtsPlayers[i].Reset();
447 delete mEventHandler;
448 mEventHandler = NULL;
450 delete mNotificationTrigger;
451 mNotificationTrigger = NULL;
453 mCallbackManager->Stop();
459 void Adaptor::ContextLost()
461 mCore->GetContextNotifier()->NotifyContextLost(); // Inform stage
464 void Adaptor::ContextRegained()
466 // Inform core, so that texture resources can be reloaded
467 mCore->RecoverFromContextLoss();
469 mCore->GetContextNotifier()->NotifyContextRegained(); // Inform stage
472 void Adaptor::FeedTouchPoint( TouchPoint& point, int timeStamp )
474 mEventHandler->FeedTouchPoint( point, timeStamp );
477 void Adaptor::FeedWheelEvent( WheelEvent& wheelEvent )
479 mEventHandler->FeedWheelEvent( wheelEvent );
482 void Adaptor::FeedKeyEvent( KeyEvent& keyEvent )
484 mEventHandler->FeedKeyEvent( keyEvent );
487 void Adaptor::ReplaceSurface( Any nativeWindow, RenderSurface& surface )
489 PositionSize positionSize = surface.GetPositionSize();
491 // let the core know the surface size has changed
492 mCore->SurfaceResized( positionSize.width, positionSize.height );
494 mResizedSignal.Emit( mAdaptor );
496 mNativeWindow = nativeWindow;
499 // flush the event queue to give the update-render thread chance
500 // to start processing messages for new camera setup etc as soon as possible
503 // this method blocks until the render thread has completed the replace.
504 mThreadController->ReplaceSurface(mSurface);
507 RenderSurface& Adaptor::GetSurface() const
512 void Adaptor::ReleaseSurfaceLock()
514 mSurface->ReleaseLock();
517 Dali::TtsPlayer Adaptor::GetTtsPlayer(Dali::TtsPlayer::Mode mode)
519 if(!mTtsPlayers[mode])
521 // Create the TTS player when it needed, because it can reduce launching time.
522 mTtsPlayers[mode] = TtsPlayer::New(mode);
525 return mTtsPlayers[mode];
528 bool Adaptor::AddIdle( CallbackBase* callback, bool forceAdd )
530 bool idleAdded(false);
532 // Only add an idle if the Adaptor is actually running
533 if( RUNNING == mState || READY == mState || forceAdd )
535 idleAdded = mCallbackManager->AddIdleCallback( callback );
541 void Adaptor::RemoveIdle( CallbackBase* callback )
543 mCallbackManager->RemoveIdleCallback( callback );
546 Dali::Adaptor& Adaptor::Get()
548 DALI_ASSERT_ALWAYS( IsAvailable() && "Adaptor not instantiated" );
549 return gThreadLocalAdaptor->mAdaptor;
552 bool Adaptor::IsAvailable()
554 return gThreadLocalAdaptor != NULL;
557 void Adaptor::SceneCreated()
559 mCore->SceneCreated();
562 Dali::Integration::Core& Adaptor::GetCore()
567 void Adaptor::SetRenderRefreshRate( unsigned int numberOfVSyncsPerRender )
569 mThreadController->SetRenderRefreshRate( numberOfVSyncsPerRender );
572 void Adaptor::SetUseHardwareVSync( bool useHardware )
574 mVSyncMonitor->SetUseHardwareVSync( useHardware );
577 EglFactory& Adaptor::GetEGLFactory() const
579 DALI_ASSERT_DEBUG( mEglFactory && "EGL Factory not created" );
583 EglFactoryInterface& Adaptor::GetEGLFactoryInterface() const
588 Integration::GlAbstraction& Adaptor::GetGlAbstraction() const
590 DALI_ASSERT_DEBUG( mGLES && "GLImplementation not created" );
594 Dali::Integration::PlatformAbstraction& Adaptor::GetPlatformAbstractionInterface()
596 return *mPlatformAbstraction;
599 Dali::Integration::GlAbstraction& Adaptor::GetGlesInterface()
604 TriggerEventInterface& Adaptor::GetProcessCoreEventsTrigger()
606 return *mNotificationTrigger;
609 TriggerEventFactoryInterface& Adaptor::GetTriggerEventFactoryInterface()
611 return mTriggerEventFactory;
614 SocketFactoryInterface& Adaptor::GetSocketFactoryInterface()
616 return mSocketFactory;
619 RenderSurface* Adaptor::GetRenderSurfaceInterface()
624 VSyncMonitorInterface* Adaptor::GetVSyncMonitorInterface()
626 return mVSyncMonitor;
629 TraceInterface& Adaptor::GetKernelTraceInterface()
631 return mKernelTracer;
634 TraceInterface& Adaptor::GetSystemTraceInterface()
636 return mSystemTracer;
639 PerformanceInterface* Adaptor::GetPerformanceInterface()
641 return mPerformanceInterface;
644 Integration::PlatformAbstraction& Adaptor::GetPlatformAbstraction() const
646 DALI_ASSERT_DEBUG( mPlatformAbstraction && "PlatformAbstraction not created" );
647 return *mPlatformAbstraction;
650 void Adaptor::SetDragAndDropDetector( DragAndDropDetectorPtr detector )
652 mDragAndDropDetector = detector;
656 mEventHandler->SetDragAndDropDetector( detector );
660 void Adaptor::SetRotationObserver( RotationObserver* observer )
664 mEventHandler->SetRotationObserver( observer );
666 else if( mState == READY )
668 // Set once event handler exists
669 mDeferredRotationObserver = observer;
673 void Adaptor::DestroyTtsPlayer(Dali::TtsPlayer::Mode mode)
675 if(mTtsPlayers[mode])
677 mTtsPlayers[mode].Reset();
681 void Adaptor::SetMinimumPinchDistance(float distance)
683 if( mGestureManager )
685 mGestureManager->SetMinimumPinchDistance(distance);
689 Any Adaptor::GetNativeWindowHandle()
691 return mNativeWindow;
694 void Adaptor::SetUseRemoteSurface(bool useRemoteSurface)
696 mUseRemoteSurface = useRemoteSurface;
699 void Adaptor::AddObserver( LifeCycleObserver& observer )
701 ObserverContainer::iterator match ( find(mObservers.begin(), mObservers.end(), &observer) );
703 if ( match == mObservers.end() )
705 mObservers.push_back( &observer );
709 void Adaptor::RemoveObserver( LifeCycleObserver& observer )
711 ObserverContainer::iterator match ( find(mObservers.begin(), mObservers.end(), &observer) );
713 if ( match != mObservers.end() )
715 mObservers.erase( match );
719 void Adaptor::QueueCoreEvent(const Dali::Integration::Event& event)
723 mCore->QueueEvent(event);
727 void Adaptor::ProcessCoreEvents()
731 if( mPerformanceInterface )
733 mPerformanceInterface->AddMarker( PerformanceInterface::PROCESS_EVENTS_START );
736 mCore->ProcessEvents();
738 if( mPerformanceInterface )
740 mPerformanceInterface->AddMarker( PerformanceInterface::PROCESS_EVENTS_END );
745 void Adaptor::RequestUpdate( bool forceUpdate )
751 mThreadController->RequestUpdate();
755 case PAUSED_WHILE_HIDDEN:
757 // When Dali applications are partially visible behind the lock-screen,
758 // the indicator must be updated (therefore allow updates in the PAUSED state)
761 mThreadController->RequestUpdateOnce();
773 void Adaptor::RequestProcessEventsOnIdle( bool forceProcess )
775 // Only request a notification if the Adaptor is actually running
776 // and we haven't installed the idle notification
777 if( ( ! mNotificationOnIdleInstalled ) && ( RUNNING == mState || READY == mState || forceProcess ) )
779 mNotificationOnIdleInstalled = AddIdle( MakeCallback( this, &Adaptor::ProcessCoreEventsFromIdle ), forceProcess );
783 void Adaptor::OnWindowShown()
785 if ( PAUSED_WHILE_HIDDEN == mState )
787 accessibilityObserver.atspiBridge->ApplicationShown();
789 // Adaptor can now be resumed
794 // Force a render task
799 void Adaptor::OnWindowHidden()
801 if ( RUNNING == mState )
803 accessibilityObserver.atspiBridge->ApplicationHidden();
807 // Adaptor cannot be resumed until the window is shown
808 mState = PAUSED_WHILE_HIDDEN;
812 // Dali::Internal::Adaptor::Adaptor::OnDamaged
813 void Adaptor::OnDamaged( const DamageArea& area )
815 // This is needed for the case where Dali window is partially obscured
816 RequestUpdate( false );
819 void Adaptor::SurfaceResizePrepare( SurfaceSize surfaceSize )
821 // let the core know the surface size has changed
822 mCore->SurfaceResized( surfaceSize.GetWidth(), surfaceSize.GetHeight() );
824 mResizedSignal.Emit( mAdaptor );
827 void Adaptor::SurfaceResizeComplete( SurfaceSize surfaceSize )
829 // flush the event queue to give the update-render thread chance
830 // to start processing messages for new camera setup etc as soon as possible
833 // this method blocks until the render thread has completed the resizing.
834 mThreadController->ResizeSurface();
837 void Adaptor::NotifySceneCreated()
839 GetCore().SceneCreated();
841 // Start thread controller after the scene has been created
842 mThreadController->Start();
844 // process after surface is created (registering to remote surface provider if required)
845 SurfaceInitialized();
850 void Adaptor::NotifyLanguageChanged()
852 mLanguageChangedSignal.Emit( mAdaptor );
855 void Adaptor::RenderOnce()
860 const LogFactoryInterface& Adaptor::GetLogFactory()
862 return *mEnvironmentOptions;
865 void Adaptor::RequestUpdateOnce()
867 if( mThreadController )
869 mThreadController->RequestUpdateOnce();
873 void Adaptor::IndicatorSizeChanged(int height)
875 // let the core know the indicator height is changed
876 mCore->SetTopMargin(height);
879 void Adaptor::ProcessCoreEventsFromIdle()
883 // the idle handle automatically un-installs itself
884 mNotificationOnIdleInstalled = false;
887 Adaptor::Adaptor(Any nativeWindow, Dali::Adaptor& adaptor, RenderSurface* surface, EnvironmentOptions* environmentOptions)
889 mLanguageChangedSignal(),
893 mThreadController( NULL ),
894 mVSyncMonitor( NULL ),
898 mNativeWindow( nativeWindow ),
900 mPlatformAbstraction( NULL ),
901 mEventHandler( NULL ),
902 mCallbackManager( NULL ),
903 mNotificationOnIdleInstalled( false ),
904 mNotificationTrigger( NULL ),
905 mGestureManager( NULL ),
906 mDaliFeedbackPlugin(),
907 mFeedbackController( NULL ),
910 mDragAndDropDetector(),
911 mDeferredRotationObserver( NULL ),
912 mEnvironmentOptions( environmentOptions ? environmentOptions : new EnvironmentOptions /* Create the options if not provided */),
913 mPerformanceInterface( NULL ),
916 mTriggerEventFactory(),
917 mObjectProfiler( NULL ),
919 mEnvironmentOptionsOwned( environmentOptions ? false : true /* If not provided then we own the object */ ),
920 mUseRemoteSurface( false )
922 DALI_ASSERT_ALWAYS( !IsAvailable() && "Cannot create more than one Adaptor per thread" );
923 gThreadLocalAdaptor = this;
928 void Adaptor::SetViewMode( ViewMode viewMode )
930 mSurface->SetViewMode( viewMode );
931 mCore->SetViewMode( viewMode );
934 ViewMode Adaptor::GetViewMode() const
936 return mCore->GetViewMode();
939 void Adaptor::SetStereoBase( float stereoBase )
941 mCore->SetStereoBase( stereoBase );
944 float Adaptor::GetStereoBase() const
946 return mCore->GetStereoBase();
949 void Adaptor::SetRootLayoutDirection( std::string locale )
951 Dali::Stage stage = Dali::Stage::GetCurrent();
953 stage.GetRootLayer().SetProperty( Dali::Actor::Property::LAYOUT_DIRECTION,
954 static_cast< LayoutDirection::Type >( Internal::Adaptor::Locale::GetDirection( std::string( locale ) ) ) );
957 } // namespace Adaptor
959 } // namespace Internal