X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali-toolkit%2Finternal%2Fvisuals%2Fanimated-vector-image%2Fvector-rasterize-thread.h;h=ef262bd5ee71b5b23bb38318c5b948ba0678adc4;hb=a08597a200d87bbc9e43fce6a94a3269c972346e;hp=f05f8b6c39b8c9cfec641b29242a627614d86ab8;hpb=79267e9786ebcba2b4d79e2f8f75d9b01610e29d;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git diff --git a/dali-toolkit/internal/visuals/animated-vector-image/vector-rasterize-thread.h b/dali-toolkit/internal/visuals/animated-vector-image/vector-rasterize-thread.h index f05f8b6..ef262bd 100644 --- a/dali-toolkit/internal/visuals/animated-vector-image/vector-rasterize-thread.h +++ b/dali-toolkit/internal/visuals/animated-vector-image/vector-rasterize-thread.h @@ -25,6 +25,10 @@ #include #include #include +#include + +// INTERNAL INCLUDES +#include namespace Dali { @@ -46,11 +50,8 @@ public: * @brief Constructor. * * @param[in] url The url of the vector animation file - * @param[in] renderer The renderer used to render the image - * @param[in] width The width of the content - * @param[in] height The height of the content */ - VectorRasterizeThread( const std::string& url, Renderer renderer, uint32_t width, uint32_t height ); + VectorRasterizeThread( const std::string& url ); /** * @brief Destructor. @@ -58,6 +59,13 @@ public: virtual ~VectorRasterizeThread(); /** + * @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 ); + + /** * @brief Sets the target image size. * * @param[in] width The target image width @@ -68,7 +76,7 @@ public: /** * @brief Play the vector animation. */ - void StartAnimation(); + void PlayAnimation(); /** * @brief Stop the vector animation. @@ -81,11 +89,6 @@ public: void PauseAnimation(); /** - * @brief Resume the vector animation. - */ - void ResumeAnimation(); - - /** * @brief Render one frame. The current frame number will be increased. */ void RenderFrame(); @@ -97,17 +100,73 @@ public: void SetResourceReadyCallback( EventThreadCallback* callback ); /** + * @brief This callback is called after the animation is finished. + * @param[in] callback The animation finished callback + */ + 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( int16_t count ); + void SetLoopCount( int32_t count ); /** - * @brief Set the playing range. - * @param[in] range Two values between [0,1] to specify minimum and maximum progress. + * @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( Vector2 range ); + void SetPlayRange( uint32_t startFrame, uint32_t endFrame ); + + /** + * @brief Get the play state + * @return The play state + */ + DevelImageVisual::PlayState::Type GetPlayState() const; + + /** + * @brief Queries whether the resource is ready. + * @return true if ready, false otherwise + */ + bool IsResourceReady() 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 + */ + uint32_t GetCurrentFrameNumber() const; + + /** + * @brief Retrieves the total frame number of the animation. + * @return The total frame number + */ + uint32_t GetTotalFrameNumber() const; + + /** + * @brief Gets the default size of the file,. + * @return The default size of the file + */ + 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 + */ + 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 ); protected: @@ -120,20 +179,19 @@ protected: private: /** - * @brief Called by the rasterize thread which ensures a wait if required. - * @return false if the thread should stop. + * @brief Initializes the vector renderer. */ - bool IsThreadReady(); + void Initialize(); /** - * @brief Start rendering + * @brief Rasterizes the current frame. */ - bool StartRender(); + void Rasterize(); /** - * @brief Rasterize the current frame. + * @brief Gets the frame number when the animation is stopped according to the stop behavior. */ - void Rasterize(); + uint32_t GetStoppedFrame( uint32_t startFrame, uint32_t endFrame, uint32_t currentFrame ); // Undefined VectorRasterizeThread( const VectorRasterizeThread& thread ) = delete; @@ -143,25 +201,39 @@ private: private: - std::string mUrl; - VectorAnimationRenderer mVectorRenderer; - ConditionalWait mConditionalWait; - Dali::Mutex mMutex; - EventThreadCallback* mResourceReadyTrigger; - Vector2 mPlayRange; - uint32_t mCurrentFrame; - uint32_t mTotalFrame; - uint32_t mStartFrame; - uint32_t mEndFrame; - uint32_t mWidth; - uint32_t mHeight; - int16_t mLoopCount; - int16_t mCurrentLoop; - bool mNeedRender; - bool mPlaying; - bool mPaused; - bool mDestroyThread; ///< Whether the thread be destroyed - bool mResourceReady; + enum class PlayState + { + 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; + ConditionalWait mConditionalWait; + std::unique_ptr< EventThreadCallback > mResourceReadyTrigger; + std::unique_ptr< EventThreadCallback > mAnimationFinishedTrigger; + Vector2 mPlayRange; + PlayState mPlayState; + DevelImageVisual::StopBehavior::Type mStopBehavior; + DevelImageVisual::LoopingMode::Type mLoopingMode; + int64_t mFrameDurationNanoSeconds; + float mFrameRate; + uint32_t mCurrentFrame; + uint32_t mTotalFrame; + uint32_t mStartFrame; + uint32_t mEndFrame; + uint32_t mWidth; + uint32_t mHeight; + int32_t mLoopCount; + int32_t mCurrentLoop; + bool mNeedRender; + bool mDestroyThread; ///< Whether the thread be destroyed + bool mResourceReady; + bool mCurrentFrameUpdated; + bool mForward; + bool mUpdateFrameNumber; const Dali::LogFactoryInterface& mLogFactory; ///< The log factory };