/*
- * Copyright (c) 2022 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2023 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/pixel-buffer.h>
#include <dali/devel-api/adaptor-framework/vector-animation-renderer.h>
+#include <dali/devel-api/threading/mutex.h>
#include <dali/public-api/object/base-object.h>
+#include <dali/public-api/object/property-array.h>
#include <toolkit-application.h>
#include <toolkit-event-thread-callback.h>
#include <toolkit-vector-animation-renderer.h>
bool Load(const std::string& url)
{
+ Dali::Mutex::ScopedLock lock(mMutex);
mUrl = url;
if(mUrl == "invalid.json")
{
{
// Change total frame number for test
mTotalFrameNumber = 200;
- mTestFrameDrop = true;
}
mDefaultWidth = 100;
return true;
}
+ bool Load(const Dali::Vector<uint8_t>& data)
+ {
+ Dali::Mutex::ScopedLock lock(mMutex);
+
+ mDefaultWidth = 100;
+ mDefaultHeight = 100;
+
+ return true;
+ }
+
void SetRenderer(Dali::Renderer renderer)
{
mRenderer = renderer;
void SetSize(uint32_t width, uint32_t height)
{
+ Dali::Mutex::ScopedLock lock(mMutex);
mWidth = width;
mHeight = height;
bool Render(uint32_t frameNumber)
{
+ Dali::Mutex::ScopedLock lock(mMutex);
if(mWidth == 0 || mHeight == 0)
{
return false;
mNeedDroppedFrames = false;
}
+ if(mDynamicPropertyCallback)
+ {
+ CallbackBase::ExecuteReturn<Property::Value>(*mDynamicPropertyCallback, 0, 0, frameNumber);
+ }
+
if(mNeedTrigger)
{
mEventThreadCallback->Trigger();
void InvalidateBuffer()
{
- mNeedTrigger = true;
- mResourceReady = false;
+ Dali::Mutex::ScopedLock lock(mMutex);
+ if(mResourceReady)
+ {
+ mNeedTrigger = true;
+ mResourceReady = false;
+ }
+ }
+
+ void AddPropertyValueCallback(const std::string& keyPath, Dali::VectorAnimationRenderer::VectorProperty property, CallbackBase* callback, int32_t id)
+ {
+ mDynamicPropertyCallback = std::unique_ptr<CallbackBase>(callback);
}
Dali::VectorAnimationRenderer::UploadCompletedSignalType& UploadCompletedSignal()
public:
static uint32_t mCount;
- std::string mUrl;
- Dali::Renderer mRenderer;
- uint32_t mWidth;
- uint32_t mHeight;
- uint32_t mDefaultWidth;
- uint32_t mDefaultHeight;
- uint32_t mTotalFrameNumber;
- uint32_t mPreviousFrame;
- uint32_t mDelayTime;
- uint32_t mDroppedFrames;
- float mFrameRate;
- bool mTestFrameDrop;
- bool mNeedDroppedFrames;
- bool mLoadFailed{false};
- bool mResourceReady{false};
- bool mNeedTrigger{true};
+ std::string mUrl;
+ Dali::Renderer mRenderer;
+ Dali::Mutex mMutex;
+ std::unique_ptr<CallbackBase> mDynamicPropertyCallback{nullptr};
+
+ uint32_t mWidth;
+ uint32_t mHeight;
+ uint32_t mDefaultWidth;
+ uint32_t mDefaultHeight;
+ uint32_t mTotalFrameNumber;
+ uint32_t mPreviousFrame;
+ uint32_t mDelayTime;
+ uint32_t mDroppedFrames;
+ float mFrameRate;
+ bool mTestFrameDrop;
+ bool mNeedDroppedFrames;
+ bool mLoadFailed{false};
+ bool mResourceReady{false};
+ bool mNeedTrigger{true};
Dali::VectorAnimationRenderer::UploadCompletedSignalType mUploadCompletedSignal;
std::unique_ptr<EventThreadCallback> mEventThreadCallback;
return Internal::Adaptor::GetImplementation(*this).Load(url);
}
+bool VectorAnimationRenderer::Load(const Dali::Vector<uint8_t>& data)
+{
+ return Internal::Adaptor::GetImplementation(*this).Load(data);
+}
+
void VectorAnimationRenderer::SetRenderer(Renderer renderer)
{
Internal::Adaptor::GetImplementation(*this).SetRenderer(renderer);
return Internal::Adaptor::GetImplementation(*this).Render(frameNumber);
}
+void VectorAnimationRenderer::RenderStopped()
+{
+}
+
uint32_t VectorAnimationRenderer::GetTotalFrameNumber() const
{
return Internal::Adaptor::GetImplementation(*this).GetTotalFrameNumber();
return Internal::Adaptor::GetImplementation(*this).GetMarkerInfo(marker, startFrame, endFrame);
}
+void VectorAnimationRenderer::GetMarkerInfo(Property::Map& map) const
+{
+ map.Add(VECTOR_ANIMATION_MARKER_NAME_1, Property::Array({VECTOR_ANIMATION_MARKER_START_FRAME_1, VECTOR_ANIMATION_MARKER_END_FRAME_1}));
+ map.Add(VECTOR_ANIMATION_MARKER_NAME_2, Property::Array({VECTOR_ANIMATION_MARKER_START_FRAME_2, VECTOR_ANIMATION_MARKER_END_FRAME_2}));
+}
+
void VectorAnimationRenderer::InvalidateBuffer()
{
return Internal::Adaptor::GetImplementation(*this).InvalidateBuffer();
}
+void VectorAnimationRenderer::AddPropertyValueCallback(const std::string& keyPath, VectorProperty property, CallbackBase* callback, int32_t id)
+{
+ Internal::Adaptor::GetImplementation(*this).AddPropertyValueCallback(keyPath, property, callback, id);
+}
+
VectorAnimationRenderer::UploadCompletedSignalType& VectorAnimationRenderer::UploadCompletedSignal()
{
return Internal::Adaptor::GetImplementation(*this).UploadCompletedSignal();
{
void DelayRendering(uint32_t delay)
{
- Dali::Internal::Adaptor::gVectorAnimationRenderer->mDelayTime = delay;
+ Dali::Internal::Adaptor::gVectorAnimationRenderer->mDelayTime = delay;
+ Dali::Internal::Adaptor::gVectorAnimationRenderer->mTestFrameDrop = true;
}
uint32_t GetDroppedFrames()