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=03b8a89d85fefe1e86fcb112a8a0246e8e2b51c4;hp=e9c69022478ee9f9f509aec38a5b1c64dd8761b0;hb=7018f61b640b6fcf9cb576b537bafcb6bb8240e8;hpb=5cefe49bcc101e10e8a10acb546d8ea2587cad31 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 e9c6902..03b8a89 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) 2020 Samsung Electronics Co., Ltd. + * Copyright (c) 2021 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. @@ -18,29 +18,26 @@ */ // EXTERNAL INCLUDES -#include #include #include #include -#include +#include #include +#include // INTERNAL INCLUDES #include namespace Dali { - namespace Toolkit { - namespace Internal { - class VisualFactoryCache; class VectorAnimationThread; class VectorAnimationTask; -typedef IntrusivePtr< VectorAnimationTask > VectorAnimationTaskPtr; +typedef IntrusivePtr VectorAnimationTaskPtr; /** * The task of the vector animation. @@ -48,7 +45,6 @@ typedef IntrusivePtr< VectorAnimationTask > VectorAnimationTaskPtr; class VectorAnimationTask : public RefObject { public: - using UploadCompletedSignalType = Dali::VectorAnimationRenderer::UploadCompletedSignalType; /** @@ -71,29 +67,29 @@ public: struct AnimationData { AnimationData() - : resendFlag( 0 ), + : resendFlag(0), playRange(), playState(), - stopBehavior( DevelImageVisual::StopBehavior::CURRENT_FRAME ), - loopingMode( DevelImageVisual::LoopingMode::RESTART ), - currentFrame( 0 ), - width( 0 ), - height( 0 ), - loopCount( -1 ) + stopBehavior(DevelImageVisual::StopBehavior::CURRENT_FRAME), + loopingMode(DevelImageVisual::LoopingMode::RESTART), + currentFrame(0), + width(0), + height(0), + loopCount(-1) { } - AnimationData& operator= ( const AnimationData& rhs ) + AnimationData& operator=(const AnimationData& rhs) { resendFlag |= rhs.resendFlag; // OR resend flag - playRange = rhs.playRange; - playState = rhs.playState; + playRange = rhs.playRange; + playState = rhs.playState; stopBehavior = rhs.stopBehavior; - loopingMode = rhs.loopingMode; + loopingMode = rhs.loopingMode; currentFrame = rhs.currentFrame; - width = rhs.width; - height = rhs.height; - loopCount = rhs.loopCount; + width = rhs.width; + height = rhs.height; + loopCount = rhs.loopCount; return *this; } @@ -112,9 +108,8 @@ public: * @brief Constructor. * * @param[in] factoryCache A pointer pointing to the VisualFactoryCache object - * @param[in] url The url of the vector animation file */ - VectorAnimationTask( VisualFactoryCache& factoryCache, const std::string& url ); + VectorAnimationTask(VisualFactoryCache& factoryCache); /** * @brief Destructor. @@ -127,30 +122,38 @@ public: void Finalize(); /** + * @brief Loads the animation file. + * + * @param[in] url The url of the vector animation file + * @return True if loading success, false otherwise. + */ + bool Load(const std::string& url); + + /** * @brief Sets the renderer used to display the result image. * * @param[in] renderer The renderer used to display the result image */ - void SetRenderer( Renderer renderer ); + void SetRenderer(Renderer renderer); /** * @brief Sets data to specify animation playback. * @param[in] data The animation data */ - void SetAnimationData( const AnimationData& data ); + void SetAnimationData(const AnimationData& data); /** * @brief This callback is called after the animation is finished. * @param[in] callback The animation finished callback */ - void SetAnimationFinishedCallback( EventThreadCallback* callback ); + void SetAnimationFinishedCallback(EventThreadCallback* callback); /** * @brief Gets the playing range in frame number. * @param[out] startFrame The frame number to specify minimum progress. * @param[out] endFrame The frame number to specify maximum progress. */ - void GetPlayRange( uint32_t& startFrame, uint32_t& endFrame ); + void GetPlayRange(uint32_t& startFrame, uint32_t& endFrame); /** * @brief Retrieves the current frame number of the animation. @@ -168,13 +171,13 @@ public: * @brief Gets the default size of the file,. * @return The default size of the file */ - void GetDefaultSize( uint32_t& width, uint32_t& height ) const; + void GetDefaultSize(uint32_t& width, uint32_t& height) const; /** * @brief Gets the layer information of all the child layers. * @param[out] map The layer information */ - void GetLayerInfo( Property::Map& map ) const; + void GetLayerInfo(Property::Map& map) const; /** * @brief Connect to this signal to be notified when the texture upload is completed. @@ -192,21 +195,15 @@ public: * @brief Calculates the time for the next frame rasterization. * @return The time for the next frame rasterization. */ - std::chrono::time_point< std::chrono::system_clock > CalculateNextFrameTime( bool renderNow ); + std::chrono::time_point CalculateNextFrameTime(bool renderNow); /** * @brief Gets the time for the next frame rasterization. * @return The time for the next frame rasterization. */ - std::chrono::time_point< std::chrono::system_clock > GetNextFrameTime(); + std::chrono::time_point GetNextFrameTime(); private: - - /** - * @brief Initializes the vector renderer. - */ - void Initialize(); - /** * @brief Play the vector animation. */ @@ -228,44 +225,44 @@ private: * @param[in] width The target image width * @param[in] height The target image height */ - void SetSize( uint32_t width, uint32_t height ); + void SetSize(uint32_t width, uint32_t height); /** * @brief Enable looping for 'count' repeats. -1 means to repeat forever. * @param[in] count The number of times to loop */ - void SetLoopCount( int32_t count ); + void SetLoopCount(int32_t count); /** * @brief Set the playing range in frame number. * @param[in] playRange The array to specify minimum and maximum progress. * The animation will play between those values. */ - void SetPlayRange( const Property::Array& playRange ); + void SetPlayRange(const Property::Array& playRange); /** * @brief Sets the current frame number of the animation. * @param[in] frameNumber The new frame number between [0, the maximum frame number] or between the play range if specified. */ - void SetCurrentFrameNumber( uint32_t frameNumber ); + void SetCurrentFrameNumber(uint32_t frameNumber); /** * @brief Sets the stop behavior of the animation. This is performed when the animation is stopped. * @param[in] stopBehavior The stop behavior */ - void SetStopBehavior( DevelImageVisual::StopBehavior::Type stopBehavior ); + void SetStopBehavior(DevelImageVisual::StopBehavior::Type stopBehavior); /** * @brief Sets the looping mode. * Animation plays forwards and then restarts from the beginning or runs backwards again. * @param[in] loopingMode The looping mode */ - void SetLoopingMode( DevelImageVisual::LoopingMode::Type loopingMode ); + void SetLoopingMode(DevelImageVisual::LoopingMode::Type loopingMode); /** * @brief Gets the frame number when the animation is stopped according to the stop behavior. */ - uint32_t GetStoppedFrame( uint32_t startFrame, uint32_t endFrame, uint32_t currentFrame ); + uint32_t GetStoppedFrame(uint32_t startFrame, uint32_t endFrame, uint32_t currentFrame); /** * @brief Applies the animation data set by the main thread. @@ -273,47 +270,46 @@ private: void ApplyAnimationData(); // Undefined - VectorAnimationTask( const VectorAnimationTask& task ) = delete; + VectorAnimationTask(const VectorAnimationTask& task) = delete; // Undefined - VectorAnimationTask& operator=( const VectorAnimationTask& task ) = delete; + VectorAnimationTask& operator=(const VectorAnimationTask& task) = delete; private: - enum class PlayState { - STOPPING, ///< The animation is stopping - STOPPED, ///< The animation has stopped - PLAYING, ///< The animation is playing - PAUSED ///< The animation is paused + STOPPING, ///< The animation is stopping + STOPPED, ///< The animation has stopped + PLAYING, ///< The animation is playing + PAUSED ///< The animation is paused }; - std::string mUrl; - VectorAnimationRenderer mVectorRenderer; - AnimationData mAnimationData[2]; - VectorAnimationThread& mVectorAnimationThread; - ConditionalWait mConditionalWait; - std::unique_ptr< EventThreadCallback > mAnimationFinishedTrigger; - PlayState mPlayState; - DevelImageVisual::StopBehavior::Type mStopBehavior; - DevelImageVisual::LoopingMode::Type mLoopingMode; - std::chrono::time_point< std::chrono::system_clock > mNextFrameStartTime; - int64_t mFrameDurationNanoSeconds; - float mFrameRate; - uint32_t mCurrentFrame; - uint32_t mTotalFrame; - uint32_t mStartFrame; - uint32_t mEndFrame; - uint32_t mWidth; - uint32_t mHeight; - uint32_t mAnimationDataIndex; - int32_t mLoopCount; - int32_t mCurrentLoop; - bool mForward; - bool mUpdateFrameNumber; - bool mNeedAnimationFinishedTrigger; - bool mAnimationDataUpdated; - bool mDestroyTask; + std::string mUrl; + VectorAnimationRenderer mVectorRenderer; + AnimationData mAnimationData[2]; + VectorAnimationThread& mVectorAnimationThread; + ConditionalWait mConditionalWait; + std::unique_ptr mAnimationFinishedTrigger; + PlayState mPlayState; + DevelImageVisual::StopBehavior::Type mStopBehavior; + DevelImageVisual::LoopingMode::Type mLoopingMode; + std::chrono::time_point mNextFrameStartTime; + int64_t mFrameDurationNanoSeconds; + float mFrameRate; + uint32_t mCurrentFrame; + uint32_t mTotalFrame; + uint32_t mStartFrame; + uint32_t mEndFrame; + uint32_t mWidth; + uint32_t mHeight; + uint32_t mAnimationDataIndex; + int32_t mLoopCount; + int32_t mCurrentLoop; + bool mForward; + bool mUpdateFrameNumber; + bool mNeedAnimationFinishedTrigger; + bool mAnimationDataUpdated; + bool mDestroyTask; }; } // namespace Internal