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