Merge "DALi Version 2.1.32" into devel/master
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit / dali-toolkit-test-utils / toolkit-vector-animation-renderer.cpp
index 4b6c5c8..a8f3ab8 100644 (file)
@@ -17,6 +17,7 @@
 
 #include <dali/devel-api/adaptor-framework/pixel-buffer.h>
 #include <dali/devel-api/adaptor-framework/vector-animation-renderer.h>
+#include <dali/devel-api/threading/mutex.h>
 #include <dali/public-api/object/base-object.h>
 #include <toolkit-application.h>
 #include <toolkit-event-thread-callback.h>
@@ -70,6 +71,7 @@ public:
 
   bool Load(const std::string& url)
   {
+    Dali::Mutex::ScopedLock lock(mMutex);
     mUrl = url;
     if(mUrl == "invalid.json")
     {
@@ -80,7 +82,6 @@ public:
     {
       // Change total frame number for test
       mTotalFrameNumber = 200;
-      mTestFrameDrop    = true;
     }
 
     mDefaultWidth  = 100;
@@ -96,6 +97,7 @@ public:
 
   void SetSize(uint32_t width, uint32_t height)
   {
+    Dali::Mutex::ScopedLock lock(mMutex);
     mWidth  = width;
     mHeight = height;
 
@@ -108,6 +110,7 @@ public:
 
   bool Render(uint32_t frameNumber)
   {
+    Dali::Mutex::ScopedLock lock(mMutex);
     if(mWidth == 0 || mHeight == 0)
     {
       return false;
@@ -126,6 +129,11 @@ public:
       mNeedDroppedFrames = false;
     }
 
+    if(mDynamicPropertyCallback)
+    {
+      CallbackBase::ExecuteReturn<Property::Value>(*mDynamicPropertyCallback, 0, 0, frameNumber);
+    }
+
     if(mNeedTrigger)
     {
       mEventThreadCallback->Trigger();
@@ -179,8 +187,17 @@ public:
 
   void InvalidateBuffer()
   {
-    mNeedTrigger   = true;
-    mResourceReady = false;
+    Dali::Mutex::ScopedLock lock(mMutex);
+    if(mResourceReady)
+    {
+      mNeedTrigger   = true;
+      mResourceReady = false;
+    }
+  }
+
+  void AddPropertyValueCallback(const std::string& keyPath, Dali::VectorAnimationRenderer::VectorProperty property, CallbackBase* callback, int32_t id)
+  {
+    mDynamicPropertyCallback = std::unique_ptr<CallbackBase>(callback);
   }
 
   Dali::VectorAnimationRenderer::UploadCompletedSignalType& UploadCompletedSignal()
@@ -209,22 +226,25 @@ public:
 public:
   static uint32_t mCount;
 
-  std::string    mUrl;
-  Dali::Renderer mRenderer;
-  uint32_t       mWidth;
-  uint32_t       mHeight;
-  uint32_t       mDefaultWidth;
-  uint32_t       mDefaultHeight;
-  uint32_t       mTotalFrameNumber;
-  uint32_t       mPreviousFrame;
-  uint32_t       mDelayTime;
-  uint32_t       mDroppedFrames;
-  float          mFrameRate;
-  bool           mTestFrameDrop;
-  bool           mNeedDroppedFrames;
-  bool           mLoadFailed{false};
-  bool           mResourceReady{false};
-  bool           mNeedTrigger{true};
+  std::string                   mUrl;
+  Dali::Renderer                mRenderer;
+  Dali::Mutex                   mMutex;
+  std::unique_ptr<CallbackBase> mDynamicPropertyCallback{nullptr};
+
+  uint32_t mWidth;
+  uint32_t mHeight;
+  uint32_t mDefaultWidth;
+  uint32_t mDefaultHeight;
+  uint32_t mTotalFrameNumber;
+  uint32_t mPreviousFrame;
+  uint32_t mDelayTime;
+  uint32_t mDroppedFrames;
+  float    mFrameRate;
+  bool     mTestFrameDrop;
+  bool     mNeedDroppedFrames;
+  bool     mLoadFailed{false};
+  bool     mResourceReady{false};
+  bool     mNeedTrigger{true};
 
   Dali::VectorAnimationRenderer::UploadCompletedSignalType mUploadCompletedSignal;
   std::unique_ptr<EventThreadCallback>                     mEventThreadCallback;
@@ -340,6 +360,11 @@ void VectorAnimationRenderer::InvalidateBuffer()
   return Internal::Adaptor::GetImplementation(*this).InvalidateBuffer();
 }
 
+void VectorAnimationRenderer::AddPropertyValueCallback(const std::string& keyPath, VectorProperty property, CallbackBase* callback, int32_t id)
+{
+  Internal::Adaptor::GetImplementation(*this).AddPropertyValueCallback(keyPath, property, callback, id);
+}
+
 VectorAnimationRenderer::UploadCompletedSignalType& VectorAnimationRenderer::UploadCompletedSignal()
 {
   return Internal::Adaptor::GetImplementation(*this).UploadCompletedSignal();
@@ -353,7 +378,8 @@ namespace VectorAnimationRenderer
 {
 void DelayRendering(uint32_t delay)
 {
-  Dali::Internal::Adaptor::gVectorAnimationRenderer->mDelayTime = delay;
+  Dali::Internal::Adaptor::gVectorAnimationRenderer->mDelayTime     = delay;
+  Dali::Internal::Adaptor::gVectorAnimationRenderer->mTestFrameDrop = true;
 }
 
 uint32_t GetDroppedFrames()