X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali-toolkit%2Finternal%2Fvisuals%2Fanimated-vector-image%2Fvector-animation-task.h;h=6d668855f7d0754f2345d3ee467ef1a4543f7875;hb=3c3eb69051c03ed8d04db1294f8839da7469b536;hp=fb4a55c4a39aa9a4e7d76c686990da0b4451e459;hpb=7b406456059abec8a9085c02814e3ea526fc525a;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git diff --git a/dali-toolkit/internal/visuals/animated-vector-image/vector-animation-task.h b/dali-toolkit/internal/visuals/animated-vector-image/vector-animation-task.h index fb4a55c..6d66885 100644 --- a/dali-toolkit/internal/visuals/animated-vector-image/vector-animation-task.h +++ b/dali-toolkit/internal/visuals/animated-vector-image/vector-animation-task.h @@ -2,7 +2,7 @@ #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. @@ -21,12 +21,17 @@ #include #include #include +#include +#include +#include #include #include #include // INTERNAL INCLUDES +#include #include +#include namespace Dali { @@ -42,12 +47,20 @@ typedef IntrusivePtr VectorAnimationTaskPtr; /** * The task of the vector animation. */ -class VectorAnimationTask : public RefObject, public ConnectionTracker +class VectorAnimationTask : public AsyncTask, public ConnectionTracker { public: - using ResourceReadySignalType = Signal; + enum class ResourceStatus + { + LOADED, /// Resource is loaded + READY, /// Resource is ready + FAILED /// Resource is fail to load + }; + + using ResourceReadySignalType = Signal; - using TimePoint = std::chrono::time_point; + using TimePoint = std::chrono::time_point; + using DynamicPropertyType = std::vector; /** * Flags for re-sending data to the vector animation thread @@ -61,7 +74,8 @@ public: RESEND_CURRENT_FRAME = 1 << 4, RESEND_SIZE = 1 << 5, RESEND_PLAY_STATE = 1 << 6, - RESEND_NEED_RESOURCE_READY = 1 << 7 + RESEND_NEED_RESOURCE_READY = 1 << 7, + RESEND_DYNAMIC_PROPERTY = 1 << 8 }; /** @@ -72,6 +86,7 @@ public: AnimationData() : resendFlag(0), playRange(), + dynamicProperties(), playState(), stopBehavior(DevelImageVisual::StopBehavior::CURRENT_FRAME), loopingMode(DevelImageVisual::LoopingMode::RESTART), @@ -93,11 +108,13 @@ public: width = rhs.width; height = rhs.height; loopCount = rhs.loopCount; + dynamicProperties.insert(dynamicProperties.end(), rhs.dynamicProperties.begin(), rhs.dynamicProperties.end()); return *this; } uint32_t resendFlag; Property::Array playRange; + DynamicPropertyType dynamicProperties; DevelImageVisual::PlayState::Type playState; DevelImageVisual::StopBehavior::Type stopBehavior; DevelImageVisual::LoopingMode::Type loopingMode; @@ -132,11 +149,19 @@ public: void SetRenderer(Renderer renderer); /** - * @brief Request to load the animation file. + * @brief Requests to load the animation file. * * @param[in] url The url of the vector animation file + * @param[in] encodedImageBuffer The resource buffer if required. + * @param[in] synchronousLoading True if the url should be loaded synchronously */ - void RequestLoad(const std::string& url); + void RequestLoad(const VisualUrl& url, EncodedImageBuffer encodedImageBuffer, bool synchronousLoading); + + /** + * @brief Queries whether loading is requested. + * @return True if loading is requested. + */ + bool IsLoadRequested() const; /** * @brief Sets data to specify animation playback. @@ -148,7 +173,7 @@ public: * @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. @@ -182,6 +207,12 @@ public: void GetLayerInfo(Property::Map& map) const; /** + * @brief Gets the all marker information. + * @param[out] map The marker information + */ + void GetMarkerInfo(Property::Map& map) const; + + /** * @brief Connect to this signal to be notified when the resource is ready. * @return The signal to connect to. */ @@ -189,10 +220,9 @@ public: /** * @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. @@ -206,13 +236,61 @@ public: */ 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(); + +public: // Implementation of AsyncTask + /** + * @copydoc Dali::AsyncTask::Process() + */ + void Process() override; + + /** + * @copydoc Dali::AsyncTask::IsReady() + */ + bool IsReady() override; + + /** + * @copydoc Dali::AsyncTask::GetTaskName() + */ + std::string_view GetTaskName() const override + { + return "VectorAnimationTask"; + } + + void KeepRasterizedBuffer(bool enableFrameCache) + { + mEnableFrameCache = enableFrameCache; + } + + bool IsKeptRasterizedBuffer() + { + return mEnableFrameCache; + } + private: /** * @brief Loads the animation file. * + * @param[in] synchronousLoading True if loading is requested synchronously * @return True if loading succeeded, false otherwise. */ - bool Load(); + bool Load(bool synchronousLoading); /** * @brief Play the vector animation. @@ -304,14 +382,17 @@ private: PAUSED ///< The animation is paused }; - std::string mUrl; + VisualUrl mImageUrl; + EncodedImageBuffer mEncodedImageBuffer; VectorAnimationRenderer mVectorRenderer; - AnimationData mAnimationData[2]; + std::vector mAnimationData[2]; VectorAnimationThread& mVectorAnimationThread; ConditionalWait mConditionalWait; ResourceReadySignalType mResourceReadySignal; - std::unique_ptr mAnimationFinishedTrigger; - std::unique_ptr mLoadCompletedTrigger; + std::unique_ptr mAnimationFinishedCallback{}; + std::unique_ptr mLoadCompletedCallback{}; + mutable Property::Map mCachedLayerInfo; + mutable Property::Map mCachedMarkerInfo; PlayState mPlayState; DevelImageVisual::StopBehavior::Type mStopBehavior; DevelImageVisual::LoopingMode::Type mLoopingMode; @@ -328,13 +409,19 @@ private: uint32_t mAnimationDataIndex; int32_t mLoopCount; int32_t mCurrentLoop; - bool mForward; - bool mUpdateFrameNumber; - bool mNeedAnimationFinishedTrigger; - bool mAnimationDataUpdated; - bool mDestroyTask; - bool mLoadRequest; - bool mLoadFailed; + bool mForward : 1; + bool mUpdateFrameNumber : 1; + bool mNeedAnimationFinishedTrigger : 1; + bool mAnimationDataUpdated : 1; + bool mDestroyTask : 1; + bool mLoadRequest : 1; + bool mLoadFailed : 1; + bool mRasterized : 1; + bool mKeepAnimation : 1; + mutable bool mLayerInfoCached : 1; + mutable bool mMarkerInfoCached : 1; + bool mEnableFrameCache : 1; + bool mSizeUpdated : 1; }; } // namespace Internal