END_TEST;
}
-int UtcDaliImageViewSvgDesiredSize01(void)
-{
- ToolkitTestApplication application;
-
- TestGlAbstraction& gl = application.GetGlAbstraction();
- TraceCallStack& textureTrace = gl.GetTextureTrace();
- textureTrace.Enable(true);
-
- int desiredWidth = 100, desiredHeight = 150;
- ImageView imageView = ImageView::New(TEST_SVG_FILE_NAME, ImageDimensions(desiredWidth, desiredHeight));
-
- application.GetScene().Add(imageView);
-
- application.SendNotification();
-
- // Wait for loading & rasterization
- DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
-
- application.SendNotification();
- application.Render(16);
-
- {
- std::stringstream out;
- out << GL_TEXTURE_2D << ", " << 0u << ", " << desiredWidth << ", " << desiredHeight;
- DALI_TEST_CHECK(textureTrace.FindMethodAndParams("TexImage2D", out.str().c_str()));
- }
-
- END_TEST;
-}
-
-int UtcDaliImageViewSvgDesiredSize02(void)
-{
- ToolkitTestApplication application;
-
- TestGlAbstraction& gl = application.GetGlAbstraction();
- TraceCallStack& textureTrace = gl.GetTextureTrace();
- textureTrace.Enable(true);
-
- int desiredWidth = 150, desiredHeight = 100;
- ImageView imageView = ImageView::New();
- imageView[ImageView::Property::IMAGE] = Property::Map().Add("url", TEST_SVG_FILE_NAME).Add("desiredWidth", desiredWidth).Add("desiredHeight", desiredHeight);
- application.GetScene().Add(imageView);
-
- application.SendNotification();
-
- // Wait for loading & rasterization
- DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
-
- application.SendNotification();
- application.Render(16);
-
- {
- std::stringstream out;
- out << GL_TEXTURE_2D << ", " << 0u << ", " << desiredWidth << ", " << desiredHeight;
- DALI_TEST_CHECK(textureTrace.FindMethodAndParams("TexImage2D", out.str().c_str()));
- }
-
- END_TEST;
-}
-
int UtcDaliImageViewImageLoadFailure01(void)
{
ToolkitTestApplication application;
SvgVisualPtr SvgVisual::New(VisualFactoryCache& factoryCache, ImageVisualShaderFactory& shaderFactory, const VisualUrl& imageUrl, const Property::Map& properties)
{
- SvgVisualPtr svgVisual(new SvgVisual(factoryCache, shaderFactory, imageUrl, ImageDimensions{}));
+ SvgVisualPtr svgVisual(new SvgVisual(factoryCache, shaderFactory, imageUrl));
svgVisual->SetProperties(properties);
svgVisual->Initialize();
return svgVisual;
}
-SvgVisualPtr SvgVisual::New(VisualFactoryCache& factoryCache, ImageVisualShaderFactory& shaderFactory, const VisualUrl& imageUrl, ImageDimensions size)
+SvgVisualPtr SvgVisual::New(VisualFactoryCache& factoryCache, ImageVisualShaderFactory& shaderFactory, const VisualUrl& imageUrl)
{
- SvgVisualPtr svgVisual(new SvgVisual(factoryCache, shaderFactory, imageUrl, size));
+ SvgVisualPtr svgVisual(new SvgVisual(factoryCache, shaderFactory, imageUrl));
svgVisual->Initialize();
return svgVisual;
}
-SvgVisual::SvgVisual(VisualFactoryCache& factoryCache, ImageVisualShaderFactory& shaderFactory, const VisualUrl& imageUrl, ImageDimensions size)
+SvgVisual::SvgVisual(VisualFactoryCache& factoryCache, ImageVisualShaderFactory& shaderFactory, const VisualUrl& imageUrl)
: Visual::Base(factoryCache, Visual::FittingMode::FILL, Toolkit::Visual::SVG),
mImageVisualShaderFactory(shaderFactory),
mAtlasRect(FULL_TEXTURE_RECT),
mDefaultHeight(0),
mPlacementActor(),
mRasterizedSize(Vector2::ZERO),
- mDesiredSize(size),
mLoadFailed(false),
mAttemptAtlasing(false)
{
{
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 SvgVisual::GetNaturalSize(Vector2& naturalSize)
{
- if(mDesiredSize.GetWidth() > 0 && mDesiredSize.GetHeight() > 0)
- {
- naturalSize.x = mDesiredSize.GetWidth();
- naturalSize.y = mDesiredSize.GetHeight();
- }
- else if(mLoadFailed && mImpl->mRenderer)
+ if(mLoadFailed && mImpl->mRenderer)
{
// Load failed, use broken image size
auto textureSet = mImpl->mRenderer.GetTextures();
map.Insert(Toolkit::ImageVisual::Property::ATLASING, mAttemptAtlasing);
}
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 SvgVisual::DoCreateInstancePropertyMap(Property::Map& map) const
void SvgVisual::OnSetTransform()
{
+ Vector2 visualSize = mImpl->mTransform.GetVisualSize(mImpl->mControlSize);
+
if(IsOnScene() && !mLoadFailed)
{
- Vector2 size;
- if(mDesiredSize.GetWidth() > 0 && mDesiredSize.GetHeight() > 0)
- {
- // Use desired size
- size = Vector2(mDesiredSize.GetWidth(), mDesiredSize.GetHeight());
- }
- else
- {
- // Use visual size
- size = mImpl->mTransform.GetVisualSize(mImpl->mControlSize);
- }
-
- if(size != mRasterizedSize || mDefaultWidth == 0 || mDefaultHeight == 0)
+ if(visualSize != mRasterizedSize || mDefaultWidth == 0 || mDefaultHeight == 0)
{
- mRasterizedSize = size;
- AddRasterizationTask(size);
+ mRasterizedSize = visualSize;
+ AddRasterizationTask(visualSize);
}
}
* @param[in] factoryCache A pointer pointing to the VisualFactoryCache object
* @param[in] shaderFactory The ImageVisualShaderFactory object
* @param[in] imageUrl The URL to svg resource 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 SvgVisualPtr New(VisualFactoryCache& factoryCache, ImageVisualShaderFactory& shaderFactory, const VisualUrl& imageUrl, ImageDimensions size = ImageDimensions());
+ static SvgVisualPtr New(VisualFactoryCache& factoryCache, ImageVisualShaderFactory& shaderFactory, const VisualUrl& imageUrl);
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 svg resource to use
- * @param[in] size The width and height of the rasterized buffer. The visual size will be used if these are 0.
*/
- SvgVisual(VisualFactoryCache& factoryCache, ImageVisualShaderFactory& shaderFactory, const VisualUrl& imageUrl, ImageDimensions size);
+ SvgVisual(VisualFactoryCache& factoryCache, ImageVisualShaderFactory& shaderFactory, const VisualUrl& imageUrl);
/**
* @brief A reference counted object may only be deleted by calling Unreference().
uint32_t mDefaultHeight;
WeakHandle<Actor> mPlacementActor;
Vector2 mRasterizedSize;
- Dali::ImageDimensions mDesiredSize{};
bool mLoadFailed;
bool mAttemptAtlasing; ///< If true will attempt atlasing, otherwise create unique texture
};