1 #ifndef DALI_INTERNAL_THREAD_CONTROLLER_H
2 #define DALI_INTERNAL_THREAD_CONTROLLER_H
5 * Copyright (c) 2021 Samsung Electronics Co., Ltd.
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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.
20 #include <dali/public-api/signals/callback.h>
23 #include <dali/internal/window-system/common/display-connection.h>
27 class RenderSurfaceInterface;
33 enum class UpdateMode;
34 enum class ThreadMode;
36 class AdaptorInternalServices;
37 class EnvironmentOptions;
38 class ThreadControllerInterface;
41 * Class to control all the threads.
43 class ThreadController
49 ThreadController(AdaptorInternalServices& adaptorInterfaces, const EnvironmentOptions& environmentOptions, ThreadMode threadMode);
52 * Non virtual destructor. Not intended as base class.
57 * @brief Initializes the thread controller
59 * Will do any required initialiszation, e.g. initialize EGL, create threads (if required), etc.
61 * @note When this function returns, the application Init signal should be emitted
66 * @brief Called AFTER the Init signal has been emitted.
68 * In other words, should be called AFTER the Init signal has been emitted and all messages for the first scene
69 * have been queued for update to process.
74 * @brief When called, update and rendering is paused.
79 * @brief Resumes update/rendering after a previous pause.
84 * @brief Stops update/rendering altogether.
86 * Will shutdown EGL, destroy threads (if required) etc.
91 * @brief Called by the adaptor when core requires another update
96 * @brief Called by the adaptor when core requires one update
98 * @note If Adaptor is paused, we do one update/render only
100 * @param updateMode The update mode (i.e. either update and render, or update and upload without rendering)
102 void RequestUpdateOnce(UpdateMode updateMode);
105 * @brief Replaces the surface.
107 * @param surface new surface
109 void ReplaceSurface(Dali::RenderSurfaceInterface* surface);
112 * Deletes the surface.
113 * @param surface The surface to be deleted
115 void DeleteSurface(Dali::RenderSurfaceInterface* surface);
118 * Resize the surface.
120 void ResizeSurface();
123 * Wait until the graphics is initialised.
125 void WaitForGraphicsInitialization();
128 * @copydoc Dali::Adaptor::SetRenderRefreshRate()
130 void SetRenderRefreshRate(unsigned int numberOfVSyncsPerRender);
133 * @copydoc Dali::Adaptor::SetPreRenderCallback
135 void SetPreRenderCallback(CallbackBase* callback);
138 * @brief Adds the new surface.
140 * @param surface new surface
142 void AddSurface(Dali::RenderSurfaceInterface* surface);
145 // Undefined copy constructor.
146 ThreadController(const ThreadController&) = delete;
148 // Undefined assignment operator.
149 ThreadController& operator=(const ThreadController&) = delete;
152 ThreadControllerInterface* mThreadControllerInterface;
155 } // namespace Adaptor
157 } // namespace Internal
161 #endif // DALI_INTERNAL_THREAD_CONTROLLER_H