Revert "[Tizen] Revert "Delete elementary dependency of ui_app_main""
[platform/core/uifw/dali-adaptor.git] / adaptors / common / adaptor-impl.cpp
1 /*
2  * Copyright (c) 2017 Samsung Electronics Co., Ltd.
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  *
16  */
17
18 // CLASS HEADER
19 #include "adaptor-impl.h"
20
21 // EXTERNAL INCLUDES
22 #include <dali/public-api/common/dali-common.h>
23 #include <dali/integration-api/debug.h>
24 #include <dali/integration-api/core.h>
25 #include <dali/integration-api/context-notifier.h>
26 #include <dali/integration-api/profiling.h>
27 #include <dali/integration-api/input-options.h>
28 #include <dali/integration-api/events/touch-event-integ.h>
29
30 // INTERNAL INCLUDES
31 #include <base/thread-controller.h>
32 #include <base/performance-logging/performance-interface-factory.h>
33 #include <base/lifecycle-observer.h>
34
35 #include <dali/devel-api/text-abstraction/font-client.h>
36
37 #include <callback-manager.h>
38 #include <render-surface.h>
39 #include <tts-player-impl.h>
40 #include <accessibility-adaptor-impl.h>
41 #include <events/gesture-manager.h>
42 #include <events/event-handler.h>
43 #include <gl/gl-proxy-implementation.h>
44 #include <gl/gl-implementation.h>
45 #include <gl/egl-sync-implementation.h>
46 #include <gl/egl-image-extensions.h>
47 #include <gl/egl-factory.h>
48 #include <imf-manager-impl.h>
49 #include <clipboard-impl.h>
50 #include <vsync-monitor.h>
51 #include <object-profiler.h>
52 #include <base/display-connection.h>
53 #include <window-impl.h>
54
55 #include <tizen-logging.h>
56 #include <image-loading.h>
57
58 using Dali::TextAbstraction::FontClient;
59
60 namespace Dali
61 {
62
63 namespace Internal
64 {
65
66 namespace Adaptor
67 {
68
69 namespace
70 {
71 __thread Adaptor* gThreadLocalAdaptor = NULL; // raw thread specific pointer to allow Adaptor::Get
72 } // unnamed namespace
73
74 Dali::Adaptor* Adaptor::New( Any nativeWindow, RenderSurface *surface, Dali::Configuration::ContextLoss configuration, EnvironmentOptions* environmentOptions )
75 {
76   Dali::Adaptor* adaptor = new Dali::Adaptor;
77   Adaptor* impl = new Adaptor( nativeWindow, *adaptor, surface, environmentOptions );
78   adaptor->mImpl = impl;
79
80   impl->Initialize(configuration);
81
82   return adaptor;
83 }
84
85 Dali::Adaptor* Adaptor::New( Dali::Window window, Dali::Configuration::ContextLoss configuration, EnvironmentOptions* environmentOptions )
86 {
87   Any winId = window.GetNativeHandle();
88
89   Window& windowImpl = Dali::GetImplementation(window);
90   Dali::Adaptor* adaptor = New( winId, windowImpl.GetSurface(), configuration, environmentOptions );
91   windowImpl.SetAdaptor(*adaptor);
92   return adaptor;
93 }
94
95 void Adaptor::Initialize( Dali::Configuration::ContextLoss configuration )
96 {
97   // all threads here (event, update, and render) will send their logs to TIZEN Platform's LogMessage handler.
98   Dali::Integration::Log::LogFunction logFunction( Dali::TizenPlatform::LogMessage );
99   mEnvironmentOptions->SetLogFunction( logFunction );
100   mEnvironmentOptions->InstallLogFunction(); // install logging for main thread
101
102   mPlatformAbstraction = new TizenPlatform::TizenPlatformAbstraction;
103
104   std::string path;
105   GetDataStoragePath( path );
106   mPlatformAbstraction->SetDataStoragePath( path );
107
108   ResourcePolicy::DataRetention dataRetentionPolicy = ResourcePolicy::DALI_DISCARDS_ALL_DATA;
109   if( configuration == Dali::Configuration::APPLICATION_DOES_NOT_HANDLE_CONTEXT_LOSS )
110   {
111     dataRetentionPolicy = ResourcePolicy::DALI_DISCARDS_ALL_DATA;
112   }
113   // Note, Tizen does not use DALI_RETAINS_ALL_DATA, as it can reload images from
114   // files automatically.
115
116   if( mEnvironmentOptions->PerformanceServerRequired() )
117   {
118     mPerformanceInterface = PerformanceInterfaceFactory::CreateInterface( *this, *mEnvironmentOptions );
119   }
120
121   mCallbackManager = CallbackManager::New();
122
123   PositionSize size = mSurface->GetPositionSize();
124
125   mGestureManager = new GestureManager(*this, Vector2(size.width, size.height), mCallbackManager, *mEnvironmentOptions);
126
127   if( mEnvironmentOptions->GetGlesCallTime() > 0 )
128   {
129     mGLES = new GlProxyImplementation( *mEnvironmentOptions );
130   }
131   else
132   {
133     mGLES = new GlImplementation();
134   }
135
136   mEglFactory = new EglFactory( mEnvironmentOptions->GetMultiSamplingLevel() );
137
138   EglSyncImplementation* eglSyncImpl = mEglFactory->GetSyncImplementation();
139
140   mCore = Integration::Core::New( *this, *mPlatformAbstraction, *mGLES, *eglSyncImpl, *mGestureManager, dataRetentionPolicy );
141
142   const unsigned int timeInterval = mEnvironmentOptions->GetObjectProfilerInterval();
143   if( 0u < timeInterval )
144   {
145     mObjectProfiler = new ObjectProfiler( timeInterval );
146   }
147
148   mNotificationTrigger = mTriggerEventFactory.CreateTriggerEvent( MakeCallback( this, &Adaptor::ProcessCoreEvents ), TriggerEventInterface::KEEP_ALIVE_AFTER_TRIGGER);
149
150   mVSyncMonitor = new VSyncMonitor;
151
152   mThreadController = new ThreadController( *this, *mEnvironmentOptions );
153
154   // Should be called after Core creation
155   if( mEnvironmentOptions->GetPanGestureLoggingLevel() )
156   {
157     Integration::EnableProfiling( Dali::Integration::PROFILING_TYPE_PAN_GESTURE );
158   }
159   if( mEnvironmentOptions->GetPanGesturePredictionMode() >= 0 )
160   {
161     Integration::SetPanGesturePredictionMode(mEnvironmentOptions->GetPanGesturePredictionMode());
162   }
163   if( mEnvironmentOptions->GetPanGesturePredictionAmount() >= 0 )
164   {
165     Integration::SetPanGesturePredictionAmount(mEnvironmentOptions->GetPanGesturePredictionAmount());
166   }
167   if( mEnvironmentOptions->GetPanGestureMaximumPredictionAmount() >= 0 )
168   {
169     Integration::SetPanGestureMaximumPredictionAmount(mEnvironmentOptions->GetPanGestureMaximumPredictionAmount());
170   }
171   if( mEnvironmentOptions->GetPanGestureMinimumPredictionAmount() >= 0 )
172   {
173     Integration::SetPanGestureMinimumPredictionAmount(mEnvironmentOptions->GetPanGestureMinimumPredictionAmount());
174   }
175   if( mEnvironmentOptions->GetPanGesturePredictionAmountAdjustment() >= 0 )
176   {
177     Integration::SetPanGesturePredictionAmountAdjustment(mEnvironmentOptions->GetPanGesturePredictionAmountAdjustment());
178   }
179   if( mEnvironmentOptions->GetPanGestureSmoothingMode() >= 0 )
180   {
181     Integration::SetPanGestureSmoothingMode(mEnvironmentOptions->GetPanGestureSmoothingMode());
182   }
183   if( mEnvironmentOptions->GetPanGestureSmoothingAmount() >= 0.0f )
184   {
185     Integration::SetPanGestureSmoothingAmount(mEnvironmentOptions->GetPanGestureSmoothingAmount());
186   }
187
188   // Set max texture size
189   if( mEnvironmentOptions->GetMaxTextureSize() > 0 )
190   {
191     Dali::SetMaxTextureSize( mEnvironmentOptions->GetMaxTextureSize() );
192   }
193 }
194
195 Adaptor::~Adaptor()
196 {
197   // Ensure stop status
198   Stop();
199
200   // set to NULL first as we do not want any access to Adaptor as it is being destroyed.
201   gThreadLocalAdaptor = NULL;
202
203   for ( ObserverContainer::iterator iter = mObservers.begin(), endIter = mObservers.end(); iter != endIter; ++iter )
204   {
205     (*iter)->OnDestroy();
206   }
207
208   delete mThreadController; // this will shutdown render thread, which will call Core::ContextDestroyed before exit
209   delete mVSyncMonitor;
210   delete mEventHandler;
211   delete mObjectProfiler;
212
213   delete mCore;
214   delete mEglFactory;
215   delete mGLES;
216   delete mGestureManager;
217   delete mPlatformAbstraction;
218   delete mCallbackManager;
219   delete mPerformanceInterface;
220
221   // uninstall it on this thread (main actor thread)
222   Dali::Integration::Log::UninstallLogFunction();
223
224   // Delete environment options if we own it
225   if( mEnvironmentOptionsOwned )
226   {
227     delete mEnvironmentOptions;
228   }
229 }
230
231 void Adaptor::Start()
232 {
233   // it doesn't support restart after stop at this moment
234   // to support restarting, need more testing
235   if( READY != mState )
236   {
237     return;
238   }
239
240   // Start the callback manager
241   mCallbackManager->Start();
242
243   // create event handler
244   mEventHandler = new EventHandler( mSurface, *this, *mGestureManager, *this, mDragAndDropDetector );
245
246   if( mDeferredRotationObserver != NULL )
247   {
248     mEventHandler->SetRotationObserver(mDeferredRotationObserver);
249     mDeferredRotationObserver = NULL;
250   }
251
252   unsigned int dpiHor, dpiVer;
253   dpiHor = dpiVer = 0;
254   Dali::DisplayConnection::GetDpi(dpiHor, dpiVer);
255
256   // tell core about the DPI value
257   mCore->SetDpi(dpiHor, dpiVer);
258
259   // set the DPI value for font rendering
260   FontClient fontClient = FontClient::Get();
261   fontClient.SetDpi( dpiHor, dpiVer );
262
263   // Tell the core the size of the surface just before we start the render-thread
264   PositionSize size = mSurface->GetPositionSize();
265   mCore->SurfaceResized( size.width, size.height );
266
267   // Initialize the thread controller
268   mThreadController->Initialize();
269
270   mState = RUNNING;
271
272   ProcessCoreEvents(); // Ensure any startup messages are processed.
273
274   for ( ObserverContainer::iterator iter = mObservers.begin(), endIter = mObservers.end(); iter != endIter; ++iter )
275   {
276     (*iter)->OnStart();
277   }
278 }
279
280 // Dali::Internal::Adaptor::Adaptor::Pause
281 void Adaptor::Pause()
282 {
283   // Only pause the adaptor if we're actually running.
284   if( RUNNING == mState )
285   {
286     // Inform observers that we are about to be paused.
287     for( ObserverContainer::iterator iter = mObservers.begin(), endIter = mObservers.end(); iter != endIter; ++iter )
288     {
289       (*iter)->OnPause();
290     }
291
292     // Reset the event handler when adaptor paused
293     if( mEventHandler )
294     {
295       mEventHandler->Pause();
296     }
297
298     mThreadController->Pause();
299     mCore->Suspend();
300     mState = PAUSED;
301   }
302 }
303
304 // Dali::Internal::Adaptor::Adaptor::Resume
305 void Adaptor::Resume()
306 {
307   // Only resume the adaptor if we are in the suspended state.
308   if( PAUSED == mState )
309   {
310     mState = RUNNING;
311
312     // Reset the event handler when adaptor resumed
313     if( mEventHandler )
314     {
315       mEventHandler->Resume();
316     }
317
318     // Inform observers that we have resumed.
319     for( ObserverContainer::iterator iter = mObservers.begin(), endIter = mObservers.end(); iter != endIter; ++iter )
320     {
321       (*iter)->OnResume();
322     }
323
324     // Resume core so it processes any requests as well
325     mCore->Resume();
326
327     // Do at end to ensure our first update/render after resumption includes the processed messages as well
328     mThreadController->Resume();
329   }
330 }
331
332 void Adaptor::Stop()
333 {
334   if( RUNNING == mState ||
335       PAUSED  == mState ||
336       PAUSED_WHILE_HIDDEN == mState )
337   {
338     for( ObserverContainer::iterator iter = mObservers.begin(), endIter = mObservers.end(); iter != endIter; ++iter )
339     {
340       (*iter)->OnStop();
341     }
342
343     mThreadController->Stop();
344     mCore->Suspend();
345
346     // Delete the TTS player
347     for(int i =0; i < Dali::TtsPlayer::MODE_NUM; i++)
348     {
349       if(mTtsPlayers[i])
350       {
351         mTtsPlayers[i].Reset();
352       }
353     }
354
355     delete mEventHandler;
356     mEventHandler = NULL;
357
358     delete mNotificationTrigger;
359     mNotificationTrigger = NULL;
360
361     mCallbackManager->Stop();
362
363     mState = STOPPED;
364   }
365 }
366
367 void Adaptor::ContextLost()
368 {
369   mCore->GetContextNotifier()->NotifyContextLost(); // Inform stage
370 }
371
372 void Adaptor::ContextRegained()
373 {
374   // Inform core, so that texture resources can be reloaded
375   mCore->RecoverFromContextLoss();
376
377   mCore->GetContextNotifier()->NotifyContextRegained(); // Inform stage
378 }
379
380 void Adaptor::FeedTouchPoint( TouchPoint& point, int timeStamp )
381 {
382   mEventHandler->FeedTouchPoint( point, timeStamp );
383 }
384
385 void Adaptor::FeedWheelEvent( WheelEvent& wheelEvent )
386 {
387   mEventHandler->FeedWheelEvent( wheelEvent );
388 }
389
390 void Adaptor::FeedKeyEvent( KeyEvent& keyEvent )
391 {
392   mEventHandler->FeedKeyEvent( keyEvent );
393 }
394
395 void Adaptor::ReplaceSurface( Any nativeWindow, RenderSurface& surface )
396 {
397   mNativeWindow = nativeWindow;
398   mSurface = &surface;
399
400   // flush the event queue to give update and render threads chance
401   // to start processing messages for new camera setup etc as soon as possible
402   ProcessCoreEvents();
403
404   // this method blocks until the render thread has completed the replace.
405   mThreadController->ReplaceSurface(mSurface);
406 }
407
408 RenderSurface& Adaptor::GetSurface() const
409 {
410   return *mSurface;
411 }
412
413 void Adaptor::ReleaseSurfaceLock()
414 {
415   mSurface->ReleaseLock();
416 }
417
418 Dali::TtsPlayer Adaptor::GetTtsPlayer(Dali::TtsPlayer::Mode mode)
419 {
420   if(!mTtsPlayers[mode])
421   {
422     // Create the TTS player when it needed, because it can reduce launching time.
423     mTtsPlayers[mode] = TtsPlayer::New(mode);
424   }
425
426   return mTtsPlayers[mode];
427 }
428
429 bool Adaptor::AddIdle( CallbackBase* callback )
430 {
431   bool idleAdded(false);
432
433   // Only add an idle if the Adaptor is actually running
434   if( RUNNING == mState )
435   {
436     idleAdded = mCallbackManager->AddIdleCallback( callback );
437   }
438
439   return idleAdded;
440 }
441
442 void Adaptor::RemoveIdle( CallbackBase* callback )
443 {
444   mCallbackManager->RemoveIdleCallback( callback );
445 }
446
447 Dali::Adaptor& Adaptor::Get()
448 {
449   DALI_ASSERT_ALWAYS( IsAvailable() && "Adaptor not instantiated" );
450   return gThreadLocalAdaptor->mAdaptor;
451 }
452
453 bool Adaptor::IsAvailable()
454 {
455   return gThreadLocalAdaptor != NULL;
456 }
457
458 void Adaptor::SceneCreated()
459 {
460   mCore->SceneCreated();
461 }
462
463 Dali::Integration::Core& Adaptor::GetCore()
464 {
465   return *mCore;
466 }
467
468 void Adaptor::SetRenderRefreshRate( unsigned int numberOfVSyncsPerRender )
469 {
470   mThreadController->SetRenderRefreshRate( numberOfVSyncsPerRender );
471 }
472
473 void Adaptor::SetUseHardwareVSync( bool useHardware )
474 {
475   mVSyncMonitor->SetUseHardwareVSync( useHardware );
476 }
477
478 EglFactory& Adaptor::GetEGLFactory() const
479 {
480   DALI_ASSERT_DEBUG( mEglFactory && "EGL Factory not created" );
481   return *mEglFactory;
482 }
483
484 EglFactoryInterface& Adaptor::GetEGLFactoryInterface() const
485 {
486   return *mEglFactory;
487 }
488
489 Integration::GlAbstraction& Adaptor::GetGlAbstraction() const
490 {
491   DALI_ASSERT_DEBUG( mGLES && "GLImplementation not created" );
492   return *mGLES;
493 }
494
495 Dali::Integration::PlatformAbstraction& Adaptor::GetPlatformAbstractionInterface()
496 {
497   return *mPlatformAbstraction;
498 }
499
500 Dali::Integration::GlAbstraction& Adaptor::GetGlesInterface()
501 {
502   return *mGLES;
503 }
504
505 TriggerEventInterface& Adaptor::GetProcessCoreEventsTrigger()
506 {
507   return *mNotificationTrigger;
508 }
509
510 TriggerEventFactoryInterface& Adaptor::GetTriggerEventFactoryInterface()
511 {
512   return mTriggerEventFactory;
513 }
514
515 SocketFactoryInterface& Adaptor::GetSocketFactoryInterface()
516 {
517   return mSocketFactory;
518 }
519
520 RenderSurface* Adaptor::GetRenderSurfaceInterface()
521 {
522   return mSurface;
523 }
524
525 VSyncMonitorInterface* Adaptor::GetVSyncMonitorInterface()
526 {
527   return mVSyncMonitor;
528 }
529
530 TraceInterface& Adaptor::GetKernelTraceInterface()
531 {
532   return mKernelTracer;
533 }
534
535 TraceInterface& Adaptor::GetSystemTraceInterface()
536 {
537   return mSystemTracer;
538 }
539
540 PerformanceInterface* Adaptor::GetPerformanceInterface()
541 {
542   return mPerformanceInterface;
543 }
544
545 Integration::PlatformAbstraction& Adaptor::GetPlatformAbstraction() const
546 {
547   DALI_ASSERT_DEBUG( mPlatformAbstraction && "PlatformAbstraction not created" );
548   return *mPlatformAbstraction;
549 }
550
551 void Adaptor::SetDragAndDropDetector( DragAndDropDetectorPtr detector )
552 {
553   mDragAndDropDetector = detector;
554
555   if ( mEventHandler )
556   {
557     mEventHandler->SetDragAndDropDetector( detector );
558   }
559 }
560
561 void Adaptor::SetRotationObserver( RotationObserver* observer )
562 {
563   if( mEventHandler )
564   {
565     mEventHandler->SetRotationObserver( observer );
566   }
567   else if( mState == READY )
568   {
569     // Set once event handler exists
570     mDeferredRotationObserver = observer;
571   }
572 }
573
574 void Adaptor::DestroyTtsPlayer(Dali::TtsPlayer::Mode mode)
575 {
576   if(mTtsPlayers[mode])
577   {
578     mTtsPlayers[mode].Reset();
579   }
580 }
581
582 void Adaptor::SetMinimumPinchDistance(float distance)
583 {
584   if( mGestureManager )
585   {
586     mGestureManager->SetMinimumPinchDistance(distance);
587   }
588 }
589
590 Any Adaptor::GetNativeWindowHandle()
591 {
592   return mNativeWindow;
593 }
594
595 void Adaptor::SetUseRemoteSurface(bool useRemoteSurface)
596 {
597   mUseRemoteSurface = useRemoteSurface;
598 }
599
600 void Adaptor::AddObserver( LifeCycleObserver& observer )
601 {
602   ObserverContainer::iterator match ( find(mObservers.begin(), mObservers.end(), &observer) );
603
604   if ( match == mObservers.end() )
605   {
606     mObservers.push_back( &observer );
607   }
608 }
609
610 void Adaptor::RemoveObserver( LifeCycleObserver& observer )
611 {
612   ObserverContainer::iterator match ( find(mObservers.begin(), mObservers.end(), &observer) );
613
614   if ( match != mObservers.end() )
615   {
616     mObservers.erase( match );
617   }
618 }
619
620 void Adaptor::QueueCoreEvent(const Dali::Integration::Event& event)
621 {
622   if( mCore )
623   {
624     mCore->QueueEvent(event);
625   }
626 }
627
628 void Adaptor::ProcessCoreEvents()
629 {
630   if( mCore )
631   {
632     if( mPerformanceInterface )
633     {
634       mPerformanceInterface->AddMarker( PerformanceInterface::PROCESS_EVENTS_START );
635     }
636
637     mCore->ProcessEvents();
638
639     if( mPerformanceInterface )
640     {
641       mPerformanceInterface->AddMarker( PerformanceInterface::PROCESS_EVENTS_END );
642     }
643   }
644 }
645
646 void Adaptor::RequestUpdate()
647 {
648   // When Dali applications are partially visible behind the lock-screen,
649   // the indicator must be updated (therefore allow updates in the PAUSED state)
650   if ( PAUSED  == mState ||
651        RUNNING == mState )
652   {
653     mThreadController->RequestUpdate();
654   }
655 }
656
657 void Adaptor::RequestProcessEventsOnIdle()
658 {
659   // Only request a notification if the Adaptor is actually running
660   // and we haven't installed the idle notification
661   if( ( ! mNotificationOnIdleInstalled ) && ( RUNNING == mState ) )
662   {
663     mNotificationOnIdleInstalled = AddIdle( MakeCallback( this, &Adaptor::ProcessCoreEventsFromIdle ) );
664   }
665 }
666
667 void Adaptor::OnWindowShown()
668 {
669   if ( PAUSED_WHILE_HIDDEN == mState )
670   {
671     // Adaptor can now be resumed
672     mState = PAUSED;
673
674     Resume();
675
676     // Force a render task
677     RequestUpdateOnce();
678   }
679 }
680
681 void Adaptor::OnWindowHidden()
682 {
683   if ( STOPPED != mState )
684   {
685     Pause();
686
687     // Adaptor cannot be resumed until the window is shown
688     mState = PAUSED_WHILE_HIDDEN;
689   }
690 }
691
692 // Dali::Internal::Adaptor::Adaptor::OnDamaged
693 void Adaptor::OnDamaged( const DamageArea& area )
694 {
695   // This is needed for the case where Dali window is partially obscured
696   RequestUpdate();
697 }
698
699 void Adaptor::SurfaceSizeChanged( Dali::Adaptor::SurfaceSize surfaceSize )
700 {
701   // let the core know the surface size has changed
702   mCore->SurfaceResized( surfaceSize.GetWidth(), surfaceSize.GetHeight() );
703
704   mResizedSignal.Emit( mAdaptor );
705 }
706
707 void Adaptor::NotifySceneCreated()
708 {
709   GetCore().SceneCreated();
710
711   // Start thread controller after the scene has been created
712   mThreadController->Start();
713
714   // process after surface is created (registering to remote surface provider if required)
715   SurfaceInitialized();
716 }
717
718 void Adaptor::NotifyLanguageChanged()
719 {
720   mLanguageChangedSignal.Emit( mAdaptor );
721 }
722
723 void Adaptor::RequestUpdateOnce()
724 {
725   if( PAUSED_WHILE_HIDDEN != mState )
726   {
727     if( mThreadController )
728     {
729       mThreadController->RequestUpdateOnce();
730     }
731   }
732 }
733
734 void Adaptor::IndicatorSizeChanged(int height)
735 {
736   // let the core know the indicator height is changed
737   mCore->SetTopMargin(height);
738 }
739
740 void Adaptor::ProcessCoreEventsFromIdle()
741 {
742   ProcessCoreEvents();
743
744   // the idle handle automatically un-installs itself
745   mNotificationOnIdleInstalled = false;
746 }
747
748 Adaptor::Adaptor(Any nativeWindow, Dali::Adaptor& adaptor, RenderSurface* surface, EnvironmentOptions* environmentOptions)
749 : mResizedSignal(),
750   mLanguageChangedSignal(),
751   mAdaptor( adaptor ),
752   mState( READY ),
753   mCore( NULL ),
754   mThreadController( NULL ),
755   mVSyncMonitor( NULL ),
756   mGLES( NULL ),
757   mGlSync( NULL ),
758   mEglFactory( NULL ),
759   mNativeWindow( nativeWindow ),
760   mSurface( surface ),
761   mPlatformAbstraction( NULL ),
762   mEventHandler( NULL ),
763   mCallbackManager( NULL ),
764   mNotificationOnIdleInstalled( false ),
765   mNotificationTrigger( NULL ),
766   mGestureManager( NULL ),
767   mDaliFeedbackPlugin(),
768   mFeedbackController( NULL ),
769   mTtsPlayers(),
770   mObservers(),
771   mDragAndDropDetector(),
772   mDeferredRotationObserver( NULL ),
773   mEnvironmentOptions( environmentOptions ? environmentOptions : new EnvironmentOptions /* Create the options if not provided */),
774   mPerformanceInterface( NULL ),
775   mKernelTracer(),
776   mSystemTracer(),
777   mTriggerEventFactory(),
778   mObjectProfiler( NULL ),
779   mSocketFactory(),
780   mEnvironmentOptionsOwned( environmentOptions ? false : true /* If not provided then we own the object */ ),
781   mUseRemoteSurface( false )
782 {
783   DALI_ASSERT_ALWAYS( !IsAvailable() && "Cannot create more than one Adaptor per thread" );
784   gThreadLocalAdaptor = this;
785 }
786
787 // Stereoscopy
788
789 void Adaptor::SetViewMode( ViewMode viewMode )
790 {
791   mSurface->SetViewMode( viewMode );
792   mCore->SetViewMode( viewMode );
793 }
794
795 ViewMode Adaptor::GetViewMode() const
796 {
797   return mCore->GetViewMode();
798 }
799
800 void Adaptor::SetStereoBase( float stereoBase )
801 {
802   mCore->SetStereoBase( stereoBase );
803 }
804
805 float Adaptor::GetStereoBase() const
806 {
807   return mCore->GetStereoBase();
808 }
809
810 } // namespace Adaptor
811
812 } // namespace Internal
813
814 } // namespace Dali