Add GetRenderThreadId()
[platform/core/uifw/dali-adaptor.git] / dali / internal / adaptor / common / thread-controller-interface.h
1 #ifndef DALI_INTERNAL_THREAD_CONTROLLER_INTERFACE_H
2 #define DALI_INTERNAL_THREAD_CONTROLLER_INTERFACE_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
21 // EXTERNAL INCLUDES
22 #include <dali/public-api/signals/callback.h>
23 #include <stdint.h>
24
25 namespace Dali
26 {
27 class RenderSurfaceInterface;
28
29 namespace Internal
30 {
31 namespace Adaptor
32 {
33 enum class UpdateMode
34 {
35   NORMAL,      ///< Update and render
36   SKIP_RENDER, ///< Update and resource upload but no rendering
37   FORCE_RENDER ///< Force update and render
38 };
39
40 enum class ThreadMode
41 {
42   NORMAL,          ///< The thread runs continuously
43   RUN_IF_REQUESTED ///< The threads runs when it is requested
44 };
45
46 /**
47  * Interface Class for all controlling threads.
48  */
49 class ThreadControllerInterface
50 {
51 public:
52   /**
53    * Virtual destructor. Not intended as base class.
54    */
55   virtual ~ThreadControllerInterface()
56   {
57   }
58
59   /**
60    * Initializes the thread controller
61    */
62   virtual void Initialize() = 0;
63
64   /**
65    * @copydoc Dali::Adaptor::Start()
66    */
67   virtual void Start() = 0;
68
69   /**
70    * @copydoc Dali::Adaptor::Pause()
71    */
72   virtual void Pause() = 0;
73
74   /**
75    * @copydoc Dali::Adaptor::Resume()
76    */
77   virtual void Resume() = 0;
78
79   /**
80    * @copydoc Dali::Adaptor::Stop()
81    */
82   virtual void Stop() = 0;
83
84   /**
85    * Called by the adaptor when core requires another update
86    */
87   virtual void RequestUpdate() = 0;
88
89   /**
90    * Called by the adaptor when core requires one update
91    * If Adaptor is paused, we do one update/render and return to pause
92    * @param updateMode The update mode (i.e. i.e. either update & render or skip rendering)
93    */
94   virtual void RequestUpdateOnce(UpdateMode updateMode) = 0;
95
96   /**
97    * Replaces the surface.
98    * @param surface new surface
99    */
100   virtual void ReplaceSurface(Dali::RenderSurfaceInterface* surface) = 0;
101
102   /**
103    * Deletes the surface.
104    * @param[in] surface The surface to be deleted
105    */
106   virtual void DeleteSurface(Dali::RenderSurfaceInterface* surface) = 0;
107
108   /**
109    * Resize the surface.
110    */
111   virtual void ResizeSurface() = 0;
112
113   /**
114    * Wait until the graphics is initialised.
115    */
116   virtual void WaitForGraphicsInitialization() = 0;
117
118   /**
119    * @copydoc Dali::Adaptor::SetRenderRefreshRate()
120    */
121   virtual void SetRenderRefreshRate(unsigned int numberOfVSyncsPerRender) = 0;
122
123   /**
124    * @copydoc Dali::Adaptor::SetPreRenderCallback()
125    */
126   virtual void SetPreRenderCallback(CallbackBase* callback) = 0;
127
128   /**
129    * @brief Adds the new surface.
130    * @param surface new surface
131    */
132   virtual void AddSurface(Dali::RenderSurfaceInterface* surface) = 0;
133
134   /**
135    * @brief Gets the thread id.
136    * @return The thread id.
137    */
138   virtual int32_t GetThreadId() const = 0;
139
140 protected:
141   /**
142    * Constructor
143    */
144   ThreadControllerInterface()
145   {
146   }
147
148 private:
149   // Undefined copy constructor.
150   ThreadControllerInterface(const ThreadControllerInterface&);
151
152   // Undefined assignment operator.
153   ThreadControllerInterface& operator=(const ThreadControllerInterface&);
154 };
155
156 } // namespace Adaptor
157
158 } // namespace Internal
159
160 } // namespace Dali
161
162 #endif // DALI_INTERNAL_THREAD_CONTROLLER_INTERFACE_H