2 * Copyright (c) 2014 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 #include "adaptor-impl.h"
22 #include <boost/thread/tss.hpp>
23 #include <dali/public-api/common/dali-common.h>
24 #include <dali/integration-api/debug.h>
25 #include <dali/integration-api/core.h>
26 #include <dali/integration-api/context-notifier.h>
27 #include <dali/integration-api/profiling.h>
28 #include <dali/integration-api/input-options.h>
29 #include <dali/integration-api/events/touch-event-integ.h>
32 #include <base/update-render-controller.h>
33 #include <base/environment-variables.h>
34 #include <base/performance-logging/performance-interface-factory.h>
35 #include <base/lifecycle-observer.h>
37 #include <callback-manager.h>
38 #include <trigger-event.h>
39 #include <window-render-surface.h>
40 #include <render-surface-impl.h>
41 #include <tts-player-impl.h>
42 #include <accessibility-manager-impl.h>
43 #include <timer-impl.h>
44 #include <events/gesture-manager.h>
45 #include <events/event-handler.h>
46 #include <feedback/feedback-controller.h>
47 #include <feedback/feedback-plugin-proxy.h>
48 #include <gl/gl-proxy-implementation.h>
49 #include <gl/gl-implementation.h>
50 #include <gl/egl-sync-implementation.h>
51 #include <gl/egl-image-extensions.h>
52 #include <gl/egl-factory.h>
53 #include <imf-manager-impl.h>
54 #include <clipboard-impl.h>
55 #include <vsync-monitor.h>
56 #include <object-profiler.h>
58 #include <slp-logging.h>
73 boost::thread_specific_ptr<Adaptor> gThreadLocalAdaptor;
75 unsigned int GetIntegerEnvironmentVariable( const char* variable, unsigned int defaultValue )
77 const char* variableParameter = std::getenv(variable);
79 // if the parameter exists convert it to an integer, else return the default value
80 unsigned int intValue = variableParameter ? atoi(variableParameter) : defaultValue;
84 bool GetIntegerEnvironmentVariable( const char* variable, int& intValue )
86 const char* variableParameter = std::getenv(variable);
88 if( !variableParameter )
92 // if the parameter exists convert it to an integer, else return the default value
93 intValue = atoi(variableParameter);
97 bool GetFloatEnvironmentVariable( const char* variable, float& floatValue )
99 const char* variableParameter = std::getenv(variable);
101 if( !variableParameter )
105 // if the parameter exists convert it to an integer, else return the default value
106 floatValue = atof(variableParameter);
110 } // unnamed namespace
112 Dali::Adaptor* Adaptor::New( RenderSurface *surface, const DeviceLayout& baseLayout,
113 Dali::Configuration::ContextLoss configuration )
115 DALI_ASSERT_ALWAYS( surface->GetType() != Dali::RenderSurface::NO_SURFACE && "No surface for adaptor" );
117 Dali::Adaptor* adaptor = new Dali::Adaptor;
118 Adaptor* impl = new Adaptor( *adaptor, surface, baseLayout );
119 adaptor->mImpl = impl;
121 impl->Initialize(configuration);
126 void Adaptor::ParseEnvironmentOptions()
128 // get logging options
129 unsigned int logFrameRateFrequency = GetIntegerEnvironmentVariable( DALI_ENV_FPS_TRACKING, 0 );
130 unsigned int logupdateStatusFrequency = GetIntegerEnvironmentVariable( DALI_ENV_UPDATE_STATUS_INTERVAL, 0 );
131 unsigned int logPerformanceStats = GetIntegerEnvironmentVariable( DALI_ENV_LOG_PERFORMANCE_STATS, 0 );
132 unsigned int logPerformanceStatsFrequency = GetIntegerEnvironmentVariable( DALI_ENV_LOG_PERFORMANCE_STATS_FREQUENCY, 0 );
133 unsigned int performanceTimeStampOutput= GetIntegerEnvironmentVariable( DALI_ENV_PERFORMANCE_TIMESTAMP_OUTPUT, 0 );
136 unsigned int logPanGesture = GetIntegerEnvironmentVariable( DALI_ENV_LOG_PAN_GESTURE, 0 );
138 // all threads here (event, update, and render) will send their logs to SLP Platform's LogMessage handler.
139 Dali::Integration::Log::LogFunction logFunction(Dali::SlpPlatform::LogMessage);
141 mEnvironmentOptions.SetLogOptions( logFunction, logFrameRateFrequency, logupdateStatusFrequency, logPerformanceStats, logPerformanceStatsFrequency, performanceTimeStampOutput, logPanGesture );
144 if( GetIntegerEnvironmentVariable(DALI_ENV_PAN_PREDICTION_MODE, predictionMode) )
146 mEnvironmentOptions.SetPanGesturePredictionMode(predictionMode);
148 int predictionAmount(-1);
149 if( GetIntegerEnvironmentVariable(DALI_ENV_PAN_PREDICTION_AMOUNT, predictionAmount) )
151 if( predictionAmount < 0 )
153 // do not support times in the past
154 predictionAmount = 0;
156 mEnvironmentOptions.SetPanGesturePredictionAmount(predictionAmount);
158 int minPredictionAmount(-1);
159 if( GetIntegerEnvironmentVariable(DALI_ENV_PAN_MIN_PREDICTION_AMOUNT, minPredictionAmount) )
161 if( minPredictionAmount < 0 )
163 // do not support times in the past
164 minPredictionAmount = 0;
166 mEnvironmentOptions.SetPanGestureMinimumPredictionAmount(minPredictionAmount);
168 int maxPredictionAmount(-1);
169 if( GetIntegerEnvironmentVariable(DALI_ENV_PAN_MAX_PREDICTION_AMOUNT, maxPredictionAmount) )
171 if( minPredictionAmount > -1 && maxPredictionAmount < minPredictionAmount )
173 // maximum amount should not be smaller than minimum amount
174 maxPredictionAmount = minPredictionAmount;
176 mEnvironmentOptions.SetPanGestureMaximumPredictionAmount(maxPredictionAmount);
178 int predictionAmountAdjustment(-1);
179 if( GetIntegerEnvironmentVariable(DALI_ENV_PAN_PREDICTION_AMOUNT_ADJUSTMENT, predictionAmountAdjustment) )
181 if( predictionAmountAdjustment < 0 )
183 // negative amount doesn't make sense
184 predictionAmountAdjustment = 0;
186 mEnvironmentOptions.SetPanGesturePredictionAmountAdjustment(predictionAmountAdjustment);
189 if( GetIntegerEnvironmentVariable(DALI_ENV_PAN_SMOOTHING_MODE, smoothingMode) )
191 mEnvironmentOptions.SetPanGestureSmoothingMode(smoothingMode);
193 float smoothingAmount = 1.0f;
194 if( GetFloatEnvironmentVariable(DALI_ENV_PAN_SMOOTHING_AMOUNT, smoothingAmount) )
196 smoothingAmount = Clamp(smoothingAmount, 0.0f, 1.0f);
197 mEnvironmentOptions.SetPanGestureSmoothingAmount(smoothingAmount);
200 int minimumDistance(-1);
201 if ( GetIntegerEnvironmentVariable(DALI_ENV_PAN_MINIMUM_DISTANCE, minimumDistance ))
203 mEnvironmentOptions.SetMinimumPanDistance( minimumDistance );
206 int minimumEvents(-1);
207 if ( GetIntegerEnvironmentVariable(DALI_ENV_PAN_MINIMUM_EVENTS, minimumEvents ))
209 mEnvironmentOptions.SetMinimumPanEvents( minimumEvents );
213 if ( GetIntegerEnvironmentVariable(DALI_GLES_CALL_TIME, glesCallTime ))
215 mEnvironmentOptions.SetGlesCallTime( glesCallTime );
218 mEnvironmentOptions.InstallLogFunction();
221 void Adaptor::Initialize(Dali::Configuration::ContextLoss configuration)
223 ParseEnvironmentOptions();
225 mPlatformAbstraction = new SlpPlatform::SlpPlatformAbstraction;
228 GetDataStoragePath( path );
229 mPlatformAbstraction->SetDataStoragePath( path );
231 ResourcePolicy::DataRetention dataRetentionPolicy = ResourcePolicy::DALI_DISCARDS_ALL_DATA;
232 if( configuration == Dali::Configuration::APPLICATION_DOES_NOT_HANDLE_CONTEXT_LOSS )
234 dataRetentionPolicy = ResourcePolicy::DALI_RETAINS_MESH_DATA;
236 // Note, Tizen does not use DALI_RETAINS_ALL_DATA, as it can reload images from
237 // files automatically.
239 if( mEnvironmentOptions.PerformanceServerRequired() )
241 mPerformanceInterface = PerformanceInterfaceFactory::CreateInterface( *this, mEnvironmentOptions );
244 mCallbackManager = CallbackManager::New();
246 PositionSize size = mSurface->GetPositionSize();
248 mGestureManager = new GestureManager(*this, Vector2(size.width, size.height), mCallbackManager, mEnvironmentOptions);
250 if( mEnvironmentOptions.GetGlesCallTime() > 0 )
252 mGLES = new GlProxyImplementation( mEnvironmentOptions );
256 mGLES = new GlImplementation();
259 mEglFactory = new EglFactory();
261 EglSyncImplementation* eglSyncImpl = mEglFactory->GetSyncImplementation();
263 mCore = Integration::Core::New( *this, *mPlatformAbstraction, *mGLES, *eglSyncImpl, *mGestureManager, dataRetentionPolicy );
265 mObjectProfiler = new ObjectProfiler();
267 mNotificationTrigger = new TriggerEvent( MakeCallback( this, &Adaptor::ProcessCoreEvents ) );
269 mVSyncMonitor = new VSyncMonitor;
271 mUpdateRenderController = new UpdateRenderController( *this, mEnvironmentOptions );
273 mDaliFeedbackPlugin = new FeedbackPluginProxy( FeedbackPluginProxy::DEFAULT_OBJECT_NAME );
275 // Should be called after Core creation
276 if( mEnvironmentOptions.GetPanGestureLoggingLevel() )
278 Integration::EnableProfiling( Dali::Integration::PROFILING_TYPE_PAN_GESTURE );
280 if( mEnvironmentOptions.GetPanGesturePredictionMode() >= 0 )
282 Integration::SetPanGesturePredictionMode(mEnvironmentOptions.GetPanGesturePredictionMode());
284 if( mEnvironmentOptions.GetPanGesturePredictionAmount() >= 0 )
286 Integration::SetPanGesturePredictionAmount(mEnvironmentOptions.GetPanGesturePredictionAmount());
288 if( mEnvironmentOptions.GetPanGestureMaximumPredictionAmount() >= 0 )
290 Integration::SetPanGestureMaximumPredictionAmount(mEnvironmentOptions.GetPanGestureMaximumPredictionAmount());
292 if( mEnvironmentOptions.GetPanGestureMinimumPredictionAmount() >= 0 )
294 Integration::SetPanGestureMinimumPredictionAmount(mEnvironmentOptions.GetPanGestureMinimumPredictionAmount());
296 if( mEnvironmentOptions.GetPanGesturePredictionAmountAdjustment() >= 0 )
298 Integration::SetPanGesturePredictionAmountAdjustment(mEnvironmentOptions.GetPanGesturePredictionAmountAdjustment());
300 if( mEnvironmentOptions.GetPanGestureSmoothingMode() >= 0 )
302 Integration::SetPanGestureSmoothingMode(mEnvironmentOptions.GetPanGestureSmoothingMode());
304 if( mEnvironmentOptions.GetPanGestureSmoothingAmount() >= 0.0f )
306 Integration::SetPanGestureSmoothingAmount(mEnvironmentOptions.GetPanGestureSmoothingAmount());
312 // Ensure stop status
315 // Release first as we do not want any access to Adaptor as it is being destroyed.
316 gThreadLocalAdaptor.release();
318 for ( ObserverContainer::iterator iter = mObservers.begin(), endIter = mObservers.end(); iter != endIter; ++iter )
320 (*iter)->OnDestroy();
323 delete mUpdateRenderController; // this will shutdown render thread, which will call Core::ContextDestroyed before exit
324 delete mVSyncMonitor;
325 delete mEventHandler;
326 delete mObjectProfiler;
330 // Delete feedback controller before feedback plugin & style monitor dependencies
331 delete mFeedbackController;
332 delete mDaliFeedbackPlugin;
334 delete mGestureManager;
335 delete mPlatformAbstraction;
336 delete mCallbackManager;
337 delete mPerformanceInterface;
339 // uninstall it on this thread (main actor thread)
340 Dali::Integration::Log::UninstallLogFunction();
343 void Adaptor::Start()
345 // it doesn't support restart after stop at this moment
346 // to support restarting, need more testing
347 if( READY != mState )
352 // Start the callback manager
353 mCallbackManager->Start();
355 // create event handler
356 mEventHandler = new EventHandler( mSurface, *this, *mGestureManager, *this, mDragAndDropDetector );
358 if( mDeferredRotationObserver != NULL )
360 mEventHandler->SetRotationObserver(mDeferredRotationObserver);
361 mDeferredRotationObserver = NULL;
364 // guarantee map the surface before starting render-thread.
367 // use default or command line settings if not run on device
368 if( mHDpi == 0 || mVDpi == 0 )
370 unsigned int dpiHor, dpiVer;
372 mSurface->GetDpi(dpiHor, dpiVer);
374 // tell core about the value
375 mCore->SetDpi(dpiHor, dpiVer);
379 mCore->SetDpi(mHDpi, mVDpi);
382 // Tell the core the size of the surface just before we start the render-thread
383 PositionSize size = mSurface->GetPositionSize();
384 mCore->SurfaceResized( size.width, size.height );
386 // Start the update & render threads
387 mUpdateRenderController->Start();
391 ProcessCoreEvents(); // Ensure any startup messages are processed.
393 if ( !mFeedbackController )
395 // Start sound & haptic feedback
396 mFeedbackController = new FeedbackController( *mDaliFeedbackPlugin );
399 for ( ObserverContainer::iterator iter = mObservers.begin(), endIter = mObservers.end(); iter != endIter; ++iter )
405 // Dali::Internal::Adaptor::Adaptor::Pause
406 void Adaptor::Pause()
408 // Only pause the adaptor if we're actually running.
409 if( RUNNING == mState )
411 // Inform observers that we are about to be paused.
412 for( ObserverContainer::iterator iter = mObservers.begin(), endIter = mObservers.end(); iter != endIter; ++iter )
417 // Reset the event handler when adaptor paused
420 mEventHandler->Reset();
423 mUpdateRenderController->Pause();
429 // Dali::Internal::Adaptor::Adaptor::Resume
430 void Adaptor::Resume()
432 // Only resume the adaptor if we are in the suspended state.
433 if( PAUSED == mState )
435 // We put ResumeFrameTime first, as this was originally called at the start of mCore->Resume()
436 // If there were events pending, mCore->Resume() will call
437 // RenderController->RequestUpdate()
438 // UpdateRenderController->RequestUpdate()
439 // UpdateRenderSynchronization->RequestUpdate()
440 // and we should have reset the frame timers before allowing Core->Update() to be called.
441 //@todo Should we call UpdateRenderController->Resume before mCore->Resume()?
443 mUpdateRenderController->ResumeFrameTime();
445 mUpdateRenderController->Resume();
449 // Reset the event handler when adaptor resumed
452 mEventHandler->Reset();
455 // Inform observers that we have resumed.
456 for( ObserverContainer::iterator iter = mObservers.begin(), endIter = mObservers.end(); iter != endIter; ++iter )
461 ProcessCoreEvents(); // Ensure any outstanding messages are processed
467 if( RUNNING == mState ||
469 PAUSED_WHILE_HIDDEN == mState )
471 for( ObserverContainer::iterator iter = mObservers.begin(), endIter = mObservers.end(); iter != endIter; ++iter )
476 mUpdateRenderController->Stop();
479 // Delete the TTS player
480 for(int i =0; i < Dali::TtsPlayer::MODE_NUM; i++)
484 mTtsPlayers[i].Reset();
488 delete mEventHandler;
489 mEventHandler = NULL;
491 delete mNotificationTrigger;
492 mNotificationTrigger = NULL;
494 mCallbackManager->Stop();
500 void Adaptor::FeedTouchPoint( TouchPoint& point, int timeStamp )
502 mEventHandler->FeedTouchPoint( point, timeStamp );
505 void Adaptor::FeedWheelEvent( MouseWheelEvent& wheelEvent )
507 mEventHandler->FeedWheelEvent( wheelEvent );
510 void Adaptor::FeedKeyEvent( KeyEvent& keyEvent )
512 mEventHandler->FeedKeyEvent( keyEvent );
515 bool Adaptor::MoveResize( const PositionSize& positionSize )
517 PositionSize old = mSurface->GetPositionSize();
519 // just resize the surface. The driver should automatically resize the egl Surface (untested)
520 // EGL Spec says : EGL window surfaces need to be resized when their corresponding native window
521 // is resized. Implementations typically use hooks into the OS and native window
522 // system to perform this resizing on demand, transparently to the client.
523 mSurface->MoveResize( positionSize );
525 if(old.width != positionSize.width || old.height != positionSize.height)
527 SurfaceSizeChanged(positionSize);
533 void Adaptor::SurfaceResized( const PositionSize& positionSize )
535 PositionSize old = mSurface->GetPositionSize();
537 // Called by an application, when it has resized a window outside of Dali.
538 // The EGL driver automatically detects X Window resize calls, and resizes
539 // the EGL surface for us.
540 mSurface->MoveResize( positionSize );
542 if(old.width != positionSize.width || old.height != positionSize.height)
544 SurfaceSizeChanged(positionSize);
548 void Adaptor::ReplaceSurface( Dali::RenderSurface& surface )
550 // adaptor implementation needs the implementation of
551 RenderSurface* internalSurface = dynamic_cast<Internal::Adaptor::RenderSurface*>( &surface );
552 DALI_ASSERT_ALWAYS( internalSurface && "Incorrect surface" );
554 ECore::WindowRenderSurface* windowSurface = dynamic_cast<Internal::Adaptor::ECore::WindowRenderSurface*>( &surface);
555 if( windowSurface != NULL )
557 windowSurface->Map();
558 // @todo Restart event handler with new surface
561 mSurface = internalSurface;
563 SurfaceSizeChanged( internalSurface->GetPositionSize() );
565 // flush the event queue to give update and render threads chance
566 // to start processing messages for new camera setup etc as soon as possible
569 mCore->GetContextNotifier()->NotifyContextLost(); // Inform stage
571 // this method blocks until the render thread has completed the replace.
572 mUpdateRenderController->ReplaceSurface(internalSurface);
574 // Inform core, so that texture resources can be reloaded
575 mCore->RecoverFromContextLoss();
577 mCore->GetContextNotifier()->NotifyContextRegained(); // Inform stage
580 Dali::RenderSurface& Adaptor::GetSurface() const
585 void Adaptor::ReleaseSurfaceLock()
587 mSurface->ReleaseLock();
590 Dali::TtsPlayer Adaptor::GetTtsPlayer(Dali::TtsPlayer::Mode mode)
592 if(!mTtsPlayers[mode])
594 // Create the TTS player when it needed, because it can reduce launching time.
595 mTtsPlayers[mode] = TtsPlayer::New(mode);
598 return mTtsPlayers[mode];
601 bool Adaptor::AddIdle( CallbackBase* callback )
603 bool idleAdded(false);
605 // Only add an idle if the Adaptor is actually running
606 if( RUNNING == mState )
608 idleAdded = mCallbackManager->AddCallback( callback, CallbackManager::IDLE_PRIORITY );
614 bool Adaptor::CallFromMainLoop( CallbackBase* callback )
616 bool callAdded(false);
618 // Only allow the callback if the Adaptor is actually running
619 if ( RUNNING == mState )
621 callAdded = mCallbackManager->AddCallback( callback, CallbackManager::DEFAULT_PRIORITY );
627 Dali::Adaptor& Adaptor::Get()
629 DALI_ASSERT_ALWAYS( gThreadLocalAdaptor.get() != NULL && "Adaptor not instantiated" );
630 return gThreadLocalAdaptor->mAdaptor;
633 bool Adaptor::IsAvailable()
635 return gThreadLocalAdaptor.get() != NULL;
638 Dali::Integration::Core& Adaptor::GetCore()
643 void Adaptor::SetRenderRefreshRate( unsigned int numberOfVSyncsPerRender )
645 mUpdateRenderController->SetRenderRefreshRate( numberOfVSyncsPerRender );
648 void Adaptor::SetUseHardwareVSync( bool useHardware )
650 mVSyncMonitor->SetUseHardwareVSync( useHardware );
653 void Adaptor::SetDpi(size_t hDpi, size_t vDpi)
659 EglFactory& Adaptor::GetEGLFactory() const
661 DALI_ASSERT_DEBUG( mEglFactory && "EGL Factory not created" );
665 EglFactoryInterface& Adaptor::GetEGLFactoryInterface() const
670 Integration::GlAbstraction& Adaptor::GetGlAbstraction() const
672 DALI_ASSERT_DEBUG( mGLES && "GLImplementation not created" );
676 Dali::Integration::PlatformAbstraction& Adaptor::GetPlatformAbstractionInterface()
678 return *mPlatformAbstraction;
681 Dali::Integration::GlAbstraction& Adaptor::GetGlesInterface()
686 TriggerEventInterface& Adaptor::GetTriggerEventInterface()
688 return *mNotificationTrigger;
690 TriggerEventFactoryInterface& Adaptor::GetTriggerEventFactoryInterface()
692 return mTriggerEventFactory;
694 RenderSurface* Adaptor::GetRenderSurfaceInterface()
698 VSyncMonitorInterface* Adaptor::GetVSyncMonitorInterface()
700 return mVSyncMonitor;
703 KernelTraceInterface& Adaptor::GetKernelTraceInterface()
705 return mKernelTracer;
708 PerformanceInterface* Adaptor::GetPerformanceInterface()
710 return mPerformanceInterface;
713 Integration::PlatformAbstraction& Adaptor::GetPlatformAbstraction() const
715 DALI_ASSERT_DEBUG( mPlatformAbstraction && "PlatformAbstraction not created" );
716 return *mPlatformAbstraction;
719 void Adaptor::SetDragAndDropDetector( DragAndDropDetectorPtr detector )
721 mDragAndDropDetector = detector;
725 mEventHandler->SetDragAndDropDetector( detector );
729 void Adaptor::SetRotationObserver( RotationObserver* observer )
733 mEventHandler->SetRotationObserver( observer );
735 else if( mState == READY )
737 // Set once event handler exists
738 mDeferredRotationObserver = observer;
742 void Adaptor::DestroyTtsPlayer(Dali::TtsPlayer::Mode mode)
744 if(mTtsPlayers[mode])
746 mTtsPlayers[mode].Reset();
750 void Adaptor::SetMinimumPinchDistance(float distance)
752 if( mGestureManager )
754 mGestureManager->SetMinimumPinchDistance(distance);
759 void Adaptor::AddObserver( LifeCycleObserver& observer )
761 ObserverContainer::iterator match ( find(mObservers.begin(), mObservers.end(), &observer) );
763 if ( match == mObservers.end() )
765 mObservers.push_back( &observer );
769 void Adaptor::RemoveObserver( LifeCycleObserver& observer )
771 ObserverContainer::iterator match ( find(mObservers.begin(), mObservers.end(), &observer) );
773 if ( match != mObservers.end() )
775 mObservers.erase( match );
779 void Adaptor::QueueCoreEvent(const Dali::Integration::Event& event)
783 mCore->QueueEvent(event);
787 void Adaptor::ProcessCoreEvents()
791 if( mPerformanceInterface )
793 mPerformanceInterface->AddMarker( PerformanceInterface::PROCESS_EVENTS_START );
796 mCore->ProcessEvents();
798 if( mPerformanceInterface )
800 mPerformanceInterface->AddMarker( PerformanceInterface::PROCESS_EVENTS_END );
805 void Adaptor::RequestUpdate()
807 // When Dali applications are partially visible behind the lock-screen,
808 // the indicator must be updated (therefore allow updates in the PAUSED state)
809 if ( PAUSED == mState ||
812 mUpdateRenderController->RequestUpdate();
816 void Adaptor::RequestProcessEventsOnIdle()
818 // Only request a notification if the Adaptor is actually running
819 // and we haven't installed the idle notification
820 if( ( ! mNotificationOnIdleInstalled ) && ( RUNNING == mState ) )
822 mNotificationOnIdleInstalled = AddIdle( MakeCallback( this, &Adaptor::ProcessCoreEventsFromIdle ) );
826 void Adaptor::OnWindowShown()
828 if ( PAUSED_WHILE_HIDDEN == mState )
830 // Adaptor can now be resumed
835 // Force a render task
840 void Adaptor::OnWindowHidden()
842 if ( STOPPED != mState )
846 // Adaptor cannot be resumed until the window is shown
847 mState = PAUSED_WHILE_HIDDEN;
851 // Dali::Internal::Adaptor::Adaptor::OnDamaged
852 void Adaptor::OnDamaged( const DamageArea& area )
854 // This is needed for the case where Dali window is partially obscured
858 void Adaptor::SurfaceSizeChanged(const PositionSize& positionSize)
860 // let the core know the surface size has changed
861 mCore->SurfaceResized(positionSize.width, positionSize.height);
863 mResizedSignal.Emit( mAdaptor );
866 void Adaptor::NotifyLanguageChanged()
868 mLanguageChangedSignal.Emit( mAdaptor );
871 void Adaptor::RequestUpdateOnce()
873 if( PAUSED_WHILE_HIDDEN != mState )
875 if( mUpdateRenderController )
877 mUpdateRenderController->RequestUpdateOnce();
882 void Adaptor::ProcessCoreEventsFromIdle()
886 // the idle handle automatically un-installs itself
887 mNotificationOnIdleInstalled = false;
890 Adaptor::Adaptor(Dali::Adaptor& adaptor, RenderSurface* surface, const DeviceLayout& baseLayout)
892 mLanguageChangedSignal(),
896 mUpdateRenderController(NULL),
901 mPlatformAbstraction( NULL ),
902 mEventHandler( NULL ),
903 mCallbackManager( NULL ),
904 mNotificationOnIdleInstalled( false ),
905 mNotificationTrigger(NULL),
906 mGestureManager(NULL),
909 mDaliFeedbackPlugin(NULL),
910 mFeedbackController(NULL),
912 mDragAndDropDetector(),
913 mDeferredRotationObserver(NULL),
914 mBaseLayout(baseLayout),
915 mEnvironmentOptions(),
916 mPerformanceInterface(NULL),
917 mObjectProfiler(NULL)
919 DALI_ASSERT_ALWAYS( gThreadLocalAdaptor.get() == NULL && "Cannot create more than one Adaptor per thread" );
920 gThreadLocalAdaptor.reset(this);
925 void Adaptor::SetViewMode( ViewMode viewMode )
927 mSurface->SetViewMode( viewMode );
928 mCore->SetViewMode( viewMode );
931 ViewMode Adaptor::GetViewMode() const
933 return mCore->GetViewMode();
936 void Adaptor::SetStereoBase( float stereoBase )
938 mCore->SetStereoBase( stereoBase );
941 float Adaptor::GetStereoBase() const
943 return mCore->GetStereoBase();
946 } // namespace Adaptor
948 } // namespace Internal