1 #ifndef __DALI_INTERNAL_ADAPTOR_FRAME_TIME_H__
2 #define __DALI_INTERNAL_ADAPTOR_FRAME_TIME_H__
5 * Copyright (c) 2014 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.
29 class PlatformAbstraction;
38 * FrameTime stores the time of the last VSync. It can then be used by the update thread to predict
39 * the current update will be rendered.
45 // Called from Event thread
53 * Destructor, non virtual
58 * Sets the expected minimum frame time interval.
59 * @param[in] interval The interval in microseconds.
61 void SetMinimumFrameTimeInterval( unsigned int interval );
64 * Suspends the FrameTime object when the application state changes
69 * Resumes the FrameTime object when the application state changes
73 // Called from Update thread
76 * Sets the FrameTime object to sleep, i.e. when there are no more updates required.
81 * Wakes the FrameTime object from a sleep state.
86 * Predicts when the next render time will occur.
88 * @param[out] lastFrameDeltaSeconds The delta, in seconds (with float precision), between the last two renders.
89 * @param[out] lastSyncTimeMilliseconds The time, in milliseconds, of the last Sync.
90 * @param[out] nextSyncTimeMilliseconds The estimated time, in milliseconds, at the next Sync.
92 * @note Should only be called once per tick, from the update thread.
94 void PredictNextSyncTime( float& lastFrameDeltaSeconds, unsigned int& lastVSyncTimeMilliseconds, unsigned int& nextVSyncTimeMilliseconds );
96 // Called from VSync thread
99 * Tells the FrameTime object that a Sync has occurred.
101 * @param[in] frameNumber The frame number of the current Sync.
103 * @note Should only be called from the VSync thread.
105 void SetSyncTime( unsigned int frameNumber );
110 * Sets the current time to be the last Vsync time.
112 inline void SetLastSyncTime();
116 unsigned int mMinimumFrameTimeInterval; ///< The minimum frame time interval, set by Adaptor.
118 uint64_t mLastSyncTime; ///< The last Sync time (in microseconds).
119 uint64_t mLastSyncTimeAtUpdate; ///< The last Sync time at Update (in microseconds).
121 unsigned int mLastSyncFrameNumber; ///< The last Sync frame number
122 unsigned int mLastUpdateFrameNumber; ///< The last Sync frame number handled in Update.
124 // NOTE cannot use bitfields or booleans as these are used from multiple threads, must use variable with machine word size for atomic read/write
125 unsigned int mRunning; ///< The state of the FrameTime object.
126 unsigned int mFirstFrame; ///< Whether the current update is the first frame (after initialisation, resume or wake up).
128 unsigned int mPreviousUpdateFrames[3]; ///< Array holding the number of frames Update took in the last three iterations.
129 unsigned int writePos; ///< The current write position in the array.
131 unsigned int mExtraUpdatesSinceSync; ///< The number of extra updates since the last Sync.
134 } // namespace Adaptor
135 } // namespace Internal
138 #endif // __DALI_INTERNAL_ADAPTOR_FRAME_TIME_H__