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 <dali/public-api/text-abstraction/font-client.h>
39 #include <callback-manager.h>
40 #include <trigger-event.h>
41 #include <window-render-surface.h>
42 #include <render-surface-impl.h>
43 #include <tts-player-impl.h>
44 #include <accessibility-manager-impl.h>
45 #include <timer-impl.h>
46 #include <events/gesture-manager.h>
47 #include <events/event-handler.h>
48 #include <feedback/feedback-controller.h>
49 #include <feedback/feedback-plugin-proxy.h>
50 #include <gl/gl-proxy-implementation.h>
51 #include <gl/gl-implementation.h>
52 #include <gl/egl-sync-implementation.h>
53 #include <gl/egl-image-extensions.h>
54 #include <gl/egl-factory.h>
55 #include <imf-manager-impl.h>
56 #include <clipboard-impl.h>
57 #include <vsync-monitor.h>
58 #include <object-profiler.h>
59 #include <slp-logging.h>
61 using Dali::TextAbstraction::FontClient;
74 boost::thread_specific_ptr<Adaptor> gThreadLocalAdaptor;
76 unsigned int GetIntegerEnvironmentVariable( const char* variable, unsigned int defaultValue )
78 const char* variableParameter = std::getenv(variable);
80 // if the parameter exists convert it to an integer, else return the default value
81 unsigned int intValue = variableParameter ? atoi(variableParameter) : defaultValue;
85 bool GetIntegerEnvironmentVariable( const char* variable, int& intValue )
87 const char* variableParameter = std::getenv(variable);
89 if( !variableParameter )
93 // if the parameter exists convert it to an integer, else return the default value
94 intValue = atoi(variableParameter);
98 bool GetFloatEnvironmentVariable( const char* variable, float& floatValue )
100 const char* variableParameter = std::getenv(variable);
102 if( !variableParameter )
106 // if the parameter exists convert it to an integer, else return the default value
107 floatValue = atof(variableParameter);
111 } // unnamed namespace
113 Dali::Adaptor* Adaptor::New( RenderSurface *surface, const DeviceLayout& baseLayout,
114 Dali::Configuration::ContextLoss configuration )
116 DALI_ASSERT_ALWAYS( surface->GetType() != Dali::RenderSurface::NO_SURFACE && "No surface for adaptor" );
118 Dali::Adaptor* adaptor = new Dali::Adaptor;
119 Adaptor* impl = new Adaptor( *adaptor, surface, baseLayout );
120 adaptor->mImpl = impl;
122 impl->Initialize(configuration);
127 void Adaptor::ParseEnvironmentOptions()
129 // get logging options
130 unsigned int logFrameRateFrequency = GetIntegerEnvironmentVariable( DALI_ENV_FPS_TRACKING, 0 );
131 unsigned int logupdateStatusFrequency = GetIntegerEnvironmentVariable( DALI_ENV_UPDATE_STATUS_INTERVAL, 0 );
132 unsigned int logPerformanceStats = GetIntegerEnvironmentVariable( DALI_ENV_LOG_PERFORMANCE_STATS, 0 );
133 unsigned int logPerformanceStatsFrequency = GetIntegerEnvironmentVariable( DALI_ENV_LOG_PERFORMANCE_STATS_FREQUENCY, 0 );
134 unsigned int performanceTimeStampOutput= GetIntegerEnvironmentVariable( DALI_ENV_PERFORMANCE_TIMESTAMP_OUTPUT, 0 );
137 unsigned int logPanGesture = GetIntegerEnvironmentVariable( DALI_ENV_LOG_PAN_GESTURE, 0 );
139 // all threads here (event, update, and render) will send their logs to SLP Platform's LogMessage handler.
140 Dali::Integration::Log::LogFunction logFunction(Dali::SlpPlatform::LogMessage);
142 mEnvironmentOptions.SetLogOptions( logFunction, logFrameRateFrequency, logupdateStatusFrequency, logPerformanceStats, logPerformanceStatsFrequency, performanceTimeStampOutput, logPanGesture );
145 if( GetIntegerEnvironmentVariable(DALI_ENV_PAN_PREDICTION_MODE, predictionMode) )
147 mEnvironmentOptions.SetPanGesturePredictionMode(predictionMode);
149 int predictionAmount(-1);
150 if( GetIntegerEnvironmentVariable(DALI_ENV_PAN_PREDICTION_AMOUNT, predictionAmount) )
152 if( predictionAmount < 0 )
154 // do not support times in the past
155 predictionAmount = 0;
157 mEnvironmentOptions.SetPanGesturePredictionAmount(predictionAmount);
159 int minPredictionAmount(-1);
160 if( GetIntegerEnvironmentVariable(DALI_ENV_PAN_MIN_PREDICTION_AMOUNT, minPredictionAmount) )
162 if( minPredictionAmount < 0 )
164 // do not support times in the past
165 minPredictionAmount = 0;
167 mEnvironmentOptions.SetPanGestureMinimumPredictionAmount(minPredictionAmount);
169 int maxPredictionAmount(-1);
170 if( GetIntegerEnvironmentVariable(DALI_ENV_PAN_MAX_PREDICTION_AMOUNT, maxPredictionAmount) )
172 if( minPredictionAmount > -1 && maxPredictionAmount < minPredictionAmount )
174 // maximum amount should not be smaller than minimum amount
175 maxPredictionAmount = minPredictionAmount;
177 mEnvironmentOptions.SetPanGestureMaximumPredictionAmount(maxPredictionAmount);
179 int predictionAmountAdjustment(-1);
180 if( GetIntegerEnvironmentVariable(DALI_ENV_PAN_PREDICTION_AMOUNT_ADJUSTMENT, predictionAmountAdjustment) )
182 if( predictionAmountAdjustment < 0 )
184 // negative amount doesn't make sense
185 predictionAmountAdjustment = 0;
187 mEnvironmentOptions.SetPanGesturePredictionAmountAdjustment(predictionAmountAdjustment);
190 if( GetIntegerEnvironmentVariable(DALI_ENV_PAN_SMOOTHING_MODE, smoothingMode) )
192 mEnvironmentOptions.SetPanGestureSmoothingMode(smoothingMode);
194 float smoothingAmount = 1.0f;
195 if( GetFloatEnvironmentVariable(DALI_ENV_PAN_SMOOTHING_AMOUNT, smoothingAmount) )
197 smoothingAmount = Clamp(smoothingAmount, 0.0f, 1.0f);
198 mEnvironmentOptions.SetPanGestureSmoothingAmount(smoothingAmount);
201 int minimumDistance(-1);
202 if ( GetIntegerEnvironmentVariable(DALI_ENV_PAN_MINIMUM_DISTANCE, minimumDistance ))
204 mEnvironmentOptions.SetMinimumPanDistance( minimumDistance );
207 int minimumEvents(-1);
208 if ( GetIntegerEnvironmentVariable(DALI_ENV_PAN_MINIMUM_EVENTS, minimumEvents ))
210 mEnvironmentOptions.SetMinimumPanEvents( minimumEvents );
214 if ( GetIntegerEnvironmentVariable(DALI_GLES_CALL_TIME, glesCallTime ))
216 mEnvironmentOptions.SetGlesCallTime( glesCallTime );
219 mEnvironmentOptions.InstallLogFunction();
222 void Adaptor::Initialize(Dali::Configuration::ContextLoss configuration)
224 ParseEnvironmentOptions();
226 mPlatformAbstraction = new SlpPlatform::SlpPlatformAbstraction;
229 GetDataStoragePath( path );
230 mPlatformAbstraction->SetDataStoragePath( path );
232 ResourcePolicy::DataRetention dataRetentionPolicy = ResourcePolicy::DALI_DISCARDS_ALL_DATA;
233 if( configuration == Dali::Configuration::APPLICATION_DOES_NOT_HANDLE_CONTEXT_LOSS )
235 dataRetentionPolicy = ResourcePolicy::DALI_RETAINS_MESH_DATA;
237 // Note, Tizen does not use DALI_RETAINS_ALL_DATA, as it can reload images from
238 // files automatically.
240 if( mEnvironmentOptions.PerformanceServerRequired() )
242 mPerformanceInterface = PerformanceInterfaceFactory::CreateInterface( *this, mEnvironmentOptions );
245 mCallbackManager = CallbackManager::New();
247 PositionSize size = mSurface->GetPositionSize();
249 mGestureManager = new GestureManager(*this, Vector2(size.width, size.height), mCallbackManager, mEnvironmentOptions);
251 if( mEnvironmentOptions.GetGlesCallTime() > 0 )
253 mGLES = new GlProxyImplementation( mEnvironmentOptions );
257 mGLES = new GlImplementation();
260 mEglFactory = new EglFactory();
262 EglSyncImplementation* eglSyncImpl = mEglFactory->GetSyncImplementation();
264 mCore = Integration::Core::New( *this, *mPlatformAbstraction, *mGLES, *eglSyncImpl, *mGestureManager, dataRetentionPolicy );
266 mObjectProfiler = new ObjectProfiler();
268 mNotificationTrigger = new TriggerEvent( MakeCallback( this, &Adaptor::ProcessCoreEvents ) );
270 mVSyncMonitor = new VSyncMonitor;
272 mUpdateRenderController = new UpdateRenderController( *this, mEnvironmentOptions );
274 mDaliFeedbackPlugin = new FeedbackPluginProxy( FeedbackPluginProxy::DEFAULT_OBJECT_NAME );
276 // Should be called after Core creation
277 if( mEnvironmentOptions.GetPanGestureLoggingLevel() )
279 Integration::EnableProfiling( Dali::Integration::PROFILING_TYPE_PAN_GESTURE );
281 if( mEnvironmentOptions.GetPanGesturePredictionMode() >= 0 )
283 Integration::SetPanGesturePredictionMode(mEnvironmentOptions.GetPanGesturePredictionMode());
285 if( mEnvironmentOptions.GetPanGesturePredictionAmount() >= 0 )
287 Integration::SetPanGesturePredictionAmount(mEnvironmentOptions.GetPanGesturePredictionAmount());
289 if( mEnvironmentOptions.GetPanGestureMaximumPredictionAmount() >= 0 )
291 Integration::SetPanGestureMaximumPredictionAmount(mEnvironmentOptions.GetPanGestureMaximumPredictionAmount());
293 if( mEnvironmentOptions.GetPanGestureMinimumPredictionAmount() >= 0 )
295 Integration::SetPanGestureMinimumPredictionAmount(mEnvironmentOptions.GetPanGestureMinimumPredictionAmount());
297 if( mEnvironmentOptions.GetPanGesturePredictionAmountAdjustment() >= 0 )
299 Integration::SetPanGesturePredictionAmountAdjustment(mEnvironmentOptions.GetPanGesturePredictionAmountAdjustment());
301 if( mEnvironmentOptions.GetPanGestureSmoothingMode() >= 0 )
303 Integration::SetPanGestureSmoothingMode(mEnvironmentOptions.GetPanGestureSmoothingMode());
305 if( mEnvironmentOptions.GetPanGestureSmoothingAmount() >= 0.0f )
307 Integration::SetPanGestureSmoothingAmount(mEnvironmentOptions.GetPanGestureSmoothingAmount());
313 // Ensure stop status
316 // Release first as we do not want any access to Adaptor as it is being destroyed.
317 gThreadLocalAdaptor.release();
319 for ( ObserverContainer::iterator iter = mObservers.begin(), endIter = mObservers.end(); iter != endIter; ++iter )
321 (*iter)->OnDestroy();
324 delete mUpdateRenderController; // this will shutdown render thread, which will call Core::ContextDestroyed before exit
325 delete mVSyncMonitor;
326 delete mEventHandler;
327 delete mObjectProfiler;
331 // Delete feedback controller before feedback plugin & style monitor dependencies
332 delete mFeedbackController;
333 delete mDaliFeedbackPlugin;
335 delete mGestureManager;
336 delete mPlatformAbstraction;
337 delete mCallbackManager;
338 delete mPerformanceInterface;
340 // uninstall it on this thread (main actor thread)
341 Dali::Integration::Log::UninstallLogFunction();
344 void Adaptor::Start()
346 // it doesn't support restart after stop at this moment
347 // to support restarting, need more testing
348 if( READY != mState )
353 // Start the callback manager
354 mCallbackManager->Start();
356 // create event handler
357 mEventHandler = new EventHandler( mSurface, *this, *mGestureManager, *this, mDragAndDropDetector );
359 if( mDeferredRotationObserver != NULL )
361 mEventHandler->SetRotationObserver(mDeferredRotationObserver);
362 mDeferredRotationObserver = NULL;
365 // guarantee map the surface before starting render-thread.
368 unsigned int dpiHor(0);
369 unsigned int dpiVer(0);
370 mSurface->GetDpi( dpiHor, dpiVer );
372 // tell core about the DPI value
373 mCore->SetDpi(dpiHor, dpiVer);
375 // set the DPI value for font rendering
376 FontClient fontClient = FontClient::Get();
377 fontClient.SetDpi( dpiHor, dpiVer );
379 // Tell the core the size of the surface just before we start the render-thread
380 PositionSize size = mSurface->GetPositionSize();
381 mCore->SurfaceResized( size.width, size.height );
383 // Start the update & render threads
384 mUpdateRenderController->Start();
388 ProcessCoreEvents(); // Ensure any startup messages are processed.
390 if ( !mFeedbackController )
392 // Start sound & haptic feedback
393 mFeedbackController = new FeedbackController( *mDaliFeedbackPlugin );
396 for ( ObserverContainer::iterator iter = mObservers.begin(), endIter = mObservers.end(); iter != endIter; ++iter )
402 // Dali::Internal::Adaptor::Adaptor::Pause
403 void Adaptor::Pause()
405 // Only pause the adaptor if we're actually running.
406 if( RUNNING == mState )
408 // Inform observers that we are about to be paused.
409 for( ObserverContainer::iterator iter = mObservers.begin(), endIter = mObservers.end(); iter != endIter; ++iter )
414 // Reset the event handler when adaptor paused
417 mEventHandler->Reset();
420 mUpdateRenderController->Pause();
426 // Dali::Internal::Adaptor::Adaptor::Resume
427 void Adaptor::Resume()
429 // Only resume the adaptor if we are in the suspended state.
430 if( PAUSED == mState )
432 // We put ResumeFrameTime first, as this was originally called at the start of mCore->Resume()
433 // If there were events pending, mCore->Resume() will call
434 // RenderController->RequestUpdate()
435 // UpdateRenderController->RequestUpdate()
436 // UpdateRenderSynchronization->RequestUpdate()
437 // and we should have reset the frame timers before allowing Core->Update() to be called.
438 //@todo Should we call UpdateRenderController->Resume before mCore->Resume()?
440 mUpdateRenderController->ResumeFrameTime();
442 mUpdateRenderController->Resume();
446 // Reset the event handler when adaptor resumed
449 mEventHandler->Reset();
452 // Inform observers that we have resumed.
453 for( ObserverContainer::iterator iter = mObservers.begin(), endIter = mObservers.end(); iter != endIter; ++iter )
458 ProcessCoreEvents(); // Ensure any outstanding messages are processed
464 if( RUNNING == mState ||
466 PAUSED_WHILE_HIDDEN == mState )
468 for( ObserverContainer::iterator iter = mObservers.begin(), endIter = mObservers.end(); iter != endIter; ++iter )
473 mUpdateRenderController->Stop();
476 // Delete the TTS player
477 for(int i =0; i < Dali::TtsPlayer::MODE_NUM; i++)
481 mTtsPlayers[i].Reset();
485 delete mEventHandler;
486 mEventHandler = NULL;
488 delete mNotificationTrigger;
489 mNotificationTrigger = NULL;
491 mCallbackManager->Stop();
497 void Adaptor::FeedTouchPoint( TouchPoint& point, int timeStamp )
499 mEventHandler->FeedTouchPoint( point, timeStamp );
502 void Adaptor::FeedWheelEvent( MouseWheelEvent& wheelEvent )
504 mEventHandler->FeedWheelEvent( wheelEvent );
507 void Adaptor::FeedKeyEvent( KeyEvent& keyEvent )
509 mEventHandler->FeedKeyEvent( keyEvent );
512 bool Adaptor::MoveResize( const PositionSize& positionSize )
514 PositionSize old = mSurface->GetPositionSize();
516 // just resize the surface. The driver should automatically resize the egl Surface (untested)
517 // EGL Spec says : EGL window surfaces need to be resized when their corresponding native window
518 // is resized. Implementations typically use hooks into the OS and native window
519 // system to perform this resizing on demand, transparently to the client.
520 mSurface->MoveResize( positionSize );
522 if(old.width != positionSize.width || old.height != positionSize.height)
524 SurfaceSizeChanged(positionSize);
530 void Adaptor::SurfaceResized( const PositionSize& positionSize )
532 PositionSize old = mSurface->GetPositionSize();
534 // Called by an application, when it has resized a window outside of Dali.
535 // The EGL driver automatically detects X Window resize calls, and resizes
536 // the EGL surface for us.
537 mSurface->MoveResize( positionSize );
539 if(old.width != positionSize.width || old.height != positionSize.height)
541 SurfaceSizeChanged(positionSize);
545 void Adaptor::ReplaceSurface( Dali::RenderSurface& surface )
547 // adaptor implementation needs the implementation of
548 RenderSurface* internalSurface = dynamic_cast<Internal::Adaptor::RenderSurface*>( &surface );
549 DALI_ASSERT_ALWAYS( internalSurface && "Incorrect surface" );
551 ECore::WindowRenderSurface* windowSurface = dynamic_cast<Internal::Adaptor::ECore::WindowRenderSurface*>( &surface);
552 if( windowSurface != NULL )
554 windowSurface->Map();
555 // @todo Restart event handler with new surface
558 mSurface = internalSurface;
560 SurfaceSizeChanged( internalSurface->GetPositionSize() );
562 // flush the event queue to give update and render threads chance
563 // to start processing messages for new camera setup etc as soon as possible
566 mCore->GetContextNotifier()->NotifyContextLost(); // Inform stage
568 // this method blocks until the render thread has completed the replace.
569 mUpdateRenderController->ReplaceSurface(internalSurface);
571 // Inform core, so that texture resources can be reloaded
572 mCore->RecoverFromContextLoss();
574 mCore->GetContextNotifier()->NotifyContextRegained(); // Inform stage
577 Dali::RenderSurface& Adaptor::GetSurface() const
582 void Adaptor::ReleaseSurfaceLock()
584 mSurface->ReleaseLock();
587 Dali::TtsPlayer Adaptor::GetTtsPlayer(Dali::TtsPlayer::Mode mode)
589 if(!mTtsPlayers[mode])
591 // Create the TTS player when it needed, because it can reduce launching time.
592 mTtsPlayers[mode] = TtsPlayer::New(mode);
595 return mTtsPlayers[mode];
598 bool Adaptor::AddIdle( CallbackBase* callback )
600 bool idleAdded(false);
602 // Only add an idle if the Adaptor is actually running
603 if( RUNNING == mState )
605 idleAdded = mCallbackManager->AddCallback( callback, CallbackManager::IDLE_PRIORITY );
611 bool Adaptor::CallFromMainLoop( CallbackBase* callback )
613 bool callAdded(false);
615 // Only allow the callback if the Adaptor is actually running
616 if ( RUNNING == mState )
618 callAdded = mCallbackManager->AddCallback( callback, CallbackManager::DEFAULT_PRIORITY );
624 Dali::Adaptor& Adaptor::Get()
626 DALI_ASSERT_ALWAYS( gThreadLocalAdaptor.get() != NULL && "Adaptor not instantiated" );
627 return gThreadLocalAdaptor->mAdaptor;
630 bool Adaptor::IsAvailable()
632 return gThreadLocalAdaptor.get() != NULL;
635 Dali::Integration::Core& Adaptor::GetCore()
640 void Adaptor::SetRenderRefreshRate( unsigned int numberOfVSyncsPerRender )
642 mUpdateRenderController->SetRenderRefreshRate( numberOfVSyncsPerRender );
645 void Adaptor::SetUseHardwareVSync( bool useHardware )
647 mVSyncMonitor->SetUseHardwareVSync( useHardware );
650 EglFactory& Adaptor::GetEGLFactory() const
652 DALI_ASSERT_DEBUG( mEglFactory && "EGL Factory not created" );
656 EglFactoryInterface& Adaptor::GetEGLFactoryInterface() const
661 Integration::GlAbstraction& Adaptor::GetGlAbstraction() const
663 DALI_ASSERT_DEBUG( mGLES && "GLImplementation not created" );
667 Dali::Integration::PlatformAbstraction& Adaptor::GetPlatformAbstractionInterface()
669 return *mPlatformAbstraction;
672 Dali::Integration::GlAbstraction& Adaptor::GetGlesInterface()
677 TriggerEventInterface& Adaptor::GetTriggerEventInterface()
679 return *mNotificationTrigger;
681 TriggerEventFactoryInterface& Adaptor::GetTriggerEventFactoryInterface()
683 return mTriggerEventFactory;
685 RenderSurface* Adaptor::GetRenderSurfaceInterface()
689 VSyncMonitorInterface* Adaptor::GetVSyncMonitorInterface()
691 return mVSyncMonitor;
694 KernelTraceInterface& Adaptor::GetKernelTraceInterface()
696 return mKernelTracer;
699 PerformanceInterface* Adaptor::GetPerformanceInterface()
701 return mPerformanceInterface;
704 Integration::PlatformAbstraction& Adaptor::GetPlatformAbstraction() const
706 DALI_ASSERT_DEBUG( mPlatformAbstraction && "PlatformAbstraction not created" );
707 return *mPlatformAbstraction;
710 void Adaptor::SetDragAndDropDetector( DragAndDropDetectorPtr detector )
712 mDragAndDropDetector = detector;
716 mEventHandler->SetDragAndDropDetector( detector );
720 void Adaptor::SetRotationObserver( RotationObserver* observer )
724 mEventHandler->SetRotationObserver( observer );
726 else if( mState == READY )
728 // Set once event handler exists
729 mDeferredRotationObserver = observer;
733 void Adaptor::DestroyTtsPlayer(Dali::TtsPlayer::Mode mode)
735 if(mTtsPlayers[mode])
737 mTtsPlayers[mode].Reset();
741 void Adaptor::SetMinimumPinchDistance(float distance)
743 if( mGestureManager )
745 mGestureManager->SetMinimumPinchDistance(distance);
750 void Adaptor::AddObserver( LifeCycleObserver& observer )
752 ObserverContainer::iterator match ( find(mObservers.begin(), mObservers.end(), &observer) );
754 if ( match == mObservers.end() )
756 mObservers.push_back( &observer );
760 void Adaptor::RemoveObserver( LifeCycleObserver& observer )
762 ObserverContainer::iterator match ( find(mObservers.begin(), mObservers.end(), &observer) );
764 if ( match != mObservers.end() )
766 mObservers.erase( match );
770 void Adaptor::QueueCoreEvent(const Dali::Integration::Event& event)
774 mCore->QueueEvent(event);
778 void Adaptor::ProcessCoreEvents()
782 if( mPerformanceInterface )
784 mPerformanceInterface->AddMarker( PerformanceInterface::PROCESS_EVENTS_START );
787 mCore->ProcessEvents();
789 if( mPerformanceInterface )
791 mPerformanceInterface->AddMarker( PerformanceInterface::PROCESS_EVENTS_END );
796 void Adaptor::RequestUpdate()
798 // When Dali applications are partially visible behind the lock-screen,
799 // the indicator must be updated (therefore allow updates in the PAUSED state)
800 if ( PAUSED == mState ||
803 mUpdateRenderController->RequestUpdate();
807 void Adaptor::RequestProcessEventsOnIdle()
809 // Only request a notification if the Adaptor is actually running
810 // and we haven't installed the idle notification
811 if( ( ! mNotificationOnIdleInstalled ) && ( RUNNING == mState ) )
813 mNotificationOnIdleInstalled = AddIdle( MakeCallback( this, &Adaptor::ProcessCoreEventsFromIdle ) );
817 void Adaptor::OnWindowShown()
819 if ( PAUSED_WHILE_HIDDEN == mState )
821 // Adaptor can now be resumed
826 // Force a render task
831 void Adaptor::OnWindowHidden()
833 if ( STOPPED != mState )
837 // Adaptor cannot be resumed until the window is shown
838 mState = PAUSED_WHILE_HIDDEN;
842 // Dali::Internal::Adaptor::Adaptor::OnDamaged
843 void Adaptor::OnDamaged( const DamageArea& area )
845 // This is needed for the case where Dali window is partially obscured
849 void Adaptor::SurfaceSizeChanged(const PositionSize& positionSize)
851 // let the core know the surface size has changed
852 mCore->SurfaceResized(positionSize.width, positionSize.height);
854 mResizedSignal.Emit( mAdaptor );
857 void Adaptor::NotifyLanguageChanged()
859 mLanguageChangedSignal.Emit( mAdaptor );
862 void Adaptor::RequestUpdateOnce()
864 if( PAUSED_WHILE_HIDDEN != mState )
866 if( mUpdateRenderController )
868 mUpdateRenderController->RequestUpdateOnce();
873 void Adaptor::ProcessCoreEventsFromIdle()
877 // the idle handle automatically un-installs itself
878 mNotificationOnIdleInstalled = false;
881 Adaptor::Adaptor(Dali::Adaptor& adaptor, RenderSurface* surface, const DeviceLayout& baseLayout)
883 mLanguageChangedSignal(),
887 mUpdateRenderController(NULL),
892 mPlatformAbstraction( NULL ),
893 mEventHandler( NULL ),
894 mCallbackManager( NULL ),
895 mNotificationOnIdleInstalled( false ),
896 mNotificationTrigger(NULL),
897 mGestureManager(NULL),
898 mDaliFeedbackPlugin(NULL),
899 mFeedbackController(NULL),
901 mDragAndDropDetector(),
902 mDeferredRotationObserver(NULL),
903 mBaseLayout(baseLayout),
904 mEnvironmentOptions(),
905 mPerformanceInterface(NULL),
906 mObjectProfiler(NULL)
908 DALI_ASSERT_ALWAYS( gThreadLocalAdaptor.get() == NULL && "Cannot create more than one Adaptor per thread" );
909 gThreadLocalAdaptor.reset(this);
914 void Adaptor::SetViewMode( ViewMode viewMode )
916 mSurface->SetViewMode( viewMode );
917 mCore->SetViewMode( viewMode );
920 ViewMode Adaptor::GetViewMode() const
922 return mCore->GetViewMode();
925 void Adaptor::SetStereoBase( float stereoBase )
927 mCore->SetStereoBase( stereoBase );
930 float Adaptor::GetStereoBase() const
932 return mCore->GetStereoBase();
935 } // namespace Adaptor
937 } // namespace Internal