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