propertyMap5.Insert(ImageVisual::Property::URL, TEST_SVG_FILE_NAME);
Visual::Base svgVisual = factory.CreateVisual(propertyMap5);
DALI_TEST_CHECK(svgVisual);
- TestDebugVisual(application.GetScene(), svgVisual, Visual::SVG, Vector2(100.f, 100.f));
+ TestDebugVisual(application.GetScene(), svgVisual, Visual::SVG, Vector2::ZERO);
// Test that AnimatedImageVisual is replaced with debug visual
// TEST_GIF_FILE: anim.gif
#include <sys/stat.h>
#include <toolkit-application.h>
#include <toolkit-event-thread-callback.h>
+#include <toolkit-vector-image-renderer.h>
#include <cstring>
#include <memory>
{
namespace Adaptor
{
+namespace
+{
+Dali::Internal::Adaptor::VectorImageRenderer* gVectorImageRenderer = nullptr;
+}
+
class VectorImageRenderer : public Dali::BaseObject
{
public:
VectorImageRenderer()
- : mWidth(0),
- mHeight(0),
- mRasterizeSuccess(true)
{
}
bool Load(const Vector<uint8_t>& data, float dpi)
{
+ mLoadCount++;
if(strncmp(reinterpret_cast<char*>(data.Begin()), "invalid", 7) == 0)
{
return false;
return true;
}
+ bool IsLoaded() const
+ {
+ return mLoadCount > 0 ? true : false;
+ }
+
Dali::Devel::PixelBuffer Rasterize(uint32_t width, uint32_t height)
{
if(mRasterizeSuccess)
}
public:
- uint32_t mWidth;
- uint32_t mHeight;
- bool mRasterizeSuccess;
+ uint32_t mWidth{0};
+ uint32_t mHeight{0};
+ uint32_t mLoadCount{0};
+ bool mRasterizeSuccess{true};
};
inline VectorImageRenderer& GetImplementation(Dali::VectorImageRenderer& renderer)
{
Internal::Adaptor::VectorImageRenderer* imageRenderer = new Internal::Adaptor::VectorImageRenderer();
+ Internal::Adaptor::gVectorImageRenderer = imageRenderer;
+
return VectorImageRenderer(imageRenderer);
}
return Internal::Adaptor::GetImplementation(*this).Load(data, dpi);
}
+bool VectorImageRenderer::IsLoaded() const
+{
+ return Internal::Adaptor::GetImplementation(*this).IsLoaded();
+}
+
Dali::Devel::PixelBuffer VectorImageRenderer::Rasterize(uint32_t width, uint32_t height)
{
return Internal::Adaptor::GetImplementation(*this).Rasterize(width, height);
}
} // namespace Dali
+
+namespace Test
+{
+namespace VectorImageRenderer
+{
+uint32_t GetLoadCount()
+{
+ return Dali::Internal::Adaptor::gVectorImageRenderer->mLoadCount;
+}
+
+} // namespace VectorImageRenderer
+} // namespace Test
--- /dev/null
+#ifndef DALI_TOOLKIT_TEST_VECTOR_IMAGE_RENDERER_H
+#define DALI_TOOLKIT_TEST_VECTOR_IMAGE_RENDERER_H
+
+/*
+ * 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+namespace Test
+{
+namespace VectorImageRenderer
+{
+uint32_t GetLoadCount();
+
+} // namespace VectorImageRenderer
+} // namespace Test
+
+#endif // DALI_TOOLKIT_TEST_VECTOR_IMAGE_RENDERER_H
const char* TEST_LARGE_IMAGE_FILE_NAME = TEST_RESOURCE_DIR "/tbcol.png";
const char* TEST_IMAGE_FILE_NAME = TEST_RESOURCE_DIR "/gallery-small-1.jpg";
-const char* TEST_SVG_FILE_NAME = TEST_RESOURCE_DIR "/Kid1.svg";
+const char* TEST_SVG_FILE_NAME = TEST_RESOURCE_DIR "/svg1.svg";
Vector4 GetControlBackgroundColor(Control& control)
{
DALI_TEST_EQUALS(-1, control.GetProperty(DevelControl::Property::RIGHT_FOCUSABLE_ACTOR_ID).Get<int>(), TEST_LOCATION);
DALI_TEST_EQUALS(-1, control.GetProperty(DevelControl::Property::UP_FOCUSABLE_ACTOR_ID).Get<int>(), TEST_LOCATION);
DALI_TEST_EQUALS(-1, control.GetProperty(DevelControl::Property::DOWN_FOCUSABLE_ACTOR_ID).Get<int>(), TEST_LOCATION);
- DALI_TEST_EQUALS(-1, control.GetProperty( DevelControl::Property::CLOCKWISE_FOCUSABLE_ACTOR_ID ).Get< int >(), TEST_LOCATION);
- DALI_TEST_EQUALS(-1, control.GetProperty( DevelControl::Property::COUNTER_CLOCKWISE_FOCUSABLE_ACTOR_ID ).Get< int >(), TEST_LOCATION);
+ DALI_TEST_EQUALS(-1, control.GetProperty(DevelControl::Property::CLOCKWISE_FOCUSABLE_ACTOR_ID).Get<int>(), TEST_LOCATION);
+ DALI_TEST_EQUALS(-1, control.GetProperty(DevelControl::Property::COUNTER_CLOCKWISE_FOCUSABLE_ACTOR_ID).Get<int>(), TEST_LOCATION);
control.SetProperty(DevelControl::Property::LEFT_FOCUSABLE_ACTOR_ID, 1);
DALI_TEST_EQUALS(1, control.GetProperty(DevelControl::Property::LEFT_FOCUSABLE_ACTOR_ID).Get<int>(), TEST_LOCATION);
control.SetProperty(DevelControl::Property::DOWN_FOCUSABLE_ACTOR_ID, 18);
DALI_TEST_EQUALS(18, control.GetProperty(DevelControl::Property::DOWN_FOCUSABLE_ACTOR_ID).Get<int>(), TEST_LOCATION);
control.SetProperty(DevelControl::Property::CLOCKWISE_FOCUSABLE_ACTOR_ID, 19);
- DALI_TEST_EQUALS(19, control.GetProperty( DevelControl::Property::CLOCKWISE_FOCUSABLE_ACTOR_ID ).Get< int >(), TEST_LOCATION);
+ DALI_TEST_EQUALS(19, control.GetProperty(DevelControl::Property::CLOCKWISE_FOCUSABLE_ACTOR_ID).Get<int>(), TEST_LOCATION);
control.SetProperty(DevelControl::Property::COUNTER_CLOCKWISE_FOCUSABLE_ACTOR_ID, 20);
- DALI_TEST_EQUALS(20, control.GetProperty( DevelControl::Property::COUNTER_CLOCKWISE_FOCUSABLE_ACTOR_ID ).Get< int >(), TEST_LOCATION);
+ DALI_TEST_EQUALS(20, control.GetProperty(DevelControl::Property::COUNTER_CLOCKWISE_FOCUSABLE_ACTOR_ID).Get<int>(), TEST_LOCATION);
END_TEST;
}
application.SendNotification();
application.Render();
+ // Wait for rasterization
+ DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
+
DALI_TEST_EQUALS(control.IsResourceReady(), true, TEST_LOCATION);
DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
gResourceReadySignalFired = false;
#include <dali-toolkit-test-suite-utils.h>
#include <toolkit-event-thread-callback.h>
+#include <toolkit-vector-image-renderer.h>
#include "dummy-control.h"
#include <test-encoded-image-buffer.h>
tet_infoline("ImageView Testing SVG image sync loading");
- // Sync loading, automatic atlasing for small size image
{
- TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
- callStack.Reset();
- callStack.Enable(true);
-
ImageView imageView = ImageView::New();
// Sync loading is used
DALI_TEST_CHECK(imageView);
application.SendNotification();
- application.Render(16);
Vector3 naturalSize = imageView.GetNaturalSize();
DALI_TEST_EQUALS(naturalSize.width, 100.0f, TEST_LOCATION);
tet_infoline("ImageView Testing SVG image async loading");
- // Sync loading, automatic atlasing for small size image
{
- TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
- callStack.Reset();
- callStack.Enable(true);
-
ImageView imageView = ImageView::New();
- // Sync loading is used
- Property::Map syncLoadingMap;
- syncLoadingMap.Insert(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
- syncLoadingMap.Insert(Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/svg1.svg");
- syncLoadingMap.Insert(Toolkit::ImageVisual::Property::SYNCHRONOUS_LOADING, false);
- imageView.SetProperty(ImageView::Property::IMAGE, syncLoadingMap);
+ // Async loading is used - default value of SYNCHRONOUS_LOADING is false.
+ Property::Map propertyMap;
+ propertyMap.Insert(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE);
+ propertyMap.Insert(Toolkit::ImageVisual::Property::URL, TEST_RESOURCE_DIR "/svg1.svg");
+ imageView.SetProperty(ImageView::Property::IMAGE, propertyMap);
application.GetScene().Add(imageView);
DALI_TEST_CHECK(imageView);
application.SendNotification();
+
+ // Wait for rasterization
+ DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
+
+ application.SendNotification();
application.Render(16);
- Vector3 naturalSize = imageView.GetNaturalSize();
+ Vector3 naturalSize = imageView.GetNaturalSize();
DALI_TEST_EQUALS(naturalSize.width, 100.0f, TEST_LOCATION);
DALI_TEST_EQUALS(naturalSize.height, 100.0f, TEST_LOCATION);
}
tet_infoline("ImageView Testing SVG image async loading");
- // Sync loading, automatic atlasing for small size image
+ // Sync loading
{
- TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
- callStack.Reset();
- callStack.Enable(true);
-
ImageView imageView = ImageView::New();
// Sync loading is used
DALI_TEST_CHECK(imageView);
application.SendNotification();
+
+ // Wait for rasterization
+ DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
+
+ application.SendNotification();
application.Render(16);
+
Vector3 naturalSize = imageView.GetNaturalSize();
DALI_TEST_EQUALS(naturalSize.width, 100.0f, TEST_LOCATION);
DALI_TEST_EQUALS(naturalSize.height, 100.0f, 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);
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);
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);
END_TEST;
}
+int UtcDaliImageViewSvgChageSize(void)
+{
+ ToolkitTestApplication application;
+
+ TestGlAbstraction& gl = application.GetGlAbstraction();
+ TraceCallStack& textureTrace = gl.GetTextureTrace();
+ textureTrace.Enable(true);
+
+ ImageView imageView = ImageView::New(TEST_SVG_FILE_NAME);
+ 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(Test::VectorImageRenderer::GetLoadCount(), 1, TEST_LOCATION);
+
+ // Change actor size, then rasterization should be done again
+ imageView.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
+
+ application.SendNotification();
+
+ // loading started, this waits for the loader thread
+ DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
+
+ application.SendNotification();
+ application.Render(16);
+
+ // We should not load the file again.
+ DALI_TEST_EQUALS(Test::VectorImageRenderer::GetLoadCount(), 1, TEST_LOCATION);
+
+ END_TEST;
+}
+
int UtcDaliImageViewTVGLoading(void)
{
ToolkitTestApplication application;
tet_infoline("ImageView Testing TVG image loading");
{
- ImageView imageView = ImageView::New();
-
- imageView.SetImage(TEST_RESOURCE_DIR "/test.tvg");
-
+ ImageView imageView = ImageView::New(TEST_RESOURCE_DIR "/test.tvg");
application.GetScene().Add(imageView);
DALI_TEST_CHECK(imageView);
+
+ application.SendNotification();
+
+ DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
+
+ application.SendNotification();
+ application.Render(16);
+
Vector3 naturalSize = imageView.GetNaturalSize();
DALI_TEST_EQUALS(naturalSize.width, 100.0f, TEST_LOCATION);
// Test broken case
TestResourceReadyUrl(1, 0, 0, "invalid.jpg", "", TEST_LOCATION);
- TestResourceReadyUrl(0, 0, 0, "invalid.svg", "", TEST_LOCATION); // 0 rasterize
+ TestResourceReadyUrl(1, 0, 0, "invalid.svg", "", TEST_LOCATION);
TestResourceReadyUrl(1, 0, 0, "invalid.9.png", "", TEST_LOCATION);
TestResourceReadyUrl(1, 0, 0, "invalid.gif", "", TEST_LOCATION); // 1 image loading
TestResourceReadyUrl(0, 0, 0, "invalid.json", "", TEST_LOCATION); // 0 rasterize
// Test broken case
TestResourceReadyUrl(0, 1, 0, "invalid.jpg", "", TEST_LOCATION);
- TestResourceReadyUrl(0, 1, 0, "invalid.svg", "", TEST_LOCATION); // 0 rasterize
+ TestResourceReadyUrl(0, 1, 0, "invalid.svg", "", TEST_LOCATION);
TestResourceReadyUrl(0, 1, 0, "invalid.9.png", "", TEST_LOCATION);
TestResourceReadyUrl(0, 1, 0, "invalid.gif", "", TEST_LOCATION);
TestResourceReadyUrl(0, 1, 0, "invalid.json", "", TEST_LOCATION); // 0 rasterize
DALI_TEST_EQUALS(naturalSize, Vector2::ZERO, TEST_LOCATION);
// animated gradient visual
- Vector2 animated_gradient_visual_size(10.f, 10.f);
propertyMap.Clear();
propertyMap.Insert(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_GRADIENT);
Visual::Base animatedGradientVisual = factory.CreateVisual(propertyMap);
animatedGradientVisual.SetTransformAndSize(DefaultTransform(), controlSize);
DALI_TEST_EQUALS(naturalSize, Vector2::ZERO, TEST_LOCATION);
- // svg visual
- Visual::Base svgVisual = factory.CreateVisual(TEST_SVG_FILE_NAME, ImageDimensions());
- svgVisual.GetNaturalSize(naturalSize);
- // TEST_SVG_FILE:
- // <svg width="100" height="100">
- // <circle cx="50" cy="50" r="40" stroke="green" stroke-width="4" fill="yellow" />
- // </svg>
- DALI_TEST_EQUALS(naturalSize, Vector2(100.f, 100.f), TEST_LOCATION);
-
- // svg visual with a size
- Visual::Base svgVisual2 = factory.CreateVisual(TEST_SVG_FILE_NAME, ImageDimensions(200, 200));
- svgVisual2.GetNaturalSize(naturalSize);
- DALI_TEST_EQUALS(naturalSize, Vector2(100.f, 100.f), TEST_LOCATION); // Natural size should still be 100, 100
-
// Text visual.
// Load some fonts to get the same metrics on different platforms.
{
namespace Internal
{
-RasterizingTask::RasterizingTask(SvgVisual* svgRenderer, VectorImageRenderer vectorRenderer, const VisualUrl& url, float dpi, unsigned int width, unsigned int height)
-: mSvgVisual(svgRenderer),
+RasterizingTask::RasterizingTask(SvgVisual* svgVisual, VectorImageRenderer vectorRenderer, const VisualUrl& url, float dpi, unsigned int width, unsigned int height)
+: mSvgVisual(svgVisual),
mVectorRenderer(vectorRenderer),
mUrl(url),
mDpi(dpi),
void RasterizingTask::Load()
{
+ if(mVectorRenderer.IsLoaded())
+ {
+ // Already loaded
+ mLoadSuccess = true;
+ return;
+ }
+
+ Dali::Vector<uint8_t> buffer;
+
if(!mUrl.IsLocalResource())
{
- Dali::Vector<uint8_t> remoteBuffer;
- if(!Dali::FileLoader::DownloadFileSynchronously(mUrl.GetUrl(), remoteBuffer))
+ if(!Dali::FileLoader::DownloadFileSynchronously(mUrl.GetUrl(), buffer))
{
- DALI_LOG_ERROR("RasterizingTask::Load: Failed to download file! [%s]\n", mUrl.GetUrl().c_str());
+ DALI_LOG_ERROR("Failed to download file! [%s]\n", mUrl.GetUrl().c_str());
return;
}
-
- remoteBuffer.PushBack('\0');
-
- if(!mVectorRenderer.Load(remoteBuffer, mDpi))
+ }
+ else
+ {
+ if(!Dali::FileLoader::ReadFile(mUrl.GetUrl(), buffer))
{
- DALI_LOG_ERROR("RasterizingTask::Load:Failed to load data! [%s]\n", mUrl.GetUrl().c_str());
+ DALI_LOG_ERROR("Failed to read file! [%s]\n", mUrl.GetUrl().c_str());
return;
}
-
- mLoadSuccess = true;
}
- else
+
+ buffer.PushBack('\0');
+
+ if(!mVectorRenderer.Load(buffer, mDpi))
{
- mLoadSuccess = true;
+ DALI_LOG_ERROR("Failed to load data! [%s]\n", mUrl.GetUrl().c_str());
+ return;
}
+
+ mLoadSuccess = true;
}
void RasterizingTask::Rasterize()
mPixelData = Devel::PixelBuffer::Convert(pixelBuffer);
}
-VectorImageRenderer RasterizingTask::GetVectorRenderer() const
-{
- return mVectorRenderer;
-}
-
bool RasterizingTask::IsLoaded() const
{
return mLoadSuccess;
{
while(RasterizingTaskPtr task = NextCompletedTask())
{
- task->GetSvgVisual()->ApplyRasterizedImage(task->GetVectorRenderer(), task->GetPixelData(), task->IsLoaded());
+ task->GetSvgVisual()->ApplyRasterizedImage(task->GetPixelData(), task->IsLoaded());
}
UnregisterProcessor();
#define DALI_TOOLKIT_SVG_RASTERIZE_THREAD_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.
#include <dali/public-api/common/vector-wrapper.h>
#include <dali/public-api/images/pixel-data.h>
#include <dali/public-api/object/ref-object.h>
-#include <dali/public-api/rendering/texture-set.h>
#include <memory>
// INTERNAL INCLUDES
public:
/**
* Constructor
- * @param[in] svgRenderer The renderer which the rasterized image to be applied.
+ * @param[in] svgVisual The visual which the rasterized image to be applied.
+ * @param[in] vectorRenderer The vector rasterizer.
* @param[in] url The URL to svg resource to use.
+ * @param[in] dpi The DPI of the screen.
* @param[in] width The rasterization width.
* @param[in] height The rasterization height.
*/
- RasterizingTask(SvgVisual* svgRenderer, VectorImageRenderer vectorRenderer, const VisualUrl& url, float dpi, unsigned int width, unsigned int height);
+ RasterizingTask(SvgVisual* svgVisual, VectorImageRenderer vectorRenderer, const VisualUrl& url, float dpi, unsigned int width, unsigned int height);
/**
* Destructor.
~RasterizingTask() override;
/**
+ * Load svg file
+ */
+ void Load();
+
+ /**
* Do the rasterization with the mRasterizer.
*/
void Rasterize();
PixelData GetPixelData() const;
/**
- * Get the VectorRenderer.
- * @return VectorRenderer.
- */
- VectorImageRenderer GetVectorRenderer() const;
- /**
* Whether the resource is loaded.
* @return True if the resource is loaded.
*/
bool IsLoaded() const;
- /**
- * Load svg file
- */
- void Load();
-
private:
// Undefined
RasterizingTask(const RasterizingTask& task);
VisualUrl mUrl;
PixelData mPixelData;
float mDpi;
- unsigned int mWidth;
- unsigned int mHeight;
+ uint32_t mWidth;
+ uint32_t mHeight;
bool mLoadSuccess;
};
#include <dali-toolkit/public-api/visuals/image-visual-properties.h>
// EXTERNAL INCLUDES
-#include <dali/devel-api/adaptor-framework/file-loader.h>
#include <dali/devel-api/common/stage.h>
#include <dali/integration-api/debug.h>
SvgVisualPtr SvgVisual::New(VisualFactoryCache& factoryCache, ImageVisualShaderFactory& shaderFactory, const VisualUrl& imageUrl, const Property::Map& properties)
{
SvgVisualPtr svgVisual(new SvgVisual(factoryCache, shaderFactory, imageUrl));
- svgVisual->Load();
svgVisual->SetProperties(properties);
svgVisual->Initialize();
return svgVisual;
SvgVisualPtr SvgVisual::New(VisualFactoryCache& factoryCache, ImageVisualShaderFactory& shaderFactory, const VisualUrl& imageUrl)
{
SvgVisualPtr svgVisual(new SvgVisual(factoryCache, shaderFactory, imageUrl));
- svgVisual->Load();
svgVisual->Initialize();
return svgVisual;
}
}
}
-void SvgVisual::Load()
-{
- // load remote resource on svg rasterize thread.
- if(mImageUrl.IsLocalResource())
- {
- Dali::Vector<uint8_t> buffer;
- if(Dali::FileLoader::ReadFile(mImageUrl.GetUrl(), buffer))
- {
- buffer.PushBack('\0');
-
- Vector2 dpi = Stage::GetCurrent().GetDpi();
- float meanDpi = (dpi.height + dpi.width) * 0.5f;
- if(!mVectorRenderer.Load(buffer, meanDpi))
- {
- mLoadFailed = true;
- DALI_LOG_ERROR("SvgVisual::Load: Failed to load file! [%s]\n", mImageUrl.GetUrl().c_str());
- return;
- }
- mVectorRenderer.GetDefaultSize(mDefaultWidth, mDefaultHeight);
- }
- else
- {
- mLoadFailed = true;
- DALI_LOG_ERROR("SvgVisual::Load: Failed to read file! [%s]\n", mImageUrl.GetUrl().c_str());
- }
- }
-}
-
void SvgVisual::AddRasterizationTask(const Vector2& size)
{
if(mImpl->mRenderer)
float meanDpi = (dpi.height + dpi.width) * 0.5f;
RasterizingTaskPtr newTask = new RasterizingTask(this, mVectorRenderer, mImageUrl, meanDpi, width, height);
+
if(IsSynchronousLoadingRequired() && mImageUrl.IsLocalResource())
{
newTask->Load();
newTask->Rasterize();
- ApplyRasterizedImage(newTask->GetVectorRenderer(), newTask->GetPixelData(), newTask->IsLoaded());
+ ApplyRasterizedImage(newTask->GetPixelData(), newTask->IsLoaded());
}
else
{
}
}
-void SvgVisual::ApplyRasterizedImage(VectorImageRenderer vectorRenderer, PixelData rasterizedPixelData, bool isLoaded)
+void SvgVisual::ApplyRasterizedImage(PixelData rasterizedPixelData, bool isLoaded)
{
if(isLoaded && rasterizedPixelData && IsOnScene())
{
{
if(visualSize != mRasterizedSize || mDefaultWidth == 0 || mDefaultHeight == 0)
{
- AddRasterizationTask(visualSize);
mRasterizedSize = visualSize;
+ AddRasterizationTask(visualSize);
}
}
/**
* @bried Apply the rasterized image to the visual.
*
- * @param[in] vectorImage The data of vector image.
* @param[in] rasterizedPixelData The pixel buffer with the rasterized pixels
* @param[in] bool Whether the resource is loaded
*/
- void ApplyRasterizedImage(VectorImageRenderer vectorImage, PixelData rasterizedPixelData, bool isLoaded);
+ void ApplyRasterizedImage(PixelData rasterizedPixelData, bool isLoaded);
private:
/**
- * @brief Load the SVG Image from the set URL.
- */
- void Load();
-
- /**
* @bried Rasterize the svg with the given size, and add it to the visual.
*
* @param[in] size The target size of the SVG rasterization.