From: Heeyong Song Date: Mon, 21 Oct 2019 08:42:52 +0000 (+0900) Subject: [Tizen] (Vector) Use Processor to reduce delay X-Git-Tag: accepted/tizen/unified/20191104.111356~3 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F17%2F216717%2F1;p=platform%2Fcore%2Fuifw%2Fdali-extension.git [Tizen] (Vector) Use Processor to reduce delay Change-Id: I15100403644245b444a512b662f12c8b3dd85dda --- diff --git a/dali-extension/vector-animation-renderer/tizen-vector-animation-renderer.cpp b/dali-extension/vector-animation-renderer/tizen-vector-animation-renderer.cpp index 416041d..c57f9f1 100755 --- a/dali-extension/vector-animation-renderer/tizen-vector-animation-renderer.cpp +++ b/dali-extension/vector-animation-renderer/tizen-vector-animation-renderer.cpp @@ -21,6 +21,7 @@ // EXTERNAL INCLUDES #include #include +#include #include #include #include // for strlen() @@ -67,7 +68,8 @@ TizenVectorAnimationRenderer::TizenVectorAnimationRenderer() mDefaultHeight( 0 ), mFrameRate( 60.0f ), mResourceReady( false ), - mShaderChanged( false ) + mShaderChanged( false ), + mResourceReadyTriggered( false ) { } @@ -76,6 +78,11 @@ TizenVectorAnimationRenderer::~TizenVectorAnimationRenderer() Dali::Mutex::ScopedLock lock( mMutex ); ResetBuffers(); + + if( Adaptor::IsAvailable() ) + { + Adaptor::Get().UnregisterProcessor( *this ); + } } bool TizenVectorAnimationRenderer::Initialize( const std::string& url ) @@ -97,6 +104,8 @@ bool TizenVectorAnimationRenderer::Initialize( const std::string& url ) mDefaultWidth = static_cast< uint32_t >( w ); mDefaultHeight = static_cast< uint32_t >( h ); + Adaptor::Get().RegisterProcessor( *this ); + DALI_LOG_RELEASE_INFO( "TizenVectorAnimationRenderer::Initialize: file [%s] [%p]\n", url.c_str(), this ); return true; @@ -157,10 +166,10 @@ void TizenVectorAnimationRenderer::SetSize( uint32_t width, uint32_t height ) bool TizenVectorAnimationRenderer::Render( uint32_t frameNumber ) { + Dali::Mutex::ScopedLock lock( mMutex ); + if( tbm_surface_queue_can_dequeue( mTbmQueue, 0 ) ) { - Dali::Mutex::ScopedLock lock( mMutex ); - tbm_surface_h tbmSurface; if( tbm_surface_queue_dequeue( mTbmQueue, &tbmSurface ) != TBM_SURFACE_QUEUE_ERROR_NONE ) @@ -219,17 +228,16 @@ bool TizenVectorAnimationRenderer::Render( uint32_t frameNumber ) mRenderedTexture = mTexture; mResourceReady = true; + mResourceReadyTriggered = true; mResourceReadyTrigger->Trigger(); DALI_LOG_RELEASE_INFO( "TizenVectorAnimationRenderer::Render: Resource ready [current = %d] [%p]\n", frameNumber, this ); } - } - else - { - return false; + + return true; } - return true; + return false; } uint32_t TizenVectorAnimationRenderer::GetTotalFrameNumber() const @@ -250,8 +258,10 @@ void TizenVectorAnimationRenderer::GetDefaultSize( uint32_t& width, uint32_t& he DALI_LOG_RELEASE_INFO( "TizenVectorAnimationRenderer::GetDefaultSize: width = %d, height = %d [%p]\n", width, height, this ); } -void TizenVectorAnimationRenderer::GetLayerInfo( Property::Map& map ) const +void TizenVectorAnimationRenderer::GetLayerInfo( Property::Map& map ) { + Dali::Mutex::ScopedLock lock( mMutex ); + auto layerInfo = mVectorRenderer->layers(); for( auto&& iter : layerInfo ) @@ -268,6 +278,11 @@ VectorAnimationRendererPlugin::UploadCompletedSignalType& TizenVectorAnimationRe return mUploadCompletedSignal; } +void TizenVectorAnimationRenderer::Process() +{ + OnResourceReady(); +} + void TizenVectorAnimationRenderer::SetShader() { if( mShaderChanged ) @@ -341,16 +356,23 @@ void TizenVectorAnimationRenderer::ResetBuffers() void TizenVectorAnimationRenderer::OnResourceReady() { - DALI_LOG_RELEASE_INFO( "TizenVectorAnimationRenderer::OnResourceReady: Set Texture [%p]\n", this ); + Dali::Mutex::ScopedLock lock( mMutex ); - // Set texture - if( mRenderer ) + if( mResourceReadyTriggered ) { - TextureSet textureSet = mRenderer.GetTextures(); - textureSet.SetTexture( 0, mRenderedTexture ); - } + DALI_LOG_RELEASE_INFO( "TizenVectorAnimationRenderer::OnResourceReady: Set Texture [%p]\n", this ); - mUploadCompletedSignal.Emit(); + // Set texture + if( mRenderer ) + { + TextureSet textureSet = mRenderer.GetTextures(); + textureSet.SetTexture( 0, mRenderedTexture ); + } + + mResourceReadyTriggered = false; + + mUploadCompletedSignal.Emit(); + } } } // namespace Plugin diff --git a/dali-extension/vector-animation-renderer/tizen-vector-animation-renderer.h b/dali-extension/vector-animation-renderer/tizen-vector-animation-renderer.h index 9b61e01..e9f6213 100755 --- a/dali-extension/vector-animation-renderer/tizen-vector-animation-renderer.h +++ b/dali-extension/vector-animation-renderer/tizen-vector-animation-renderer.h @@ -19,12 +19,12 @@ */ // EXTERNAL INCLUDES -#include #include #include #include #include #include +#include #include #include #include @@ -39,7 +39,7 @@ namespace Plugin /** * @brief Implementation of the Tizen vector animation renderer class which has Tizen platform dependency. */ -class TizenVectorAnimationRenderer : public Dali::VectorAnimationRendererPlugin +class TizenVectorAnimationRenderer : public Dali::VectorAnimationRendererPlugin, public Integration::Processor { public: @@ -91,13 +91,20 @@ public: /** * @copydoc Dali::VectorAnimationRendererPlugin::GetLayerInfo() */ - void GetLayerInfo( Property::Map& map ) const override; + void GetLayerInfo( Property::Map& map ) override; /** * @copydoc Dali::VectorAnimationRendererPlugin::UploadCompletedSignal() */ UploadCompletedSignalType& UploadCompletedSignal() override; +protected: // Implementation of Processor + + /** + * @copydoc Dali::Integration::Processor::Process() + */ + void Process() override; + private: /** @@ -138,6 +145,7 @@ private: float mFrameRate; ///< The frame rate of the content bool mResourceReady; ///< Whether the resource is ready bool mShaderChanged; ///< Whether the shader is changed to support native image + bool mResourceReadyTriggered;///< Whether the resource ready is triggered }; } // namespace Plugin