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