[dali_1.9.31] Merge branch 'devel/master'
[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) 2019 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 <vector>
22 #include <memory>
23 #include <dali/devel-api/threading/conditional-wait.h>
24 #include <dali/devel-api/threading/thread.h>
25 #include <dali/integration-api/adaptor-framework/log-factory-interface.h>
26
27 // INTERNAL INCLUDES
28 #include <dali-toolkit/internal/visuals/animated-vector-image/vector-animation-task.h>
29
30 namespace Dali
31 {
32
33 namespace Toolkit
34 {
35
36 namespace Internal
37 {
38
39 /**
40  * The worker thread for vector image rasterization.
41  */
42 class VectorRasterizeThread : public Thread
43 {
44 public:
45
46   /**
47    * @brief Constructor.
48    */
49   VectorRasterizeThread();
50
51   /**
52    * @brief Destructor.
53    */
54   ~VectorRasterizeThread() override;
55
56   /**
57    * The callback is called from the rasterize thread after the rasterization is completed.
58    * @param[in] callBack  The function to call.
59    */
60   void SetCompletedCallback( CallbackBase* callback );
61
62   /**
63    * Add a task to rasterize.
64    *
65    * @param[in] task The task to rasterize
66    */
67   void AddTask( VectorAnimationTaskPtr task );
68
69 protected:
70
71   /**
72    * @brief The entry function of the worker thread.
73    *        It rasterizes the vector image.
74    */
75   void Run() override;
76
77 private:
78
79   /**
80    * Rasterizes the tasks.
81    */
82   void Rasterize();
83
84 private:
85
86   // Undefined
87   VectorRasterizeThread( const VectorRasterizeThread& thread ) = delete;
88
89   // Undefined
90   VectorRasterizeThread& operator=( const VectorRasterizeThread& thread ) = delete;
91
92 private:
93
94   std::vector< VectorAnimationTaskPtr > mRasterizeTasks;
95   ConditionalWait                       mConditionalWait;
96   std::unique_ptr< CallbackBase >       mCompletedCallback;
97   bool                                  mDestroyThread;  ///< Whether the thread be destroyed
98   bool                                  mIsThreadStarted;
99   const Dali::LogFactoryInterface&      mLogFactory; ///< The log factory
100
101 };
102
103 } // namespace Internal
104
105 } // namespace Toolkit
106
107 } // namespace Dali
108
109 #endif // DALI_TOOLKIT_VECTOR_IMAGE_RASTERIZE_THREAD_H