From: taeyoon Date: Thu, 17 Nov 2016 11:46:03 +0000 (+0900) Subject: [3.0] Modify native render surface for sync. with replace surface X-Git-Tag: accepted/tizen/3.0/common/20161124.181854^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;ds=sidebyside;h=9cd619bcda422b5be3f8efb3ce2dd6519c902a3f;p=platform%2Fcore%2Fuifw%2Fdali-adaptor.git [3.0] Modify native render surface for sync. with replace surface Fix black scene after replace surface in NativeRenderSurface Change-Id: Ie3e575c7d7cc1bfc88694ac104bd16e7383ea944 --- diff --git a/adaptors/common/adaptor-impl.cpp b/adaptors/common/adaptor-impl.cpp index da9476b..a24c54c 100644 --- a/adaptors/common/adaptor-impl.cpp +++ b/adaptors/common/adaptor-impl.cpp @@ -423,8 +423,6 @@ 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 // to start processing messages for new camera setup etc as soon as possible ProcessCoreEvents(); @@ -719,7 +717,7 @@ void Adaptor::OnDamaged( const DamageArea& area ) RequestUpdate(); } -void Adaptor::SurfaceSizeChanged(const PositionSize& positionSize) +void Adaptor::SurfaceSizeChanged( const PositionSize& positionSize ) { // let the core know the surface size has changed mCore->SurfaceResized(positionSize.width, positionSize.height); diff --git a/adaptors/common/adaptor-impl.h b/adaptors/common/adaptor-impl.h index 704d414..62d21fa 100644 --- a/adaptors/common/adaptor-impl.h +++ b/adaptors/common/adaptor-impl.h @@ -334,6 +334,11 @@ public: */ void GetAppId( std::string& appId ); + /** + * Informs core the surface size has changed + */ + void SurfaceSizeChanged( const PositionSize& positionSize ); + public: //AdaptorInternalServices /** @@ -484,11 +489,6 @@ private: private: /** - * Informs core the surface size has changed - */ - void SurfaceSizeChanged(const PositionSize& positionSize); - - /** * Assigns the render surface to the adaptor * */ diff --git a/adaptors/common/adaptor.cpp b/adaptors/common/adaptor.cpp index a2e80ad..3e96cf1 100644 --- a/adaptors/common/adaptor.cpp +++ b/adaptors/common/adaptor.cpp @@ -184,6 +184,10 @@ void Adaptor::SetStereoBase( float stereoBase ) mImpl->SetStereoBase( stereoBase ); } +void Adaptor::SurfaceSizeChanged( const PositionSize& positionSize ) +{ + mImpl->SurfaceSizeChanged( positionSize ); +} Adaptor::Adaptor() : mImpl( NULL ) diff --git a/adaptors/integration-api/adaptor.h b/adaptors/integration-api/adaptor.h index 7de4d65..93fbd7b 100644 --- a/adaptors/integration-api/adaptor.h +++ b/adaptors/integration-api/adaptor.h @@ -337,6 +337,11 @@ public: */ void SetStereoBase( float stereoBase ); + /** + * @brief Informs core the surface size has changed + */ + void SurfaceSizeChanged( const PositionSize& positionSize ); + public: // Signals /** diff --git a/adaptors/integration-api/wayland/native-render-surface.h b/adaptors/integration-api/wayland/native-render-surface.h index 23a3120..565eec2 100644 --- a/adaptors/integration-api/wayland/native-render-surface.h +++ b/adaptors/integration-api/wayland/native-render-surface.h @@ -73,12 +73,18 @@ public: // API virtual tbm_surface_h GetDrawable(); /** - * @brief Get the surface + * @brief Gets the surface * - * @return tbm surface + * @return TBM surface */ virtual Any GetSurface(); + /** + * @brief Waits tbm surface after replace surface + * After tbm surface is acquired in PostRender, this function is finished. + */ + void WaitDrawableAfterReplaceSurface(); + public: // from Dali::RenderSurface /** @@ -158,6 +164,11 @@ private: */ virtual void CreateNativeRenderable(); + /** + * Release tbm surface + */ + void ReleaseDrawable(); + private: // Data struct Impl; diff --git a/adaptors/tizen/native-render-surface-tizen.cpp b/adaptors/tizen/native-render-surface-tizen.cpp index ecca85d..a43aa12 100644 --- a/adaptors/tizen/native-render-surface-tizen.cpp +++ b/adaptors/tizen/native-render-surface-tizen.cpp @@ -26,6 +26,7 @@ #include #include #include +#include // INTERNAL INCLUDES #include @@ -49,6 +50,7 @@ struct NativeRenderSurface::Impl mColorDepth( isTransparent ? COLOR_DEPTH_32 : COLOR_DEPTH_24 ), mTbmFormat( isTransparent ? TBM_FORMAT_ARGB8888 : TBM_FORMAT_RGB888 ), mOwnSurface( false ), + mDrawableCompleted( false ), mConsumeSurface( NULL ), mThreadSynchronization( NULL ) { @@ -60,6 +62,7 @@ struct NativeRenderSurface::Impl ColorDepth mColorDepth; tbm_format mTbmFormat; bool mOwnSurface; + bool mDrawableCompleted; tbm_surface_queue_h mTbmQueue; tbm_surface_h mConsumeSurface; @@ -82,11 +85,7 @@ NativeRenderSurface::~NativeRenderSurface() // release the surface if we own one if( mImpl->mOwnSurface ) { - if( mImpl->mConsumeSurface ) - { - tbm_surface_queue_release( mImpl->mTbmQueue, mImpl->mConsumeSurface ); - mImpl->mConsumeSurface = NULL; - } + ReleaseDrawable(); if( mImpl->mTbmQueue ) { @@ -106,8 +105,6 @@ void NativeRenderSurface::SetRenderNotification( TriggerEventInterface* renderNo tbm_surface_h NativeRenderSurface::GetDrawable() { - ConditionalWait::ScopedLock lock( mImpl->mTbmSurfaceCondition ); - return mImpl->mConsumeSurface; } @@ -147,19 +144,6 @@ bool NativeRenderSurface::ReplaceEGLSurface( EglInterface& egl ) { DALI_LOG_TRACE_METHOD( gRenderSurfaceLogFilter ); - if( mImpl->mConsumeSurface ) - { - tbm_surface_queue_release( mImpl->mTbmQueue, mImpl->mConsumeSurface ); - mImpl->mConsumeSurface = NULL; - } - - if( mImpl->mTbmQueue ) - { - tbm_surface_queue_destroy( mImpl->mTbmQueue ); - } - - CreateNativeRenderable(); - if( !mImpl->mTbmQueue ) { return false; @@ -199,8 +183,17 @@ void NativeRenderSurface::PostRender( EglInterface& egl, Integration::GlAbstract } } + tbm_surface_internal_ref( mImpl->mConsumeSurface ); + + if( replacingSurface ) + { + ConditionalWait::ScopedLock lock( mImpl->mTbmSurfaceCondition ); + mImpl->mDrawableCompleted = true; + mImpl->mTbmSurfaceCondition.Notify( lock ); + } + // create damage for client applications which wish to know the update timing - if( mImpl->mRenderNotification ) + if( !replacingSurface && mImpl->mRenderNotification ) { // use notification trigger // Tell the event-thread to render the tbm_surface @@ -214,11 +207,7 @@ void NativeRenderSurface::PostRender( EglInterface& egl, Integration::GlAbstract } // release the consumed surface after post render was completed - if( mImpl->mConsumeSurface ) - { - tbm_surface_queue_release( mImpl->mTbmQueue, mImpl->mConsumeSurface ); - mImpl->mConsumeSurface = NULL; - } + ReleaseDrawable(); } void NativeRenderSurface::StopRender() @@ -252,7 +241,7 @@ RenderSurface::Type NativeRenderSurface::GetSurfaceType() void NativeRenderSurface::CreateNativeRenderable() { // check we're creating one with a valid size - DALI_ASSERT_ALWAYS( mImpl->mPosition.width > 0 && mImpl->mPosition.height > 0 && "Pixmap size is invalid" ); + DALI_ASSERT_ALWAYS( mImpl->mPosition.width > 0 && mImpl->mPosition.height > 0 && "tbm_surface size is invalid" ); mImpl->mTbmQueue = tbm_surface_queue_create( 3, mImpl->mPosition.width, mImpl->mPosition.height, mImpl->mTbmFormat, TBM_BO_DEFAULT ); @@ -274,4 +263,29 @@ void NativeRenderSurface::ReleaseLock() } } +void NativeRenderSurface::WaitDrawableAfterReplaceSurface() +{ + ConditionalWait::ScopedLock lock( mImpl->mTbmSurfaceCondition ); + while( !mImpl->mDrawableCompleted ) + { + mImpl->mTbmSurfaceCondition.Wait( lock ); + } + + mImpl->mDrawableCompleted = false; +} + +void NativeRenderSurface::ReleaseDrawable() +{ + if( mImpl->mConsumeSurface ) + { + tbm_surface_internal_unref( mImpl->mConsumeSurface ); + + if( tbm_surface_internal_is_valid( mImpl->mConsumeSurface ) ) + { + tbm_surface_queue_release( mImpl->mTbmQueue, mImpl->mConsumeSurface ); + } + mImpl->mConsumeSurface = NULL; + } +} + } // namespace Dali