6feddc19a9e199cdffc00a682fe037b503de5b9a
[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) 2017 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
21 namespace Dali
22 {
23
24 class RenderSurface;
25
26 namespace Internal
27 {
28
29 namespace Adaptor
30 {
31
32 class AdaptorInternalServices;
33 class EnvironmentOptions;
34 class ThreadControllerInterface;
35
36 /**
37  * Class to control all the threads.
38  */
39 class ThreadController
40 {
41 public:
42
43   /**
44    * Constructor
45    */
46   ThreadController( AdaptorInternalServices& adaptorInterfaces, const EnvironmentOptions& environmentOptions );
47
48   /**
49    * Non virtual destructor. Not intended as base class.
50    */
51   ~ThreadController();
52
53   /**
54    * @brief Initializes the thread controller
55    *
56    * Will do any required initialiszation, e.g. initialize EGL, create threads (if required), etc.
57    *
58    * @note When this function returns, the application Init signal should be emitted
59    */
60   void Initialize();
61
62   /**
63    * @brief Called AFTER the Init signal has been emitted.
64    *
65    * In other words, should be called AFTER the Init signal has been emitted and all messages for the first scene
66    * have been queued for update to process.
67    */
68   void Start();
69
70   /**
71    * @brief When called, update and rendering is paused.
72    */
73   void Pause();
74
75   /**
76    * @brief Resumes update/rendering after a previous pause.
77    */
78   void Resume();
79
80   /**
81    * @brief Stops update/rendering altogether.
82    *
83    * Will shutdown EGL, destroy threads (if required) etc.
84    */
85   void Stop();
86
87   /**
88    * @brief Called by the adaptor when core requires another update
89    */
90   void RequestUpdate();
91
92   /**
93    * @brief Called by the adaptor when core requires one update
94    *
95    * @note If Adaptor is paused, we do one update/render only
96    */
97   void RequestUpdateOnce();
98
99   /**
100    * @brief Replaces the surface.
101    *
102    * @param surface new surface
103    */
104   void ReplaceSurface( RenderSurface* surface );
105
106   /**
107    * Resize the surface.
108    */
109   void ResizeSurface();
110
111   /**
112    * @copydoc Dali::Adaptor::SetRenderRefreshRate()
113    */
114   void SetRenderRefreshRate( unsigned int numberOfVSyncsPerRender );
115
116 private:
117
118   // Undefined copy constructor.
119   ThreadController( const ThreadController& );
120
121   // Undefined assignment operator.
122   ThreadController& operator=( const ThreadController& );
123
124 private:
125
126   ThreadControllerInterface* mThreadControllerInterface;
127 };
128
129 } // namespace Adaptor
130
131 } // namespace Internal
132
133 } // namespace Dali
134
135 #endif // __DALI_INTERNAL_THREAD_CONTROLLER_H__