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