1 #ifndef __DALI_INTERNAL_FRAME_TIME_H__
2 #define __DALI_INTERNAL_FRAME_TIME_H__
5 // Copyright (c) 2014 Samsung Electronics Co., Ltd.
7 // Licensed under the Flora License, Version 1.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://floralicense.org/license/
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.
27 class PlatformAbstraction;
34 * FrameTime stores the time of the last VSync. It can then be used by the update thread to predict
35 * the current update will be rendered.
39 public: // Core Methods
41 // Called from Event thread
45 * @param[in] platform The platform used to retrieve the current time
47 FrameTime( Integration::PlatformAbstraction& platform );
50 * Destructor, non virtual
55 * Sets the expected minimum frame time interval.
56 * @param[in] interval The interval in microseconds.
58 void SetMinimumFrameTimeInterval( unsigned int interval );
61 * Suspends the FrameTime object.
62 * During the suspended state animations will be paused.
63 * @note Should only be called by the Core.
68 * Resumes the FrameTime object.
69 * Animations etc. will carry on from where they left off.
70 * @note Should only be called by the Core.
74 // Called from Update thread
77 * Sets the FrameTime object to sleep.
78 * @note Should only be called by the Core, from the update thread.
83 * Wakes the FrameTime object from a sleep state.
84 * @note Should only be called by the Core, from the update thread.
89 * Predicts when the next render time will occur.
91 * @param[out] lastFrameDeltaSeconds The delta, in seconds (with float precision), between the last two renders.
92 * @param[out] lastVSyncTimeMilliseconds The time, in milliseconds, of the last VSync.
93 * @param[out] nextVSyncTimeMilliseconds The estimated time, in milliseconds, at the next VSync.
95 * @note Should only be called once per tick, from the update thread.
97 void PredictNextVSyncTime( float& lastFrameDeltaSeconds, unsigned int& lastVSyncTimeMilliseconds, unsigned int& nextVSyncTimeMilliseconds );
99 // Called from VSync thread
102 * Tells the FrameTime object that a VSync has occurred.
104 * @param[in] frameNumber The frame number of the current VSync.
106 * @note Should only be called by the Core (from the VSync thread).
108 void SetVSyncTime( unsigned int frameNumber );
113 * Sets the current time to be the last Vsync time.
115 inline void SetLastVSyncTime();
119 Integration::PlatformAbstraction& mPlatform; ///< The platform abstraction.
121 unsigned int mMinimumFrameTimeInterval; ///< The minimum frame time interval, set by Adaptor.
123 uint64_t mLastVSyncTime; ///< The last VSync time (in microseconds).
124 uint64_t mLastVSyncTimeAtUpdate; ///< The last VSync time at Update (in microseconds).
126 unsigned int mLastVSyncFrameNumber; ///< The last VSync frame number
127 unsigned int mLastUpdateFrameNumber; ///< The last VSync frame number handled in Update.
129 bool mRunning:1; ///< The state of the FrameTime object.
130 bool mFirstFrame:1; ///< Whether the current update is the first frame (after initialisation, resume or wake up).
132 unsigned int mPreviousUpdateFrames[3]; ///< Array holding the number of frames Update took in the last three iterations.
133 unsigned int writePos; ///< The current write position in the array.
135 unsigned int mExtraUpdatesSinceVSync; ///< The number of extra updates since the last VSync.
138 } // namespace Internal
142 #endif // __DALI_INTERNAL_FRAME_TIME_H__