X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=adaptors%2Fcommon%2Fadaptor-impl.cpp;h=0c7c4e4b50e16105177e20fb7df9297f4bf6c518;hb=62911dcd069b5cfebc0f2589621cd1620e570997;hp=da9476b51a483369635f7ed469c46318fbe2e9b5;hpb=ebd8f93a5ebadd7805185c5fea8923af13491176;p=platform%2Fcore%2Fuifw%2Fdali-adaptor.git diff --git a/adaptors/common/adaptor-impl.cpp b/adaptors/common/adaptor-impl.cpp index da9476b..0c7c4e4 100644 --- a/adaptors/common/adaptor-impl.cpp +++ b/adaptors/common/adaptor-impl.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016 Samsung Electronics Co., Ltd. + * Copyright (c) 2017 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. @@ -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; } @@ -132,11 +140,17 @@ void Adaptor::Initialize( Dali::Configuration::ContextLoss configuration ) mGLES = new GlImplementation(); } - mEglFactory = new EglFactory(); + mEglFactory = new EglFactory( mEnvironmentOptions->GetMultiSamplingLevel() ); 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++) @@ -385,47 +406,19 @@ void Adaptor::FeedKeyEvent( KeyEvent& keyEvent ) mEventHandler->FeedKeyEvent( keyEvent ); } -bool Adaptor::MoveResize( const PositionSize& positionSize ) -{ - PositionSize old = mSurface->GetPositionSize(); - - // just resize the surface. The driver should automatically resize the egl Surface (untested) - // EGL Spec says : EGL window surfaces need to be resized when their corresponding native window - // is resized. Implementations typically use hooks into the OS and native window - // system to perform this resizing on demand, transparently to the client. - mSurface->MoveResize( positionSize ); - - if(old.width != positionSize.width || old.height != positionSize.height) - { - SurfaceSizeChanged(positionSize); - } - - return true; -} - -void Adaptor::SurfaceResized( const PositionSize& positionSize ) +void Adaptor::ReplaceSurface( Any nativeWindow, RenderSurface& surface ) { - PositionSize old = mSurface->GetPositionSize(); + PositionSize positionSize = surface.GetPositionSize(); - // Called by an application, when it has resized a window outside of Dali. - // The EGL driver automatically detects X Window resize calls, and resizes - // the EGL surface for us. - mSurface->MoveResize( positionSize ); + // let the core know the surface size has changed + mCore->SurfaceResized( positionSize.width, positionSize.height ); - if(old.width != positionSize.width || old.height != positionSize.height) - { - SurfaceSizeChanged(positionSize); - } -} + mResizedSignal.Emit( mAdaptor ); -void Adaptor::ReplaceSurface( Any nativeWindow, RenderSurface& surface ) -{ mNativeWindow = nativeWindow; mSurface = &surface; - SurfaceSizeChanged(mSurface->GetPositionSize()); - - // 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(); @@ -454,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 ); } @@ -620,6 +613,11 @@ Any Adaptor::GetNativeWindowHandle() return mNativeWindow; } +void Adaptor::SetUseRemoteSurface(bool useRemoteSurface) +{ + mUseRemoteSurface = useRemoteSurface; +} + void Adaptor::AddObserver( LifeCycleObserver& observer ) { ObserverContainer::iterator match ( find(mObservers.begin(), mObservers.end(), &observer) ); @@ -666,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 ); } } @@ -703,7 +718,7 @@ void Adaptor::OnWindowShown() void Adaptor::OnWindowHidden() { - if ( STOPPED != mState ) + if ( RUNNING == mState ) { Pause(); @@ -716,23 +731,38 @@ 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(const PositionSize& positionSize) +void Adaptor::SurfaceResizePrepare( SurfaceSize surfaceSize ) { // let the core know the surface size has changed - mCore->SurfaceResized(positionSize.width, positionSize.height); + mCore->SurfaceResized( surfaceSize.GetWidth(), surfaceSize.GetHeight() ); 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(); // Start thread controller after the scene has been created mThreadController->Start(); + + // process after surface is created (registering to remote surface provider if required) + SurfaceInitialized(); + + mState = RUNNING; } void Adaptor::NotifyLanguageChanged() @@ -740,17 +770,25 @@ 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(); } } +void Adaptor::IndicatorSizeChanged(int height) +{ + // let the core know the indicator height is changed + mCore->SetTopMargin(height); +} + void Adaptor::ProcessCoreEventsFromIdle() { ProcessCoreEvents(); @@ -791,7 +829,9 @@ Adaptor::Adaptor(Any nativeWindow, Dali::Adaptor& adaptor, RenderSurface* surfac mTriggerEventFactory(), mObjectProfiler( NULL ), mSocketFactory(), - mEnvironmentOptionsOwned( environmentOptions ? false : true /* If not provided then we own the object */ ) + mWindow(), + 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; @@ -820,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