QcPreviewPacer Class
Frame pacing of the character preview: it draws only while it is visible and at most at its frame rate, so an open screen with a preview adds a small, bounded load and a hidden one none. More...
| Header: | #include <clientcore/preview/QcPreviewPacer.h> |
Public Functions
| bool | frameDue(bool visible, qint64 nowMs) |
| int | framesPerSecond() const |
| void | hide() |
| int | intervalMs() const |
| void | setFramesPerSecond(int framesPerSecond) |
Static Public Members
| const int | defaultFramesPerSecond |
| const int | maxFramesPerSecond |
Detailed Description
The clock is passed in (milliseconds of a monotonic clock), so the rules are testable.
Member Function Documentation
bool QcPreviewPacer::frameDue(bool visible, qint64 nowMs)
Returns whether to draw a frame at nowMs; when it says yes, the frame counts as drawn. Never while not visible; the first frame after becoming visible at once, later ones an interval apart (a timer a millisecond early still counts).
int QcPreviewPacer::framesPerSecond() const
Returns the frame rate.
See also setFramesPerSecond().
void QcPreviewPacer::hide()
Hidden: the next visible frame is drawn at once.
int QcPreviewPacer::intervalMs() const
Returns the shortest time between two frames in milliseconds.
void QcPreviewPacer::setFramesPerSecond(int framesPerSecond)
Sets the frame rate to framesPerSecond, clamped to 1..maxFramesPerSecond.
See also framesPerSecond().
Member Variable Documentation
const int QcPreviewPacer::defaultFramesPerSecond
Frame rate of a new pacer.
const int QcPreviewPacer::maxFramesPerSecond
Highest frame rate.