It will use a default size of the content file if the size is not set.
Change-Id: I5dbfe79146a461d412c39ab5dcf37fabd94b683c
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2022 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-image-renderer.h>
#include <dali/public-api/object/base-object.h>
#include <dali/public-api/rendering/renderer.h>
+#include <sys/stat.h>
#include <toolkit-application.h>
#include <toolkit-event-thread-callback.h>
-#include <memory>
#include <cstring>
-#include <sys/stat.h>
+#include <memory>
namespace Dali
{
-
namespace Internal
{
-
namespace Adaptor
{
-
-class VectorImageRenderer: public Dali::BaseObject
+class VectorImageRenderer : public Dali::BaseObject
{
public:
-
VectorImageRenderer()
: mWidth(0),
mHeight(0),
return true;
}
- bool Rasterize(Dali::Devel::PixelBuffer& buffer, float scale)
+ Dali::Devel::PixelBuffer Rasterize(uint32_t width, uint32_t height)
{
- return mRasterizeSuccess;
+ if(mRasterizeSuccess)
+ {
+ Devel::PixelBuffer pixelBuffer = Devel::PixelBuffer::New(width, height, Dali::Pixel::RGBA8888);
+ return pixelBuffer;
+ }
+ return Dali::Devel::PixelBuffer();
}
void GetDefaultSize(uint32_t& width, uint32_t& height) const
{
- width = 100;
+ width = 100;
height = 100;
}
public:
-
uint32_t mWidth;
uint32_t mHeight;
bool mRasterizeSuccess;
};
-inline VectorImageRenderer& GetImplementation( Dali::VectorImageRenderer& renderer )
+inline VectorImageRenderer& GetImplementation(Dali::VectorImageRenderer& renderer)
{
- DALI_ASSERT_ALWAYS( renderer && "VectorImageRenderer handle is empty." );
+ DALI_ASSERT_ALWAYS(renderer && "VectorImageRenderer handle is empty.");
BaseObject& handle = renderer.GetBaseObject();
- return static_cast< Internal::Adaptor::VectorImageRenderer& >( handle );
+ return static_cast<Internal::Adaptor::VectorImageRenderer&>(handle);
}
-inline const VectorImageRenderer& GetImplementation( const Dali::VectorImageRenderer& renderer )
+inline const VectorImageRenderer& GetImplementation(const Dali::VectorImageRenderer& renderer)
{
- DALI_ASSERT_ALWAYS( renderer && "VectorImageRenderer handle is empty." );
+ DALI_ASSERT_ALWAYS(renderer && "VectorImageRenderer handle is empty.");
const BaseObject& handle = renderer.GetBaseObject();
- return static_cast< const Internal::Adaptor::VectorImageRenderer& >( handle );
+ return static_cast<const Internal::Adaptor::VectorImageRenderer&>(handle);
}
} // namespace Adaptor
} // namespace Internal
-
/********************************************************************************/
/********************************* PUBLIC CLASS *******************************/
/********************************************************************************/
{
Internal::Adaptor::VectorImageRenderer* imageRenderer = new Internal::Adaptor::VectorImageRenderer();
- return VectorImageRenderer( imageRenderer );
+ return VectorImageRenderer(imageRenderer);
}
VectorImageRenderer::VectorImageRenderer()
{
}
-VectorImageRenderer::VectorImageRenderer( Internal::Adaptor::VectorImageRenderer* internal )
-: BaseHandle( internal )
+VectorImageRenderer::VectorImageRenderer(Internal::Adaptor::VectorImageRenderer* internal)
+: BaseHandle(internal)
{
}
return Internal::Adaptor::GetImplementation(*this).Load(data, dpi);
}
-bool VectorImageRenderer::Rasterize(Dali::Devel::PixelBuffer& buffer, float scale)
+Dali::Devel::PixelBuffer VectorImageRenderer::Rasterize(uint32_t width, uint32_t height)
{
- return Internal::Adaptor::GetImplementation(*this).Rasterize(buffer, scale);
+ return Internal::Adaptor::GetImplementation(*this).Rasterize(width, height);
}
-void VectorImageRenderer::GetDefaultSize( uint32_t& width, uint32_t& height ) const
+void VectorImageRenderer::GetDefaultSize(uint32_t& width, uint32_t& height) const
{
- Internal::Adaptor::GetImplementation( *this ).GetDefaultSize( width, height );
+ Internal::Adaptor::GetImplementation(*this).GetDefaultSize(width, height);
}
} // namespace Dali
tet_infoline("Test load from a remote server.");
ToolkitTestApplication application;
- Toolkit::ImageView imageView;
- imageView = Toolkit::ImageView::New();
- imageView.SetImage("https://dev.w3.org/SVG/tools/svgweb/samples/svg-files/check.svg");
- // Victor. Temporary (or permanent?) update as the url above seems not to work from time to time ...
- // imageView.SetImage("https://upload.wikimedia.org/wikipedia/commons/thumb/0/02/SVG_logo.svg/64px-SVG_logo.svg.png");
- imageView.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
- imageView.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
- imageView.SetProperty(Actor::Property::SIZE, Vector2(300, 300));
- imageView.SetProperty(Actor::Property::POSITION, Vector3(150.0f, 150.0f, 0.0f));
- application.GetScene().Add(imageView);
+ {
+ Toolkit::ImageView imageView;
+ imageView = Toolkit::ImageView::New();
+ imageView.SetImage("https://dev.w3.org/SVG/tools/svgweb/samples/svg-files/check.svg");
+ imageView.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
+ imageView.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
+ imageView.SetProperty(Actor::Property::SIZE, Vector2(300, 300));
+ imageView.SetProperty(Actor::Property::POSITION, Vector3(150.0f, 150.0f, 0.0f));
- DALI_TEST_CHECK(imageView);
+ application.GetScene().Add(imageView);
- DALI_TEST_EQUALS(imageView.GetRendererCount(), 0u, TEST_LOCATION);
+ DALI_TEST_CHECK(imageView);
- application.SendNotification();
+ DALI_TEST_EQUALS(imageView.GetRendererCount(), 0u, TEST_LOCATION);
- DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
+ application.SendNotification();
- application.SendNotification();
- application.Render();
+ DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
- DALI_TEST_EQUALS(imageView.GetRendererCount(), 1u, TEST_LOCATION);
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS(imageView.GetRendererCount(), 1u, TEST_LOCATION);
+ }
+
+ // Without size set
+ {
+ Toolkit::ImageView imageView;
+ imageView = Toolkit::ImageView::New();
+ imageView.SetImage("https://dev.w3.org/SVG/tools/svgweb/samples/svg-files/check.svg");
+ imageView.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
+ imageView.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
+ imageView.SetProperty(Actor::Property::POSITION, Vector3(150.0f, 150.0f, 0.0f));
+
+ application.GetScene().Add(imageView);
+
+ DALI_TEST_CHECK(imageView);
+
+ DALI_TEST_EQUALS(imageView.GetRendererCount(), 0u, TEST_LOCATION);
+
+ application.SendNotification();
+
+ DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
+
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS(imageView.GetRendererCount(), 1u, TEST_LOCATION);
+ }
END_TEST;
}
{
ToolkitTestApplication application;
+ TestGlAbstraction& gl = application.GetGlAbstraction();
+ TraceCallStack& textureTrace = gl.GetTextureTrace();
+ textureTrace.Enable(true);
+
// Local svg file - invalid file path
{
gResourceReadySignalFired = false;
DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
DALI_TEST_EQUALS(imageView.GetVisualResourceStatus(ImageView::Property::IMAGE), Visual::ResourceStatus::FAILED, TEST_LOCATION);
+
+ // Should be shown a broken image
+ DALI_TEST_EQUALS(imageView.GetRendererCount(), 1u, TEST_LOCATION);
+ DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
+ }
+
+ // Local svg file - invalid file path without size set
+ {
+ gResourceReadySignalFired = false;
+ textureTrace.Reset();
+
+ ImageView imageView = ImageView::New(TEST_RESOURCE_DIR "/foo.svg");
+ imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
+
+ DALI_TEST_EQUALS(imageView.IsResourceReady(), false, TEST_LOCATION);
+
+ application.GetScene().Add(imageView);
+
+ application.SendNotification();
+ application.Render(16);
+
+ DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
+ DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
+ DALI_TEST_EQUALS(imageView.GetVisualResourceStatus(ImageView::Property::IMAGE), Visual::ResourceStatus::FAILED, TEST_LOCATION);
+
+ // Should be shown a broken image
+ DALI_TEST_EQUALS(imageView.GetRendererCount(), 1u, TEST_LOCATION);
+ DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
}
// Local svg file - invalid file
{
gResourceReadySignalFired = false;
+ textureTrace.Reset();
ImageView imageView = ImageView::New(TEST_RESOURCE_DIR "/invalid.svg");
imageView.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
DALI_TEST_EQUALS(imageView.GetVisualResourceStatus(ImageView::Property::IMAGE), Visual::ResourceStatus::FAILED, TEST_LOCATION);
+
+ // Should be shown a broken image
+ DALI_TEST_EQUALS(imageView.GetRendererCount(), 1u, TEST_LOCATION);
+ DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
}
// Remote svg file
{
gResourceReadySignalFired = false;
+ textureTrace.Reset();
ImageView imageView = ImageView::New("https://bar.org/foobar.svg");
imageView.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
DALI_TEST_EQUALS(imageView.GetVisualResourceStatus(ImageView::Property::IMAGE), Visual::ResourceStatus::FAILED, TEST_LOCATION);
+
+ // Should be shown a broken image
+ DALI_TEST_EQUALS(imageView.GetRendererCount(), 1u, TEST_LOCATION);
+ DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
+ }
+
+ // Remote svg file without size set
+ {
+ gResourceReadySignalFired = false;
+ textureTrace.Reset();
+
+ ImageView imageView = ImageView::New("https://bar.org/foobar.svg");
+ imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
+
+ DALI_TEST_EQUALS(imageView.IsResourceReady(), false, TEST_LOCATION);
+
+ application.GetScene().Add(imageView);
+
+ application.SendNotification();
+
+ // loading started, this waits for the loader thread
+ DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
+
+ application.SendNotification();
+ application.Render(16);
+
+ DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
+ DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
+ DALI_TEST_EQUALS(imageView.GetVisualResourceStatus(ImageView::Property::IMAGE), Visual::ResourceStatus::FAILED, TEST_LOCATION);
+
+ // Should be shown a broken image
+ DALI_TEST_EQUALS(imageView.GetRendererCount(), 1u, TEST_LOCATION);
+ DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
}
END_TEST;
gResourceReadySignalFired = false;
- ImageView imageView = ImageView::New(TEST_RESOURCE_DIR "/svg1.svg");
+ TestGlAbstraction& gl = application.GetGlAbstraction();
+ TraceCallStack& textureTrace = gl.GetTextureTrace();
+ textureTrace.Enable(true);
+
+ ImageView imageView = ImageView::New(TEST_RESOURCE_DIR "/invalid1.svg");
imageView.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
- DALI_TEST_EQUALS(imageView.GetVisualResourceStatus(ImageView::Property::IMAGE), Visual::ResourceStatus::READY, TEST_LOCATION);
-
- // Reset flag
- gResourceReadySignalFired = false;
-
- // Change size
- imageView.SetProperty(Actor::Property::SIZE, Vector2(0.f, 0.f));
-
- application.SendNotification();
-
- // rasterization started, this waits for the rasterize thread
- DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
-
- application.SendNotification();
- application.Render(16);
-
- DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
- DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
- // Fail to rasterize because the size is 0.
DALI_TEST_EQUALS(imageView.GetVisualResourceStatus(ImageView::Property::IMAGE), Visual::ResourceStatus::FAILED, TEST_LOCATION);
+ // Should be shown a broken image
+ DALI_TEST_EQUALS(imageView.GetRendererCount(), 1u, TEST_LOCATION);
+ DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
+
END_TEST;
}
}
END_TEST;
}
+
int UtcDaliImageViewImageLoadFailure01(void)
{
ToolkitTestApplication application;
else if(control.GetVisualResourceStatus(ImageView::Property::IMAGE) == Visual::ResourceStatus::FAILED)
{
// Make the resource ready immediately
- control[ImageView::Property::IMAGE] = TEST_RESOURCE_DIR "/svg1.svg";
+ control[ImageView::Property::IMAGE] = gImage_600_RGB;
}
}
DALI_TEST_EQUALS(imageView.IsResourceReady(), true, TEST_LOCATION);
+ // Create a new ImageView to cache the image
+ ImageView imageView1 = ImageView::New(gImage_600_RGB);
+ application.GetScene().Add(imageView1);
+
+ DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
+
+ application.SendNotification();
+ application.Render();
+
// Reset count
gResourceReadySignalCounter = 0;
/*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2022 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 <limits>
// INTERNAL INCLUDES
-#include <dali-toolkit/devel-api/visuals/visual-actions-devel.h>
#include <dali-toolkit/devel-api/asset-manager/asset-manager.h>
#include <dali-toolkit/devel-api/controls/control-depth-index-ranges.h>
#include <dali-toolkit/devel-api/controls/control-devel.h>
#include <dali-toolkit/devel-api/controls/control-wrapper-impl.h>
+#include <dali-toolkit/devel-api/visuals/visual-actions-devel.h>
#include <dali-toolkit/internal/styling/style-manager-impl.h>
#include <dali-toolkit/internal/visuals/visual-base-impl.h>
#include <dali-toolkit/internal/visuals/visual-string-constants.h>
Dali::Accessibility::Accessible* ExternalAccessibleGetter(Dali::Actor actor)
{
auto control = Toolkit::Control::DownCast(actor);
- if (!control)
+ if(!control)
{
return nullptr;
}
auto accessible = GetAccessibleObject();
auto lastPosition = accessible->GetLastPosition();
auto accessibleRect = accessible->GetExtents(Dali::Accessibility::CoordinateType::WINDOW);
- auto rect = GetShowingGeometry(accessibleRect, accessible);
+ auto rect = GetShowingGeometry(accessibleRect, accessible);
switch(mAccessibilityLastScreenRelativeMoveType)
{
mAccessibilityLastScreenRelativeMoveType = Dali::Accessibility::ScreenRelativeMoveType::OUTSIDE;
// recalculate mAccessibilityLastScreenRelativeMoveType accordingly to the initial position
CheckHighlightedObjectGeometry();
- mAccessibilityPositionNotification = mControlImpl.Self().AddPropertyNotification(Actor::Property::WORLD_POSITION, StepCondition(1.0f, 1.0f));
+ mAccessibilityPositionNotification = mControlImpl.Self().AddPropertyNotification(Actor::Property::WORLD_POSITION, StepCondition(1.0f, 1.0f));
mAccessibilityPositionNotification.SetNotifyMode(PropertyNotification::NOTIFY_ON_CHANGED);
- mAccessibilityPositionNotification.NotifySignal().Connect(this, [this](PropertyNotification&){ CheckHighlightedObjectGeometry(); });
+ mAccessibilityPositionNotification.NotifySignal().Connect(this, [this](PropertyNotification&) { CheckHighlightedObjectGeometry(); });
mIsAccessibilityPositionPropertyNotificationSet = true;
}
}
}
+void Control::Impl::RelayoutRequest(Visual::Base& object)
+{
+ mControlImpl.RelayoutRequest();
+}
+
bool Control::Impl::IsResourceReady() const
{
// Iterate through and check all the enabled visuals are ready
auto* accessible = controlImpl.GetAccessibleObject();
auto* parent = dynamic_cast<Dali::Accessibility::ActorAccessible*>(accessible->GetParent());
- if (parent)
+ if(parent)
{
parent->OnChildrenChanged();
}
void Control::Impl::CreateTransitions(std::vector<std::pair<Dali::Property::Index, Dali::Property::Map>>& sourceProperties,
std::vector<std::pair<Dali::Property::Index, Dali::Property::Map>>& destinationProperties,
- Dali::Toolkit::Control source, Dali::Toolkit::Control destination)
+ Dali::Toolkit::Control source,
+ Dali::Toolkit::Control destination)
{
// Retrieves background properties to be transitioned.
Dali::Property::Map backgroundSourcePropertyMap, backgroundDestinationPropertyMap;
#define DALI_TOOLKIT_CONTROL_DATA_IMPL_H
/*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2022 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.
void NotifyVisualEvent(Visual::Base& object, Property::Index signalId) override;
/**
+ * @brief Called when the visual needs relayout request.
+ * @param[in] object The visual who requests relayout
+ */
+ void RelayoutRequest(Visual::Base& object) override;
+
+ /**
* @copydoc Dali::Toolkit::DevelControl::RegisterVisual()
*/
void RegisterVisual(Property::Index index, Toolkit::Visual::Base& visual);
*/
void CreateTransitions(std::vector<std::pair<Dali::Property::Index, Dali::Property::Map>>& sourceProperties,
std::vector<std::pair<Dali::Property::Index, Dali::Property::Map>>& destinationProperties,
- Dali::Toolkit::Control source, Dali::Toolkit::Control destination);
+ Dali::Toolkit::Control source,
+ Dali::Toolkit::Control destination);
/**
* @brief Update visual properties.
std::string mSubStateName;
Property::Map mAccessibilityAttributes;
- int mLeftFocusableActorId; ///< Actor ID of Left focusable control.
- int mRightFocusableActorId; ///< Actor ID of Right focusable control.
- int mUpFocusableActorId; ///< Actor ID of Up focusable control.
- int mDownFocusableActorId; ///< Actor ID of Down focusable control.
- int mClockwiseFocusableActorId; ///< Actor ID of Clockwise focusable control.
- int mCounterClockwiseFocusableActorId; ///< Actor ID of Counter clockwise focusable control.
+ int mLeftFocusableActorId; ///< Actor ID of Left focusable control.
+ int mRightFocusableActorId; ///< Actor ID of Right focusable control.
+ int mUpFocusableActorId; ///< Actor ID of Up focusable control.
+ int mDownFocusableActorId; ///< Actor ID of Down focusable control.
+ int mClockwiseFocusableActorId; ///< Actor ID of Clockwise focusable control.
+ int mCounterClockwiseFocusableActorId; ///< Actor ID of Counter clockwise focusable control.
RegisteredVisualContainer mVisuals; ///< Stores visuals needed by the control, non trivial type so std::vector used.
std::string mStyleName;
/*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2022 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.
void RasterizingTask::Rasterize()
{
- if(mWidth <= 0u || mHeight <= 0u)
+ Devel::PixelBuffer pixelBuffer = mVectorRenderer.Rasterize(mWidth, mHeight);
+ if(!pixelBuffer)
{
- DALI_LOG_ERROR("RasterizingTask::Rasterize: Size is zero!\n");
- return;
- }
-
- Devel::PixelBuffer pixelBuffer = Devel::PixelBuffer::New(mWidth, mHeight, Dali::Pixel::RGBA8888);
-
- uint32_t defaultWidth, defaultHeight;
- mVectorRenderer.GetDefaultSize(defaultWidth, defaultHeight);
-
- float scaleX = static_cast<float>(mWidth) / static_cast<float>(defaultWidth);
- float scaleY = static_cast<float>(mHeight) / static_cast<float>(defaultHeight);
- float scale = scaleX < scaleY ? scaleX : scaleY;
-
- if(!mVectorRenderer.Rasterize(pixelBuffer, scale))
- {
- DALI_LOG_ERROR("RasterizingTask::Rasterize: Rasterize is failed! [%s]\n", mUrl.GetUrl().c_str());
+ DALI_LOG_ERROR("Rasterize is failed! [%s]\n", mUrl.GetUrl().c_str());
return;
}
mDefaultWidth(0),
mDefaultHeight(0),
mPlacementActor(),
- mVisualSize(Vector2::ZERO),
+ mRasterizedSize(Vector2::ZERO),
mLoadFailed(false),
mAttemptAtlasing(false)
{
}
else
{
- // SVG visual needs it's size set before it can be rasterized hence set ResourceReady once on stage
- ResourceReady(Toolkit::Visual::ResourceStatus::READY);
+ if(mImpl->mEventObserver)
+ {
+ // SVG visual needs it's size set before it can be rasterized hence request relayout once on stage
+ mImpl->mEventObserver->RelayoutRequest(*this);
+ }
}
}
mPlacementActor.Reset();
// Reset the visual size to zero so that when adding the actor back to stage the SVG rasterization is forced
- mVisualSize = Vector2::ZERO;
+ mRasterizedSize = Vector2::ZERO;
}
void SvgVisual::GetNaturalSize(Vector2& naturalSize)
{
- naturalSize.x = mDefaultWidth;
- naturalSize.y = mDefaultHeight;
+ if(mLoadFailed && mImpl->mRenderer)
+ {
+ // Load failed, use broken image size
+ auto textureSet = mImpl->mRenderer.GetTextures();
+ if(textureSet && textureSet.GetTextureCount())
+ {
+ auto texture = textureSet.GetTexture(0);
+ if(texture)
+ {
+ naturalSize.x = texture.GetWidth();
+ naturalSize.y = texture.GetHeight();
+ return;
+ }
+ }
+ }
+ else
+ {
+ naturalSize.x = mDefaultWidth;
+ naturalSize.y = mDefaultHeight;
+ }
}
void SvgVisual::DoCreatePropertyMap(Property::Map& map) const
{
if(isLoaded && rasterizedPixelData && IsOnScene())
{
+ if(mDefaultWidth == 0 || mDefaultHeight == 0)
+ {
+ mVectorRenderer.GetDefaultSize(mDefaultWidth, mDefaultHeight);
+ }
+
+ mRasterizedSize.x = static_cast<float>(rasterizedPixelData.GetWidth());
+ mRasterizedSize.y = static_cast<float>(rasterizedPixelData.GetHeight());
+
TextureSet currentTextureSet = mImpl->mRenderer.GetTextures();
if(mImpl->mFlags & Impl::IS_ATLASING_APPLIED)
{
}
else if(!isLoaded || !rasterizedPixelData)
{
+ mLoadFailed = true;
+
Actor actor = mPlacementActor.GetHandle();
if(actor)
{
if(IsOnScene() && !mLoadFailed)
{
- if(visualSize != mVisualSize)
+ if(visualSize != mRasterizedSize || mDefaultWidth == 0 || mDefaultHeight == 0)
{
AddRasterizationTask(visualSize);
- mVisualSize = visualSize;
+ mRasterizedSize = visualSize;
}
}
uint32_t mDefaultWidth;
uint32_t mDefaultHeight;
WeakHandle<Actor> mPlacementActor;
- Vector2 mVisualSize;
+ Vector2 mRasterizedSize;
bool mLoadFailed;
bool mAttemptAtlasing; ///< If true will attempt atlasing, otherwise create unique texture
};
#define DALI_INTERNAL_TOOLKIT_VISUAL_EVENT_OBSERVER_H
/*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2022 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.
*/
virtual void NotifyVisualEvent(Visual::Base& object, Property::Index signalId) = 0;
+ /**
+ * Requests a relayout to the observer.
+ * @param[in] object The connection owner
+ */
+ virtual void RelayoutRequest(Visual::Base& object) = 0;
+
protected:
/**
* constructor