X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=adaptors%2Fcommon%2Fadaptor-impl.cpp;h=0c7c4e4b50e16105177e20fb7df9297f4bf6c518;hb=62911dcd069b5cfebc0f2589621cd1620e570997;hp=a97a6afaa677574ae9d376a0a5f9ec399046fbbd;hpb=13a89dfbeb961e9f3b5e9701290b1c0eac0e86ff;p=platform%2Fcore%2Fuifw%2Fdali-adaptor.git diff --git a/adaptors/common/adaptor-impl.cpp b/adaptors/common/adaptor-impl.cpp index a97a6af..0c7c4e4 100644 --- a/adaptors/common/adaptor-impl.cpp +++ b/adaptors/common/adaptor-impl.cpp @@ -20,6 +20,9 @@ // EXTERNAL INCLUDES #include +#include +#include +#include #include #include #include @@ -29,7 +32,7 @@ // INTERNAL INCLUDES #include -# include +#include #include #include @@ -53,6 +56,9 @@ #include #include +#include + +#include using Dali::TextAbstraction::FontClient; @@ -67,7 +73,7 @@ namespace Adaptor namespace { -__thread Adaptor* gThreadLocalAdaptor = NULL; // raw thread specific pointer to allow Adaptor::Get +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 ) @@ -87,6 +93,8 @@ Dali::Adaptor* Adaptor::New( Dali::Window window, Dali::Configuration::ContextLo Window& windowImpl = Dali::GetImplementation(window); Dali::Adaptor* adaptor = New( winId, windowImpl.GetSurface(), configuration, environmentOptions ); + + Internal::Adaptor::Adaptor::GetImplementation( *adaptor ).SetWindow( window ); windowImpl.SetAdaptor(*adaptor); return adaptor; } @@ -136,7 +144,13 @@ void Adaptor::Initialize( Dali::Configuration::ContextLoss configuration ) EglSyncImplementation* eglSyncImpl = mEglFactory->GetSyncImplementation(); - mCore = Integration::Core::New( *this, *mPlatformAbstraction, *mGLES, *eglSyncImpl, *mGestureManager, dataRetentionPolicy ); + mCore = Integration::Core::New( *this, + *mPlatformAbstraction, + *mGLES, + *eglSyncImpl, + *mGestureManager, + dataRetentionPolicy , + 0u != mEnvironmentOptions->GetRenderToFboInterval() ); const unsigned int timeInterval = mEnvironmentOptions->GetObjectProfilerInterval(); if( 0u < timeInterval ) @@ -183,6 +197,14 @@ void Adaptor::Initialize( Dali::Configuration::ContextLoss configuration ) { Integration::SetPanGestureSmoothingAmount(mEnvironmentOptions->GetPanGestureSmoothingAmount()); } + + // Set max texture size + if( mEnvironmentOptions->GetMaxTextureSize() > 0 ) + { + Dali::SetMaxTextureSize( mEnvironmentOptions->GetMaxTextureSize() ); + } + + SetupSystemInformation(); } Adaptor::~Adaptor() @@ -260,8 +282,6 @@ void Adaptor::Start() // Initialize the thread controller mThreadController->Initialize(); - mState = RUNNING; - ProcessCoreEvents(); // Ensure any startup messages are processed. for ( ObserverContainer::iterator iter = mObservers.begin(), endIter = mObservers.end(); iter != endIter; ++iter ) @@ -289,8 +309,10 @@ void Adaptor::Pause() } mThreadController->Pause(); - mCore->Suspend(); mState = PAUSED; + + // Process remained events and rendering in the update thread + RequestUpdateOnce(); } } @@ -314,8 +336,8 @@ void Adaptor::Resume() (*iter)->OnResume(); } - // Resume core so it processes any requests as well - mCore->Resume(); + // 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(); @@ -334,7 +356,6 @@ void Adaptor::Stop() } mThreadController->Stop(); - mCore->Suspend(); // Delete the TTS player for(int i =0; i < Dali::TtsPlayer::MODE_NUM; i++) @@ -387,10 +408,17 @@ void Adaptor::FeedKeyEvent( KeyEvent& keyEvent ) void Adaptor::ReplaceSurface( Any nativeWindow, RenderSurface& surface ) { + PositionSize positionSize = surface.GetPositionSize(); + + // let the core know the surface size has changed + mCore->SurfaceResized( positionSize.width, positionSize.height ); + + mResizedSignal.Emit( mAdaptor ); + mNativeWindow = nativeWindow; mSurface = &surface; - // flush the event queue to give update and render threads 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(); @@ -419,12 +447,12 @@ Dali::TtsPlayer Adaptor::GetTtsPlayer(Dali::TtsPlayer::Mode mode) return mTtsPlayers[mode]; } -bool Adaptor::AddIdle( CallbackBase* callback ) +bool Adaptor::AddIdle( CallbackBase* callback, bool forceAdd ) { bool idleAdded(false); // Only add an idle if the Adaptor is actually running - if( RUNNING == mState ) + if( RUNNING == mState || forceAdd ) { idleAdded = mCallbackManager->AddIdleCallback( callback ); } @@ -636,24 +664,41 @@ void Adaptor::ProcessCoreEvents() } } -void Adaptor::RequestUpdate() +void Adaptor::RequestUpdate( bool forceUpdate ) { - // When Dali applications are partially visible behind the lock-screen, - // the indicator must be updated (therefore allow updates in the PAUSED state) - if ( PAUSED == mState || - RUNNING == mState ) + switch( mState ) { - mThreadController->RequestUpdate(); + case RUNNING: + { + mThreadController->RequestUpdate(); + break; + } + case PAUSED: + case PAUSED_WHILE_HIDDEN: + { + // When Dali applications are partially visible behind the lock-screen, + // the indicator must be updated (therefore allow updates in the PAUSED state) + if( forceUpdate ) + { + mThreadController->RequestUpdateOnce(); + } + break; + } + default: + { + // Do nothing + break; + } } } -void Adaptor::RequestProcessEventsOnIdle() +void Adaptor::RequestProcessEventsOnIdle( bool forceProcess ) { // Only request a notification if the Adaptor is actually running // and we haven't installed the idle notification - if( ( ! mNotificationOnIdleInstalled ) && ( RUNNING == mState ) ) + if( ( ! mNotificationOnIdleInstalled ) && ( RUNNING == mState || forceProcess ) ) { - mNotificationOnIdleInstalled = AddIdle( MakeCallback( this, &Adaptor::ProcessCoreEventsFromIdle ) ); + mNotificationOnIdleInstalled = AddIdle( MakeCallback( this, &Adaptor::ProcessCoreEventsFromIdle ), forceProcess ); } } @@ -673,7 +718,7 @@ void Adaptor::OnWindowShown() void Adaptor::OnWindowHidden() { - if ( STOPPED != mState ) + if ( RUNNING == mState ) { Pause(); @@ -686,10 +731,10 @@ void Adaptor::OnWindowHidden() void Adaptor::OnDamaged( const DamageArea& area ) { // This is needed for the case where Dali window is partially obscured - RequestUpdate(); + RequestUpdate( false ); } -void Adaptor::SurfaceSizeChanged( Dali::Adaptor::SurfaceSize surfaceSize ) +void Adaptor::SurfaceResizePrepare( SurfaceSize surfaceSize ) { // let the core know the surface size has changed mCore->SurfaceResized( surfaceSize.GetWidth(), surfaceSize.GetHeight() ); @@ -697,6 +742,16 @@ void Adaptor::SurfaceSizeChanged( Dali::Adaptor::SurfaceSize surfaceSize ) mResizedSignal.Emit( mAdaptor ); } +void Adaptor::SurfaceResizeComplete( SurfaceSize surfaceSize ) +{ + // 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(); +} + void Adaptor::NotifySceneCreated() { GetCore().SceneCreated(); @@ -706,6 +761,8 @@ void Adaptor::NotifySceneCreated() // process after surface is created (registering to remote surface provider if required) SurfaceInitialized(); + + mState = RUNNING; } void Adaptor::NotifyLanguageChanged() @@ -713,14 +770,16 @@ void Adaptor::NotifyLanguageChanged() mLanguageChangedSignal.Emit( mAdaptor ); } +void Adaptor::RenderOnce() +{ + RequestUpdateOnce(); +} + void Adaptor::RequestUpdateOnce() { - if( PAUSED_WHILE_HIDDEN != mState ) + if( mThreadController ) { - if( mThreadController ) - { - mThreadController->RequestUpdateOnce(); - } + mThreadController->RequestUpdateOnce(); } } @@ -770,6 +829,7 @@ Adaptor::Adaptor(Any nativeWindow, Dali::Adaptor& adaptor, RenderSurface* surfac mTriggerEventFactory(), mObjectProfiler( NULL ), mSocketFactory(), + mWindow(), mEnvironmentOptionsOwned( environmentOptions ? false : true /* If not provided then we own the object */ ), mUseRemoteSurface( false ) { @@ -800,6 +860,24 @@ float Adaptor::GetStereoBase() const return mCore->GetStereoBase(); } +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 ) ) ) ); +} + +void Adaptor::SetWindow( Dali::Window window ) +{ + mWindow = window; +} + +Dali::Window Adaptor::GetWindow() +{ + return mWindow; +} + } // namespace Adaptor } // namespace Internal