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