#define DALI_TOOLKIT_VECTOR_ANIMATION_TASK_H
/*
- * 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/event-thread-callback.h>
#include <dali/devel-api/adaptor-framework/vector-animation-renderer.h>
#include <dali/devel-api/threading/conditional-wait.h>
+#include <dali/public-api/adaptor-framework/async-task-manager.h>
#include <dali/public-api/common/vector-wrapper.h>
#include <dali/public-api/object/property-array.h>
#include <chrono>
/**
* The task of the vector animation.
*/
-class VectorAnimationTask : public RefObject, public ConnectionTracker
+class VectorAnimationTask : public AsyncTask, public ConnectionTracker
{
public:
enum class ResourceStatus
~VectorAnimationTask() override;
/**
+ * Process the task accodring to the type
+ */
+ void Process() override;
+
+ /**
+ * Whether the task is ready to process.
+ * @return True if the task is ready to process.
+ */
+ bool IsReady() override;
+
+ /**
* @brief Finalizes the task.
*/
void Finalize();
* @brief This callback is called after the animation is finished.
* @param[in] callback The animation finished callback
*/
- void SetAnimationFinishedCallback(EventThreadCallback* callback);
+ void SetAnimationFinishedCallback(CallbackBase* callback);
/**
* @brief Gets the playing range in frame number.
/**
* @brief Rasterizes the current frame.
- * @param[out] keepAnimation true if the animation is running, false otherwise.
* @return true if the rasterization succeeded, false otherwise.
*/
- bool Rasterize(bool& keepAnimation);
+ bool Rasterize();
/**
* @brief Calculates the time for the next frame rasterization.
*/
TimePoint GetNextFrameTime();
+ /**
+ * @brief Called when the rasterization is completed from the asyncTaskManager
+ * @param[in] task The completed task
+ */
+ void TaskCompleted(VectorAnimationTaskPtr task);
+
+ /**
+ * @brief Check the rasterization succeeded
+ * @return true if the rasterization succeeded, false otherwise.
+ */
+ bool IsRasterized();
+
+ /**
+ * @brief Check the animation is running
+ * @return true if the animation is running, false otherwise.
+ */
+ bool IsAnimating();
+
private:
/**
* @brief Loads the animation file.
std::string mUrl;
VectorAnimationRenderer mVectorRenderer;
- AnimationData mAnimationData[2];
+ std::vector<AnimationData> mAnimationData[2];
VectorAnimationThread& mVectorAnimationThread;
ConditionalWait mConditionalWait;
ResourceReadySignalType mResourceReadySignal;
- std::unique_ptr<EventThreadCallback> mAnimationFinishedTrigger;
- std::unique_ptr<EventThreadCallback> mLoadCompletedTrigger;
+ std::unique_ptr<CallbackBase> mAnimationFinishedCallback{};
+ std::unique_ptr<CallbackBase> mLoadCompletedCallback{};
PlayState mPlayState;
DevelImageVisual::StopBehavior::Type mStopBehavior;
DevelImageVisual::LoopingMode::Type mLoopingMode;
bool mDestroyTask;
bool mLoadRequest;
bool mLoadFailed;
+ bool mRasterized;
+ bool mKeepAnimation;
};
} // namespace Internal