Add post processor
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / visuals / animated-vector-image / vector-rasterize-thread.h
1 #ifndef DALI_TOOLKIT_VECTOR_IMAGE_RASTERIZE_THREAD_H
2 #define DALI_TOOLKIT_VECTOR_IMAGE_RASTERIZE_THREAD_H
3
4 /*
5  * Copyright (c) 2021 Samsung Electronics Co., Ltd.
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  */
19
20 // EXTERNAL INCLUDES
21 #include <dali/devel-api/threading/conditional-wait.h>
22 #include <dali/devel-api/threading/thread.h>
23 #include <dali/integration-api/adaptor-framework/log-factory-interface.h>
24 #include <memory>
25 #include <vector>
26
27 // INTERNAL INCLUDES
28 #include <dali-toolkit/internal/visuals/animated-vector-image/vector-animation-task.h>
29
30 namespace Dali
31 {
32 namespace Toolkit
33 {
34 namespace Internal
35 {
36 /**
37  * The worker thread for vector image rasterization.
38  */
39 class VectorRasterizeThread : public Thread
40 {
41 public:
42   /**
43    * @brief Constructor.
44    */
45   VectorRasterizeThread();
46
47   /**
48    * @brief Destructor.
49    */
50   ~VectorRasterizeThread() override;
51
52   /**
53    * The callback is called from the rasterize thread after the rasterization is completed.
54    * @param[in] callBack  The function to call.
55    */
56   void SetCompletedCallback(CallbackBase* callback);
57
58   /**
59    * Add a task to rasterize.
60    *
61    * @param[in] task The task to rasterize
62    */
63   void AddTask(VectorAnimationTaskPtr task);
64
65 protected:
66   /**
67    * @brief The entry function of the worker thread.
68    *        It rasterizes the vector image.
69    */
70   void Run() override;
71
72 private:
73   /**
74    * Rasterizes the tasks.
75    */
76   void Rasterize();
77
78 private:
79   // Undefined
80   VectorRasterizeThread(const VectorRasterizeThread& thread) = delete;
81
82   // Undefined
83   VectorRasterizeThread& operator=(const VectorRasterizeThread& thread) = delete;
84
85 private:
86   std::vector<VectorAnimationTaskPtr> mRasterizeTasks;
87   ConditionalWait                     mConditionalWait;
88   std::unique_ptr<CallbackBase>       mCompletedCallback;
89   bool                                mDestroyThread; ///< Whether the thread be destroyed
90   bool                                mIsThreadStarted;
91   const Dali::LogFactoryInterface&    mLogFactory; ///< The log factory
92 };
93
94 } // namespace Internal
95
96 } // namespace Toolkit
97
98 } // namespace Dali
99
100 #endif // DALI_TOOLKIT_VECTOR_IMAGE_RASTERIZE_THREAD_H