X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali-toolkit%2Finternal%2Fvisuals%2Fanimated-vector-image%2Fvector-animation-task.h;h=e9c69022478ee9f9f509aec38a5b1c64dd8761b0;hb=446d6a921c670c4c56aeaa4fec6415f6e6262b0a;hp=c13b4d317e724e654cc8f375e05eadf12cbc2408;hpb=313392fb575a7b9bf3657d2091adc77adc7eb3ca;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 c13b4d3..e9c6902 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) 2019 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 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,6 +18,7 @@ */ // EXTERNAL INCLUDES +#include #include #include #include @@ -51,52 +52,92 @@ public: using UploadCompletedSignalType = Dali::VectorAnimationRenderer::UploadCompletedSignalType; /** - * @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 ); - - /** - * @brief Destructor. + * Flags for re-sending data to the vector animation thread */ - virtual ~VectorAnimationTask(); + 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 + }; /** - * @brief Sets the renderer used to display the result image. - * - * @param[in] renderer The renderer used to display the result image + * @brief Structure used to pass parameters to the vector animation task */ - void SetRenderer( Renderer renderer ); + struct AnimationData + { + AnimationData() + : resendFlag( 0 ), + playRange(), + playState(), + stopBehavior( DevelImageVisual::StopBehavior::CURRENT_FRAME ), + loopingMode( DevelImageVisual::LoopingMode::RESTART ), + currentFrame( 0 ), + width( 0 ), + height( 0 ), + loopCount( -1 ) + { + } + + 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; + return *this; + } + + uint32_t resendFlag; + Property::Array playRange; + DevelImageVisual::PlayState::Type playState; + DevelImageVisual::StopBehavior::Type stopBehavior; + DevelImageVisual::LoopingMode::Type loopingMode; + uint32_t currentFrame; + uint32_t width; + uint32_t height; + int32_t loopCount; + }; /** - * @brief Sets the target image size. + * @brief Constructor. * - * @param[in] width The target image width - * @param[in] height The target image height + * @param[in] factoryCache A pointer pointing to the VisualFactoryCache object + * @param[in] url The url of the vector animation file */ - void SetSize( uint32_t width, uint32_t height ); + VectorAnimationTask( VisualFactoryCache& factoryCache, const std::string& url ); /** - * @brief Play the vector animation. + * @brief Destructor. */ - void PlayAnimation(); + ~VectorAnimationTask() override; /** - * @brief Stop the vector animation. + * @brief Finalizes the task. */ - void StopAnimation(); + void Finalize(); /** - * @brief Pause the vector animation. + * @brief Sets the renderer used to display the result image. + * + * @param[in] renderer The renderer used to display the result image */ - void PauseAnimation(); + void SetRenderer( Renderer renderer ); /** - * @brief Render one frame. The current frame number will be increased. + * @brief Sets data to specify animation playback. + * @param[in] data The animation data */ - void RenderFrame(); + void SetAnimationData( const AnimationData& data ); /** * @brief This callback is called after the animation is finished. @@ -105,20 +146,6 @@ public: void SetAnimationFinishedCallback( EventThreadCallback* callback ); /** - * @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 ); - - /** - * @brief Set the playing range in frame number. - * @param[in] startFrame The frame number to specify minimum progress. - * @param[in] endFrame The frame number to specify maximum progress. - * The animation will play between those values. - */ - void SetPlayRange( uint32_t startFrame, uint32_t endFrame ); - - /** * @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. @@ -126,18 +153,6 @@ public: void GetPlayRange( uint32_t& startFrame, uint32_t& endFrame ); /** - * @brief Get the play state - * @return The play state - */ - DevelImageVisual::PlayState::Type GetPlayState() const; - - /** - * @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 ); - - /** * @brief Retrieves the current frame number of the animation. * @return The current frame number */ @@ -156,17 +171,10 @@ public: void GetDefaultSize( uint32_t& width, uint32_t& height ) const; /** - * @brief Sets the stop behavior of the animation. This is performed when the animation is stopped. - * @param[in] stopBehavior The stop behavior + * @brief Gets the layer information of all the child layers. + * @param[out] map The layer information */ - 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 GetLayerInfo( Property::Map& map ) const; /** * @brief Connect to this signal to be notified when the texture upload is completed. @@ -200,10 +208,70 @@ private: void Initialize(); /** + * @brief Play the vector animation. + */ + void PlayAnimation(); + + /** + * @brief Stop the vector animation. + */ + void StopAnimation(); + + /** + * @brief Pause the vector animation. + */ + void PauseAnimation(); + + /** + * @brief Sets the target image size. + * + * @param[in] width The target image width + * @param[in] height The target image 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 ); + + /** + * @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 ); + + /** + * @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 ); + + /** + * @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 ); + + /** + * @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 ); + + /** * @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 ); + /** + * @brief Applies the animation data set by the main thread. + */ + void ApplyAnimationData(); + // Undefined VectorAnimationTask( const VectorAnimationTask& task ) = delete; @@ -222,10 +290,10 @@ private: std::string mUrl; VectorAnimationRenderer mVectorRenderer; + AnimationData mAnimationData[2]; VectorAnimationThread& mVectorAnimationThread; ConditionalWait mConditionalWait; std::unique_ptr< EventThreadCallback > mAnimationFinishedTrigger; - Vector2 mPlayRange; PlayState mPlayState; DevelImageVisual::StopBehavior::Type mStopBehavior; DevelImageVisual::LoopingMode::Type mLoopingMode; @@ -238,15 +306,14 @@ private: uint32_t mEndFrame; uint32_t mWidth; uint32_t mHeight; + uint32_t mAnimationDataIndex; int32_t mLoopCount; int32_t mCurrentLoop; - bool mResourceReady; - bool mCurrentFrameUpdated; - bool mCurrentLoopUpdated; bool mForward; bool mUpdateFrameNumber; bool mNeedAnimationFinishedTrigger; - + bool mAnimationDataUpdated; + bool mDestroyTask; }; } // namespace Internal