X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=dali-toolkit%2Finternal%2Fvisuals%2Fanimated-vector-image%2Fvector-animation-task.h;h=eb48a136a6df8ed66b90cfed2f20ca3bd96c59be;hp=42d13f8bc53cf0c24608fedb6459c2cda817725f;hb=HEAD;hpb=b6e5096fe564c1fb6c56383b1e878eb51358ae41 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 42d13f8..c741be1 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) 2024 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. @@ -20,7 +20,9 @@ // EXTERNAL INCLUDES #include #include -#include +#include +#include +#include #include #include #include @@ -29,6 +31,7 @@ // INTERNAL INCLUDES #include #include +#include namespace Dali { @@ -44,7 +47,7 @@ typedef IntrusivePtr VectorAnimationTaskPtr; /** * The task of the vector animation. */ -class VectorAnimationTask : public RefObject, public ConnectionTracker +class VectorAnimationTask : public AsyncTask, public ConnectionTracker { public: enum class ResourceStatus @@ -64,15 +67,16 @@ public: */ enum ResendFlags { - RESEND_PLAY_RANGE = 1 << 0, - RESEND_LOOP_COUNT = 1 << 1, - RESEND_STOP_BEHAVIOR = 1 << 2, - RESEND_LOOPING_MODE = 1 << 3, - RESEND_CURRENT_FRAME = 1 << 4, - RESEND_SIZE = 1 << 5, - RESEND_PLAY_STATE = 1 << 6, - RESEND_NEED_RESOURCE_READY = 1 << 7, - RESEND_DYNAMIC_PROPERTY = 1 << 8 + RESEND_PLAY_RANGE = 1 << 0, + RESEND_LOOP_COUNT = 1 << 1, + RESEND_STOP_BEHAVIOR = 1 << 2, + RESEND_LOOPING_MODE = 1 << 3, + RESEND_CURRENT_FRAME = 1 << 4, + RESEND_SIZE = 1 << 5, + RESEND_PLAY_STATE = 1 << 6, + RESEND_NEED_RESOURCE_READY = 1 << 7, + RESEND_DYNAMIC_PROPERTY = 1 << 8, + RESEND_NOTIFY_AFTER_RASTERIZATION = 1 << 9, }; /** @@ -90,21 +94,25 @@ public: currentFrame(0), width(0), height(0), - loopCount(-1) + loopCount(-1), + playStateId(0), + notifyAfterRasterization(false) { } AnimationData& operator=(const AnimationData& rhs) { resendFlag |= rhs.resendFlag; // OR resend flag - playRange = rhs.playRange; - playState = rhs.playState; - stopBehavior = rhs.stopBehavior; - loopingMode = rhs.loopingMode; - currentFrame = rhs.currentFrame; - width = rhs.width; - height = rhs.height; - loopCount = rhs.loopCount; + playRange = rhs.playRange; + playState = rhs.playState; + stopBehavior = rhs.stopBehavior; + loopingMode = rhs.loopingMode; + currentFrame = rhs.currentFrame; + width = rhs.width; + height = rhs.height; + loopCount = rhs.loopCount; + playStateId = rhs.playStateId; + notifyAfterRasterization = rhs.notifyAfterRasterization; dynamicProperties.insert(dynamicProperties.end(), rhs.dynamicProperties.begin(), rhs.dynamicProperties.end()); return *this; } @@ -119,6 +127,8 @@ public: uint32_t width; uint32_t height; int32_t loopCount; + uint32_t playStateId; + bool notifyAfterRasterization; }; /** @@ -149,8 +159,10 @@ public: * @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. @@ -168,7 +180,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. @@ -202,6 +214,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. */ @@ -209,10 +227,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. @@ -226,13 +243,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(); + + void KeepRasterizedBuffer(bool enableFrameCache) + { + mEnableFrameCache = enableFrameCache; + } + + bool IsKeptRasterizedBuffer() const + { + return mEnableFrameCache; + } + +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"; + } + 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. @@ -307,7 +372,7 @@ private: /** * @brief Event callback from rasterize thread. This is called when the file loading is completed. */ - void OnLoadCompleted(); + void OnLoadCompleted(uint32_t argument); // Undefined VectorAnimationTask(const VectorAnimationTask& task) = delete; @@ -324,14 +389,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; + Mutex mMutex; 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; @@ -346,15 +414,24 @@ private: uint32_t mWidth; uint32_t mHeight; uint32_t mAnimationDataIndex; + uint32_t mAppliedPlayStateId; 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 mNeedForceRenderOnceTrigger : 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 mNotifyAfterRasterization : 1; + bool mSizeUpdated : 1; }; } // namespace Internal