tet_infoline("UtcDaliVisualFactoryGetAnimatedVectorImageVisual04: Request animated vector image visual with a Property::Map");
int startFrame = 1, endFrame = 3;
+ int desiredWidth = 100, desiredHeight = 150;
float cornerRadius = 22.0f;
float borderlineWidth = 2.0f;
Vector4 borderlineColor = Vector4(1.0f, 1.0f, 1.0f, 1.0f);
.Add("borderlineWidth", borderlineWidth)
.Add("borderlineColor", borderlineColor)
.Add("borderlineOffset", borderlineOffset)
- .Add("synchronousLoading", true);
+ .Add("desiredWidth", desiredWidth)
+ .Add("desiredHeight", desiredHeight);
Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap);
DALI_TEST_CHECK(visual);
DALI_TEST_CHECK(value);
DALI_TEST_EQUALS(value->Get<float>(), borderlineOffset, TEST_LOCATION);
+ value = resultMap.Find(ImageVisual::Property::DESIRED_WIDTH, Property::INTEGER);
+ DALI_TEST_CHECK(value);
+ DALI_TEST_EQUALS(value->Get<int>(), desiredWidth, TEST_LOCATION);
+
+ value = resultMap.Find(ImageVisual::Property::DESIRED_HEIGHT, Property::INTEGER);
+ DALI_TEST_CHECK(value);
+ DALI_TEST_EQUALS(value->Get<int>(), desiredHeight, TEST_LOCATION);
+
actor.Unparent();
DALI_TEST_CHECK(actor.GetRendererCount() == 0u);
tet_infoline("UtcDaliAnimatedVectorImageVisualGetPropertyMap01");
int startFrame = 1, endFrame = 3;
+ int desiredWidth = 100, desiredHeight = 150;
Vector4 cornerRadius(50.0f, 22.0f, 0.0f, 3.0f);
float borderlineWidth = 2.3f;
Vector4 borderlineColor = Vector4(0.3f, 0.3f, 1.0f, 1.0f);
.Add(DevelVisual::Property::BORDERLINE_WIDTH, borderlineWidth)
.Add(DevelVisual::Property::BORDERLINE_COLOR, borderlineColor)
.Add(DevelVisual::Property::BORDERLINE_OFFSET, borderlineOffset)
- .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false);
+ .Add(ImageVisual::Property::SYNCHRONOUS_LOADING, false)
+ .Add(ImageVisual::Property::DESIRED_WIDTH, desiredWidth)
+ .Add(ImageVisual::Property::DESIRED_HEIGHT, desiredHeight);
// request AnimatedVectorImageVisual with a property map
VisualFactory factory = VisualFactory::Get();
DALI_TEST_CHECK(value);
DALI_TEST_EQUALS(value->Get<float>(), borderlineOffset, TEST_LOCATION);
+ value = resultMap.Find(ImageVisual::Property::DESIRED_WIDTH, Property::INTEGER);
+ DALI_TEST_CHECK(value);
+ DALI_TEST_EQUALS(value->Get<int>(), desiredWidth, TEST_LOCATION);
+
+ value = resultMap.Find(ImageVisual::Property::DESIRED_HEIGHT, Property::INTEGER);
+ DALI_TEST_CHECK(value);
+ DALI_TEST_EQUALS(value->Get<int>(), desiredHeight, TEST_LOCATION);
+
// request AnimatedVectorImageVisual with an URL
Visual::Base visual2 = factory.CreateVisual(TEST_VECTOR_IMAGE_FILE_NAME, ImageDimensions());
END_TEST;
}
+
+int UtcDaliAnimatedVectorImageVisualDesiredSize(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline("UtcDaliAnimatedVectorImageVisualDesiredSize");
+
+ TestGlAbstraction& gl = application.GetGlAbstraction();
+ TraceCallStack& textureTrace = gl.GetTextureTrace();
+ int desiredWidth = 150, desiredHeight = 200;
+
+ Visual::Base visual = VisualFactory::Get().CreateVisual(TEST_VECTOR_IMAGE_FILE_NAME, ImageDimensions(desiredWidth, desiredHeight));
+ DALI_TEST_CHECK(visual);
+
+ DummyControl actor = DummyControl::New(true);
+ DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
+ dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
+
+ application.GetScene().Add(actor);
+
+ application.SendNotification();
+ application.Render();
+
+ // Trigger count is 1 - resource ready
+ DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
+
+ textureTrace.Enable(true);
+
+ application.SendNotification();
+ application.Render();
+
+ {
+ std::stringstream out;
+ out << GL_TEXTURE_2D << ", " << 0u << ", " << desiredWidth << ", " << desiredHeight;
+ DALI_TEST_CHECK(textureTrace.FindMethodAndParams("TexImage2D", out.str().c_str()));
+ }
+
+ // Unparent to make next trigger
+ actor.Unparent();
+
+ application.SendNotification();
+ application.Render();
+
+ // Set visual size
+ actor.SetProperty(Actor::Property::SIZE, Vector2(300.0f, 300.0f));
+ application.GetScene().Add(actor);
+
+ application.SendNotification();
+ application.Render();
+
+ // Trigger count is 1 - resource ready
+ DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
+
+ textureTrace.Reset();
+
+ application.SendNotification();
+ application.Render();
+
+ {
+ std::stringstream out;
+ out << GL_TEXTURE_2D << ", " << 0u << ", " << desiredWidth << ", " << desiredHeight;
+ DALI_TEST_CHECK(textureTrace.FindMethodAndParams("TexImage2D", out.str().c_str())); // The size should not be changed
+ }
+
+ END_TEST;
+}
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),
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);
+ }
}
}
}
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)
{
* @param[in] factoryCache A pointer pointing to the VisualFactoryCache object
* @param[in] shaderFactory The ImageVisualShaderFactory object
* @param[in] imageUrl The URL to an animated vector image to use
+ * @param[in] size The width and height of the rasterized buffer. The visual size will be used if these are 0.
* @return A smart-pointer to the newly allocated visual.
*/
- static AnimatedVectorImageVisualPtr New(VisualFactoryCache& factoryCache, ImageVisualShaderFactory& shaderFactory, const VisualUrl& imageUrl);
+ static AnimatedVectorImageVisualPtr New(VisualFactoryCache& factoryCache, ImageVisualShaderFactory& shaderFactory, const VisualUrl& imageUrl, ImageDimensions size = ImageDimensions());
public: // from Visual
/**
* @param[in] factoryCache A pointer pointing to the VisualFactoryCache object
* @param[in] shaderFactory The ImageVisualShaderFactory object
* @param[in] imageUrl The URL to an animated vector image to use
+ * @param[in] size The width and height of the rasterized buffer. The visual size will be used if these are 0.
*/
- AnimatedVectorImageVisual(VisualFactoryCache& factoryCache, ImageVisualShaderFactory& shaderFactory, const VisualUrl& imageUrl);
+ AnimatedVectorImageVisual(VisualFactoryCache& factoryCache, ImageVisualShaderFactory& shaderFactory, const VisualUrl& imageUrl, ImageDimensions size);
/**
* @brief A reference counted object may only be deleted by calling Unreference().
PropertyNotification mSizeNotification;
Vector2 mVisualSize;
Vector2 mVisualScale;
+ Dali::ImageDimensions mDesiredSize{};
WeakHandle<Actor> mPlacementActor;
DevelImageVisual::PlayState::Type mPlayState;
CallbackBase* mEventCallback; // Not owned
case Toolkit::ImageVisual::Property::DESIRED_WIDTH:
{
- float desiredWidth = 0.0f;
+ int32_t desiredWidth = 0;
if(value.Get(desiredWidth))
{
mDesiredSize.SetWidth(desiredWidth);
case Toolkit::ImageVisual::Property::DESIRED_HEIGHT:
{
- float desiredHeight = 0.0f;
+ int32_t desiredHeight = 0;
if(value.Get(desiredHeight))
{
mDesiredSize.SetHeight(desiredHeight);
}
case VisualUrl::JSON:
{
- visualPtr = AnimatedVectorImageVisual::New(GetFactoryCache(), GetImageVisualShaderFactory(), visualUrl);
+ visualPtr = AnimatedVectorImageVisual::New(GetFactoryCache(), GetImageVisualShaderFactory(), visualUrl, size);
break;
}
case VisualUrl::REGULAR_IMAGE: