/*
- * 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.
#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>
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();
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
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;
/**
* @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.
* But it can spend a lot of memory if the resource has high resolution image or many frame count.
* @note It is used in the AnimatedImageVisual. The default is false
*/
- USE_FIXED_CACHE = ORIENTATION_CORRECTION + 13
+ USE_FIXED_CACHE = ORIENTATION_CORRECTION + 13,
+
+ /**
+ * @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