1 #ifndef __DALI_INTERNAL_SINGLE_THREAD_CONTROLLER_H__
2 #define __DALI_INTERNAL_SINGLE_THREAD_CONTROLLER_H__
5 * Copyright (c) 2015 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.
23 #include <dali/public-api/signals/connection-tracker.h>
24 #include <dali/integration-api/core.h>
28 #include <base/interfaces/performance-interface.h>
29 #include <base/fps-tracker.h>
30 #include <base/render-helper.h>
31 #include <base/thread-controller-interface.h>
32 #include <base/update-status-logger.h>
45 class AdaptorInternalServices;
46 class EnvironmentOptions;
49 * Single Thread Controller, where events, updates & renders ALL occur on the same thread.
51 class SingleThreadController : public ConnectionTracker,
52 public ThreadControllerInterface
59 SingleThreadController( AdaptorInternalServices& adaptorInterfaces, const EnvironmentOptions& environmentOptions );
62 * Non virtual destructor. Not intended as base class.
64 ~SingleThreadController();
67 * @copydoc ThreadControllerInterface::Initialize()
72 * @copydoc ThreadControllerInterface::Start()
77 * @copydoc ThreadControllerInterface::Pause()
82 * @copydoc ThreadControllerInterface::Resume()
87 * @copydoc ThreadControllerInterface::Stop()
92 * @copydoc ThreadControllerInterface::RequestUpdate()
97 * @copydoc ThreadControllerInterface::RequestUpdateOnce()
99 void RequestUpdateOnce();
102 * @copydoc ThreadControllerInterface::ReplaceSurface()
104 void ReplaceSurface( RenderSurface* surface );
107 * @copydoc ThreadControllerInterface::SetRenderRefreshRate()
109 void SetRenderRefreshRate( unsigned int refreshRate );
127 // Undefined copy constructor.
128 SingleThreadController( const SingleThreadController& );
130 // Undefined assignment operator.
131 SingleThreadController& operator=( const SingleThreadController& );
134 * Ticks whenever the timer expires
139 * Runs the update and render
141 * @param[in] incrementTime If true, then the animation times are incremented.
143 void UpdateRender( bool incrementTime );
146 * Updates mCurrentTime and gets the time elapsed (in seconds) since last time this function was called.
148 * @return time elapsed (in seconds) since last call.
150 float UpdateTimeSinceLastRender();
153 * Helper to add a performance marker to the performance server (if it's active)
154 * @param type performance marker type
156 void AddPerformanceMarker( PerformanceInterface::MarkerType type );
159 * Changes the state and performs any other state-change related functionality.
160 * @param[in] state The new state
162 void ChangeState( State::Type state );
165 * Performs operations to stop rendering, e.g. informing Core of context being destroyed & shutting down EGL.
167 void StopRendering();
170 * Runs render (along with pre & post steps as required).
171 * @return True if an update is required.
177 Dali::Timer mTimer; ///< Ensures an update & render is run every frame.
178 FpsTracker mFpsTracker; ///< Object that tracks the FPS
179 UpdateStatusLogger mUpdateStatusLogger; ///< Object that logs the update-status as required.
181 RenderHelper mRenderHelper; ///< Helper class for EGL, pre & post rendering
183 Integration::Core& mCore; ///< DALi core reference
184 PerformanceInterface* mPerformanceInterface; ///< The performance logging interface
186 uint64_t mLastUpdateRenderTime; ///< Last time we did an update and render
187 uint64_t mSystemTime; ///< The current system time for FPS calculations
188 unsigned int mRefreshRate; ///< Frame skipping count
189 State::Type mState; ///< The state
190 bool mUpdatingAndRendering:1; ///< Set to true when we are updating and rendering.
191 bool mStopRequestedWhileRendering:1; ///< Set to true if we were told to stop while we were in the middle of a render
194 } // namespace Adaptor
196 } // namespace Internal
200 #endif // __DALI_INTERNAL_SINGLE_THREAD_CONTROLLER_H__