X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=adaptors%2Fcommon%2Fadaptor-impl.cpp;h=6f52ff625998fe1288bf39196b829671a86e9452;hb=c97aabad2073f2a1516fe2025346dc9ddca18651;hp=90342ae8096f28add1f6ce92bdab126c8f2738f3;hpb=eeff0e3d551e3a14aa2c93688f8894e2d28decbe;p=platform%2Fcore%2Fuifw%2Fdali-adaptor.git diff --git a/adaptors/common/adaptor-impl.cpp b/adaptors/common/adaptor-impl.cpp index 90342ae..6f52ff6 100644 --- a/adaptors/common/adaptor-impl.cpp +++ b/adaptors/common/adaptor-impl.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 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 @@ -28,7 +31,7 @@ #include // INTERNAL INCLUDES -#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 ) @@ -84,7 +90,6 @@ Dali::Adaptor* Adaptor::New( Any nativeWindow, RenderSurface *surface, Dali::Con Dali::Adaptor* Adaptor::New( Dali::Window window, Dali::Configuration::ContextLoss configuration, EnvironmentOptions* environmentOptions ) { Any winId = window.GetNativeHandle(); - Window& windowImpl = Dali::GetImplementation(window); Dali::Adaptor* adaptor = New( winId, windowImpl.GetSurface(), configuration, environmentOptions ); windowImpl.SetAdaptor(*adaptor); @@ -132,7 +137,7 @@ void Adaptor::Initialize( Dali::Configuration::ContextLoss configuration ) mGLES = new GlImplementation(); } - mEglFactory = new EglFactory(); + mEglFactory = new EglFactory( mEnvironmentOptions->GetMultiSamplingLevel() ); EglSyncImplementation* eglSyncImpl = mEglFactory->GetSyncImplementation(); @@ -148,7 +153,7 @@ void Adaptor::Initialize( Dali::Configuration::ContextLoss configuration ) mVSyncMonitor = new VSyncMonitor; - mUpdateRenderController = new UpdateRenderController( *this, *mEnvironmentOptions ); + mThreadController = new ThreadController( *this, *mEnvironmentOptions ); // Should be called after Core creation if( mEnvironmentOptions->GetPanGestureLoggingLevel() ) @@ -183,6 +188,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() @@ -198,7 +211,7 @@ Adaptor::~Adaptor() (*iter)->OnDestroy(); } - delete mUpdateRenderController; // this will shutdown render thread, which will call Core::ContextDestroyed before exit + delete mThreadController; // this will shutdown render thread, which will call Core::ContextDestroyed before exit delete mVSyncMonitor; delete mEventHandler; delete mObjectProfiler; @@ -257,8 +270,8 @@ void Adaptor::Start() PositionSize size = mSurface->GetPositionSize(); mCore->SurfaceResized( size.width, size.height ); - // Start the update & render threads - mUpdateRenderController->Start(); + // Initialize the thread controller + mThreadController->Initialize(); mState = RUNNING; @@ -285,10 +298,10 @@ void Adaptor::Pause() // Reset the event handler when adaptor paused if( mEventHandler ) { - mEventHandler->Reset(); + mEventHandler->Pause(); } - mUpdateRenderController->Pause(); + mThreadController->Pause(); mCore->Suspend(); mState = PAUSED; } @@ -300,24 +313,12 @@ void Adaptor::Resume() // Only resume the adaptor if we are in the suspended state. if( PAUSED == mState ) { - // We put ResumeFrameTime first, as this was originally called at the start of mCore->Resume() - // If there were events pending, mCore->Resume() will call - // RenderController->RequestUpdate() - // UpdateRenderController->RequestUpdate() - // UpdateRenderSynchronization->RequestUpdate() - // and we should have reset the frame timers before allowing Core->Update() to be called. - //@todo Should we call UpdateRenderController->Resume before mCore->Resume()? - - mUpdateRenderController->ResumeFrameTime(); - mCore->Resume(); - mUpdateRenderController->Resume(); - mState = RUNNING; // Reset the event handler when adaptor resumed if( mEventHandler ) { - mEventHandler->Reset(); + mEventHandler->Resume(); } // Inform observers that we have resumed. @@ -326,7 +327,11 @@ void Adaptor::Resume() (*iter)->OnResume(); } - ProcessCoreEvents(); // Ensure any outstanding messages are processed + // Resume core so it processes any requests as well + mCore->Resume(); + + // Do at end to ensure our first update/render after resumption includes the processed messages as well + mThreadController->Resume(); } } @@ -341,7 +346,7 @@ void Adaptor::Stop() (*iter)->OnStop(); } - mUpdateRenderController->Stop(); + mThreadController->Stop(); mCore->Suspend(); // Delete the TTS player @@ -365,6 +370,19 @@ void Adaptor::Stop() } } +void Adaptor::ContextLost() +{ + mCore->GetContextNotifier()->NotifyContextLost(); // Inform stage +} + +void Adaptor::ContextRegained() +{ + // Inform core, so that texture resources can be reloaded + mCore->RecoverFromContextLoss(); + + mCore->GetContextNotifier()->NotifyContextRegained(); // Inform stage +} + void Adaptor::FeedTouchPoint( TouchPoint& point, int timeStamp ) { mEventHandler->FeedTouchPoint( point, timeStamp ); @@ -380,59 +398,24 @@ 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(); - mCore->GetContextNotifier()->NotifyContextLost(); // Inform stage - // this method blocks until the render thread has completed the replace. - mUpdateRenderController->ReplaceSurface(mSurface); - - // Inform core, so that texture resources can be reloaded - mCore->RecoverFromContextLoss(); - - mCore->GetContextNotifier()->NotifyContextRegained(); // Inform stage + mThreadController->ReplaceSurface(mSurface); } RenderSurface& Adaptor::GetSurface() const @@ -469,6 +452,10 @@ bool Adaptor::AddIdle( CallbackBase* callback ) return idleAdded; } +void Adaptor::RemoveIdle( CallbackBase* callback ) +{ + mCallbackManager->RemoveIdleCallback( callback ); +} Dali::Adaptor& Adaptor::Get() { @@ -493,7 +480,7 @@ Dali::Integration::Core& Adaptor::GetCore() void Adaptor::SetRenderRefreshRate( unsigned int numberOfVSyncsPerRender ) { - mUpdateRenderController->SetRenderRefreshRate( numberOfVSyncsPerRender ); + mThreadController->SetRenderRefreshRate( numberOfVSyncsPerRender ); } void Adaptor::SetUseHardwareVSync( bool useHardware ) @@ -618,6 +605,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) ); @@ -671,7 +663,7 @@ void Adaptor::RequestUpdate() if ( PAUSED == mState || RUNNING == mState ) { - mUpdateRenderController->RequestUpdate(); + mThreadController->RequestUpdate(); } } @@ -717,17 +709,33 @@ void Adaptor::OnDamaged( const DamageArea& area ) RequestUpdate(); } -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(); } void Adaptor::NotifyLanguageChanged() @@ -735,17 +743,28 @@ void Adaptor::NotifyLanguageChanged() mLanguageChangedSignal.Emit( mAdaptor ); } +void Adaptor::RenderOnce() +{ + RequestUpdateOnce(); +} + void Adaptor::RequestUpdateOnce() { if( PAUSED_WHILE_HIDDEN != mState ) { - if( mUpdateRenderController ) + if( mThreadController ) { - mUpdateRenderController->RequestUpdateOnce(); + mThreadController->RequestUpdateOnce(); } } } +void Adaptor::IndicatorSizeChanged(int height) +{ + // let the core know the indicator height is changed + mCore->SetTopMargin(height); +} + void Adaptor::ProcessCoreEventsFromIdle() { ProcessCoreEvents(); @@ -757,12 +776,13 @@ void Adaptor::ProcessCoreEventsFromIdle() Adaptor::Adaptor(Any nativeWindow, Dali::Adaptor& adaptor, RenderSurface* surface, EnvironmentOptions* environmentOptions) : mResizedSignal(), mLanguageChangedSignal(), - mAdaptor(adaptor), - mState(READY), - mCore(NULL), - mUpdateRenderController(NULL), - mVSyncMonitor(NULL), + mAdaptor( adaptor ), + mState( READY ), + mCore( NULL ), + mThreadController( NULL ), + mVSyncMonitor( NULL ), mGLES( NULL ), + mGlSync( NULL ), mEglFactory( NULL ), mNativeWindow( nativeWindow ), mSurface( surface ), @@ -770,15 +790,23 @@ Adaptor::Adaptor(Any nativeWindow, Dali::Adaptor& adaptor, RenderSurface* surfac mEventHandler( NULL ), mCallbackManager( NULL ), mNotificationOnIdleInstalled( false ), - mNotificationTrigger(NULL), - mGestureManager(NULL), + mNotificationTrigger( NULL ), + mGestureManager( NULL ), + mDaliFeedbackPlugin(), + mFeedbackController( NULL ), + mTtsPlayers(), mObservers(), mDragAndDropDetector(), - mDeferredRotationObserver(NULL), + mDeferredRotationObserver( NULL ), mEnvironmentOptions( environmentOptions ? environmentOptions : new EnvironmentOptions /* Create the options if not provided */), - mPerformanceInterface(NULL), - mObjectProfiler(NULL), - mEnvironmentOptionsOwned( environmentOptions ? false : true /* If not provided then we own the object */ ) + mPerformanceInterface( NULL ), + mKernelTracer(), + mSystemTracer(), + mTriggerEventFactory(), + mObjectProfiler( NULL ), + 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; @@ -807,6 +835,14 @@ float Adaptor::GetStereoBase() const return mCore->GetStereoBase(); } +void Adaptor::SetRootLayoutDirection( std::string locale ) +{ + Dali::Stage stage = Dali::Stage::GetCurrent(); + + stage.GetRootLayer().SetProperty( DevelActor::Property::LAYOUT_DIRECTION, + static_cast< DevelActor::LayoutDirection::Type >( Internal::Adaptor::Locale::GetDirection( std::string( locale ) ) ) ); +} + } // namespace Adaptor } // namespace Internal