const float MICROSECONDS_TO_SECONDS( 0.000001f );
const unsigned int HISTORY_SIZE(3);
+
+// constants to keep code readability with unsigned int has to be used as boolean (due to multithreading)
+const unsigned int TRUE = 1u;
+const unsigned int FALSE = 0u;
} // unnamed namespace
mLastSyncTimeAtUpdate( 0u ),
mLastSyncFrameNumber( 0u ),
mLastUpdateFrameNumber( 0u ),
- mRunning( true ),
- mFirstFrame( true ),
+ mRunning( TRUE ),
+ mFirstFrame( TRUE ),
writePos( 0u ),
mExtraUpdatesSinceSync( 0u )
{
void FrameTime::Suspend()
{
- mRunning = false;
+ mRunning = FALSE;
// Reset members
mLastSyncFrameNumber = 0;
DALI_LOG_INFO( gLogFilter, Debug::Concise, "FrameTime: Resuming\n" );
SetLastSyncTime(); // Should only update the last Sync time so the elapsed time during suspension is taken into consideration when we next update.
- mFirstFrame = true;
+ mFirstFrame = TRUE;
- mRunning = true;
+ mRunning = TRUE;
}
void FrameTime::Sleep()
SetLastSyncTime();
mLastSyncTimeAtUpdate = mLastSyncTime; // We do not want any animations to progress as we have just been woken up.
- mFirstFrame = true;
- mRunning = true;
+ mFirstFrame = TRUE;
+ mRunning = TRUE;
}
void FrameTime::PredictNextSyncTime( float& lastFrameDeltaSeconds, unsigned int& lastSyncTimeMilliseconds, unsigned int& nextSyncTimeMilliseconds )
mLastUpdateFrameNumber = lastSyncFrameNumber;
mLastSyncTimeAtUpdate = lastSyncTime;
- mFirstFrame = false;
+ mFirstFrame = FALSE;
// Calculate the time till the next render
unsigned int timeTillNextRender( minimumFrameTimeInterval * framesTillNextSync );
private:
- Integration::PlatformAbstraction& mPlatform; ///< The platform abstraction.
+ Integration::PlatformAbstraction& mPlatform; ///< The platform abstraction.
- unsigned int mMinimumFrameTimeInterval; ///< The minimum frame time interval, set by Adaptor.
+ unsigned int mMinimumFrameTimeInterval; ///< The minimum frame time interval, set by Adaptor.
- uint64_t mLastSyncTime; ///< The last Sync time (in microseconds).
- uint64_t mLastSyncTimeAtUpdate; ///< The last Sync time at Update (in microseconds).
+ uint64_t mLastSyncTime; ///< The last Sync time (in microseconds).
+ uint64_t mLastSyncTimeAtUpdate; ///< The last Sync time at Update (in microseconds).
- unsigned int mLastSyncFrameNumber; ///< The last Sync frame number
- unsigned int mLastUpdateFrameNumber; ///< The last Sync frame number handled in Update.
+ unsigned int mLastSyncFrameNumber; ///< The last Sync frame number
+ unsigned int mLastUpdateFrameNumber; ///< The last Sync frame number handled in Update.
- bool mRunning:1; ///< The state of the FrameTime object.
- bool mFirstFrame:1; ///< Whether the current update is the first frame (after initialisation, resume or wake up).
+ // NOTE cannot use bitfields or booleans as these are used from multiple threads, must use variable with machine word size for atomic read/write
+ unsigned int mRunning; ///< The state of the FrameTime object.
+ unsigned int mFirstFrame; ///< Whether the current update is the first frame (after initialisation, resume or wake up).
- unsigned int mPreviousUpdateFrames[3]; ///< Array holding the number of frames Update took in the last three iterations.
- unsigned int writePos; ///< The current write position in the array.
+ unsigned int mPreviousUpdateFrames[3]; ///< Array holding the number of frames Update took in the last three iterations.
+ unsigned int writePos; ///< The current write position in the array.
- unsigned int mExtraUpdatesSinceSync; ///< The number of extra updates since the last Sync.
+ unsigned int mExtraUpdatesSinceSync; ///< The number of extra updates since the last Sync.
};
} // namespace Adaptor