(VectorRenderer) Add a method to get a default size 32/202632/3
authorHeeyong Song <heeyong.song@samsung.com>
Tue, 2 Apr 2019 05:05:49 +0000 (14:05 +0900)
committerHeeyong Song <heeyong.song@samsung.com>
Wed, 10 Apr 2019 01:25:05 +0000 (01:25 +0000)
Change-Id: Ibe8e3507da0d40211c83f486504dd656ba1722e2

dali-extension/vector-animation-renderer/tizen-vector-animation-renderer.cpp
dali-extension/vector-animation-renderer/tizen-vector-animation-renderer.h

index 12f8082..f7d36a7 100755 (executable)
@@ -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();
index d90abdb..3ffd248 100755 (executable)
@@ -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:
 
   /**