From 453c842a7aa5a253807bbda9506b8495062c4756 Mon Sep 17 00:00:00 2001 From: Heeyong Song Date: Tue, 2 Apr 2019 14:05:49 +0900 Subject: [PATCH] (VectorRenderer) Add a method to get a default size Change-Id: Ibe8e3507da0d40211c83f486504dd656ba1722e2 --- .../tizen-vector-animation-renderer.cpp | 43 ++++++++++++---------- .../tizen-vector-animation-renderer.h | 14 +++---- 2 files changed, 31 insertions(+), 26 deletions(-) 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 12f8082..f7d36a7 100755 --- a/dali-extension/vector-animation-renderer/tizen-vector-animation-renderer.cpp +++ b/dali-extension/vector-animation-renderer/tizen-vector-animation-renderer.cpp @@ -78,11 +78,23 @@ TizenVectorAnimationRenderer::~TizenVectorAnimationRenderer() } } -void TizenVectorAnimationRenderer::SetUrl( const std::string& url ) +bool TizenVectorAnimationRenderer::Initialize( const std::string& url ) { mUrl = url; - DALI_LOG_RELEASE_INFO( "TizenVectorAnimationRenderer::SetUrl: file [%s]\n", url.c_str() ); + mVectorRenderer = rlottie::Animation::loadFromFile( mUrl ); + if( !mVectorRenderer ) + { + DALI_LOG_ERROR( "Failed to load a Lottie file [%s]\n", mUrl.c_str() ); + return false; + } + + mTotalFrameNumber = mVectorRenderer->totalFrame(); + mFrameRate = static_cast< float >( mVectorRenderer->frameRate() ); + + DALI_LOG_RELEASE_INFO( "TizenVectorAnimationRenderer::Initialize: file [%s]\n", url.c_str() ); + + return true; } void TizenVectorAnimationRenderer::SetRenderer( Renderer renderer ) @@ -146,23 +158,6 @@ void TizenVectorAnimationRenderer::SetSize( uint32_t width, uint32_t height ) DALI_LOG_RELEASE_INFO( "TizenVectorAnimationRenderer::SetSize: width = %d, height = %d\n", mWidth, mHeight ); } -bool TizenVectorAnimationRenderer::StartRender() -{ - mVectorRenderer = rlottie::Animation::loadFromFile( mUrl ); - if( !mVectorRenderer ) - { - DALI_LOG_ERROR( "Failed to load a Lottie file [%s]\n", mUrl.c_str() ); - return false; - } - - mTotalFrameNumber = mVectorRenderer->totalFrame(); - mFrameRate = static_cast< float >( mVectorRenderer->frameRate() ); - - DALI_LOG_RELEASE_INFO( "TizenVectorAnimationRenderer::StartRender: file [%s]\n", mUrl.c_str() ); - - return true; -} - void TizenVectorAnimationRenderer::StopRender() { Dali::Mutex::ScopedLock lock( mMutex ); @@ -242,6 +237,16 @@ float TizenVectorAnimationRenderer::GetFrameRate() const return mFrameRate; } +void TizenVectorAnimationRenderer::GetDefaultSize( uint32_t& width, uint32_t& height ) const +{ + size_t w, h; + mVectorRenderer->size( w, h ); + width = static_cast< uint32_t >( w ); + height = static_cast< uint32_t >( h ); + + DALI_LOG_RELEASE_INFO( "TizenVectorAnimationRenderer::GetDefaultSize: width = %d, height = %d\n", width, height ); +} + void TizenVectorAnimationRenderer::SetShader() { NativeImageInterface::Extension* extension = static_cast< NativeImageInterface* >( mTargetSurface.Get() )->GetExtension(); 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 d90abdb..3ffd248 100755 --- a/dali-extension/vector-animation-renderer/tizen-vector-animation-renderer.h +++ b/dali-extension/vector-animation-renderer/tizen-vector-animation-renderer.h @@ -53,9 +53,9 @@ public: virtual ~TizenVectorAnimationRenderer(); /** - * @copydoc Dali::VectorAnimationRendererPlugin::SetUrl() + * @copydoc Dali::VectorAnimationRendererPlugin::Initialize() */ - void SetUrl( const std::string& url ) override; + bool Initialize( const std::string& url ) override; /** * @copydoc Dali::VectorAnimationRendererPlugin::SetRenderer() @@ -68,11 +68,6 @@ public: void SetSize( uint32_t width, uint32_t height ) override; /** - * @copydoc Dali::VectorAnimationRendererPlugin::StartRender() - */ - bool StartRender() override; - - /** * @copydoc Dali::VectorAnimationRendererPlugin::StopRender() */ void StopRender() override; @@ -92,6 +87,11 @@ public: */ float GetFrameRate() const override; + /** + * @copydoc Dali::VectorAnimationRendererPlugin::GetDefaultSize() + */ + void GetDefaultSize( uint32_t& width, uint32_t& height ) const override; + private: /** -- 2.7.4