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 <tizen-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 );
134 unsigned int networkControl= GetIntegerEnvironmentVariable( DALI_ENV_NETWORK_CONTROL, 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 TIZEN Platform's LogMessage handler.
139 Dali::Integration::Log::LogFunction logFunction(Dali::TizenPlatform::LogMessage);
141 mEnvironmentOptions.SetLogOptions( logFunction, networkControl, 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 int windowWidth(0), windowHeight(0);
219 if ( GetIntegerEnvironmentVariable( DALI_WINDOW_WIDTH, windowWidth ) && GetIntegerEnvironmentVariable( DALI_WINDOW_HEIGHT, windowHeight ) )
221 mEnvironmentOptions.SetWindowWidth( windowWidth );
222 mEnvironmentOptions.SetWindowHeight( windowHeight );
225 mEnvironmentOptions.InstallLogFunction();
228 void Adaptor::Initialize(Dali::Configuration::ContextLoss configuration)
230 ParseEnvironmentOptions();
232 mPlatformAbstraction = new TizenPlatform::TizenPlatformAbstraction;
235 GetDataStoragePath( path );
236 mPlatformAbstraction->SetDataStoragePath( path );
238 ResourcePolicy::DataRetention dataRetentionPolicy = ResourcePolicy::DALI_DISCARDS_ALL_DATA;
239 if( configuration == Dali::Configuration::APPLICATION_DOES_NOT_HANDLE_CONTEXT_LOSS )
241 dataRetentionPolicy = ResourcePolicy::DALI_RETAINS_MESH_DATA;
243 // Note, Tizen does not use DALI_RETAINS_ALL_DATA, as it can reload images from
244 // files automatically.
246 if( mEnvironmentOptions.PerformanceServerRequired() )
248 mPerformanceInterface = PerformanceInterfaceFactory::CreateInterface( *this, mEnvironmentOptions );
251 mCallbackManager = CallbackManager::New();
253 PositionSize size = mSurface->GetPositionSize();
255 mGestureManager = new GestureManager(*this, Vector2(size.width, size.height), mCallbackManager, mEnvironmentOptions);
257 if( mEnvironmentOptions.GetGlesCallTime() > 0 )
259 mGLES = new GlProxyImplementation( mEnvironmentOptions );
263 mGLES = new GlImplementation();
266 mEglFactory = new EglFactory();
268 EglSyncImplementation* eglSyncImpl = mEglFactory->GetSyncImplementation();
270 mCore = Integration::Core::New( *this, *mPlatformAbstraction, *mGLES, *eglSyncImpl, *mGestureManager, dataRetentionPolicy );
272 mObjectProfiler = new ObjectProfiler();
274 mNotificationTrigger = new TriggerEvent( MakeCallback( this, &Adaptor::ProcessCoreEvents ) );
276 mVSyncMonitor = new VSyncMonitor;
278 mUpdateRenderController = new UpdateRenderController( *this, mEnvironmentOptions );
280 mDaliFeedbackPlugin = new FeedbackPluginProxy( FeedbackPluginProxy::DEFAULT_OBJECT_NAME );
282 // Should be called after Core creation
283 if( mEnvironmentOptions.GetPanGestureLoggingLevel() )
285 Integration::EnableProfiling( Dali::Integration::PROFILING_TYPE_PAN_GESTURE );
287 if( mEnvironmentOptions.GetPanGesturePredictionMode() >= 0 )
289 Integration::SetPanGesturePredictionMode(mEnvironmentOptions.GetPanGesturePredictionMode());
291 if( mEnvironmentOptions.GetPanGesturePredictionAmount() >= 0 )
293 Integration::SetPanGesturePredictionAmount(mEnvironmentOptions.GetPanGesturePredictionAmount());
295 if( mEnvironmentOptions.GetPanGestureMaximumPredictionAmount() >= 0 )
297 Integration::SetPanGestureMaximumPredictionAmount(mEnvironmentOptions.GetPanGestureMaximumPredictionAmount());
299 if( mEnvironmentOptions.GetPanGestureMinimumPredictionAmount() >= 0 )
301 Integration::SetPanGestureMinimumPredictionAmount(mEnvironmentOptions.GetPanGestureMinimumPredictionAmount());
303 if( mEnvironmentOptions.GetPanGesturePredictionAmountAdjustment() >= 0 )
305 Integration::SetPanGesturePredictionAmountAdjustment(mEnvironmentOptions.GetPanGesturePredictionAmountAdjustment());
307 if( mEnvironmentOptions.GetPanGestureSmoothingMode() >= 0 )
309 Integration::SetPanGestureSmoothingMode(mEnvironmentOptions.GetPanGestureSmoothingMode());
311 if( mEnvironmentOptions.GetPanGestureSmoothingAmount() >= 0.0f )
313 Integration::SetPanGestureSmoothingAmount(mEnvironmentOptions.GetPanGestureSmoothingAmount());
315 if( mEnvironmentOptions.GetWindowWidth() && mEnvironmentOptions.GetWindowHeight() )
317 SurfaceResized( PositionSize( 0, 0, mEnvironmentOptions.GetWindowWidth(), mEnvironmentOptions.GetWindowHeight() ));
323 // Ensure stop status
326 // Release first as we do not want any access to Adaptor as it is being destroyed.
327 gThreadLocalAdaptor.release();
329 for ( ObserverContainer::iterator iter = mObservers.begin(), endIter = mObservers.end(); iter != endIter; ++iter )
331 (*iter)->OnDestroy();
334 delete mUpdateRenderController; // this will shutdown render thread, which will call Core::ContextDestroyed before exit
335 delete mVSyncMonitor;
336 delete mEventHandler;
337 delete mObjectProfiler;
341 // Delete feedback controller before feedback plugin & style monitor dependencies
342 delete mFeedbackController;
343 delete mDaliFeedbackPlugin;
345 delete mGestureManager;
346 delete mPlatformAbstraction;
347 delete mCallbackManager;
348 delete mPerformanceInterface;
350 // uninstall it on this thread (main actor thread)
351 Dali::Integration::Log::UninstallLogFunction();
354 void Adaptor::Start()
356 // it doesn't support restart after stop at this moment
357 // to support restarting, need more testing
358 if( READY != mState )
363 // Start the callback manager
364 mCallbackManager->Start();
366 // create event handler
367 mEventHandler = new EventHandler( mSurface, *this, *mGestureManager, *this, mDragAndDropDetector );
369 if( mDeferredRotationObserver != NULL )
371 mEventHandler->SetRotationObserver(mDeferredRotationObserver);
372 mDeferredRotationObserver = NULL;
375 // guarantee map the surface before starting render-thread.
378 // use default or command line settings if not run on device
379 if( mHDpi == 0 || mVDpi == 0 )
381 unsigned int dpiHor, dpiVer;
383 mSurface->GetDpi(dpiHor, dpiVer);
385 // tell core about the value
386 mCore->SetDpi(dpiHor, dpiVer);
390 mCore->SetDpi(mHDpi, mVDpi);
393 // Tell the core the size of the surface just before we start the render-thread
394 PositionSize size = mSurface->GetPositionSize();
395 mCore->SurfaceResized( size.width, size.height );
397 // Start the update & render threads
398 mUpdateRenderController->Start();
402 ProcessCoreEvents(); // Ensure any startup messages are processed.
404 if ( !mFeedbackController )
406 // Start sound & haptic feedback
407 mFeedbackController = new FeedbackController( *mDaliFeedbackPlugin );
410 for ( ObserverContainer::iterator iter = mObservers.begin(), endIter = mObservers.end(); iter != endIter; ++iter )
416 // Dali::Internal::Adaptor::Adaptor::Pause
417 void Adaptor::Pause()
419 // Only pause the adaptor if we're actually running.
420 if( RUNNING == mState )
422 // Inform observers that we are about to be paused.
423 for( ObserverContainer::iterator iter = mObservers.begin(), endIter = mObservers.end(); iter != endIter; ++iter )
428 // Reset the event handler when adaptor paused
431 mEventHandler->Reset();
434 mUpdateRenderController->Pause();
440 // Dali::Internal::Adaptor::Adaptor::Resume
441 void Adaptor::Resume()
443 // Only resume the adaptor if we are in the suspended state.
444 if( PAUSED == mState )
446 // We put ResumeFrameTime first, as this was originally called at the start of mCore->Resume()
447 // If there were events pending, mCore->Resume() will call
448 // RenderController->RequestUpdate()
449 // UpdateRenderController->RequestUpdate()
450 // UpdateRenderSynchronization->RequestUpdate()
451 // and we should have reset the frame timers before allowing Core->Update() to be called.
452 //@todo Should we call UpdateRenderController->Resume before mCore->Resume()?
454 mUpdateRenderController->ResumeFrameTime();
456 mUpdateRenderController->Resume();
460 // Reset the event handler when adaptor resumed
463 mEventHandler->Reset();
466 // Inform observers that we have resumed.
467 for( ObserverContainer::iterator iter = mObservers.begin(), endIter = mObservers.end(); iter != endIter; ++iter )
472 ProcessCoreEvents(); // Ensure any outstanding messages are processed
478 if( RUNNING == mState ||
480 PAUSED_WHILE_HIDDEN == mState )
482 for( ObserverContainer::iterator iter = mObservers.begin(), endIter = mObservers.end(); iter != endIter; ++iter )
487 mUpdateRenderController->Stop();
490 // Delete the TTS player
491 for(int i =0; i < Dali::TtsPlayer::MODE_NUM; i++)
495 mTtsPlayers[i].Reset();
499 delete mEventHandler;
500 mEventHandler = NULL;
502 delete mNotificationTrigger;
503 mNotificationTrigger = NULL;
505 mCallbackManager->Stop();
511 void Adaptor::FeedTouchPoint( TouchPoint& point, int timeStamp )
513 mEventHandler->FeedTouchPoint( point, timeStamp );
516 void Adaptor::FeedWheelEvent( MouseWheelEvent& wheelEvent )
518 mEventHandler->FeedWheelEvent( wheelEvent );
521 void Adaptor::FeedKeyEvent( KeyEvent& keyEvent )
523 mEventHandler->FeedKeyEvent( keyEvent );
526 bool Adaptor::MoveResize( const PositionSize& positionSize )
528 PositionSize old = mSurface->GetPositionSize();
530 // just resize the surface. The driver should automatically resize the egl Surface (untested)
531 // EGL Spec says : EGL window surfaces need to be resized when their corresponding native window
532 // is resized. Implementations typically use hooks into the OS and native window
533 // system to perform this resizing on demand, transparently to the client.
534 mSurface->MoveResize( positionSize );
536 if(old.width != positionSize.width || old.height != positionSize.height)
538 SurfaceSizeChanged(positionSize);
544 void Adaptor::SurfaceResized( const PositionSize& positionSize )
546 PositionSize old = mSurface->GetPositionSize();
548 // Called by an application, when it has resized a window outside of Dali.
549 // The EGL driver automatically detects X Window resize calls, and resizes
550 // the EGL surface for us.
551 mSurface->MoveResize( positionSize );
553 if(old.width != positionSize.width || old.height != positionSize.height)
555 SurfaceSizeChanged(positionSize);
559 void Adaptor::ReplaceSurface( Dali::RenderSurface& surface )
561 // adaptor implementation needs the implementation of
562 RenderSurface* internalSurface = dynamic_cast<Internal::Adaptor::RenderSurface*>( &surface );
563 DALI_ASSERT_ALWAYS( internalSurface && "Incorrect surface" );
565 ECore::WindowRenderSurface* windowSurface = dynamic_cast<Internal::Adaptor::ECore::WindowRenderSurface*>( &surface);
566 if( windowSurface != NULL )
568 windowSurface->Map();
569 // @todo Restart event handler with new surface
572 mSurface = internalSurface;
574 SurfaceSizeChanged( internalSurface->GetPositionSize() );
576 // flush the event queue to give update and render threads chance
577 // to start processing messages for new camera setup etc as soon as possible
580 mCore->GetContextNotifier()->NotifyContextLost(); // Inform stage
582 // this method blocks until the render thread has completed the replace.
583 mUpdateRenderController->ReplaceSurface(internalSurface);
585 // Inform core, so that texture resources can be reloaded
586 mCore->RecoverFromContextLoss();
588 mCore->GetContextNotifier()->NotifyContextRegained(); // Inform stage
591 Dali::RenderSurface& Adaptor::GetSurface() const
596 void Adaptor::ReleaseSurfaceLock()
598 mSurface->ReleaseLock();
601 Dali::TtsPlayer Adaptor::GetTtsPlayer(Dali::TtsPlayer::Mode mode)
603 if(!mTtsPlayers[mode])
605 // Create the TTS player when it needed, because it can reduce launching time.
606 mTtsPlayers[mode] = TtsPlayer::New(mode);
609 return mTtsPlayers[mode];
612 bool Adaptor::AddIdle( CallbackBase* callback )
614 bool idleAdded(false);
616 // Only add an idle if the Adaptor is actually running
617 if( RUNNING == mState )
619 idleAdded = mCallbackManager->AddCallback( callback, CallbackManager::IDLE_PRIORITY );
625 bool Adaptor::CallFromMainLoop( CallbackBase* callback )
627 bool callAdded(false);
629 // Only allow the callback if the Adaptor is actually running
630 if ( RUNNING == mState )
632 callAdded = mCallbackManager->AddCallback( callback, CallbackManager::DEFAULT_PRIORITY );
638 Dali::Adaptor& Adaptor::Get()
640 DALI_ASSERT_ALWAYS( gThreadLocalAdaptor.get() != NULL && "Adaptor not instantiated" );
641 return gThreadLocalAdaptor->mAdaptor;
644 bool Adaptor::IsAvailable()
646 return gThreadLocalAdaptor.get() != NULL;
649 Dali::Integration::Core& Adaptor::GetCore()
654 void Adaptor::SetRenderRefreshRate( unsigned int numberOfVSyncsPerRender )
656 mUpdateRenderController->SetRenderRefreshRate( numberOfVSyncsPerRender );
659 void Adaptor::SetUseHardwareVSync( bool useHardware )
661 mVSyncMonitor->SetUseHardwareVSync( useHardware );
664 void Adaptor::SetDpi(size_t hDpi, size_t vDpi)
670 EglFactory& Adaptor::GetEGLFactory() const
672 DALI_ASSERT_DEBUG( mEglFactory && "EGL Factory not created" );
676 EglFactoryInterface& Adaptor::GetEGLFactoryInterface() const
681 Integration::GlAbstraction& Adaptor::GetGlAbstraction() const
683 DALI_ASSERT_DEBUG( mGLES && "GLImplementation not created" );
687 Dali::Integration::PlatformAbstraction& Adaptor::GetPlatformAbstractionInterface()
689 return *mPlatformAbstraction;
692 Dali::Integration::GlAbstraction& Adaptor::GetGlesInterface()
697 TriggerEventInterface& Adaptor::GetTriggerEventInterface()
699 return *mNotificationTrigger;
701 TriggerEventFactoryInterface& Adaptor::GetTriggerEventFactoryInterface()
703 return mTriggerEventFactory;
706 SocketFactoryInterface& Adaptor::GetSocketFactoryInterface()
708 return mSocketFactory;
711 RenderSurface* Adaptor::GetRenderSurfaceInterface()
715 VSyncMonitorInterface* Adaptor::GetVSyncMonitorInterface()
717 return mVSyncMonitor;
720 KernelTraceInterface& Adaptor::GetKernelTraceInterface()
722 return mKernelTracer;
725 PerformanceInterface* Adaptor::GetPerformanceInterface()
727 return mPerformanceInterface;
730 Integration::PlatformAbstraction& Adaptor::GetPlatformAbstraction() const
732 DALI_ASSERT_DEBUG( mPlatformAbstraction && "PlatformAbstraction not created" );
733 return *mPlatformAbstraction;
736 void Adaptor::SetDragAndDropDetector( DragAndDropDetectorPtr detector )
738 mDragAndDropDetector = detector;
742 mEventHandler->SetDragAndDropDetector( detector );
746 void Adaptor::SetRotationObserver( RotationObserver* observer )
750 mEventHandler->SetRotationObserver( observer );
752 else if( mState == READY )
754 // Set once event handler exists
755 mDeferredRotationObserver = observer;
759 void Adaptor::DestroyTtsPlayer(Dali::TtsPlayer::Mode mode)
761 if(mTtsPlayers[mode])
763 mTtsPlayers[mode].Reset();
767 void Adaptor::SetMinimumPinchDistance(float distance)
769 if( mGestureManager )
771 mGestureManager->SetMinimumPinchDistance(distance);
776 void Adaptor::AddObserver( LifeCycleObserver& observer )
778 ObserverContainer::iterator match ( find(mObservers.begin(), mObservers.end(), &observer) );
780 if ( match == mObservers.end() )
782 mObservers.push_back( &observer );
786 void Adaptor::RemoveObserver( LifeCycleObserver& observer )
788 ObserverContainer::iterator match ( find(mObservers.begin(), mObservers.end(), &observer) );
790 if ( match != mObservers.end() )
792 mObservers.erase( match );
796 void Adaptor::QueueCoreEvent(const Dali::Integration::Event& event)
800 mCore->QueueEvent(event);
804 void Adaptor::ProcessCoreEvents()
808 if( mPerformanceInterface )
810 mPerformanceInterface->AddMarker( PerformanceInterface::PROCESS_EVENTS_START );
813 mCore->ProcessEvents();
815 if( mPerformanceInterface )
817 mPerformanceInterface->AddMarker( PerformanceInterface::PROCESS_EVENTS_END );
822 void Adaptor::RequestUpdate()
824 // When Dali applications are partially visible behind the lock-screen,
825 // the indicator must be updated (therefore allow updates in the PAUSED state)
826 if ( PAUSED == mState ||
829 mUpdateRenderController->RequestUpdate();
833 void Adaptor::RequestProcessEventsOnIdle()
835 // Only request a notification if the Adaptor is actually running
836 // and we haven't installed the idle notification
837 if( ( ! mNotificationOnIdleInstalled ) && ( RUNNING == mState ) )
839 mNotificationOnIdleInstalled = AddIdle( MakeCallback( this, &Adaptor::ProcessCoreEventsFromIdle ) );
843 void Adaptor::OnWindowShown()
845 if ( PAUSED_WHILE_HIDDEN == mState )
847 // Adaptor can now be resumed
852 // Force a render task
857 void Adaptor::OnWindowHidden()
859 if ( STOPPED != mState )
863 // Adaptor cannot be resumed until the window is shown
864 mState = PAUSED_WHILE_HIDDEN;
868 // Dali::Internal::Adaptor::Adaptor::OnDamaged
869 void Adaptor::OnDamaged( const DamageArea& area )
871 // This is needed for the case where Dali window is partially obscured
875 void Adaptor::SurfaceSizeChanged(const PositionSize& positionSize)
877 // let the core know the surface size has changed
878 mCore->SurfaceResized(positionSize.width, positionSize.height);
880 mResizedSignal.Emit( mAdaptor );
883 void Adaptor::NotifyLanguageChanged()
885 mLanguageChangedSignal.Emit( mAdaptor );
888 void Adaptor::RequestUpdateOnce()
890 if( PAUSED_WHILE_HIDDEN != mState )
892 if( mUpdateRenderController )
894 mUpdateRenderController->RequestUpdateOnce();
899 void Adaptor::ProcessCoreEventsFromIdle()
903 // the idle handle automatically un-installs itself
904 mNotificationOnIdleInstalled = false;
907 Adaptor::Adaptor(Dali::Adaptor& adaptor, RenderSurface* surface, const DeviceLayout& baseLayout)
909 mLanguageChangedSignal(),
913 mUpdateRenderController(NULL),
918 mPlatformAbstraction( NULL ),
919 mEventHandler( NULL ),
920 mCallbackManager( NULL ),
921 mNotificationOnIdleInstalled( false ),
922 mNotificationTrigger(NULL),
923 mGestureManager(NULL),
926 mDaliFeedbackPlugin(NULL),
927 mFeedbackController(NULL),
929 mDragAndDropDetector(),
930 mDeferredRotationObserver(NULL),
931 mBaseLayout(baseLayout),
932 mEnvironmentOptions(),
933 mPerformanceInterface(NULL),
934 mObjectProfiler(NULL)
936 DALI_ASSERT_ALWAYS( gThreadLocalAdaptor.get() == NULL && "Cannot create more than one Adaptor per thread" );
937 gThreadLocalAdaptor.reset(this);
942 void Adaptor::SetViewMode( ViewMode viewMode )
944 mSurface->SetViewMode( viewMode );
945 mCore->SetViewMode( viewMode );
948 ViewMode Adaptor::GetViewMode() const
950 return mCore->GetViewMode();
953 void Adaptor::SetStereoBase( float stereoBase )
955 mCore->SetStereoBase( stereoBase );
958 float Adaptor::GetStereoBase() const
960 return mCore->GetStereoBase();
963 } // namespace Adaptor
965 } // namespace Internal