10 : mMicrosSecondsPerInterval(microsSecondsPerInterval), mIntervalCounter(0), mStartTime(0), mPauseOffset(0), mPauseTime(0), mIsPaused(
false) {}
12 void reset(uint32_t startTime) {
13 mStartTime = startTime;
19 void incrementIntervalCounter() { mIntervalCounter++; }
21 void pause(uint32_t now) {
28 void resume(uint32_t now) {
30 mPauseOffset += now - mPauseTime;
35 bool needsFrame(uint32_t now, uint32_t* precise_timestamp)
const {
40 uint32_t adjustedNow = now - mPauseOffset;
41 uint32_t elapsed = adjustedNow - mStartTime;
42 uint32_t elapsedMicros = elapsed * 1000;
43 uint32_t intervalNumber = elapsedMicros / mMicrosSecondsPerInterval;
44 bool needs_update = intervalNumber > mIntervalCounter;
46 *precise_timestamp = mStartTime + ((mIntervalCounter+1) * mMicrosSecondsPerInterval) / 1000 + mPauseOffset;
51 bool isPaused()
const {
return mIsPaused; }
54 uint64_t mMicrosSecondsPerInterval;
55 uint32_t mIntervalCounter;
57 uint32_t mPauseOffset;