(Vector) Fix some issues
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit / dali-toolkit-test-utils / toolkit-vector-animation-renderer.cpp
index 003b8ea..e13a65b 100755 (executable)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2018 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2019 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.
@@ -32,36 +32,66 @@ class VectorAnimationRenderer: public Dali::BaseObject
 {
 public:
 
-  VectorAnimationRenderer( const std::string& url, Dali::Renderer renderer, uint32_t width, uint32_t height )
+  VectorAnimationRenderer( const std::string& url )
   : mUrl( url ),
-    mRenderer( renderer ),
-    mWidth( width ),
-    mHeight( height )
+    mRenderer(),
+    mWidth( 0 ),
+    mHeight( 0 ),
+    mPreviousFrame( 0 )
   {
   }
 
+  void SetRenderer( Dali::Renderer renderer )
+  {
+    mRenderer = renderer;
+
+    if( mWidth != 0 && mHeight != 0 )
+    {
+      Dali::TextureSet textureSet = mRenderer.GetTextures();
+      Dali::Texture texture = Dali::Texture::New( TextureType::TEXTURE_2D, Pixel::RGBA8888, mWidth, mHeight );
+      textureSet.SetTexture( 0, texture );
+    }
+  }
+
   void SetSize( uint32_t width, uint32_t height )
   {
     mWidth = width;
     mHeight = height;
+
+    if( mRenderer )
+    {
+      Dali::TextureSet textureSet = mRenderer.GetTextures();
+      Dali::Texture texture = Dali::Texture::New( TextureType::TEXTURE_2D, Pixel::RGBA8888, mWidth, mHeight );
+      textureSet.SetTexture( 0, texture );
+    }
   }
 
-  bool StartRender()
+  bool Render( uint32_t frameNumber )
   {
+    if( frameNumber == 1 && mPreviousFrame != frameNumber )
+    {
+      mPreviousFrame = frameNumber;
+      // For test corverage
+      return false;
+    }
+    mPreviousFrame = frameNumber;
     return true;
   }
 
-  void StopRender()
+  uint32_t GetTotalFrameNumber() const
   {
+    return 5;
   }
 
-  void Render( uint32_t frameNumber )
+  float GetFrameRate() const
   {
+    return 60.0f;
   }
 
-  uint32_t GetTotalFrameNumber()
+  void GetDefaultSize( uint32_t& width, uint32_t& height ) const
   {
-    return 5;
+    width = 100;
+    height = 100;
   }
 
 public:
@@ -70,7 +100,7 @@ public:
   Dali::Renderer mRenderer;
   uint32_t mWidth;
   uint32_t mHeight;
-
+  uint32_t mPreviousFrame;
 };
 
 inline VectorAnimationRenderer& GetImplementation( Dali::VectorAnimationRenderer& renderer )
@@ -96,9 +126,9 @@ inline const VectorAnimationRenderer& GetImplementation( const Dali::VectorAnima
 /*********************************  PUBLIC CLASS  *******************************/
 /********************************************************************************/
 
-VectorAnimationRenderer VectorAnimationRenderer::New( const std::string& url, Renderer renderer, uint32_t width, uint32_t height )
+VectorAnimationRenderer VectorAnimationRenderer::New( const std::string& url )
 {
-  Internal::Adaptor::VectorAnimationRenderer* animationRenderer = new Internal::Adaptor::VectorAnimationRenderer( url, renderer, width, height );
+  Internal::Adaptor::VectorAnimationRenderer* animationRenderer = new Internal::Adaptor::VectorAnimationRenderer( url );
 
   return VectorAnimationRenderer( animationRenderer );
 }
@@ -127,29 +157,34 @@ VectorAnimationRenderer& VectorAnimationRenderer::operator=( const VectorAnimati
   return *this;
 }
 
+void VectorAnimationRenderer::SetRenderer( Renderer renderer )
+{
+  Internal::Adaptor::GetImplementation( *this ).SetRenderer( renderer );
+}
+
 void VectorAnimationRenderer::SetSize( uint32_t width, uint32_t height )
 {
   Internal::Adaptor::GetImplementation( *this ).SetSize( width, height );
 }
 
-bool VectorAnimationRenderer::StartRender()
+bool VectorAnimationRenderer::Render( uint32_t frameNumber )
 {
-  return Internal::Adaptor::GetImplementation( *this ).StartRender();
+  return Internal::Adaptor::GetImplementation( *this ).Render( frameNumber );
 }
 
-void VectorAnimationRenderer::StopRender()
+uint32_t VectorAnimationRenderer::GetTotalFrameNumber() const
 {
-  Internal::Adaptor::GetImplementation( *this ).StopRender();
+  return Internal::Adaptor::GetImplementation( *this ).GetTotalFrameNumber();
 }
 
-void VectorAnimationRenderer::Render( uint32_t frameNumber )
+float VectorAnimationRenderer::GetFrameRate() const
 {
-  Internal::Adaptor::GetImplementation( *this ).Render( frameNumber );
+  return Internal::Adaptor::GetImplementation( *this ).GetFrameRate();
 }
 
-uint32_t VectorAnimationRenderer::GetTotalFrameNumber()
+void VectorAnimationRenderer::GetDefaultSize( uint32_t& width, uint32_t& height ) const
 {
-  return Internal::Adaptor::GetImplementation( *this ).GetTotalFrameNumber();
+  Internal::Adaptor::GetImplementation( *this ).GetDefaultSize( width, height );
 }
 
 } // namespace Dali;