/*
- * 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/common/stage.h>
#include <dali/devel-api/rendering/renderer-devel.h>
#include <dali/integration-api/debug.h>
+#include <dali/public-api/math/math-utils.h>
#include <dali/public-api/rendering/decorated-visual-renderer.h>
// INTERNAL INCLUDES
AnimatedVectorImageVisualPtr AnimatedVectorImageVisual::New(VisualFactoryCache& factoryCache, ImageVisualShaderFactory& shaderFactory, const VisualUrl& imageUrl, const Property::Map& properties)
{
- AnimatedVectorImageVisualPtr visual(new AnimatedVectorImageVisual(factoryCache, shaderFactory, imageUrl));
+ AnimatedVectorImageVisualPtr visual(new AnimatedVectorImageVisual(factoryCache, shaderFactory, imageUrl, ImageDimensions{}));
visual->SetProperties(properties);
visual->Initialize();
return visual;
}
-AnimatedVectorImageVisualPtr AnimatedVectorImageVisual::New(VisualFactoryCache& factoryCache, ImageVisualShaderFactory& shaderFactory, const VisualUrl& imageUrl)
+AnimatedVectorImageVisualPtr AnimatedVectorImageVisual::New(VisualFactoryCache& factoryCache, ImageVisualShaderFactory& shaderFactory, const VisualUrl& imageUrl, ImageDimensions size)
{
- AnimatedVectorImageVisualPtr visual(new AnimatedVectorImageVisual(factoryCache, shaderFactory, imageUrl));
+ AnimatedVectorImageVisualPtr visual(new AnimatedVectorImageVisual(factoryCache, shaderFactory, imageUrl, size));
visual->Initialize();
return visual;
}
-AnimatedVectorImageVisual::AnimatedVectorImageVisual(VisualFactoryCache& factoryCache, ImageVisualShaderFactory& shaderFactory, const VisualUrl& imageUrl)
+AnimatedVectorImageVisual::AnimatedVectorImageVisual(VisualFactoryCache& factoryCache, ImageVisualShaderFactory& shaderFactory, const VisualUrl& imageUrl, ImageDimensions size)
: Visual::Base(factoryCache, Visual::FittingMode::FILL, static_cast<Toolkit::Visual::Type>(Toolkit::DevelVisual::ANIMATED_VECTOR_IMAGE)),
mUrl(imageUrl),
mAnimationData(),
mImageVisualShaderFactory(shaderFactory),
mVisualSize(),
mVisualScale(Vector2::ONE),
+ mDesiredSize(size),
mPlacementActor(),
mPlayState(DevelImageVisual::PlayState::STOPPED),
mEventCallback(nullptr),
if(mEventCallback)
{
mFactoryCache.GetVectorAnimationManager().UnregisterEventCallback(mEventCallback);
+ mEventCallback = nullptr;
}
// Finalize animation task and disconnect the signal in the main thread
void AnimatedVectorImageVisual::GetNaturalSize(Vector2& naturalSize)
{
- if(mVisualSize != Vector2::ZERO)
+ if(mDesiredSize.GetWidth() > 0 && mDesiredSize.GetHeight() > 0)
+ {
+ naturalSize.x = mDesiredSize.GetWidth();
+ naturalSize.y = mDesiredSize.GetHeight();
+ }
+ else if(mVisualSize != Vector2::ZERO)
{
naturalSize = mVisualSize;
}
Property::Map layerInfo;
mVectorAnimationTask->GetLayerInfo(layerInfo);
map.Insert(Toolkit::DevelImageVisual::Property::CONTENT_INFO, layerInfo);
+
+ 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());
}
void AnimatedVectorImageVisual::DoCreateInstancePropertyMap(Property::Map& map) const
{
DoSetProperty(Toolkit::ImageVisual::Property::SYNCHRONOUS_LOADING, keyValue.second);
}
+ else if(keyValue.first == IMAGE_DESIRED_WIDTH)
+ {
+ DoSetProperty(Toolkit::ImageVisual::Property::DESIRED_WIDTH, keyValue.second);
+ }
+ else if(keyValue.first == IMAGE_DESIRED_HEIGHT)
+ {
+ DoSetProperty(Toolkit::ImageVisual::Property::DESIRED_HEIGHT, keyValue.second);
+ }
}
}
mAnimationData.playRange = *array;
mAnimationData.resendFlag |= VectorAnimationTask::RESEND_PLAY_RANGE;
}
+ else if(value.GetType() == Property::STRING)
+ {
+ std::string markerName;
+ if(value.Get(markerName))
+ {
+ Property::Array array;
+ array.Add(markerName);
+ mAnimationData.playRange = std::move(array);
+ mAnimationData.resendFlag |= VectorAnimationTask::RESEND_PLAY_RANGE;
+ }
+ }
break;
}
case Toolkit::DevelImageVisual::Property::STOP_BEHAVIOR:
}
break;
}
+ case Toolkit::ImageVisual::Property::DESIRED_WIDTH:
+ {
+ int32_t desiredWidth = 0;
+ if(value.Get(desiredWidth))
+ {
+ mDesiredSize.SetWidth(desiredWidth);
+ }
+ break;
+ }
+
+ case Toolkit::ImageVisual::Property::DESIRED_HEIGHT:
+ {
+ int32_t desiredHeight = 0;
+ if(value.Get(desiredHeight))
+ {
+ mDesiredSize.SetHeight(desiredHeight);
+ }
+ break;
+ }
}
}
void AnimatedVectorImageVisual::SetVectorImageSize()
{
- uint32_t width = static_cast<uint32_t>(mVisualSize.width * mVisualScale.width);
- uint32_t height = static_cast<uint32_t>(mVisualSize.height * mVisualScale.height);
+ uint32_t width, height;
+ if(mDesiredSize.GetWidth() > 0 && mDesiredSize.GetHeight() > 0)
+ {
+ width = mDesiredSize.GetWidth();
+ height = mDesiredSize.GetHeight();
+ }
+ else
+ {
+ width = static_cast<uint32_t>(mVisualSize.width * mVisualScale.width);
+ height = static_cast<uint32_t>(mVisualSize.height * mVisualScale.height);
+ }
if(mAnimationData.width != width || mAnimationData.height != height)
{
{
Vector3 scale = actor.GetProperty<Vector3>(Actor::Property::WORLD_SCALE);
- if((mVisualScale.width != scale.width || mVisualScale.height != scale.height) && (mRedrawInScalingDown || scale.width >= 1.0f || scale.height >= 1.0f))
+ if((!Dali::Equals(mVisualScale.width, scale.width) || !Dali::Equals(mVisualScale.height, scale.height)) && (mRedrawInScalingDown || scale.width >= 1.0f || scale.height >= 1.0f))
{
mVisualScale.width = scale.width;
mVisualScale.height = scale.height;
{
Vector3 size = actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE);
- if(mVisualSize.width != size.width || mVisualSize.height != size.height)
+ if(!Dali::Equals(mVisualSize.width, size.width) || !Dali::Equals(mVisualSize.height, size.height))
{
mVisualSize.width = size.width;
mVisualSize.height = size.height;