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 <tizen-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 TIZEN Platform's LogMessage handler.
140 Dali::Integration::Log::LogFunction logFunction(Dali::TizenPlatform::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 int windowWidth(0), windowHeight(0);
220 if ( GetIntegerEnvironmentVariable( DALI_WINDOW_WIDTH, windowWidth ) && GetIntegerEnvironmentVariable( DALI_WINDOW_HEIGHT, windowHeight ) )
222 mEnvironmentOptions.SetWindowWidth( windowWidth );
223 mEnvironmentOptions.SetWindowHeight( windowHeight );
226 mEnvironmentOptions.InstallLogFunction();
229 void Adaptor::Initialize(Dali::Configuration::ContextLoss configuration)
231 ParseEnvironmentOptions();
233 mPlatformAbstraction = new TizenPlatform::TizenPlatformAbstraction;
236 GetDataStoragePath( path );
237 mPlatformAbstraction->SetDataStoragePath( path );
239 ResourcePolicy::DataRetention dataRetentionPolicy = ResourcePolicy::DALI_DISCARDS_ALL_DATA;
240 if( configuration == Dali::Configuration::APPLICATION_DOES_NOT_HANDLE_CONTEXT_LOSS )
242 dataRetentionPolicy = ResourcePolicy::DALI_RETAINS_MESH_DATA;
244 // Note, Tizen does not use DALI_RETAINS_ALL_DATA, as it can reload images from
245 // files automatically.
247 if( mEnvironmentOptions.PerformanceServerRequired() )
249 mPerformanceInterface = PerformanceInterfaceFactory::CreateInterface( *this, mEnvironmentOptions );
252 mCallbackManager = CallbackManager::New();
254 PositionSize size = mSurface->GetPositionSize();
256 mGestureManager = new GestureManager(*this, Vector2(size.width, size.height), mCallbackManager, mEnvironmentOptions);
258 if( mEnvironmentOptions.GetGlesCallTime() > 0 )
260 mGLES = new GlProxyImplementation( mEnvironmentOptions );
264 mGLES = new GlImplementation();
267 mEglFactory = new EglFactory();
269 EglSyncImplementation* eglSyncImpl = mEglFactory->GetSyncImplementation();
271 mCore = Integration::Core::New( *this, *mPlatformAbstraction, *mGLES, *eglSyncImpl, *mGestureManager, dataRetentionPolicy );
273 mObjectProfiler = new ObjectProfiler();
275 mNotificationTrigger = new TriggerEvent( MakeCallback( this, &Adaptor::ProcessCoreEvents ) );
277 mVSyncMonitor = new VSyncMonitor;
279 mUpdateRenderController = new UpdateRenderController( *this, mEnvironmentOptions );
281 mDaliFeedbackPlugin = new FeedbackPluginProxy( FeedbackPluginProxy::DEFAULT_OBJECT_NAME );
283 // Should be called after Core creation
284 if( mEnvironmentOptions.GetPanGestureLoggingLevel() )
286 Integration::EnableProfiling( Dali::Integration::PROFILING_TYPE_PAN_GESTURE );
288 if( mEnvironmentOptions.GetPanGesturePredictionMode() >= 0 )
290 Integration::SetPanGesturePredictionMode(mEnvironmentOptions.GetPanGesturePredictionMode());
292 if( mEnvironmentOptions.GetPanGesturePredictionAmount() >= 0 )
294 Integration::SetPanGesturePredictionAmount(mEnvironmentOptions.GetPanGesturePredictionAmount());
296 if( mEnvironmentOptions.GetPanGestureMaximumPredictionAmount() >= 0 )
298 Integration::SetPanGestureMaximumPredictionAmount(mEnvironmentOptions.GetPanGestureMaximumPredictionAmount());
300 if( mEnvironmentOptions.GetPanGestureMinimumPredictionAmount() >= 0 )
302 Integration::SetPanGestureMinimumPredictionAmount(mEnvironmentOptions.GetPanGestureMinimumPredictionAmount());
304 if( mEnvironmentOptions.GetPanGesturePredictionAmountAdjustment() >= 0 )
306 Integration::SetPanGesturePredictionAmountAdjustment(mEnvironmentOptions.GetPanGesturePredictionAmountAdjustment());
308 if( mEnvironmentOptions.GetPanGestureSmoothingMode() >= 0 )
310 Integration::SetPanGestureSmoothingMode(mEnvironmentOptions.GetPanGestureSmoothingMode());
312 if( mEnvironmentOptions.GetPanGestureSmoothingAmount() >= 0.0f )
314 Integration::SetPanGestureSmoothingAmount(mEnvironmentOptions.GetPanGestureSmoothingAmount());
316 if( mEnvironmentOptions.GetWindowWidth() && mEnvironmentOptions.GetWindowHeight() )
318 SurfaceResized( PositionSize( 0, 0, mEnvironmentOptions.GetWindowWidth(), mEnvironmentOptions.GetWindowHeight() ));
324 // Ensure stop status
327 // Release first as we do not want any access to Adaptor as it is being destroyed.
328 gThreadLocalAdaptor.release();
330 for ( ObserverContainer::iterator iter = mObservers.begin(), endIter = mObservers.end(); iter != endIter; ++iter )
332 (*iter)->OnDestroy();
335 delete mUpdateRenderController; // this will shutdown render thread, which will call Core::ContextDestroyed before exit
336 delete mVSyncMonitor;
337 delete mEventHandler;
338 delete mObjectProfiler;
342 // Delete feedback controller before feedback plugin & style monitor dependencies
343 delete mFeedbackController;
344 delete mDaliFeedbackPlugin;
346 delete mGestureManager;
347 delete mPlatformAbstraction;
348 delete mCallbackManager;
349 delete mPerformanceInterface;
351 // uninstall it on this thread (main actor thread)
352 Dali::Integration::Log::UninstallLogFunction();
355 void Adaptor::Start()
357 // it doesn't support restart after stop at this moment
358 // to support restarting, need more testing
359 if( READY != mState )
364 // Start the callback manager
365 mCallbackManager->Start();
367 // create event handler
368 mEventHandler = new EventHandler( mSurface, *this, *mGestureManager, *this, mDragAndDropDetector );
370 if( mDeferredRotationObserver != NULL )
372 mEventHandler->SetRotationObserver(mDeferredRotationObserver);
373 mDeferredRotationObserver = NULL;
376 // guarantee map the surface before starting render-thread.
379 unsigned int dpiHor(0);
380 unsigned int dpiVer(0);
381 mSurface->GetDpi( dpiHor, dpiVer );
383 // tell core about the DPI value
384 mCore->SetDpi(dpiHor, dpiVer);
386 // set the DPI value for font rendering
387 FontClient fontClient = FontClient::Get();
388 fontClient.SetDpi( dpiHor, dpiVer );
390 // Tell the core the size of the surface just before we start the render-thread
391 PositionSize size = mSurface->GetPositionSize();
392 mCore->SurfaceResized( size.width, size.height );
394 // Start the update & render threads
395 mUpdateRenderController->Start();
399 ProcessCoreEvents(); // Ensure any startup messages are processed.
401 if ( !mFeedbackController )
403 // Start sound & haptic feedback
404 mFeedbackController = new FeedbackController( *mDaliFeedbackPlugin );
407 for ( ObserverContainer::iterator iter = mObservers.begin(), endIter = mObservers.end(); iter != endIter; ++iter )
413 // Dali::Internal::Adaptor::Adaptor::Pause
414 void Adaptor::Pause()
416 // Only pause the adaptor if we're actually running.
417 if( RUNNING == mState )
419 // Inform observers that we are about to be paused.
420 for( ObserverContainer::iterator iter = mObservers.begin(), endIter = mObservers.end(); iter != endIter; ++iter )
425 // Reset the event handler when adaptor paused
428 mEventHandler->Reset();
431 mUpdateRenderController->Pause();
437 // Dali::Internal::Adaptor::Adaptor::Resume
438 void Adaptor::Resume()
440 // Only resume the adaptor if we are in the suspended state.
441 if( PAUSED == mState )
443 // We put ResumeFrameTime first, as this was originally called at the start of mCore->Resume()
444 // If there were events pending, mCore->Resume() will call
445 // RenderController->RequestUpdate()
446 // UpdateRenderController->RequestUpdate()
447 // UpdateRenderSynchronization->RequestUpdate()
448 // and we should have reset the frame timers before allowing Core->Update() to be called.
449 //@todo Should we call UpdateRenderController->Resume before mCore->Resume()?
451 mUpdateRenderController->ResumeFrameTime();
453 mUpdateRenderController->Resume();
457 // Reset the event handler when adaptor resumed
460 mEventHandler->Reset();
463 // Inform observers that we have resumed.
464 for( ObserverContainer::iterator iter = mObservers.begin(), endIter = mObservers.end(); iter != endIter; ++iter )
469 ProcessCoreEvents(); // Ensure any outstanding messages are processed
475 if( RUNNING == mState ||
477 PAUSED_WHILE_HIDDEN == mState )
479 for( ObserverContainer::iterator iter = mObservers.begin(), endIter = mObservers.end(); iter != endIter; ++iter )
484 mUpdateRenderController->Stop();
487 // Delete the TTS player
488 for(int i =0; i < Dali::TtsPlayer::MODE_NUM; i++)
492 mTtsPlayers[i].Reset();
496 delete mEventHandler;
497 mEventHandler = NULL;
499 delete mNotificationTrigger;
500 mNotificationTrigger = NULL;
502 mCallbackManager->Stop();
508 void Adaptor::FeedTouchPoint( TouchPoint& point, int timeStamp )
510 mEventHandler->FeedTouchPoint( point, timeStamp );
513 void Adaptor::FeedWheelEvent( MouseWheelEvent& wheelEvent )
515 mEventHandler->FeedWheelEvent( wheelEvent );
518 void Adaptor::FeedKeyEvent( KeyEvent& keyEvent )
520 mEventHandler->FeedKeyEvent( keyEvent );
523 bool Adaptor::MoveResize( const PositionSize& positionSize )
525 PositionSize old = mSurface->GetPositionSize();
527 // just resize the surface. The driver should automatically resize the egl Surface (untested)
528 // EGL Spec says : EGL window surfaces need to be resized when their corresponding native window
529 // is resized. Implementations typically use hooks into the OS and native window
530 // system to perform this resizing on demand, transparently to the client.
531 mSurface->MoveResize( positionSize );
533 if(old.width != positionSize.width || old.height != positionSize.height)
535 SurfaceSizeChanged(positionSize);
541 void Adaptor::SurfaceResized( const PositionSize& positionSize )
543 PositionSize old = mSurface->GetPositionSize();
545 // Called by an application, when it has resized a window outside of Dali.
546 // The EGL driver automatically detects X Window resize calls, and resizes
547 // the EGL surface for us.
548 mSurface->MoveResize( positionSize );
550 if(old.width != positionSize.width || old.height != positionSize.height)
552 SurfaceSizeChanged(positionSize);
556 void Adaptor::ReplaceSurface( Dali::RenderSurface& surface )
558 // adaptor implementation needs the implementation of
559 RenderSurface* internalSurface = dynamic_cast<Internal::Adaptor::RenderSurface*>( &surface );
560 DALI_ASSERT_ALWAYS( internalSurface && "Incorrect surface" );
562 ECore::WindowRenderSurface* windowSurface = dynamic_cast<Internal::Adaptor::ECore::WindowRenderSurface*>( &surface);
563 if( windowSurface != NULL )
565 windowSurface->Map();
566 // @todo Restart event handler with new surface
569 mSurface = internalSurface;
571 SurfaceSizeChanged( internalSurface->GetPositionSize() );
573 // flush the event queue to give update and render threads chance
574 // to start processing messages for new camera setup etc as soon as possible
577 mCore->GetContextNotifier()->NotifyContextLost(); // Inform stage
579 // this method blocks until the render thread has completed the replace.
580 mUpdateRenderController->ReplaceSurface(internalSurface);
582 // Inform core, so that texture resources can be reloaded
583 mCore->RecoverFromContextLoss();
585 mCore->GetContextNotifier()->NotifyContextRegained(); // Inform stage
588 Dali::RenderSurface& Adaptor::GetSurface() const
593 void Adaptor::ReleaseSurfaceLock()
595 mSurface->ReleaseLock();
598 Dali::TtsPlayer Adaptor::GetTtsPlayer(Dali::TtsPlayer::Mode mode)
600 if(!mTtsPlayers[mode])
602 // Create the TTS player when it needed, because it can reduce launching time.
603 mTtsPlayers[mode] = TtsPlayer::New(mode);
606 return mTtsPlayers[mode];
609 bool Adaptor::AddIdle( CallbackBase* callback )
611 bool idleAdded(false);
613 // Only add an idle if the Adaptor is actually running
614 if( RUNNING == mState )
616 idleAdded = mCallbackManager->AddCallback( callback, CallbackManager::IDLE_PRIORITY );
622 bool Adaptor::CallFromMainLoop( CallbackBase* callback )
624 bool callAdded(false);
626 // Only allow the callback if the Adaptor is actually running
627 if ( RUNNING == mState )
629 callAdded = mCallbackManager->AddCallback( callback, CallbackManager::DEFAULT_PRIORITY );
635 Dali::Adaptor& Adaptor::Get()
637 DALI_ASSERT_ALWAYS( gThreadLocalAdaptor.get() != NULL && "Adaptor not instantiated" );
638 return gThreadLocalAdaptor->mAdaptor;
641 bool Adaptor::IsAvailable()
643 return gThreadLocalAdaptor.get() != NULL;
646 Dali::Integration::Core& Adaptor::GetCore()
651 void Adaptor::SetRenderRefreshRate( unsigned int numberOfVSyncsPerRender )
653 mUpdateRenderController->SetRenderRefreshRate( numberOfVSyncsPerRender );
656 void Adaptor::SetUseHardwareVSync( bool useHardware )
658 mVSyncMonitor->SetUseHardwareVSync( useHardware );
661 EglFactory& Adaptor::GetEGLFactory() const
663 DALI_ASSERT_DEBUG( mEglFactory && "EGL Factory not created" );
667 EglFactoryInterface& Adaptor::GetEGLFactoryInterface() const
672 Integration::GlAbstraction& Adaptor::GetGlAbstraction() const
674 DALI_ASSERT_DEBUG( mGLES && "GLImplementation not created" );
678 Dali::Integration::PlatformAbstraction& Adaptor::GetPlatformAbstractionInterface()
680 return *mPlatformAbstraction;
683 Dali::Integration::GlAbstraction& Adaptor::GetGlesInterface()
688 TriggerEventInterface& Adaptor::GetTriggerEventInterface()
690 return *mNotificationTrigger;
692 TriggerEventFactoryInterface& Adaptor::GetTriggerEventFactoryInterface()
694 return mTriggerEventFactory;
696 RenderSurface* Adaptor::GetRenderSurfaceInterface()
700 VSyncMonitorInterface* Adaptor::GetVSyncMonitorInterface()
702 return mVSyncMonitor;
705 KernelTraceInterface& Adaptor::GetKernelTraceInterface()
707 return mKernelTracer;
710 PerformanceInterface* Adaptor::GetPerformanceInterface()
712 return mPerformanceInterface;
715 Integration::PlatformAbstraction& Adaptor::GetPlatformAbstraction() const
717 DALI_ASSERT_DEBUG( mPlatformAbstraction && "PlatformAbstraction not created" );
718 return *mPlatformAbstraction;
721 void Adaptor::SetDragAndDropDetector( DragAndDropDetectorPtr detector )
723 mDragAndDropDetector = detector;
727 mEventHandler->SetDragAndDropDetector( detector );
731 void Adaptor::SetRotationObserver( RotationObserver* observer )
735 mEventHandler->SetRotationObserver( observer );
737 else if( mState == READY )
739 // Set once event handler exists
740 mDeferredRotationObserver = observer;
744 void Adaptor::DestroyTtsPlayer(Dali::TtsPlayer::Mode mode)
746 if(mTtsPlayers[mode])
748 mTtsPlayers[mode].Reset();
752 void Adaptor::SetMinimumPinchDistance(float distance)
754 if( mGestureManager )
756 mGestureManager->SetMinimumPinchDistance(distance);
761 void Adaptor::AddObserver( LifeCycleObserver& observer )
763 ObserverContainer::iterator match ( find(mObservers.begin(), mObservers.end(), &observer) );
765 if ( match == mObservers.end() )
767 mObservers.push_back( &observer );
771 void Adaptor::RemoveObserver( LifeCycleObserver& observer )
773 ObserverContainer::iterator match ( find(mObservers.begin(), mObservers.end(), &observer) );
775 if ( match != mObservers.end() )
777 mObservers.erase( match );
781 void Adaptor::QueueCoreEvent(const Dali::Integration::Event& event)
785 mCore->QueueEvent(event);
789 void Adaptor::ProcessCoreEvents()
793 if( mPerformanceInterface )
795 mPerformanceInterface->AddMarker( PerformanceInterface::PROCESS_EVENTS_START );
798 mCore->ProcessEvents();
800 if( mPerformanceInterface )
802 mPerformanceInterface->AddMarker( PerformanceInterface::PROCESS_EVENTS_END );
807 void Adaptor::RequestUpdate()
809 // When Dali applications are partially visible behind the lock-screen,
810 // the indicator must be updated (therefore allow updates in the PAUSED state)
811 if ( PAUSED == mState ||
814 mUpdateRenderController->RequestUpdate();
818 void Adaptor::RequestProcessEventsOnIdle()
820 // Only request a notification if the Adaptor is actually running
821 // and we haven't installed the idle notification
822 if( ( ! mNotificationOnIdleInstalled ) && ( RUNNING == mState ) )
824 mNotificationOnIdleInstalled = AddIdle( MakeCallback( this, &Adaptor::ProcessCoreEventsFromIdle ) );
828 void Adaptor::OnWindowShown()
830 if ( PAUSED_WHILE_HIDDEN == mState )
832 // Adaptor can now be resumed
837 // Force a render task
842 void Adaptor::OnWindowHidden()
844 if ( STOPPED != mState )
848 // Adaptor cannot be resumed until the window is shown
849 mState = PAUSED_WHILE_HIDDEN;
853 // Dali::Internal::Adaptor::Adaptor::OnDamaged
854 void Adaptor::OnDamaged( const DamageArea& area )
856 // This is needed for the case where Dali window is partially obscured
860 void Adaptor::SurfaceSizeChanged(const PositionSize& positionSize)
862 // let the core know the surface size has changed
863 mCore->SurfaceResized(positionSize.width, positionSize.height);
865 mResizedSignal.Emit( mAdaptor );
868 void Adaptor::NotifyLanguageChanged()
870 mLanguageChangedSignal.Emit( mAdaptor );
873 void Adaptor::RequestUpdateOnce()
875 if( PAUSED_WHILE_HIDDEN != mState )
877 if( mUpdateRenderController )
879 mUpdateRenderController->RequestUpdateOnce();
884 void Adaptor::ProcessCoreEventsFromIdle()
888 // the idle handle automatically un-installs itself
889 mNotificationOnIdleInstalled = false;
892 Adaptor::Adaptor(Dali::Adaptor& adaptor, RenderSurface* surface, const DeviceLayout& baseLayout)
894 mLanguageChangedSignal(),
898 mUpdateRenderController(NULL),
903 mPlatformAbstraction( NULL ),
904 mEventHandler( NULL ),
905 mCallbackManager( NULL ),
906 mNotificationOnIdleInstalled( false ),
907 mNotificationTrigger(NULL),
908 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