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