Add GetRenderThreadId()
[platform/core/uifw/dali-adaptor.git] / dali / internal / system / common / thread-controller.h
1 #ifndef DALI_INTERNAL_THREAD_CONTROLLER_H
2 #define DALI_INTERNAL_THREAD_CONTROLLER_H
3
4 /*
5  * Copyright (c) 2022 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 #include <dali/public-api/signals/callback.h>
21
22 // INTERNAL INCLUDES
23 #include <dali/internal/window-system/common/display-connection.h>
24
25 namespace Dali
26 {
27 class RenderSurfaceInterface;
28
29 namespace Internal
30 {
31 namespace Adaptor
32 {
33 enum class UpdateMode;
34 enum class ThreadMode;
35
36 class AdaptorInternalServices;
37 class EnvironmentOptions;
38 class ThreadControllerInterface;
39
40 /**
41  * Class to control all the threads.
42  */
43 class ThreadController
44 {
45 public:
46   /**
47    * Constructor
48    */
49   ThreadController(AdaptorInternalServices& adaptorInterfaces, const EnvironmentOptions& environmentOptions, ThreadMode threadMode);
50
51   /**
52    * Non virtual destructor. Not intended as base class.
53    */
54   ~ThreadController();
55
56   /**
57    * @brief Initializes the thread controller
58    *
59    * Will do any required initialiszation, e.g. initialize EGL, create threads (if required), etc.
60    *
61    * @note When this function returns, the application Init signal should be emitted
62    */
63   void Initialize();
64
65   /**
66    * @brief Called AFTER the Init signal has been emitted.
67    *
68    * In other words, should be called AFTER the Init signal has been emitted and all messages for the first scene
69    * have been queued for update to process.
70    */
71   void Start();
72
73   /**
74    * @brief When called, update and rendering is paused.
75    */
76   void Pause();
77
78   /**
79    * @brief Resumes update/rendering after a previous pause.
80    */
81   void Resume();
82
83   /**
84    * @brief Stops update/rendering altogether.
85    *
86    * Will shutdown EGL, destroy threads (if required) etc.
87    */
88   void Stop();
89
90   /**
91    * @brief Called by the adaptor when core requires another update
92    */
93   void RequestUpdate();
94
95   /**
96    * @brief Called by the adaptor when core requires one update
97    *
98    * @note If Adaptor is paused, we do one update/render only
99    *
100    * @param updateMode The update mode (i.e. either update and render, or update and upload without rendering)
101    */
102   void RequestUpdateOnce(UpdateMode updateMode);
103
104   /**
105    * @brief Replaces the surface.
106    *
107    * @param surface new surface
108    */
109   void ReplaceSurface(Dali::RenderSurfaceInterface* surface);
110
111   /**
112    * Deletes the surface.
113    * @param surface The surface to be deleted
114    */
115   void DeleteSurface(Dali::RenderSurfaceInterface* surface);
116
117   /**
118    * Resize the surface.
119    */
120   void ResizeSurface();
121
122   /**
123    * Wait until the graphics is initialised.
124    */
125   void WaitForGraphicsInitialization();
126
127   /**
128    * @copydoc Dali::Adaptor::SetRenderRefreshRate()
129    */
130   void SetRenderRefreshRate(unsigned int numberOfVSyncsPerRender);
131
132   /**
133    * @copydoc Dali::Adaptor::SetPreRenderCallback
134    */
135   void SetPreRenderCallback(CallbackBase* callback);
136
137   /**
138    * @brief Adds the new surface.
139    *
140    * @param surface new surface
141    */
142   void AddSurface(Dali::RenderSurfaceInterface* surface);
143
144   /**
145    * @brief Gets the thread id.
146    * @return The thread id.
147    */
148   int32_t GetThreadId() const;
149
150 private:
151   // Undefined copy constructor.
152   ThreadController(const ThreadController&) = delete;
153
154   // Undefined assignment operator.
155   ThreadController& operator=(const ThreadController&) = delete;
156
157 private:
158   ThreadControllerInterface* mThreadControllerInterface;
159 };
160
161 } // namespace Adaptor
162
163 } // namespace Internal
164
165 } // namespace Dali
166
167 #endif // DALI_INTERNAL_THREAD_CONTROLLER_H