Bookkeeping for frame durations and associated errors.
More...
#include <kanzi/core.ui/main_loop/frame_time_queue.hpp>
Bookkeeping for frame durations and associated errors.
◆ FrameTimeQueue() [1/3]
| kanzi::FrameTimeQueue::FrameTimeQueue |
( |
chrono::nanoseconds | window, |
|
|
size_t | desiredFrameRate ) |
|
inlineexplicit |
Constructor.
- Parameters
-
| window | Time window for bookkeeping. |
| desiredFrameRate | Desired frame rate. |
◆ FrameTimeQueue() [2/3]
| kanzi::FrameTimeQueue::FrameTimeQueue |
( |
chrono::nanoseconds | window | ) |
|
|
explicit |
Constructor.
Frame rate is unlimited.
- Parameters
-
| window | Time window for bookkeeping. |
◆ FrameTimeQueue() [3/3]
Move constructor.
- Parameters
-
◆ operator=()
Move operator.
- Parameters
-
◆ update()
| void kanzi::FrameTimeQueue::update |
( |
chrono::nanoseconds | frameTime | ) |
|
Add a frame time.
- Parameters
-
| frameTime | Time spent last frame. |
◆ getFPS()
| float kanzi::FrameTimeQueue::getFPS |
( |
| ) |
const |
|
inline |
Gets the current framerate.
- Returns
- Current framerate as calculated from recorded frame times.
◆ getDesiredFrameRate()
| size_t kanzi::FrameTimeQueue::getDesiredFrameRate |
( |
| ) |
const |
|
inline |
Gets the desired frame rate.
- Returns
- Targeted frame rate.
- Since
- Kanzi 4.0.0
◆ getDesiredFrameTime()
| chrono::nanoseconds kanzi::FrameTimeQueue::getDesiredFrameTime |
( |
| ) |
const |
|
inline |
Gets the desired frame time.
- Returns
- Frame time from the targeted frame rate.
- Since
- Kanzi 4.0.0
◆ getFrameTimeErrorTerm()
| chrono::nanoseconds kanzi::FrameTimeQueue::getFrameTimeErrorTerm |
( |
| ) |
const |
|
inline |
Gets the cumulative frame time error.
- Returns
- Cumulative frame time error.
- Since
- Kanzi 4.0.0
◆ getWindow()
| chrono::nanoseconds kanzi::FrameTimeQueue::getWindow |
( |
| ) |
const |
|
inline |
Gets the frame time window.
- Returns
- Frame window time.
- Since
- Kanzi 4.0.0
◆ fpsToDurationCeiled()
| static constexpr chrono::nanoseconds kanzi::FrameTimeQueue::fpsToDurationCeiled |
( |
size_t | desiredFrameRate | ) |
|
|
inlinestaticconstexpr |
Converts frame rate to desired frame time duration.
Always rounds nanoseconds up.
- Parameters
-
| desiredFrameRate | Desired Frame rate. |
- Returns
- Frame duration in nanoseconds.
- Since
- Kanzi 4.0.0
◆ durationDivideRoundUp()
| static constexpr chrono::nanoseconds kanzi::FrameTimeQueue::durationDivideRoundUp |
( |
chrono::nanoseconds | duration, |
|
|
size_t | divisor ) |
|
inlinestaticconstexprprotected |
Divide time by a value, round up.
- Parameters
-
| duration | Duration. |
| divisor | Divisor. |
- Since
- Kanzi 4.0.0
◆ growFrameTimeArray()
| void kanzi::FrameTimeQueue::growFrameTimeArray |
( |
| ) |
|
|
protected |
Enlarges the frame time array.
After calling this function, insertion of
- Since
- Kanzi 4.0.0
◆ decrementIterator()
| size_t kanzi::FrameTimeQueue::decrementIterator |
( |
size_t | iter | ) |
const |
|
inlineprotected |
Decrement an iterator and wrap around if needed.
- Parameters
-
- Returns
- New iterator location.
- Since
- Kanzi 4.0.0
◆ incrementIterator()
| size_t kanzi::FrameTimeQueue::incrementIterator |
( |
size_t | iter | ) |
const |
|
inlineprotected |
Increment an iterator and wrap around if needed.
- Parameters
-
- Returns
- New iterator location.
- Since
- Kanzi 4.0.0
◆ m_window
| chrono::nanoseconds kanzi::FrameTimeQueue::m_window |
|
protected |
Time window for frame time error bookkeeping.
- Since
- Kanzi 4.0.0
◆ m_frameTimes
| vector<chrono::nanoseconds> kanzi::FrameTimeQueue::m_frameTimes |
|
protected |
Array containing frame times for FPS calculation.
- Since
- Kanzi 4.0.0
- Renamed from m_frames.
- Changed the type to vector<chrono::nanoseconds>.
◆ m_frameTimeCount
| size_t kanzi::FrameTimeQueue::m_frameTimeCount |
|
protected |
Frame time element count.
- Since
- Kanzi 4.0.0 renamed from m_frameCount.
◆ m_insertionIndex
| size_t kanzi::FrameTimeQueue::m_insertionIndex |
|
protected |
Frame time insertion index.
Insertion index being identical to removal index indicates the array being empty.
- Since
- Kanzi 4.0.0
◆ m_removeIndex
| size_t kanzi::FrameTimeQueue::m_removeIndex |
|
protected |
Frame time removal index.
If insertion would increment the insertion index to the removal index, the array must be grown.
- Since
- Kanzi 4.0.0 renamed from m_firstFrame.
◆ m_totalTime
| chrono::nanoseconds kanzi::FrameTimeQueue::m_totalTime |
|
protected |
Total time spent within the frame time window.
◆ m_fps
| float kanzi::FrameTimeQueue::m_fps |
|
protected |
◆ m_errorTermCalculator
Calculator for frame time error term.
- Since
- Kanzi 4.0.0
The documentation for this class was generated from the following file: