X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali-toolkit%2Finternal%2Fvisuals%2Fanimated-vector-image%2Fvector-rasterize-thread.h;h=25bd4e5009aef0fda2c87d2228e82905d7657936;hb=7018f61b640b6fcf9cb576b537bafcb6bb8240e8;hp=f05f8b6c39b8c9cfec641b29242a627614d86ab8;hpb=7b531836b685ab75b8dc8d697f7e9d858167f9e0;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..25bd4e5 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 @@ -2,7 +2,7 @@ #define DALI_TOOLKIT_VECTOR_IMAGE_RASTERIZE_THREAD_H /* - * Copyright (c) 2018 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,99 +18,51 @@ */ // EXTERNAL INCLUDES -#include -#include #include -#include #include -#include -#include +#include +#include +#include + +// INTERNAL INCLUDES +#include namespace Dali { - namespace Toolkit { - namespace Internal { - /** * The worker thread for vector image rasterization. */ class VectorRasterizeThread : public Thread { 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(); /** * @brief Destructor. */ - virtual ~VectorRasterizeThread(); - - /** - * @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 Play the vector animation. - */ - void StartAnimation(); - - /** - * @brief Stop the vector animation. - */ - void StopAnimation(); - - /** - * @brief Pause the vector animation. - */ - void PauseAnimation(); - - /** - * @brief Resume the vector animation. - */ - void ResumeAnimation(); - - /** - * @brief Render one frame. The current frame number will be increased. - */ - void RenderFrame(); + ~VectorRasterizeThread() override; /** - * @brief This callback is called after the first frame is ready. - * @param[in] callback The resource ready callback + * The callback is called from the rasterize thread after the rasterization is completed. + * @param[in] callBack The function to call. */ - void SetResourceReadyCallback( EventThreadCallback* callback ); + void SetCompletedCallback(CallbackBase* 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 ); - - /** - * @brief Set the playing range. - * @param[in] range Two values between [0,1] to specify minimum and maximum progress. - * The animation will play between those values. + * Add a task to rasterize. + * + * @param[in] task The task to rasterize */ - void SetPlayRange( Vector2 range ); + void AddTask(VectorAnimationTaskPtr task); protected: - /** * @brief The entry function of the worker thread. * It rasterizes the vector image. @@ -118,52 +70,25 @@ protected: void Run() override; private: - - /** - * @brief Called by the rasterize thread which ensures a wait if required. - * @return false if the thread should stop. - */ - bool IsThreadReady(); - - /** - * @brief Start rendering - */ - bool StartRender(); - /** - * @brief Rasterize the current frame. + * Rasterizes the tasks. */ void Rasterize(); +private: // Undefined - VectorRasterizeThread( const VectorRasterizeThread& thread ) = delete; + VectorRasterizeThread(const VectorRasterizeThread& thread) = delete; // Undefined - VectorRasterizeThread& operator=( const VectorRasterizeThread& thread ) = delete; + VectorRasterizeThread& operator=(const VectorRasterizeThread& thread) = delete; 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; - const Dali::LogFactoryInterface& mLogFactory; ///< The log factory - + std::vector mRasterizeTasks; + ConditionalWait mConditionalWait; + std::unique_ptr mCompletedCallback; + bool mDestroyThread; ///< Whether the thread be destroyed + bool mIsThreadStarted; + const Dali::LogFactoryInterface& mLogFactory; ///< The log factory }; } // namespace Internal