From 16d28f016331d23177027d79c25f364b73792e02 Mon Sep 17 00:00:00 2001 From: "Eunki, Hong" Date: Tue, 7 Nov 2023 20:13:41 +0900 Subject: [PATCH] (AnimatedVector) Get marker informations 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 --- .../toolkit-vector-animation-renderer.cpp | 9 ++- .../utc-Dali-AnimatedVectorImageVisual.cpp | 82 ++++++++++++++++++++++ .../visuals/image-visual-properties-devel.h | 13 +++- .../animated-vector-image-visual.cpp | 4 ++ .../vector-animation-task.cpp | 5 ++ .../animated-vector-image/vector-animation-task.h | 6 ++ 6 files changed, 116 insertions(+), 3 deletions(-) diff --git a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-vector-animation-renderer.cpp b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-vector-animation-renderer.cpp index a510323..eee47b8 100644 --- a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-vector-animation-renderer.cpp +++ b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-vector-animation-renderer.cpp @@ -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 #include #include +#include #include #include #include @@ -359,6 +360,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(); diff --git a/automated-tests/src/dali-toolkit/utc-Dali-AnimatedVectorImageVisual.cpp b/automated-tests/src/dali-toolkit/utc-Dali-AnimatedVectorImageVisual.cpp index ba0fa16..3069b53 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-AnimatedVectorImageVisual.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-AnimatedVectorImageVisual.cpp @@ -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() == 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(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(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; diff --git a/dali-toolkit/devel-api/visuals/image-visual-properties-devel.h b/dali-toolkit/devel-api/visuals/image-visual-properties-devel.h index 1f92daa..cb2e3f2 100644 --- a/dali-toolkit/devel-api/visuals/image-visual-properties-devel.h +++ b/dali-toolkit/devel-api/visuals/image-visual-properties-devel.h @@ -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. @@ -165,7 +165,16 @@ enum Type * 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 diff --git a/dali-toolkit/internal/visuals/animated-vector-image/animated-vector-image-visual.cpp b/dali-toolkit/internal/visuals/animated-vector-image/animated-vector-image-visual.cpp index 1f5be69..c02f128 100644 --- a/dali-toolkit/internal/visuals/animated-vector-image/animated-vector-image-visual.cpp +++ b/dali-toolkit/internal/visuals/animated-vector-image/animated-vector-image-visual.cpp @@ -202,6 +202,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()); diff --git a/dali-toolkit/internal/visuals/animated-vector-image/vector-animation-task.cpp b/dali-toolkit/internal/visuals/animated-vector-image/vector-animation-task.cpp index 843d48b..5c595f9 100644 --- a/dali-toolkit/internal/visuals/animated-vector-image/vector-animation-task.cpp +++ b/dali-toolkit/internal/visuals/animated-vector-image/vector-animation-task.cpp @@ -410,6 +410,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; diff --git a/dali-toolkit/internal/visuals/animated-vector-image/vector-animation-task.h b/dali-toolkit/internal/visuals/animated-vector-image/vector-animation-task.h index 14085eb..5acd518 100644 --- a/dali-toolkit/internal/visuals/animated-vector-image/vector-animation-task.h +++ b/dali-toolkit/internal/visuals/animated-vector-image/vector-animation-task.h @@ -203,6 +203,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. */ -- 2.7.4