#include <dali-toolkit/internal/visuals/animated-vector-image/vector-animation-task.h>
// EXTERNAL INCLUDES
+#include <dali/devel-api/adaptor-framework/file-loader.h>
#include <dali/integration-api/debug.h>
#include <dali/integration-api/trace.h>
#include <dali/public-api/math/math-utils.h>
VectorAnimationTask::VectorAnimationTask(VisualFactoryCache& factoryCache)
: AsyncTask(MakeCallback(this, &VectorAnimationTask::TaskCompleted), AsyncTask::PriorityType::HIGH, AsyncTask::ThreadType::WORKER_THREAD),
mImageUrl(),
+ mEncodedImageBuffer(),
mVectorRenderer(VectorAnimationRenderer::New()),
mAnimationData(),
mVectorAnimationThread(factoryCache.GetVectorAnimationManager().GetVectorAnimationThread()),
{
std::ostringstream oss;
oss << "[url:" << mImageUrl.GetUrl() << "]";
- DALI_TRACE_BEGIN(gTraceFilter, "DALI_LOTTIE_LOADING_TASK");
+ // DALI_TRACE_BEGIN(gTraceFilter, "DALI_LOTTIE_LOADING_TASK"); ///< TODO : Open it if we can control trace log level
DALI_LOG_RELEASE_INFO("BEGIN: DALI_LOTTIE_LOADING_TASK %s", oss.str().c_str());
}
#endif
- if(!mVectorRenderer.Load(mImageUrl.GetUrl()))
+ if(mEncodedImageBuffer)
{
- DALI_LOG_ERROR("VectorAnimationTask::Load: Load failed [%s]\n", mImageUrl.GetUrl().c_str());
- mLoadFailed = true;
+ if(!mVectorRenderer.Load(mEncodedImageBuffer.GetRawBuffer()))
+ {
+ mLoadFailed = true;
+ }
+
+ // We don't need to hold image buffer anymore.
+ mEncodedImageBuffer.Reset();
+ }
+ else if(mImageUrl.IsLocalResource())
+ {
+ if(!mVectorRenderer.Load(mImageUrl.GetUrl()))
+ {
+ mLoadFailed = true;
+ }
+ }
+ else
+ {
+ Dali::Vector<uint8_t> remoteData;
+ if(!Dali::FileLoader::DownloadFileSynchronously(mImageUrl.GetUrl(), remoteData) || // Failed if we fail to download json file,
+ !mVectorRenderer.Load(remoteData)) // or download data is not valid vector animation file.
+ {
+ mLoadFailed = true;
+ }
}
if(mLoadFailed)
{
+ DALI_LOG_ERROR("VectorAnimationTask::Load: Load failed [%s]\n", mImageUrl.GetUrl().c_str());
mLoadRequest = false;
if(!synchronousLoading && mLoadCompletedCallback)
{
{
std::ostringstream oss;
oss << "[url:" << mImageUrl.GetUrl() << "]";
- DALI_TRACE_END(gTraceFilter, "DALI_LOTTIE_LOADING_TASK");
+ // DALI_TRACE_END(gTraceFilter, "DALI_LOTTIE_LOADING_TASK"); ///< TODO : Open it if we can control trace log level
DALI_LOG_RELEASE_INFO("END: DALI_LOTTIE_LOADING_TASK %s", oss.str().c_str());
}
#endif
{
std::ostringstream oss;
oss << "[url:" << mImageUrl.GetUrl() << "]";
- DALI_TRACE_END(gTraceFilter, "DALI_LOTTIE_LOADING_TASK");
+ // DALI_TRACE_END(gTraceFilter, "DALI_LOTTIE_LOADING_TASK"); ///< TODO : Open it if we can control trace log level
DALI_LOG_RELEASE_INFO("END: DALI_LOTTIE_LOADING_TASK %s", oss.str().c_str());
}
#endif
DALI_LOG_INFO(gVectorAnimationLogFilter, Debug::Verbose, "VectorAnimationTask::SetRenderer [%p]\n", this);
}
-void VectorAnimationTask::RequestLoad(const VisualUrl& url, bool synchronousLoading)
+void VectorAnimationTask::RequestLoad(const VisualUrl& url, EncodedImageBuffer encodedImageBuffer, bool synchronousLoading)
{
- mImageUrl = url;
+ mImageUrl = url;
+ mEncodedImageBuffer = encodedImageBuffer;
if(!synchronousLoading)
{
mVectorRenderer.GetLayerInfo(map);
}
+void VectorAnimationTask::GetMarkerInfo(Property::Map& map) const
+{
+ mVectorRenderer.GetMarkerInfo(map);
+}
+
VectorAnimationTask::ResourceReadySignalType& VectorAnimationTask::ResourceReadySignal()
{
return mResourceReadySignal;