Revert "[Tizen] Create Widget Application"
[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   PositionSize positionSize = surface.GetPositionSize();
398
399   // let the core know the surface size has changed
400   mCore->SurfaceResized( positionSize.width, positionSize.height );
401
402   mResizedSignal.Emit( mAdaptor );
403
404   mNativeWindow = nativeWindow;
405   mSurface = &surface;
406
407   // flush the event queue to give the update-render thread chance
408   // to start processing messages for new camera setup etc as soon as possible
409   ProcessCoreEvents();
410
411   // this method blocks until the render thread has completed the replace.
412   mThreadController->ReplaceSurface(mSurface);
413 }
414
415 RenderSurface& Adaptor::GetSurface() const
416 {
417   return *mSurface;
418 }
419
420 void Adaptor::ReleaseSurfaceLock()
421 {
422   mSurface->ReleaseLock();
423 }
424
425 Dali::TtsPlayer Adaptor::GetTtsPlayer(Dali::TtsPlayer::Mode mode)
426 {
427   if(!mTtsPlayers[mode])
428   {
429     // Create the TTS player when it needed, because it can reduce launching time.
430     mTtsPlayers[mode] = TtsPlayer::New(mode);
431   }
432
433   return mTtsPlayers[mode];
434 }
435
436 bool Adaptor::AddIdle( CallbackBase* callback )
437 {
438   bool idleAdded(false);
439
440   // Only add an idle if the Adaptor is actually running
441   if( RUNNING == mState )
442   {
443     idleAdded = mCallbackManager->AddIdleCallback( callback );
444   }
445
446   return idleAdded;
447 }
448
449 void Adaptor::RemoveIdle( CallbackBase* callback )
450 {
451   mCallbackManager->RemoveIdleCallback( callback );
452 }
453
454 Dali::Adaptor& Adaptor::Get()
455 {
456   DALI_ASSERT_ALWAYS( IsAvailable() && "Adaptor not instantiated" );
457   return gThreadLocalAdaptor->mAdaptor;
458 }
459
460 bool Adaptor::IsAvailable()
461 {
462   return gThreadLocalAdaptor != NULL;
463 }
464
465 void Adaptor::SceneCreated()
466 {
467   mCore->SceneCreated();
468 }
469
470 Dali::Integration::Core& Adaptor::GetCore()
471 {
472   return *mCore;
473 }
474
475 void Adaptor::SetRenderRefreshRate( unsigned int numberOfVSyncsPerRender )
476 {
477   mThreadController->SetRenderRefreshRate( numberOfVSyncsPerRender );
478 }
479
480 void Adaptor::SetUseHardwareVSync( bool useHardware )
481 {
482   mVSyncMonitor->SetUseHardwareVSync( useHardware );
483 }
484
485 EglFactory& Adaptor::GetEGLFactory() const
486 {
487   DALI_ASSERT_DEBUG( mEglFactory && "EGL Factory not created" );
488   return *mEglFactory;
489 }
490
491 EglFactoryInterface& Adaptor::GetEGLFactoryInterface() const
492 {
493   return *mEglFactory;
494 }
495
496 Integration::GlAbstraction& Adaptor::GetGlAbstraction() const
497 {
498   DALI_ASSERT_DEBUG( mGLES && "GLImplementation not created" );
499   return *mGLES;
500 }
501
502 Dali::Integration::PlatformAbstraction& Adaptor::GetPlatformAbstractionInterface()
503 {
504   return *mPlatformAbstraction;
505 }
506
507 Dali::Integration::GlAbstraction& Adaptor::GetGlesInterface()
508 {
509   return *mGLES;
510 }
511
512 TriggerEventInterface& Adaptor::GetProcessCoreEventsTrigger()
513 {
514   return *mNotificationTrigger;
515 }
516
517 TriggerEventFactoryInterface& Adaptor::GetTriggerEventFactoryInterface()
518 {
519   return mTriggerEventFactory;
520 }
521
522 SocketFactoryInterface& Adaptor::GetSocketFactoryInterface()
523 {
524   return mSocketFactory;
525 }
526
527 RenderSurface* Adaptor::GetRenderSurfaceInterface()
528 {
529   return mSurface;
530 }
531
532 VSyncMonitorInterface* Adaptor::GetVSyncMonitorInterface()
533 {
534   return mVSyncMonitor;
535 }
536
537 TraceInterface& Adaptor::GetKernelTraceInterface()
538 {
539   return mKernelTracer;
540 }
541
542 TraceInterface& Adaptor::GetSystemTraceInterface()
543 {
544   return mSystemTracer;
545 }
546
547 PerformanceInterface* Adaptor::GetPerformanceInterface()
548 {
549   return mPerformanceInterface;
550 }
551
552 Integration::PlatformAbstraction& Adaptor::GetPlatformAbstraction() const
553 {
554   DALI_ASSERT_DEBUG( mPlatformAbstraction && "PlatformAbstraction not created" );
555   return *mPlatformAbstraction;
556 }
557
558 void Adaptor::SetDragAndDropDetector( DragAndDropDetectorPtr detector )
559 {
560   mDragAndDropDetector = detector;
561
562   if ( mEventHandler )
563   {
564     mEventHandler->SetDragAndDropDetector( detector );
565   }
566 }
567
568 void Adaptor::SetRotationObserver( RotationObserver* observer )
569 {
570   if( mEventHandler )
571   {
572     mEventHandler->SetRotationObserver( observer );
573   }
574   else if( mState == READY )
575   {
576     // Set once event handler exists
577     mDeferredRotationObserver = observer;
578   }
579 }
580
581 void Adaptor::DestroyTtsPlayer(Dali::TtsPlayer::Mode mode)
582 {
583   if(mTtsPlayers[mode])
584   {
585     mTtsPlayers[mode].Reset();
586   }
587 }
588
589 void Adaptor::SetMinimumPinchDistance(float distance)
590 {
591   if( mGestureManager )
592   {
593     mGestureManager->SetMinimumPinchDistance(distance);
594   }
595 }
596
597 Any Adaptor::GetNativeWindowHandle()
598 {
599   return mNativeWindow;
600 }
601
602 void Adaptor::SetUseRemoteSurface(bool useRemoteSurface)
603 {
604   mUseRemoteSurface = useRemoteSurface;
605 }
606
607 void Adaptor::AddObserver( LifeCycleObserver& observer )
608 {
609   ObserverContainer::iterator match ( find(mObservers.begin(), mObservers.end(), &observer) );
610
611   if ( match == mObservers.end() )
612   {
613     mObservers.push_back( &observer );
614   }
615 }
616
617 void Adaptor::RemoveObserver( LifeCycleObserver& observer )
618 {
619   ObserverContainer::iterator match ( find(mObservers.begin(), mObservers.end(), &observer) );
620
621   if ( match != mObservers.end() )
622   {
623     mObservers.erase( match );
624   }
625 }
626
627 void Adaptor::QueueCoreEvent(const Dali::Integration::Event& event)
628 {
629   if( mCore )
630   {
631     mCore->QueueEvent(event);
632   }
633 }
634
635 void Adaptor::ProcessCoreEvents()
636 {
637   if( mCore )
638   {
639     if( mPerformanceInterface )
640     {
641       mPerformanceInterface->AddMarker( PerformanceInterface::PROCESS_EVENTS_START );
642     }
643
644     mCore->ProcessEvents();
645
646     if( mPerformanceInterface )
647     {
648       mPerformanceInterface->AddMarker( PerformanceInterface::PROCESS_EVENTS_END );
649     }
650   }
651 }
652
653 void Adaptor::RequestUpdate()
654 {
655   // When Dali applications are partially visible behind the lock-screen,
656   // the indicator must be updated (therefore allow updates in the PAUSED state)
657   if ( PAUSED  == mState ||
658        RUNNING == mState )
659   {
660     mThreadController->RequestUpdate();
661   }
662 }
663
664 void Adaptor::RequestProcessEventsOnIdle()
665 {
666   // Only request a notification if the Adaptor is actually running
667   // and we haven't installed the idle notification
668   if( ( ! mNotificationOnIdleInstalled ) && ( RUNNING == mState ) )
669   {
670     mNotificationOnIdleInstalled = AddIdle( MakeCallback( this, &Adaptor::ProcessCoreEventsFromIdle ) );
671   }
672 }
673
674 void Adaptor::OnWindowShown()
675 {
676   if ( PAUSED_WHILE_HIDDEN == mState )
677   {
678     // Adaptor can now be resumed
679     mState = PAUSED;
680
681     Resume();
682
683     // Force a render task
684     RequestUpdateOnce();
685   }
686 }
687
688 void Adaptor::OnWindowHidden()
689 {
690   if ( STOPPED != mState )
691   {
692     Pause();
693
694     // Adaptor cannot be resumed until the window is shown
695     mState = PAUSED_WHILE_HIDDEN;
696   }
697 }
698
699 // Dali::Internal::Adaptor::Adaptor::OnDamaged
700 void Adaptor::OnDamaged( const DamageArea& area )
701 {
702   // This is needed for the case where Dali window is partially obscured
703   RequestUpdate();
704 }
705
706 void Adaptor::SurfaceResizePrepare( Dali::Adaptor::SurfaceSize surfaceSize )
707 {
708   // let the core know the surface size has changed
709   mCore->SurfaceResized( surfaceSize.GetWidth(), surfaceSize.GetHeight() );
710
711   mResizedSignal.Emit( mAdaptor );
712 }
713
714 void Adaptor::SurfaceResizeComplete( Dali::Adaptor::SurfaceSize surfaceSize )
715 {
716   // flush the event queue to give the update-render thread chance
717   // to start processing messages for new camera setup etc as soon as possible
718   ProcessCoreEvents();
719
720   // this method blocks until the render thread has completed the resizing.
721   mThreadController->ResizeSurface();
722 }
723
724 void Adaptor::NotifySceneCreated()
725 {
726   GetCore().SceneCreated();
727
728   // Start thread controller after the scene has been created
729   mThreadController->Start();
730
731   // process after surface is created (registering to remote surface provider if required)
732   SurfaceInitialized();
733 }
734
735 void Adaptor::NotifyLanguageChanged()
736 {
737   mLanguageChangedSignal.Emit( mAdaptor );
738 }
739
740 void Adaptor::RequestUpdateOnce()
741 {
742   if( PAUSED_WHILE_HIDDEN != mState )
743   {
744     if( mThreadController )
745     {
746       mThreadController->RequestUpdateOnce();
747     }
748   }
749 }
750
751 void Adaptor::IndicatorSizeChanged(int height)
752 {
753   // let the core know the indicator height is changed
754   mCore->SetTopMargin(height);
755 }
756
757 void Adaptor::ProcessCoreEventsFromIdle()
758 {
759   ProcessCoreEvents();
760
761   // the idle handle automatically un-installs itself
762   mNotificationOnIdleInstalled = false;
763 }
764
765 Adaptor::Adaptor(Any nativeWindow, Dali::Adaptor& adaptor, RenderSurface* surface, EnvironmentOptions* environmentOptions)
766 : mResizedSignal(),
767   mLanguageChangedSignal(),
768   mAdaptor( adaptor ),
769   mState( READY ),
770   mCore( NULL ),
771   mThreadController( NULL ),
772   mVSyncMonitor( NULL ),
773   mGLES( NULL ),
774   mGlSync( NULL ),
775   mEglFactory( NULL ),
776   mNativeWindow( nativeWindow ),
777   mSurface( surface ),
778   mPlatformAbstraction( NULL ),
779   mEventHandler( NULL ),
780   mCallbackManager( NULL ),
781   mNotificationOnIdleInstalled( false ),
782   mNotificationTrigger( NULL ),
783   mGestureManager( NULL ),
784   mDaliFeedbackPlugin(),
785   mFeedbackController( NULL ),
786   mTtsPlayers(),
787   mObservers(),
788   mDragAndDropDetector(),
789   mDeferredRotationObserver( NULL ),
790   mEnvironmentOptions( environmentOptions ? environmentOptions : new EnvironmentOptions /* Create the options if not provided */),
791   mPerformanceInterface( NULL ),
792   mKernelTracer(),
793   mSystemTracer(),
794   mTriggerEventFactory(),
795   mObjectProfiler( NULL ),
796   mSocketFactory(),
797   mEnvironmentOptionsOwned( environmentOptions ? false : true /* If not provided then we own the object */ ),
798   mUseRemoteSurface( false )
799 {
800   DALI_ASSERT_ALWAYS( !IsAvailable() && "Cannot create more than one Adaptor per thread" );
801   gThreadLocalAdaptor = this;
802 }
803
804 // Stereoscopy
805
806 void Adaptor::SetViewMode( ViewMode viewMode )
807 {
808   mSurface->SetViewMode( viewMode );
809   mCore->SetViewMode( viewMode );
810 }
811
812 ViewMode Adaptor::GetViewMode() const
813 {
814   return mCore->GetViewMode();
815 }
816
817 void Adaptor::SetStereoBase( float stereoBase )
818 {
819   mCore->SetStereoBase( stereoBase );
820 }
821
822 float Adaptor::GetStereoBase() const
823 {
824   return mCore->GetStereoBase();
825 }
826
827 } // namespace Adaptor
828
829 } // namespace Internal
830
831 } // namespace Dali