X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali%2Finternal%2Fadaptor%2Fcommon%2Fadaptor-impl.cpp;h=e6ae520a9f3589428b78445231e6d20bdbb09ab9;hb=cc04adb6b541e4cfd0237e3b12f680f881234cc9;hp=737845d2aae3ce626b3efc79e80834914d2994b0;hpb=5a8431090dc144ea2ae80a103dee3650c53caf32;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 737845d..e6ae520 100755 --- a/dali/internal/adaptor/common/adaptor-impl.cpp +++ b/dali/internal/adaptor/common/adaptor-impl.cpp @@ -17,14 +17,17 @@ // CLASS HEADER #include +#include +#include #include // EXTERNAL INCLUDES #include #include -#include #include #include +#include +#include #include #include #include @@ -35,6 +38,7 @@ #include #include #include +#include // INTERNAL INCLUDES #include @@ -92,7 +96,7 @@ thread_local Adaptor* gThreadLocalAdaptor = NULL; // raw thread specific pointer } // unnamed namespace -Dali::Adaptor* Adaptor::New( Dali::Integration::SceneHolder window, Dali::RenderSurfaceInterface *surface, Dali::Configuration::ContextLoss configuration, EnvironmentOptions* environmentOptions ) +Dali::Adaptor* Adaptor::New( Dali::Integration::SceneHolder window, Dali::RenderSurfaceInterface *surface, EnvironmentOptions* environmentOptions ) { Dali::Adaptor* adaptor = new Dali::Adaptor; Adaptor* impl = new Adaptor( window, *adaptor, surface, environmentOptions ); @@ -101,40 +105,40 @@ Dali::Adaptor* Adaptor::New( Dali::Integration::SceneHolder window, Dali::Render Dali::Internal::Adaptor::AdaptorBuilder* mAdaptorBuilder = new AdaptorBuilder(); auto graphicsFactory = mAdaptorBuilder->GetGraphicsFactory(); - impl->Initialize( graphicsFactory, configuration ); + impl->Initialize( graphicsFactory ); delete mAdaptorBuilder; // Not needed anymore as the graphics interface has now been created return adaptor; } -Dali::Adaptor* Adaptor::New( Dali::Integration::SceneHolder window, Dali::Configuration::ContextLoss configuration, EnvironmentOptions* environmentOptions ) +Dali::Adaptor* Adaptor::New( Dali::Integration::SceneHolder window, EnvironmentOptions* environmentOptions ) { Internal::Adaptor::SceneHolder& windowImpl = Dali::GetImplementation( window ); - Dali::Adaptor* adaptor = New( window, windowImpl.GetSurface(), configuration, environmentOptions ); + Dali::Adaptor* adaptor = New( window, windowImpl.GetSurface(), environmentOptions ); windowImpl.SetAdaptor( *adaptor ); return adaptor; } -Dali::Adaptor* Adaptor::New( GraphicsFactory& graphicsFactory, Dali::Integration::SceneHolder window, Dali::RenderSurfaceInterface *surface, Dali::Configuration::ContextLoss configuration, EnvironmentOptions* environmentOptions ) +Dali::Adaptor* Adaptor::New( GraphicsFactory& graphicsFactory, Dali::Integration::SceneHolder window, Dali::RenderSurfaceInterface *surface, EnvironmentOptions* environmentOptions ) { Dali::Adaptor* adaptor = new Dali::Adaptor; // Public adaptor Adaptor* impl = new Adaptor( window, *adaptor, surface, environmentOptions ); // Impl adaptor adaptor->mImpl = impl; - impl->Initialize( graphicsFactory, configuration ); + impl->Initialize( graphicsFactory ); return adaptor; } // Called second -Dali::Adaptor* Adaptor::New( GraphicsFactory& graphicsFactory, Dali::Integration::SceneHolder window, Dali::Configuration::ContextLoss configuration, EnvironmentOptions* environmentOptions ) +Dali::Adaptor* Adaptor::New( GraphicsFactory& graphicsFactory, Dali::Integration::SceneHolder window, EnvironmentOptions* environmentOptions ) { Internal::Adaptor::SceneHolder& windowImpl = Dali::GetImplementation( window ); - Dali::Adaptor* adaptor = New( graphicsFactory, window, windowImpl.GetSurface(), configuration, environmentOptions ); + Dali::Adaptor* adaptor = New( graphicsFactory, window, windowImpl.GetSurface(), environmentOptions ); windowImpl.SetAdaptor( *adaptor ); return adaptor; } // Called first -void Adaptor::Initialize( GraphicsFactory& graphicsFactory, Dali::Configuration::ContextLoss configuration ) +void Adaptor::Initialize( GraphicsFactory& graphicsFactory ) { // 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 ); @@ -174,6 +178,9 @@ void Adaptor::Initialize( GraphicsFactory& graphicsFactory, Dali::Configuration: EglSyncImplementation& eglSyncImpl = eglGraphics->GetSyncImplementation(); EglContextHelperImplementation& eglContextHelperImpl = eglGraphics->GetContextHelperImplementation(); + // Create the AddOnManager + mAddOnManager.reset( Dali::Internal::AddOnManagerFactory::CreateAddOnManager() ); + mCore = Integration::Core::New( *this, *mPlatformAbstraction, mGLES, @@ -181,7 +188,9 @@ void Adaptor::Initialize( GraphicsFactory& graphicsFactory, Dali::Configuration: eglContextHelperImpl, ( 0u != mEnvironmentOptions->GetRenderToFboInterval() ) ? Integration::RenderToFrameBuffer::TRUE : Integration::RenderToFrameBuffer::FALSE, mGraphics->GetDepthBufferRequired(), - mGraphics->GetStencilBufferRequired() ); + mGraphics->GetStencilBufferRequired(), + mGraphics->GetPartialUpdateRequired() ); + defaultWindow->SetAdaptor( Get() ); @@ -192,14 +201,14 @@ void Adaptor::Initialize( GraphicsFactory& graphicsFactory, Dali::Configuration: const unsigned int timeInterval = mEnvironmentOptions->GetObjectProfilerInterval(); if( 0u < timeInterval ) { - mObjectProfiler = new ObjectProfiler( timeInterval ); + mObjectProfiler = new ObjectProfiler( mCore->GetObjectRegistry(), timeInterval ); } mNotificationTrigger = TriggerEventFactory::CreateTriggerEvent( MakeCallback( this, &Adaptor::ProcessCoreEvents ), TriggerEventInterface::KEEP_ALIVE_AFTER_TRIGGER); mDisplayConnection = Dali::DisplayConnection::New( *mGraphics, defaultWindow->GetSurface()->GetSurfaceType() ); - mThreadController = new ThreadController( *this, *mEnvironmentOptions ); + mThreadController = new ThreadController( *this, *mEnvironmentOptions, mThreadMode ); // Should be called after Core creation if( mEnvironmentOptions->GetPanGestureLoggingLevel() ) @@ -388,7 +397,6 @@ void Adaptor::Start() else { unsigned int maxTextureSize = mConfigurationManager->GetMaxTextureSize(); - setenv( DALI_ENV_MAX_TEXTURE_SIZE, std::to_string( maxTextureSize ).c_str(), 1 ); Dali::TizenPlatform::ImageLoader::SetMaxTextureSize( maxTextureSize ); } @@ -401,6 +409,11 @@ void Adaptor::Start() { (*iter)->OnStart(); } + + if (mAddOnManager) + { + mAddOnManager->Start(); + } } // Dali::Internal::Adaptor::Adaptor::Pause @@ -415,6 +428,12 @@ void Adaptor::Pause() (*iter)->OnPause(); } + // Extensions + if (mAddOnManager) + { + mAddOnManager->Pause(); + } + // Pause all windows event handlers when adaptor paused for( auto window : mWindows ) { @@ -449,6 +468,12 @@ void Adaptor::Resume() window->Resume(); } + // Resume AddOnManager + if (mAddOnManager) + { + mAddOnManager->Resume(); + } + // Inform observers that we have resumed. for( ObserverContainer::iterator iter = mObservers.begin(), endIter = mObservers.end(); iter != endIter; ++iter ) { @@ -480,6 +505,11 @@ void Adaptor::Stop() (*iter)->OnStop(); } + if (mAddOnManager) + { + mAddOnManager->Stop(); + } + mThreadController->Stop(); // Delete the TTS player @@ -524,15 +554,15 @@ void Adaptor::FeedTouchPoint( TouchPoint& point, int timeStamp ) mWindows.front()->FeedTouchPoint( convertedPoint, timeStamp ); } -void Adaptor::FeedWheelEvent( WheelEvent& wheelEvent ) +void Adaptor::FeedWheelEvent( Dali::WheelEvent& wheelEvent ) { - Integration::WheelEvent event( static_cast< Integration::WheelEvent::Type >(wheelEvent.type), wheelEvent.direction, wheelEvent.modifiers, wheelEvent.point, wheelEvent.z, wheelEvent.timeStamp ); + Integration::WheelEvent event( static_cast< Integration::WheelEvent::Type >( wheelEvent.GetType() ), wheelEvent.GetDirection(), wheelEvent.GetModifiers(), wheelEvent.GetPoint(), wheelEvent.GetDelta(), wheelEvent.GetTime() ); mWindows.front()->FeedWheelEvent( event ); } -void Adaptor::FeedKeyEvent( KeyEvent& keyEvent ) +void Adaptor::FeedKeyEvent( Dali::KeyEvent& keyEvent ) { - Integration::KeyEvent convertedEvent( keyEvent ); + Integration::KeyEvent convertedEvent( keyEvent.GetKeyName(), keyEvent.GetLogicalKey(), keyEvent.GetKeyString(), keyEvent.GetKeyCode(), keyEvent.GetKeyModifier(), keyEvent.GetTime(), static_cast< Integration::KeyEvent::State >( keyEvent.GetState() ), keyEvent.GetCompose(), keyEvent.GetDeviceName(), keyEvent.GetDeviceClass(), keyEvent.GetDeviceSubclass() ); mWindows.front()->FeedKeyEvent( convertedEvent ); } @@ -618,11 +648,14 @@ void Adaptor::SetPreRenderCallback( CallbackBase* callback ) mThreadController->SetPreRenderCallback( callback ); } -bool Adaptor::AddWindow( Dali::Integration::SceneHolder childWindow, const std::string& childWindowName, const std::string& childWindowClassName, bool childWindowMode ) +bool Adaptor::AddWindow( Dali::Integration::SceneHolder childWindow ) { Internal::Adaptor::SceneHolder& windowImpl = Dali::GetImplementation( childWindow ); windowImpl.SetAdaptor( Get() ); + // ChildWindow is set to the layout direction of the default window. + windowImpl.GetRootLayer().SetProperty( Dali::Actor::Property::LAYOUT_DIRECTION, mRootLayoutDirection ); + // Add the new Window to the container - the order is not important mWindows.push_back( &windowImpl ); @@ -921,6 +954,11 @@ void Adaptor::OnWindowShown() DALI_LOG_RELEASE_INFO( "Adaptor::OnWindowShown: Update requested.\n" ); } + else if( PAUSED_WHILE_INITIALIZING == mState ) + { + // Change the state to READY again. It will be changed to RUNNING after the adaptor is started. + mState = READY; + } else { DALI_LOG_RELEASE_INFO( "Adaptor::OnWindowShown: Adaptor is not paused state.[%d]\n", mState ); @@ -1030,7 +1068,21 @@ void Adaptor::NotifyLanguageChanged() void Adaptor::RenderOnce() { - RequestUpdateOnce(); + if( mThreadController ) + { + UpdateMode updateMode; + if( mThreadMode == ThreadMode::NORMAL ) + { + updateMode = UpdateMode::NORMAL; + } + else + { + updateMode = UpdateMode::FORCE_RENDER; + + ProcessCoreEvents(); + } + mThreadController->RequestUpdateOnce( updateMode ); + } } const LogFactoryInterface& Adaptor::GetLogFactory() @@ -1115,6 +1167,16 @@ Dali::SceneHolderList Adaptor::GetSceneHolders() const return sceneHolderList; } +Dali::ObjectRegistry Adaptor::GetObjectRegistry() const +{ + Dali::ObjectRegistry registry; + if( mCore ) + { + registry = mCore->GetObjectRegistry(); + } + return registry; +} + Adaptor::Adaptor(Dali::Integration::SceneHolder window, Dali::Adaptor& adaptor, Dali::RenderSurfaceInterface* surface, EnvironmentOptions* environmentOptions) : mResizedSignal(), mLanguageChangedSignal(), @@ -1141,8 +1203,10 @@ Adaptor::Adaptor(Dali::Integration::SceneHolder window, Dali::Adaptor& adaptor, mSystemTracer(), mObjectProfiler( nullptr ), mSocketFactory(), + mThreadMode( ThreadMode::NORMAL ), mEnvironmentOptionsOwned( environmentOptions ? false : true /* If not provided then we own the object */ ), - mUseRemoteSurface( false ) + mUseRemoteSurface( false ), + mRootLayoutDirection( Dali::LayoutDirection::LEFT_TO_RIGHT ) { DALI_ASSERT_ALWAYS( !IsAvailable() && "Cannot create more than one Adaptor per thread" ); mWindows.insert( mWindows.begin(), &Dali::GetImplementation( window ) ); @@ -1152,10 +1216,12 @@ Adaptor::Adaptor(Dali::Integration::SceneHolder window, Dali::Adaptor& adaptor, void Adaptor::SetRootLayoutDirection( std::string locale ) { - 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 ) ) ) ); + mRootLayoutDirection = static_cast< LayoutDirection::Type >( Internal::Adaptor::Locale::GetDirection( std::string( locale ) ) ); + for ( auto& window : mWindows ) + { + Dali::Actor root = window->GetRootLayer(); + root.SetProperty( Dali::Actor::Property::LAYOUT_DIRECTION, mRootLayoutDirection ); + } } bool Adaptor::AddIdleEnterer( CallbackBase* callback, bool forceAdd ) @@ -1168,6 +1234,12 @@ bool Adaptor::AddIdleEnterer( CallbackBase* callback, bool forceAdd ) idleAdded = mCallbackManager->AddIdleEntererCallback( callback ); } + if( !idleAdded ) + { + // Delete callback + delete callback; + } + return idleAdded; }