(AnimatedVector) Get marker informations 40/301040/1
authorEunki, Hong <eunkiki.hong@samsung.com>
Tue, 7 Nov 2023 11:13:41 +0000 (20:13 +0900)
committerEunki, Hong <eunkiki.hong@samsung.com>
Tue, 7 Nov 2023 11:29:03 +0000 (20:29 +0900)
Let we make API to get marker informations from json file.
Marker information contains name, and pair of frame, start and end.

Change-Id: I21b91368addff66d41a66c14fc8e86076470ddc7
Signed-off-by: Eunki, Hong <eunkiki.hong@samsung.com>
automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-vector-animation-renderer.cpp
automated-tests/src/dali-toolkit/utc-Dali-AnimatedVectorImageVisual.cpp
dali-toolkit/devel-api/visuals/image-visual-properties-devel.h
dali-toolkit/internal/visuals/animated-vector-image/animated-vector-image-visual.cpp
dali-toolkit/internal/visuals/animated-vector-image/vector-animation-task.cpp
dali-toolkit/internal/visuals/animated-vector-image/vector-animation-task.h

index bb45bda..4aec20d 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2022 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2023 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.
@@ -19,6 +19,7 @@
 #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 <dali/public-api/object/property-array.h>
 #include <toolkit-application.h>
 #include <toolkit-event-thread-callback.h>
 #include <toolkit-vector-animation-renderer.h>
@@ -374,6 +375,12 @@ bool VectorAnimationRenderer::GetMarkerInfo(const std::string& marker, uint32_t&
   return Internal::Adaptor::GetImplementation(*this).GetMarkerInfo(marker, startFrame, endFrame);
 }
 
+void VectorAnimationRenderer::GetMarkerInfo(Property::Map& map) const
+{
+  map.Add(VECTOR_ANIMATION_MARKER_NAME_1, Property::Array({VECTOR_ANIMATION_MARKER_START_FRAME_1, VECTOR_ANIMATION_MARKER_END_FRAME_1}));
+  map.Add(VECTOR_ANIMATION_MARKER_NAME_2, Property::Array({VECTOR_ANIMATION_MARKER_START_FRAME_2, VECTOR_ANIMATION_MARKER_END_FRAME_2}));
+}
+
 void VectorAnimationRenderer::InvalidateBuffer()
 {
   return Internal::Adaptor::GetImplementation(*this).InvalidateBuffer();
index 732d6b1..907b8af 100644 (file)
@@ -386,6 +386,9 @@ int UtcDaliAnimatedVectorImageVisualGetPropertyMap01(void)
   value = resultMap.Find(DevelImageVisual::Property::CONTENT_INFO, Property::MAP);
   DALI_TEST_CHECK(value);
 
+  value = resultMap.Find(DevelImageVisual::Property::MARKER_INFO, Property::MAP);
+  DALI_TEST_CHECK(value);
+
   value = resultMap.Find(DevelImageVisual::Property::REDRAW_IN_SCALING_DOWN, Property::BOOLEAN);
   DALI_TEST_CHECK(value);
   DALI_TEST_CHECK(value->Get<bool>() == true); // Check default value
@@ -967,6 +970,85 @@ int UtcDaliAnimatedVectorImageVisualPlayRangeMarker(void)
   END_TEST;
 }
 
+int UtcDaliAnimatedVectorImageVisualMarkerInfo(void)
+{
+  ToolkitTestApplication application;
+  tet_infoline("UtcDaliAnimatedVectorImageVisualMarkerInfo");
+
+  Property::Map propertyMap;
+  propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE)
+    .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME)
+    .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false);
+
+  Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
+  DALI_TEST_CHECK(visual);
+
+  DummyControl      actor     = DummyControl::New(true);
+  DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
+  dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
+
+  Vector2 controlSize(20.f, 30.f);
+  actor.SetProperty(Actor::Property::SIZE, controlSize);
+
+  application.GetScene().Add(actor);
+
+  Property::Map attributes;
+  DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes);
+
+  application.SendNotification();
+  application.Render();
+
+  // Trigger count is 2 - load & render a frame
+  DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
+
+  // renderer is added to actor
+  DALI_TEST_CHECK(actor.GetRendererCount() == 1u);
+  Renderer renderer = actor.GetRendererAt(0u);
+  DALI_TEST_CHECK(renderer);
+
+  Property::Map    map   = actor.GetProperty<Property::Map>(DummyControl::Property::TEST_VISUAL);
+  Property::Value* value = map.Find(DevelImageVisual::Property::MARKER_INFO);
+
+  DALI_TEST_CHECK(value);
+
+  Property::Map* result = value->GetMap();
+  DALI_TEST_CHECK(result);
+
+  std::string resultMarkerName;
+  int         resultStartFrame, resultEndFrame;
+  DALI_TEST_EQUALS(2u, result->Count(), TEST_LOCATION);
+
+  for(uint32_t i = 0u; i < result->Count(); ++i)
+  {
+    if(result->GetKeyAt(i).stringKey == VECTOR_ANIMATION_MARKER_NAME_1)
+    {
+      Property::Array* frameArray = result->GetValue(i).GetArray();
+      DALI_TEST_CHECK(frameArray);
+      frameArray->GetElementAt(0).Get(resultStartFrame);
+      frameArray->GetElementAt(1).Get(resultEndFrame);
+
+      DALI_TEST_EQUALS(VECTOR_ANIMATION_MARKER_START_FRAME_1, resultStartFrame, TEST_LOCATION);
+      DALI_TEST_EQUALS(VECTOR_ANIMATION_MARKER_END_FRAME_1, resultEndFrame, TEST_LOCATION);
+    }
+    else if(result->GetKeyAt(i).stringKey == VECTOR_ANIMATION_MARKER_NAME_2)
+    {
+      Property::Array* frameArray = result->GetValue(i).GetArray();
+      DALI_TEST_CHECK(frameArray);
+      frameArray->GetElementAt(0).Get(resultStartFrame);
+      frameArray->GetElementAt(1).Get(resultEndFrame);
+
+      DALI_TEST_EQUALS(VECTOR_ANIMATION_MARKER_START_FRAME_2, resultStartFrame, TEST_LOCATION);
+      DALI_TEST_EQUALS(VECTOR_ANIMATION_MARKER_END_FRAME_2, resultEndFrame, TEST_LOCATION);
+    }
+    else
+    {
+      DALI_TEST_CHECK(false);
+    }
+  }
+
+  END_TEST;
+}
+
 int UtcDaliAnimatedVectorImageVisualAnimationFinishedSignal(void)
 {
   ToolkitTestApplication application;
index 35dc49d..1677767 100644 (file)
@@ -133,7 +133,7 @@ enum Type
 
   /**
    * @brief The content information the AnimatedVectorImageVisual will use.
-   * @details Name "contentInfo", Type Property::MAP.
+   * @details Type Property::MAP.
    * The map contains the layer name as a key and Property::Array as a value.
    * And the array contains 2 integer values which are the frame numbers, the start frame number and the end frame number of the layer.
    * @note This property is read-only.
@@ -180,7 +180,16 @@ enum Type
    * Disable broken image for these visuals.
    * default is true.
    */
-  ENABLE_BROKEN_IMAGE = ORIENTATION_CORRECTION + 14
+  ENABLE_BROKEN_IMAGE = ORIENTATION_CORRECTION + 14,
+
+  /**
+   * @brief The marker information the AnimatedVectorImageVisual will use.
+   * @details Type Property::MAP.
+   * The map contains the marker name as a key and Property::Array as a value.
+   * And the array contains 2 integer values which are the frame numbers, the start frame number and the end frame number of the marker.
+   * @note This property is read-only.
+   */
+  MARKER_INFO = ORIENTATION_CORRECTION + 15,
 };
 
 } //namespace Property
index 982d6dd..a2518d9 100644 (file)
@@ -204,6 +204,10 @@ void AnimatedVectorImageVisual::DoCreatePropertyMap(Property::Map& map) const
   mVectorAnimationTask->GetLayerInfo(layerInfo);
   map.Insert(Toolkit::DevelImageVisual::Property::CONTENT_INFO, layerInfo);
 
+  Property::Map markerInfo;
+  mVectorAnimationTask->GetMarkerInfo(markerInfo);
+  map.Insert(Toolkit::DevelImageVisual::Property::MARKER_INFO, markerInfo);
+
   map.Insert(Toolkit::ImageVisual::Property::SYNCHRONOUS_LOADING, IsSynchronousLoadingRequired());
   map.Insert(Toolkit::ImageVisual::Property::DESIRED_WIDTH, mDesiredSize.GetWidth());
   map.Insert(Toolkit::ImageVisual::Property::DESIRED_HEIGHT, mDesiredSize.GetHeight());
index dc52176..6c44eac 100644 (file)
@@ -462,6 +462,11 @@ void VectorAnimationTask::GetLayerInfo(Property::Map& map) const
   mVectorRenderer.GetLayerInfo(map);
 }
 
+void VectorAnimationTask::GetMarkerInfo(Property::Map& map) const
+{
+  mVectorRenderer.GetMarkerInfo(map);
+}
+
 VectorAnimationTask::ResourceReadySignalType& VectorAnimationTask::ResourceReadySignal()
 {
   return mResourceReadySignal;
index c3ac749..a115377 100644 (file)
@@ -216,6 +216,12 @@ public:
   void GetLayerInfo(Property::Map& map) const;
 
   /**
+   * @brief Gets the all marker information.
+   * @param[out] map The marker information
+   */
+  void GetMarkerInfo(Property::Map& map) const;
+
+  /**
    * @brief Connect to this signal to be notified when the resource is ready.
    * @return The signal to connect to.
    */