X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali%2Finternal%2Fadaptor%2Fcommon%2Fadaptor-impl.cpp;h=e8683a59b5e7b1c082377e189a1c5e068e9f9a8a;hb=263ec21432f3d7c9f9be5b463748fdce8f6942e4;hp=af8a13e433c5f6f0bf5dc26d84086b5ceee2006c;hpb=92f60124b92e64ffb911a071e5493d3248ebf5ef;p=platform%2Fcore%2Fuifw%2Fdali-adaptor.git diff --git a/dali/internal/adaptor/common/adaptor-impl.cpp b/dali/internal/adaptor/common/adaptor-impl.cpp index af8a13e..e8683a5 100755 --- a/dali/internal/adaptor/common/adaptor-impl.cpp +++ b/dali/internal/adaptor/common/adaptor-impl.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018 Samsung Electronics Co., Ltd. + * Copyright (c) 2019 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,10 +17,12 @@ // CLASS HEADER #include +#include // EXTERNAL INCLUDES #include #include +#include #include #include #include @@ -28,6 +30,7 @@ #include #include #include +#include // INTERNAL INCLUDES #include @@ -35,6 +38,9 @@ #include #include +#include +#include // Temporary until Core is abstracted + #include #include @@ -42,11 +48,10 @@ #include #include #include -#include -#include -#include +#include +#include +#include #include -#include #include #include #include @@ -55,9 +60,11 @@ #include #include -#include #include +#include +#include + using Dali::TextAbstraction::FontClient; @@ -75,13 +82,18 @@ namespace thread_local Adaptor* gThreadLocalAdaptor = NULL; // raw thread specific pointer to allow Adaptor::Get } // unnamed namespace -Dali::Adaptor* Adaptor::New( Any nativeWindow, RenderSurface *surface, Dali::Configuration::ContextLoss configuration, EnvironmentOptions* environmentOptions ) + +Dali::Adaptor* Adaptor::New( Any nativeWindow, Dali::RenderSurfaceInterface *surface, Dali::Configuration::ContextLoss configuration, EnvironmentOptions* environmentOptions ) { Dali::Adaptor* adaptor = new Dali::Adaptor; Adaptor* impl = new Adaptor( nativeWindow, *adaptor, surface, environmentOptions ); adaptor->mImpl = impl; - impl->Initialize(configuration); + Dali::Internal::Adaptor::AdaptorBuilder* mAdaptorBuilder = new AdaptorBuilder(); + auto graphicsFactory = mAdaptorBuilder->GetGraphicsFactory(); + + impl->Initialize( graphicsFactory, configuration ); + delete mAdaptorBuilder; // Not needed anymore as the graphics interface has now been created return adaptor; } @@ -90,13 +102,34 @@ Dali::Adaptor* Adaptor::New( Dali::Window window, Dali::Configuration::ContextLo { Any winId = window.GetNativeHandle(); - Window& windowImpl = Dali::GetImplementation(window); + Window& windowImpl = Dali::GetImplementation( window ); Dali::Adaptor* adaptor = New( winId, windowImpl.GetSurface(), configuration, environmentOptions ); - windowImpl.SetAdaptor(*adaptor); + windowImpl.SetAdaptor( *adaptor ); return adaptor; } -void Adaptor::Initialize( Dali::Configuration::ContextLoss configuration ) +Dali::Adaptor* Adaptor::New( GraphicsFactory& graphicsFactory, Any nativeWindow, Dali::RenderSurfaceInterface *surface, Dali::Configuration::ContextLoss configuration, EnvironmentOptions* environmentOptions ) +{ + Dali::Adaptor* adaptor = new Dali::Adaptor; // Public adaptor + Adaptor* impl = new Adaptor( nativeWindow, *adaptor, surface, environmentOptions ); // Impl adaptor + adaptor->mImpl = impl; + + impl->Initialize( graphicsFactory, configuration ); + + return adaptor; +} // Called second + +Dali::Adaptor* Adaptor::New( GraphicsFactory& graphicsFactory, Dali::Window window, Dali::Configuration::ContextLoss configuration, EnvironmentOptions* environmentOptions ) +{ + Any winId = window.GetNativeHandle(); + + Window& windowImpl = Dali::GetImplementation( window ); + Dali::Adaptor* adaptor = New( graphicsFactory, winId, windowImpl.GetSurface(), configuration, environmentOptions ); + windowImpl.SetAdaptor( *adaptor ); + return adaptor; +} // Called first + +void Adaptor::Initialize( GraphicsFactory& graphicsFactory, Dali::Configuration::ContextLoss configuration ) { // all threads here (event, update, and render) will send their logs to TIZEN Platform's LogMessage handler. Dali::Integration::Log::LogFunction logFunction( Dali::TizenPlatform::LogMessage ); @@ -114,8 +147,8 @@ void Adaptor::Initialize( Dali::Configuration::ContextLoss configuration ) { dataRetentionPolicy = ResourcePolicy::DALI_DISCARDS_ALL_DATA; } - // Note, Tizen does not use DALI_RETAINS_ALL_DATA, as it can reload images from - // files automatically. + + // Note, Tizen does not use DALI_RETAINS_ALL_DATA, as it can reload images from files automatically. if( mEnvironmentOptions->PerformanceServerRequired() ) { @@ -127,35 +160,36 @@ void Adaptor::Initialize( Dali::Configuration::ContextLoss configuration ) mCallbackManager = CallbackManager::New(); - PositionSize size = mSurface->GetPositionSize(); + WindowPane defaultWindow = mWindowFrame.front(); + + DALI_ASSERT_DEBUG( defaultWindow.surface && "Surface not initialized" ); + + PositionSize size = defaultWindow.surface->GetPositionSize(); + + defaultWindow.surface->SetAdaptor(*this); mGestureManager = new GestureManager(*this, Vector2(size.width, size.height), mCallbackManager, *mEnvironmentOptions); - if( mEnvironmentOptions->GetGlesCallTime() > 0 ) - { - mGLES = new GlProxyImplementation( *mEnvironmentOptions ); - } - else - { - mGLES = new GlImplementation(); - } + mGraphics = &( graphicsFactory.Create() ); + mGraphics->Initialize( mEnvironmentOptions ); - const Integration::DepthBufferAvailable depthBufferAvailable = static_cast< Integration::DepthBufferAvailable >( mEnvironmentOptions->DepthBufferRequired() ); - const Integration::StencilBufferAvailable stencilBufferAvailable = static_cast< Integration::StencilBufferAvailable >( mEnvironmentOptions->StencilBufferRequired() ); + auto eglGraphics = static_cast( mGraphics ); // This interface is temporary until Core has been updated to match - mEglFactory = new EglFactory( mEnvironmentOptions->GetMultiSamplingLevel(), depthBufferAvailable, stencilBufferAvailable ); + // This will only be created once + eglGraphics->Create(); - EglSyncImplementation* eglSyncImpl = mEglFactory->GetSyncImplementation(); + GlImplementation& mGLES = eglGraphics->GetGlesInterface(); + EglSyncImplementation& eglSyncImpl = eglGraphics->GetSyncImplementation(); mCore = Integration::Core::New( *this, *mPlatformAbstraction, - *mGLES, - *eglSyncImpl, + mGLES, + eglSyncImpl, *mGestureManager, dataRetentionPolicy , ( 0u != mEnvironmentOptions->GetRenderToFboInterval() ) ? Integration::RenderToFrameBuffer::TRUE : Integration::RenderToFrameBuffer::FALSE, - depthBufferAvailable, - stencilBufferAvailable ); + mGraphics->GetDepthBufferRequired(), + mGraphics->GetStencilBufferRequired() ); const unsigned int timeInterval = mEnvironmentOptions->GetObjectProfilerInterval(); if( 0u < timeInterval ) @@ -167,6 +201,8 @@ void Adaptor::Initialize( Dali::Configuration::ContextLoss configuration ) mVSyncMonitor = new VSyncMonitor; + mDisplayConnection = Dali::DisplayConnection::New( *mGraphics, defaultWindow.surface->GetSurfaceType() ); + mThreadController = new ThreadController( *this, *mEnvironmentOptions ); // Should be called after Core creation @@ -238,10 +274,8 @@ void Adaptor::Initialize( Dali::Configuration::ContextLoss configuration ) // Set max texture size if( mEnvironmentOptions->GetMaxTextureSize() > 0 ) { - Dali::SetMaxTextureSize( mEnvironmentOptions->GetMaxTextureSize() ); + Dali::TizenPlatform::ImageLoader::SetMaxTextureSize( mEnvironmentOptions->GetMaxTextureSize() ); } - - SetupSystemInformation(); } Adaptor::~Adaptor() @@ -263,13 +297,15 @@ Adaptor::~Adaptor() delete mObjectProfiler; delete mCore; - delete mEglFactory; - delete mGLES; + delete mGestureManager; + delete mDisplayConnection; delete mPlatformAbstraction; delete mCallbackManager; delete mPerformanceInterface; + mGraphics->Destroy(); + // uninstall it on this thread (main actor thread) Dali::Integration::Log::UninstallLogFunction(); @@ -282,18 +318,23 @@ Adaptor::~Adaptor() void Adaptor::Start() { - // it doesn't support restart after stop at this moment - // to support restarting, need more testing + // It doesn't support restart after stop at this moment to support restarting, need more testing if( READY != mState ) { return; } + mCore->Initialize(); + + SetupSystemInformation(); + // Start the callback manager mCallbackManager->Start(); - // create event handler - mEventHandler = new EventHandler( mSurface, *this, *mGestureManager, *this, mDragAndDropDetector ); + WindowPane defaultWindow = mWindowFrame.front(); + + // Create event handler + mEventHandler = new EventHandler( defaultWindow.surface, *this, *mGestureManager, *this, mDragAndDropDetector ); if( mDeferredRotationObserver != NULL ) { @@ -303,24 +344,24 @@ void Adaptor::Start() unsigned int dpiHor, dpiVer; dpiHor = dpiVer = 0; - mSurface->GetDpi( dpiHor, dpiVer ); - // tell core about the DPI value - mCore->SetDpi(dpiHor, dpiVer); + defaultWindow.surface->GetDpi( dpiHor, dpiVer ); // set the DPI value for font rendering FontClient fontClient = FontClient::Get(); fontClient.SetDpi( dpiHor, dpiVer ); // Tell the core the size of the surface just before we start the render-thread - PositionSize size = mSurface->GetPositionSize(); - mCore->SurfaceResized( size.width, size.height ); + mCore->SurfaceResized( defaultWindow.surface ); // Initialize the thread controller mThreadController->Initialize(); ProcessCoreEvents(); // Ensure any startup messages are processed. + // Initialize the image loader plugin + Internal::Adaptor::ImageLoaderPluginProxy::Initialize(); + for ( ObserverContainer::iterator iter = mObservers.begin(), endIter = mObservers.end(); iter != endIter; ++iter ) { (*iter)->OnStart(); @@ -350,6 +391,12 @@ void Adaptor::Pause() // Ensure any messages queued during pause callbacks are processed by doing another update. RequestUpdateOnce(); + + DALI_LOG_RELEASE_INFO( "Adaptor::Pause: Paused\n" ); + } + else + { + DALI_LOG_RELEASE_INFO( "Adaptor::Pause: Not paused [%d]\n", mState ); } } @@ -373,11 +420,17 @@ void Adaptor::Resume() (*iter)->OnResume(); } - // trigger processing of events queued up while paused + // Trigger processing of events queued up while paused mCore->ProcessEvents(); // Do at end to ensure our first update/render after resumption includes the processed messages as well mThreadController->Resume(); + + DALI_LOG_RELEASE_INFO( "Adaptor::Resume: Resumed\n"); + } + else + { + DALI_LOG_RELEASE_INFO( "Adaptor::Resume: Not resumed [%d]\n", mState ); } } @@ -394,6 +447,9 @@ void Adaptor::Stop() mThreadController->Stop(); + // Clear out all the handles to Windows + mWindowFrame.clear(); + // Delete the TTS player for(int i =0; i < Dali::TtsPlayer::MODE_NUM; i++) { @@ -403,6 +459,9 @@ void Adaptor::Stop() } } + // Destroy the image loader plugin + Internal::Adaptor::ImageLoaderPluginProxy::Destroy(); + delete mEventHandler; mEventHandler = NULL; @@ -412,6 +471,8 @@ void Adaptor::Stop() mCallbackManager->Stop(); mState = STOPPED; + + DALI_LOG_RELEASE_INFO( "Adaptor::Stop\n" ); } } @@ -443,34 +504,46 @@ void Adaptor::FeedKeyEvent( KeyEvent& keyEvent ) mEventHandler->FeedKeyEvent( keyEvent ); } -void Adaptor::ReplaceSurface( Any nativeWindow, RenderSurface& surface ) +void Adaptor::ReplaceSurface( Any nativeWindow, Dali::RenderSurfaceInterface& newSurface ) { - PositionSize positionSize = surface.GetPositionSize(); - - // let the core know the surface size has changed - mCore->SurfaceResized( positionSize.width, positionSize.height ); + // Let the core know the surface size has changed + mCore->SurfaceResized( &newSurface ); mResizedSignal.Emit( mAdaptor ); - mNativeWindow = nativeWindow; - mSurface = &surface; + WindowPane newDefaultWindow; + newDefaultWindow.nativeWindow = nativeWindow; + newDefaultWindow.surface = &newSurface; + newDefaultWindow.surface->SetAdaptor(*this); + + WindowPane oldDefaultWindow = mWindowFrame.front(); + + // Update WindowFrame + std::vector::iterator iter = mWindowFrame.begin(); + iter = mWindowFrame.insert( iter, newDefaultWindow ); - // flush the event queue to give the update-render thread chance + // Flush the event queue to give the update-render thread chance // to start processing messages for new camera setup etc as soon as possible ProcessCoreEvents(); - // this method blocks until the render thread has completed the replace. - mThreadController->ReplaceSurface(mSurface); + // This method blocks until the render thread has completed the replace. + mThreadController->ReplaceSurface( newDefaultWindow.surface ); + + // Must delete the old Window only after the render thread has completed the replace + oldDefaultWindow.surface->DestroySurface(); + oldDefaultWindow.surface = nullptr; } -RenderSurface& Adaptor::GetSurface() const +Dali::RenderSurfaceInterface& Adaptor::GetSurface() const { - return *mSurface; + WindowPane defaultWindow = mWindowFrame.front(); + return *(defaultWindow.surface); } void Adaptor::ReleaseSurfaceLock() { - mSurface->ReleaseLock(); + WindowPane defaultWindow = mWindowFrame.front(); + defaultWindow.surface->ReleaseLock(); } Dali::TtsPlayer Adaptor::GetTtsPlayer(Dali::TtsPlayer::Mode mode) @@ -484,14 +557,14 @@ Dali::TtsPlayer Adaptor::GetTtsPlayer(Dali::TtsPlayer::Mode mode) return mTtsPlayers[mode]; } -bool Adaptor::AddIdle( CallbackBase* callback, bool forceAdd ) +bool Adaptor::AddIdle( CallbackBase* callback, bool hasReturnValue, bool forceAdd ) { bool idleAdded(false); // Only add an idle if the Adaptor is actually running if( RUNNING == mState || READY == mState || forceAdd ) { - idleAdded = mCallbackManager->AddIdleCallback( callback ); + idleAdded = mCallbackManager->AddIdleCallback( callback, hasReturnValue ); } return idleAdded; @@ -502,6 +575,73 @@ void Adaptor::RemoveIdle( CallbackBase* callback ) mCallbackManager->RemoveIdleCallback( callback ); } +void Adaptor::SetPreRenderCallback( CallbackBase* callback ) +{ + mThreadController->SetPreRenderCallback( callback ); +} + +bool Adaptor::AddWindow( Dali::Window* childWindow, const std::string& childWindowName, const std::string& childWindowClassName, const bool& childWindowMode ) +{ + Window& windowImpl = Dali::GetImplementation( *childWindow ); + windowImpl.SetAdaptor( Get() ); + + // This is any Window that is not the main (default) one + WindowPane additionalWindow; + additionalWindow.instance = childWindow; + additionalWindow.window_name = childWindowName; + additionalWindow.class_name = childWindowClassName; + additionalWindow.window_mode = childWindowMode; + additionalWindow.surface = windowImpl.GetSurface(); + additionalWindow.id = windowImpl.GetId(); + + // Add the new Window to the Frame - the order is not important + mWindowFrame.push_back( additionalWindow ); + + return true; +} + +bool Adaptor::RemoveWindow( Dali::Window* childWindow ) +{ + for ( WindowFrames::iterator iter = mWindowFrame.begin(); iter != mWindowFrame.end(); ++iter ) + { + if( iter->instance == childWindow ) + { + mWindowFrame.erase( iter ); + return true; + } + } + + return false; +} + +bool Adaptor::RemoveWindow( std::string childWindowName ) +{ + for ( WindowFrames::iterator iter = mWindowFrame.begin(); iter != mWindowFrame.end(); ++iter ) + { + if( iter->window_name == childWindowName ) + { + mWindowFrame.erase( iter ); + return true; + } + } + + return false; +} + +bool Adaptor::RemoveWindow( Window* childWindow ) +{ + for ( WindowFrames::iterator iter = mWindowFrame.begin(); iter != mWindowFrame.end(); ++iter ) + { + if( iter->id == childWindow->GetId() ) + { + mWindowFrame.erase( iter ); + return true; + } + } + + return false; +} + Dali::Adaptor& Adaptor::Get() { DALI_ASSERT_ALWAYS( IsAvailable() && "Adaptor not instantiated" ); @@ -533,21 +673,16 @@ void Adaptor::SetUseHardwareVSync( bool useHardware ) mVSyncMonitor->SetUseHardwareVSync( useHardware ); } -EglFactory& Adaptor::GetEGLFactory() const +Dali::DisplayConnection& Adaptor::GetDisplayConnectionInterface() { - DALI_ASSERT_DEBUG( mEglFactory && "EGL Factory not created" ); - return *mEglFactory; + DALI_ASSERT_DEBUG( mDisplayConnection && "Display connection not created" ); + return *mDisplayConnection; } -EglFactoryInterface& Adaptor::GetEGLFactoryInterface() const +GraphicsInterface& Adaptor::GetGraphicsInterface() { - return *mEglFactory; -} - -Integration::GlAbstraction& Adaptor::GetGlAbstraction() const -{ - DALI_ASSERT_DEBUG( mGLES && "GLImplementation not created" ); - return *mGLES; + DALI_ASSERT_DEBUG( mGraphics && "Graphics interface not created" ); + return *mGraphics; } Dali::Integration::PlatformAbstraction& Adaptor::GetPlatformAbstractionInterface() @@ -555,11 +690,6 @@ Dali::Integration::PlatformAbstraction& Adaptor::GetPlatformAbstractionInterface return *mPlatformAbstraction; } -Dali::Integration::GlAbstraction& Adaptor::GetGlesInterface() -{ - return *mGLES; -} - TriggerEventInterface& Adaptor::GetProcessCoreEventsTrigger() { return *mNotificationTrigger; @@ -575,9 +705,17 @@ SocketFactoryInterface& Adaptor::GetSocketFactoryInterface() return mSocketFactory; } -RenderSurface* Adaptor::GetRenderSurfaceInterface() +Dali::RenderSurfaceInterface* Adaptor::GetRenderSurfaceInterface() { - return mSurface; + if( !mWindowFrame.empty()) + { + WindowPane defaultWindow = mWindowFrame.front(); + return defaultWindow.surface; + } + else + { + return nullptr; + } } VSyncMonitorInterface* Adaptor::GetVSyncMonitorInterface() @@ -647,7 +785,23 @@ void Adaptor::SetMinimumPinchDistance(float distance) Any Adaptor::GetNativeWindowHandle() { - return mNativeWindow; + WindowPane defaultWindow = mWindowFrame.front(); + return defaultWindow.nativeWindow; +} + +Any Adaptor::GetGraphicsDisplay() +{ + Any display; + + if (mGraphics) + { + auto eglGraphics = static_cast( mGraphics ); // This interface is temporary until Core has been updated to match + + EglImplementation& eglImpl = eglGraphics->GetEglImplementation(); + display = eglImpl.GetDisplay(); + } + + return display; } void Adaptor::SetUseRemoteSurface(bool useRemoteSurface) @@ -735,7 +889,7 @@ void Adaptor::RequestProcessEventsOnIdle( bool forceProcess ) // and we haven't installed the idle notification if( ( ! mNotificationOnIdleInstalled ) && ( RUNNING == mState || READY == mState || forceProcess ) ) { - mNotificationOnIdleInstalled = AddIdle( MakeCallback( this, &Adaptor::ProcessCoreEventsFromIdle ), forceProcess ); + mNotificationOnIdleInstalled = AddIdleEnterer( MakeCallback( this, &Adaptor::ProcessCoreEventsFromIdle ), forceProcess ); } } @@ -751,6 +905,10 @@ void Adaptor::OnWindowShown() // Force a render task RequestUpdateOnce(); } + else + { + DALI_LOG_RELEASE_INFO( "Adaptor::OnWindowShown: Not shown [%d]\n", mState ); + } } void Adaptor::OnWindowHidden() @@ -762,6 +920,10 @@ void Adaptor::OnWindowHidden() // Adaptor cannot be resumed until the window is shown mState = PAUSED_WHILE_HIDDEN; } + else + { + DALI_LOG_RELEASE_INFO( "Adaptor::OnWindowHidden: Not hidden [%d]\n", mState ); + } } // Dali::Internal::Adaptor::Adaptor::OnDamaged @@ -771,21 +933,20 @@ void Adaptor::OnDamaged( const DamageArea& area ) RequestUpdate( false ); } -void Adaptor::SurfaceResizePrepare( SurfaceSize surfaceSize ) +void Adaptor::SurfaceResizePrepare( Dali::RenderSurfaceInterface* surface, SurfaceSize surfaceSize ) { - // let the core know the surface size has changed - mCore->SurfaceResized( surfaceSize.GetWidth(), surfaceSize.GetHeight() ); + // Let the core know the surface size has changed + mCore->SurfaceResized( surface ); mResizedSignal.Emit( mAdaptor ); } -void Adaptor::SurfaceResizeComplete( SurfaceSize surfaceSize ) +void Adaptor::SurfaceResizeComplete( Dali::RenderSurfaceInterface* surface, SurfaceSize surfaceSize ) { - // flush the event queue to give the update-render thread chance + // Flush the event queue to give the update-render thread chance // to start processing messages for new camera setup etc as soon as possible ProcessCoreEvents(); - // this method blocks until the render thread has completed the resizing. mThreadController->ResizeSurface(); } @@ -793,13 +954,19 @@ void Adaptor::NotifySceneCreated() { GetCore().SceneCreated(); + // Flush the event queue to give the update-render thread chance + // to start processing messages for new camera setup etc as soon as possible + ProcessCoreEvents(); + // Start thread controller after the scene has been created mThreadController->Start(); - // process after surface is created (registering to remote surface provider if required) + // Process after surface is created (registering to remote surface provider if required) SurfaceInitialized(); mState = RUNNING; + + DALI_LOG_RELEASE_INFO( "Adaptor::NotifySceneCreated\n" ); } void Adaptor::NotifyLanguageChanged() @@ -817,6 +984,16 @@ const LogFactoryInterface& Adaptor::GetLogFactory() return *mEnvironmentOptions; } +void Adaptor::RegisterProcessor( Integration::Processor& processor ) +{ + GetCore().RegisterProcessor(processor); +} + +void Adaptor::UnregisterProcessor( Integration::Processor& processor ) +{ + GetCore().UnregisterProcessor(processor); +} + void Adaptor::RequestUpdateOnce() { if( mThreadController ) @@ -825,88 +1002,86 @@ void Adaptor::RequestUpdateOnce() } } -void Adaptor::IndicatorSizeChanged(int height) -{ - // let the core know the indicator height is changed - mCore->SetTopMargin(height); -} - -void Adaptor::ProcessCoreEventsFromIdle() +bool Adaptor::ProcessCoreEventsFromIdle() { ProcessCoreEvents(); // the idle handle automatically un-installs itself mNotificationOnIdleInstalled = false; + + return false; } -Adaptor::Adaptor(Any nativeWindow, Dali::Adaptor& adaptor, RenderSurface* surface, EnvironmentOptions* environmentOptions) +Adaptor::Adaptor(Any nativeWindow, Dali::Adaptor& adaptor, Dali::RenderSurfaceInterface* surface, EnvironmentOptions* environmentOptions) : mResizedSignal(), mLanguageChangedSignal(), mAdaptor( adaptor ), mState( READY ), - mCore( NULL ), - mThreadController( NULL ), - mVSyncMonitor( NULL ), - mGLES( NULL ), - mGlSync( NULL ), - mEglFactory( NULL ), - mNativeWindow( nativeWindow ), - mSurface( surface ), - mPlatformAbstraction( NULL ), - mEventHandler( NULL ), - mCallbackManager( NULL ), + mCore( nullptr ), + mThreadController( nullptr ), + mVSyncMonitor( nullptr ), + mGraphics( nullptr ), + mDisplayConnection( nullptr ), + mWindowFrame(), + mPlatformAbstraction( nullptr ), + mEventHandler( nullptr ), + mCallbackManager( nullptr ), mNotificationOnIdleInstalled( false ), - mNotificationTrigger( NULL ), - mGestureManager( NULL ), + mNotificationTrigger( nullptr ), + mGestureManager( nullptr ), mDaliFeedbackPlugin(), - mFeedbackController( NULL ), + mFeedbackController( nullptr ), mTtsPlayers(), mObservers(), mDragAndDropDetector(), - mDeferredRotationObserver( NULL ), + mDeferredRotationObserver( nullptr ), mEnvironmentOptions( environmentOptions ? environmentOptions : new EnvironmentOptions /* Create the options if not provided */), - mPerformanceInterface( NULL ), + mPerformanceInterface( nullptr ), mKernelTracer(), mSystemTracer(), mTriggerEventFactory(), - mObjectProfiler( NULL ), + mObjectProfiler( nullptr ), mSocketFactory(), mEnvironmentOptionsOwned( environmentOptions ? false : true /* If not provided then we own the object */ ), mUseRemoteSurface( false ) { DALI_ASSERT_ALWAYS( !IsAvailable() && "Cannot create more than one Adaptor per thread" ); - gThreadLocalAdaptor = this; -} -// Stereoscopy + WindowPane defaultWindow; + defaultWindow.nativeWindow = nativeWindow; + defaultWindow.surface = surface; + defaultWindow.id = 0; -void Adaptor::SetViewMode( ViewMode viewMode ) -{ - mSurface->SetViewMode( viewMode ); - mCore->SetViewMode( viewMode ); -} + std::vector::iterator iter = mWindowFrame.begin(); + iter = mWindowFrame.insert( iter, defaultWindow ); -ViewMode Adaptor::GetViewMode() const -{ - return mCore->GetViewMode(); + gThreadLocalAdaptor = this; } -void Adaptor::SetStereoBase( float stereoBase ) +void Adaptor::SetRootLayoutDirection( std::string locale ) { - mCore->SetStereoBase( stereoBase ); + Dali::Stage stage = Dali::Stage::GetCurrent(); + + stage.GetRootLayer().SetProperty( Dali::Actor::Property::LAYOUT_DIRECTION, + static_cast< LayoutDirection::Type >( Internal::Adaptor::Locale::GetDirection( std::string( locale ) ) ) ); } -float Adaptor::GetStereoBase() const +bool Adaptor::AddIdleEnterer( CallbackBase* callback, bool forceAdd ) { - return mCore->GetStereoBase(); + bool idleAdded( false ); + + // Only add an idle if the Adaptor is actually running + if( RUNNING == mState || READY == mState || forceAdd ) + { + idleAdded = mCallbackManager->AddIdleEntererCallback( callback ); + } + + return idleAdded; } -void Adaptor::SetRootLayoutDirection( std::string locale ) +void Adaptor::RemoveIdleEnterer( CallbackBase* callback ) { - Dali::Stage stage = Dali::Stage::GetCurrent(); - - stage.GetRootLayer().SetProperty( Dali::Actor::Property::LAYOUT_DIRECTION, - static_cast< LayoutDirection::Type >( Internal::Adaptor::Locale::GetDirection( std::string( locale ) ) ) ); + mCallbackManager->RemoveIdleEntererCallback( callback ); } } // namespace Adaptor