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 <render-surface.h>
40 #include <tts-player-impl.h>
41 #include <accessibility-manager-impl.h>
42 #include <timer-impl.h>
43 #include <events/gesture-manager.h>
44 #include <events/event-handler.h>
45 #include <feedback/feedback-controller.h>
46 #include <feedback/feedback-plugin-proxy.h>
47 #include <gl/gl-proxy-implementation.h>
48 #include <gl/gl-implementation.h>
49 #include <gl/egl-sync-implementation.h>
50 #include <gl/egl-image-extensions.h>
51 #include <gl/egl-factory.h>
52 #include <imf-manager-impl.h>
53 #include <clipboard-impl.h>
54 #include <vsync-monitor.h>
55 #include <object-profiler.h>
56 #include <base/display-connection.h>
58 #include <tizen-logging.h>
71 boost::thread_specific_ptr<Adaptor> gThreadLocalAdaptor;
73 unsigned int GetIntegerEnvironmentVariable( const char* variable, unsigned int defaultValue )
75 const char* variableParameter = std::getenv(variable);
77 // if the parameter exists convert it to an integer, else return the default value
78 unsigned int intValue = variableParameter ? atoi(variableParameter) : defaultValue;
82 bool GetIntegerEnvironmentVariable( const char* variable, int& intValue )
84 const char* variableParameter = std::getenv(variable);
86 if( !variableParameter )
90 // if the parameter exists convert it to an integer, else return the default value
91 intValue = atoi(variableParameter);
95 bool GetFloatEnvironmentVariable( const char* variable, float& floatValue )
97 const char* variableParameter = std::getenv(variable);
99 if( !variableParameter )
103 // if the parameter exists convert it to an integer, else return the default value
104 floatValue = atof(variableParameter);
108 } // unnamed namespace
110 Dali::Adaptor* Adaptor::New( Any nativeWindow, RenderSurface *surface, const DeviceLayout& baseLayout,
111 Dali::Configuration::ContextLoss configuration )
113 Dali::Adaptor* adaptor = new Dali::Adaptor;
114 Adaptor* impl = new Adaptor( nativeWindow, *adaptor, surface, baseLayout );
115 adaptor->mImpl = impl;
117 impl->Initialize(configuration);
122 void Adaptor::ParseEnvironmentOptions()
124 // get logging options
125 unsigned int logFrameRateFrequency = GetIntegerEnvironmentVariable( DALI_ENV_FPS_TRACKING, 0 );
126 unsigned int logupdateStatusFrequency = GetIntegerEnvironmentVariable( DALI_ENV_UPDATE_STATUS_INTERVAL, 0 );
127 unsigned int logPerformanceStats = GetIntegerEnvironmentVariable( DALI_ENV_LOG_PERFORMANCE_STATS, 0 );
128 unsigned int logPerformanceStatsFrequency = GetIntegerEnvironmentVariable( DALI_ENV_LOG_PERFORMANCE_STATS_FREQUENCY, 0 );
129 unsigned int performanceTimeStampOutput= GetIntegerEnvironmentVariable( DALI_ENV_PERFORMANCE_TIMESTAMP_OUTPUT, 0 );
130 unsigned int networkControl= GetIntegerEnvironmentVariable( DALI_ENV_NETWORK_CONTROL, 0 );
132 unsigned int logPanGesture = GetIntegerEnvironmentVariable( DALI_ENV_LOG_PAN_GESTURE, 0 );
134 // all threads here (event, update, and render) will send their logs to TIZEN Platform's LogMessage handler.
135 Dali::Integration::Log::LogFunction logFunction(Dali::TizenPlatform::LogMessage);
137 mEnvironmentOptions.SetLogOptions( logFunction, networkControl, logFrameRateFrequency, logupdateStatusFrequency, logPerformanceStats, logPerformanceStatsFrequency, performanceTimeStampOutput, logPanGesture );
140 if( GetIntegerEnvironmentVariable(DALI_ENV_PAN_PREDICTION_MODE, predictionMode) )
142 mEnvironmentOptions.SetPanGesturePredictionMode(predictionMode);
144 int predictionAmount(-1);
145 if( GetIntegerEnvironmentVariable(DALI_ENV_PAN_PREDICTION_AMOUNT, predictionAmount) )
147 if( predictionAmount < 0 )
149 // do not support times in the past
150 predictionAmount = 0;
152 mEnvironmentOptions.SetPanGesturePredictionAmount(predictionAmount);
154 int minPredictionAmount(-1);
155 if( GetIntegerEnvironmentVariable(DALI_ENV_PAN_MIN_PREDICTION_AMOUNT, minPredictionAmount) )
157 if( minPredictionAmount < 0 )
159 // do not support times in the past
160 minPredictionAmount = 0;
162 mEnvironmentOptions.SetPanGestureMinimumPredictionAmount(minPredictionAmount);
164 int maxPredictionAmount(-1);
165 if( GetIntegerEnvironmentVariable(DALI_ENV_PAN_MAX_PREDICTION_AMOUNT, maxPredictionAmount) )
167 if( minPredictionAmount > -1 && maxPredictionAmount < minPredictionAmount )
169 // maximum amount should not be smaller than minimum amount
170 maxPredictionAmount = minPredictionAmount;
172 mEnvironmentOptions.SetPanGestureMaximumPredictionAmount(maxPredictionAmount);
174 int predictionAmountAdjustment(-1);
175 if( GetIntegerEnvironmentVariable(DALI_ENV_PAN_PREDICTION_AMOUNT_ADJUSTMENT, predictionAmountAdjustment) )
177 if( predictionAmountAdjustment < 0 )
179 // negative amount doesn't make sense
180 predictionAmountAdjustment = 0;
182 mEnvironmentOptions.SetPanGesturePredictionAmountAdjustment(predictionAmountAdjustment);
185 if( GetIntegerEnvironmentVariable(DALI_ENV_PAN_SMOOTHING_MODE, smoothingMode) )
187 mEnvironmentOptions.SetPanGestureSmoothingMode(smoothingMode);
189 float smoothingAmount = 1.0f;
190 if( GetFloatEnvironmentVariable(DALI_ENV_PAN_SMOOTHING_AMOUNT, smoothingAmount) )
192 smoothingAmount = Clamp(smoothingAmount, 0.0f, 1.0f);
193 mEnvironmentOptions.SetPanGestureSmoothingAmount(smoothingAmount);
196 int minimumDistance(-1);
197 if ( GetIntegerEnvironmentVariable(DALI_ENV_PAN_MINIMUM_DISTANCE, minimumDistance ))
199 mEnvironmentOptions.SetMinimumPanDistance( minimumDistance );
202 int minimumEvents(-1);
203 if ( GetIntegerEnvironmentVariable(DALI_ENV_PAN_MINIMUM_EVENTS, minimumEvents ))
205 mEnvironmentOptions.SetMinimumPanEvents( minimumEvents );
209 if ( GetIntegerEnvironmentVariable(DALI_GLES_CALL_TIME, glesCallTime ))
211 mEnvironmentOptions.SetGlesCallTime( glesCallTime );
214 int windowWidth(0), windowHeight(0);
215 if ( GetIntegerEnvironmentVariable( DALI_WINDOW_WIDTH, windowWidth ) && GetIntegerEnvironmentVariable( DALI_WINDOW_HEIGHT, windowHeight ) )
217 mEnvironmentOptions.SetWindowWidth( windowWidth );
218 mEnvironmentOptions.SetWindowHeight( windowHeight );
221 mEnvironmentOptions.InstallLogFunction();
224 void Adaptor::Initialize(Dali::Configuration::ContextLoss configuration)
226 ParseEnvironmentOptions();
228 mPlatformAbstraction = new TizenPlatform::TizenPlatformAbstraction;
231 GetDataStoragePath( path );
232 mPlatformAbstraction->SetDataStoragePath( path );
234 ResourcePolicy::DataRetention dataRetentionPolicy = ResourcePolicy::DALI_DISCARDS_ALL_DATA;
235 if( configuration == Dali::Configuration::APPLICATION_DOES_NOT_HANDLE_CONTEXT_LOSS )
237 dataRetentionPolicy = ResourcePolicy::DALI_RETAINS_MESH_DATA;
239 // Note, Tizen does not use DALI_RETAINS_ALL_DATA, as it can reload images from
240 // files automatically.
242 if( mEnvironmentOptions.PerformanceServerRequired() )
244 mPerformanceInterface = PerformanceInterfaceFactory::CreateInterface( *this, mEnvironmentOptions );
247 mCallbackManager = CallbackManager::New();
249 PositionSize size = mSurface->GetPositionSize();
251 mGestureManager = new GestureManager(*this, Vector2(size.width, size.height), mCallbackManager, mEnvironmentOptions);
253 if( mEnvironmentOptions.GetGlesCallTime() > 0 )
255 mGLES = new GlProxyImplementation( mEnvironmentOptions );
259 mGLES = new GlImplementation();
262 mEglFactory = new EglFactory();
264 EglSyncImplementation* eglSyncImpl = mEglFactory->GetSyncImplementation();
266 mCore = Integration::Core::New( *this, *mPlatformAbstraction, *mGLES, *eglSyncImpl, *mGestureManager, dataRetentionPolicy );
268 mObjectProfiler = new ObjectProfiler();
270 mNotificationTrigger = new TriggerEvent( MakeCallback( this, &Adaptor::ProcessCoreEvents ) );
272 mVSyncMonitor = new VSyncMonitor;
274 mUpdateRenderController = new UpdateRenderController( *this, mEnvironmentOptions );
276 mDaliFeedbackPlugin = new FeedbackPluginProxy( FeedbackPluginProxy::DEFAULT_OBJECT_NAME );
278 // Should be called after Core creation
279 if( mEnvironmentOptions.GetPanGestureLoggingLevel() )
281 Integration::EnableProfiling( Dali::Integration::PROFILING_TYPE_PAN_GESTURE );
283 if( mEnvironmentOptions.GetPanGesturePredictionMode() >= 0 )
285 Integration::SetPanGesturePredictionMode(mEnvironmentOptions.GetPanGesturePredictionMode());
287 if( mEnvironmentOptions.GetPanGesturePredictionAmount() >= 0 )
289 Integration::SetPanGesturePredictionAmount(mEnvironmentOptions.GetPanGesturePredictionAmount());
291 if( mEnvironmentOptions.GetPanGestureMaximumPredictionAmount() >= 0 )
293 Integration::SetPanGestureMaximumPredictionAmount(mEnvironmentOptions.GetPanGestureMaximumPredictionAmount());
295 if( mEnvironmentOptions.GetPanGestureMinimumPredictionAmount() >= 0 )
297 Integration::SetPanGestureMinimumPredictionAmount(mEnvironmentOptions.GetPanGestureMinimumPredictionAmount());
299 if( mEnvironmentOptions.GetPanGesturePredictionAmountAdjustment() >= 0 )
301 Integration::SetPanGesturePredictionAmountAdjustment(mEnvironmentOptions.GetPanGesturePredictionAmountAdjustment());
303 if( mEnvironmentOptions.GetPanGestureSmoothingMode() >= 0 )
305 Integration::SetPanGestureSmoothingMode(mEnvironmentOptions.GetPanGestureSmoothingMode());
307 if( mEnvironmentOptions.GetPanGestureSmoothingAmount() >= 0.0f )
309 Integration::SetPanGestureSmoothingAmount(mEnvironmentOptions.GetPanGestureSmoothingAmount());
311 if( mEnvironmentOptions.GetWindowWidth() && mEnvironmentOptions.GetWindowHeight() )
313 SurfaceResized( PositionSize( 0, 0, mEnvironmentOptions.GetWindowWidth(), mEnvironmentOptions.GetWindowHeight() ));
319 // Ensure stop status
322 // Release first as we do not want any access to Adaptor as it is being destroyed.
323 gThreadLocalAdaptor.release();
325 for ( ObserverContainer::iterator iter = mObservers.begin(), endIter = mObservers.end(); iter != endIter; ++iter )
327 (*iter)->OnDestroy();
330 delete mUpdateRenderController; // this will shutdown render thread, which will call Core::ContextDestroyed before exit
331 delete mVSyncMonitor;
332 delete mEventHandler;
333 delete mObjectProfiler;
337 // Delete feedback controller before feedback plugin & style monitor dependencies
338 delete mFeedbackController;
339 delete mDaliFeedbackPlugin;
341 delete mGestureManager;
342 delete mPlatformAbstraction;
343 delete mCallbackManager;
344 delete mPerformanceInterface;
346 // uninstall it on this thread (main actor thread)
347 Dali::Integration::Log::UninstallLogFunction();
350 void Adaptor::Start()
352 // it doesn't support restart after stop at this moment
353 // to support restarting, need more testing
354 if( READY != mState )
359 // Start the callback manager
360 mCallbackManager->Start();
362 // create event handler
363 mEventHandler = new EventHandler( mSurface, *this, *mGestureManager, *this, mDragAndDropDetector );
365 if( mDeferredRotationObserver != NULL )
367 mEventHandler->SetRotationObserver(mDeferredRotationObserver);
368 mDeferredRotationObserver = NULL;
371 // NOTE: dpi must be set before starting the render thread
372 // use default or command line settings if not run on device
373 if( mHDpi == 0 || mVDpi == 0 )
375 unsigned int dpiHor, dpiVer;
377 Dali::DisplayConnection::GetDpi(dpiHor, dpiVer);
379 // tell core about the value
380 mCore->SetDpi(dpiHor, dpiVer);
384 mCore->SetDpi(mHDpi, mVDpi);
387 // Tell the core the size of the surface just before we start the render-thread
388 PositionSize size = mSurface->GetPositionSize();
389 mCore->SurfaceResized( size.width, size.height );
391 // Start the update & render threads
392 mUpdateRenderController->Start();
396 ProcessCoreEvents(); // Ensure any startup messages are processed.
398 if ( !mFeedbackController )
400 // Start sound & haptic feedback
401 mFeedbackController = new FeedbackController( *mDaliFeedbackPlugin );
404 for ( ObserverContainer::iterator iter = mObservers.begin(), endIter = mObservers.end(); iter != endIter; ++iter )
410 // Dali::Internal::Adaptor::Adaptor::Pause
411 void Adaptor::Pause()
413 // Only pause the adaptor if we're actually running.
414 if( RUNNING == mState )
416 // Inform observers that we are about to be paused.
417 for( ObserverContainer::iterator iter = mObservers.begin(), endIter = mObservers.end(); iter != endIter; ++iter )
422 // Reset the event handler when adaptor paused
425 mEventHandler->Reset();
428 mUpdateRenderController->Pause();
434 // Dali::Internal::Adaptor::Adaptor::Resume
435 void Adaptor::Resume()
437 // Only resume the adaptor if we are in the suspended state.
438 if( PAUSED == mState )
440 // We put ResumeFrameTime first, as this was originally called at the start of mCore->Resume()
441 // If there were events pending, mCore->Resume() will call
442 // RenderController->RequestUpdate()
443 // UpdateRenderController->RequestUpdate()
444 // UpdateRenderSynchronization->RequestUpdate()
445 // and we should have reset the frame timers before allowing Core->Update() to be called.
446 //@todo Should we call UpdateRenderController->Resume before mCore->Resume()?
448 mUpdateRenderController->ResumeFrameTime();
450 mUpdateRenderController->Resume();
454 // Reset the event handler when adaptor resumed
457 mEventHandler->Reset();
460 // Inform observers that we have resumed.
461 for( ObserverContainer::iterator iter = mObservers.begin(), endIter = mObservers.end(); iter != endIter; ++iter )
466 ProcessCoreEvents(); // Ensure any outstanding messages are processed
472 if( RUNNING == mState ||
474 PAUSED_WHILE_HIDDEN == mState )
476 for( ObserverContainer::iterator iter = mObservers.begin(), endIter = mObservers.end(); iter != endIter; ++iter )
481 mUpdateRenderController->Stop();
484 // Delete the TTS player
485 for(int i =0; i < Dali::TtsPlayer::MODE_NUM; i++)
489 mTtsPlayers[i].Reset();
493 delete mEventHandler;
494 mEventHandler = NULL;
496 delete mNotificationTrigger;
497 mNotificationTrigger = NULL;
499 mCallbackManager->Stop();
505 void Adaptor::FeedTouchPoint( TouchPoint& point, int timeStamp )
507 mEventHandler->FeedTouchPoint( point, timeStamp );
510 void Adaptor::FeedWheelEvent( MouseWheelEvent& wheelEvent )
512 mEventHandler->FeedWheelEvent( wheelEvent );
515 void Adaptor::FeedKeyEvent( KeyEvent& keyEvent )
517 mEventHandler->FeedKeyEvent( keyEvent );
520 bool Adaptor::MoveResize( const PositionSize& positionSize )
522 PositionSize old = mSurface->GetPositionSize();
524 // just resize the surface. The driver should automatically resize the egl Surface (untested)
525 // EGL Spec says : EGL window surfaces need to be resized when their corresponding native window
526 // is resized. Implementations typically use hooks into the OS and native window
527 // system to perform this resizing on demand, transparently to the client.
528 mSurface->MoveResize( positionSize );
530 if(old.width != positionSize.width || old.height != positionSize.height)
532 SurfaceSizeChanged(positionSize);
538 void Adaptor::SurfaceResized( const PositionSize& positionSize )
540 PositionSize old = mSurface->GetPositionSize();
542 // Called by an application, when it has resized a window outside of Dali.
543 // The EGL driver automatically detects X Window resize calls, and resizes
544 // the EGL surface for us.
545 mSurface->MoveResize( positionSize );
547 if(old.width != positionSize.width || old.height != positionSize.height)
549 SurfaceSizeChanged(positionSize);
553 void Adaptor::ReplaceSurface( Any nativeWindow, RenderSurface& surface )
555 mNativeWindow = nativeWindow;
558 SurfaceSizeChanged(mSurface->GetPositionSize());
560 // flush the event queue to give update and render threads chance
561 // to start processing messages for new camera setup etc as soon as possible
564 mCore->GetContextNotifier()->NotifyContextLost(); // Inform stage
566 // this method blocks until the render thread has completed the replace.
567 mUpdateRenderController->ReplaceSurface(mSurface);
569 // Inform core, so that texture resources can be reloaded
570 mCore->RecoverFromContextLoss();
572 mCore->GetContextNotifier()->NotifyContextRegained(); // Inform stage
575 RenderSurface& Adaptor::GetSurface() const
580 void Adaptor::ReleaseSurfaceLock()
582 mSurface->ReleaseLock();
585 Dali::TtsPlayer Adaptor::GetTtsPlayer(Dali::TtsPlayer::Mode mode)
587 if(!mTtsPlayers[mode])
589 // Create the TTS player when it needed, because it can reduce launching time.
590 mTtsPlayers[mode] = TtsPlayer::New(mode);
593 return mTtsPlayers[mode];
596 bool Adaptor::AddIdle( CallbackBase* callback )
598 bool idleAdded(false);
600 // Only add an idle if the Adaptor is actually running
601 if( RUNNING == mState )
603 idleAdded = mCallbackManager->AddCallback( callback, CallbackManager::IDLE_PRIORITY );
609 bool Adaptor::CallFromMainLoop( CallbackBase* callback )
611 bool callAdded(false);
613 // Only allow the callback if the Adaptor is actually running
614 if ( RUNNING == mState )
616 callAdded = mCallbackManager->AddCallback( callback, CallbackManager::DEFAULT_PRIORITY );
622 Dali::Adaptor& Adaptor::Get()
624 DALI_ASSERT_ALWAYS( gThreadLocalAdaptor.get() != NULL && "Adaptor not instantiated" );
625 return gThreadLocalAdaptor->mAdaptor;
628 bool Adaptor::IsAvailable()
630 return gThreadLocalAdaptor.get() != NULL;
633 Dali::Integration::Core& Adaptor::GetCore()
638 void Adaptor::SetRenderRefreshRate( unsigned int numberOfVSyncsPerRender )
640 mUpdateRenderController->SetRenderRefreshRate( numberOfVSyncsPerRender );
643 void Adaptor::SetUseHardwareVSync( bool useHardware )
645 mVSyncMonitor->SetUseHardwareVSync( useHardware );
648 void Adaptor::SetDpi(size_t hDpi, size_t vDpi)
654 EglFactory& Adaptor::GetEGLFactory() const
656 DALI_ASSERT_DEBUG( mEglFactory && "EGL Factory not created" );
660 EglFactoryInterface& Adaptor::GetEGLFactoryInterface() const
665 Integration::GlAbstraction& Adaptor::GetGlAbstraction() const
667 DALI_ASSERT_DEBUG( mGLES && "GLImplementation not created" );
671 Dali::Integration::PlatformAbstraction& Adaptor::GetPlatformAbstractionInterface()
673 return *mPlatformAbstraction;
676 Dali::Integration::GlAbstraction& Adaptor::GetGlesInterface()
681 TriggerEventInterface& Adaptor::GetTriggerEventInterface()
683 return *mNotificationTrigger;
686 TriggerEventFactoryInterface& Adaptor::GetTriggerEventFactoryInterface()
688 return mTriggerEventFactory;
691 SocketFactoryInterface& Adaptor::GetSocketFactoryInterface()
693 return mSocketFactory;
696 RenderSurface* Adaptor::GetRenderSurfaceInterface()
701 VSyncMonitorInterface* Adaptor::GetVSyncMonitorInterface()
703 return mVSyncMonitor;
706 KernelTraceInterface& Adaptor::GetKernelTraceInterface()
708 return mKernelTracer;
711 PerformanceInterface* Adaptor::GetPerformanceInterface()
713 return mPerformanceInterface;
716 Integration::PlatformAbstraction& Adaptor::GetPlatformAbstraction() const
718 DALI_ASSERT_DEBUG( mPlatformAbstraction && "PlatformAbstraction not created" );
719 return *mPlatformAbstraction;
722 void Adaptor::SetDragAndDropDetector( DragAndDropDetectorPtr detector )
724 mDragAndDropDetector = detector;
728 mEventHandler->SetDragAndDropDetector( detector );
732 void Adaptor::SetRotationObserver( RotationObserver* observer )
736 mEventHandler->SetRotationObserver( observer );
738 else if( mState == READY )
740 // Set once event handler exists
741 mDeferredRotationObserver = observer;
745 void Adaptor::DestroyTtsPlayer(Dali::TtsPlayer::Mode mode)
747 if(mTtsPlayers[mode])
749 mTtsPlayers[mode].Reset();
753 void Adaptor::SetMinimumPinchDistance(float distance)
755 if( mGestureManager )
757 mGestureManager->SetMinimumPinchDistance(distance);
761 Any Adaptor::GetNativeWindowHandle()
763 return mNativeWindow;
766 void Adaptor::AddObserver( LifeCycleObserver& observer )
768 ObserverContainer::iterator match ( find(mObservers.begin(), mObservers.end(), &observer) );
770 if ( match == mObservers.end() )
772 mObservers.push_back( &observer );
776 void Adaptor::RemoveObserver( LifeCycleObserver& observer )
778 ObserverContainer::iterator match ( find(mObservers.begin(), mObservers.end(), &observer) );
780 if ( match != mObservers.end() )
782 mObservers.erase( match );
786 void Adaptor::QueueCoreEvent(const Dali::Integration::Event& event)
790 mCore->QueueEvent(event);
794 void Adaptor::ProcessCoreEvents()
798 if( mPerformanceInterface )
800 mPerformanceInterface->AddMarker( PerformanceInterface::PROCESS_EVENTS_START );
803 mCore->ProcessEvents();
805 if( mPerformanceInterface )
807 mPerformanceInterface->AddMarker( PerformanceInterface::PROCESS_EVENTS_END );
812 void Adaptor::RequestUpdate()
814 // When Dali applications are partially visible behind the lock-screen,
815 // the indicator must be updated (therefore allow updates in the PAUSED state)
816 if ( PAUSED == mState ||
819 mUpdateRenderController->RequestUpdate();
823 void Adaptor::RequestProcessEventsOnIdle()
825 // Only request a notification if the Adaptor is actually running
826 // and we haven't installed the idle notification
827 if( ( ! mNotificationOnIdleInstalled ) && ( RUNNING == mState ) )
829 mNotificationOnIdleInstalled = AddIdle( MakeCallback( this, &Adaptor::ProcessCoreEventsFromIdle ) );
833 void Adaptor::OnWindowShown()
835 if ( PAUSED_WHILE_HIDDEN == mState )
837 // Adaptor can now be resumed
842 // Force a render task
847 void Adaptor::OnWindowHidden()
849 if ( STOPPED != mState )
853 // Adaptor cannot be resumed until the window is shown
854 mState = PAUSED_WHILE_HIDDEN;
858 // Dali::Internal::Adaptor::Adaptor::OnDamaged
859 void Adaptor::OnDamaged( const DamageArea& area )
861 // This is needed for the case where Dali window is partially obscured
865 void Adaptor::SurfaceSizeChanged(const PositionSize& positionSize)
867 // let the core know the surface size has changed
868 mCore->SurfaceResized(positionSize.width, positionSize.height);
870 mResizedSignal.Emit( mAdaptor );
873 void Adaptor::NotifyLanguageChanged()
875 mLanguageChangedSignal.Emit( mAdaptor );
878 void Adaptor::RequestUpdateOnce()
880 if( PAUSED_WHILE_HIDDEN != mState )
882 if( mUpdateRenderController )
884 mUpdateRenderController->RequestUpdateOnce();
889 void Adaptor::ProcessCoreEventsFromIdle()
893 // the idle handle automatically un-installs itself
894 mNotificationOnIdleInstalled = false;
897 Adaptor::Adaptor(Any nativeWindow, Dali::Adaptor& adaptor, RenderSurface* surface, const DeviceLayout& baseLayout)
899 mLanguageChangedSignal(),
903 mUpdateRenderController(NULL),
907 mNativeWindow( nativeWindow ),
909 mPlatformAbstraction( NULL ),
910 mEventHandler( NULL ),
911 mCallbackManager( NULL ),
912 mNotificationOnIdleInstalled( false ),
913 mNotificationTrigger(NULL),
914 mGestureManager(NULL),
917 mDaliFeedbackPlugin(NULL),
918 mFeedbackController(NULL),
920 mDragAndDropDetector(),
921 mDeferredRotationObserver(NULL),
922 mBaseLayout(baseLayout),
923 mEnvironmentOptions(),
924 mPerformanceInterface(NULL),
925 mObjectProfiler(NULL)
927 DALI_ASSERT_ALWAYS( gThreadLocalAdaptor.get() == NULL && "Cannot create more than one Adaptor per thread" );
928 gThreadLocalAdaptor.reset(this);
933 void Adaptor::SetViewMode( ViewMode viewMode )
935 mSurface->SetViewMode( viewMode );
936 mCore->SetViewMode( viewMode );
939 ViewMode Adaptor::GetViewMode() const
941 return mCore->GetViewMode();
944 void Adaptor::SetStereoBase( float stereoBase )
946 mCore->SetStereoBase( stereoBase );
949 float Adaptor::GetStereoBase() const
951 return mCore->GetStereoBase();
954 } // namespace Adaptor
956 } // namespace Internal