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::ResizeSurface()
109 virtual void ResizeSurface();
112 * @copydoc ThreadControllerInterface::SetRenderRefreshRate()
114 void SetRenderRefreshRate( unsigned int refreshRate );
132 // Undefined copy constructor.
133 SingleThreadController( const SingleThreadController& );
135 // Undefined assignment operator.
136 SingleThreadController& operator=( const SingleThreadController& );
139 * Ticks whenever the timer expires
144 * Runs the update and render
146 * @param[in] incrementTime If true, then the animation times are incremented.
148 void UpdateRender( bool incrementTime );
151 * Updates mCurrentTime and gets the time elapsed (in seconds) since last time this function was called.
153 * @return time elapsed (in seconds) since last call.
155 float UpdateTimeSinceLastRender();
158 * Helper to add a performance marker to the performance server (if it's active)
159 * @param type performance marker type
161 void AddPerformanceMarker( PerformanceInterface::MarkerType type );
164 * Changes the state and performs any other state-change related functionality.
165 * @param[in] state The new state
167 void ChangeState( State::Type state );
170 * Performs operations to stop rendering, e.g. informing Core of context being destroyed & shutting down EGL.
172 void StopRendering();
176 Dali::Timer mTimer; ///< Ensures an update & render is run every frame.
177 FpsTracker mFpsTracker; ///< Object that tracks the FPS
178 UpdateStatusLogger mUpdateStatusLogger; ///< Object that logs the update-status as required.
180 RenderHelper mRenderHelper; ///< Helper class for EGL, pre & post rendering
182 Integration::Core& mCore; ///< DALi core reference
183 PerformanceInterface* mPerformanceInterface; ///< The performance logging interface
185 uint64_t mLastUpdateRenderTime; ///< Last time we did an update and render
186 uint64_t mSystemTime; ///< The current system time for FPS calculations
187 unsigned int mRefreshRate; ///< Frame skipping count
188 State::Type mState; ///< The state
189 bool mUpdatingAndRendering:1; ///< Set to true when we are updating and rendering.
190 bool mStopRequestedWhileRendering:1; ///< Set to true if we were told to stop while we were in the middle of a render
193 } // namespace Adaptor
195 } // namespace Internal
199 #endif // __DALI_INTERNAL_SINGLE_THREAD_CONTROLLER_H__