Add runtime option to render expired frames
Replace the compilation flag SKIP_FRAMES by a runtime flag to force rendering of expired frames. By default, the expired frames are skipped.
This commit is contained in:
@@ -16,9 +16,7 @@ fps_counter_start(struct fps_counter *counter) {
|
||||
counter->started = true;
|
||||
counter->slice_start = SDL_GetTicks();
|
||||
counter->nr_rendered = 0;
|
||||
#ifdef SKIP_FRAMES
|
||||
counter->nr_skipped = 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
@@ -28,16 +26,12 @@ fps_counter_stop(struct fps_counter *counter) {
|
||||
|
||||
static void
|
||||
display_fps(struct fps_counter *counter) {
|
||||
#ifdef SKIP_FRAMES
|
||||
if (counter->nr_skipped) {
|
||||
LOGI("%d fps (+%d frames skipped)", counter->nr_rendered,
|
||||
counter->nr_skipped);
|
||||
} else {
|
||||
#endif
|
||||
LOGI("%d fps", counter->nr_rendered);
|
||||
#ifdef SKIP_FRAMES
|
||||
LOGI("%d fps", counter->nr_rendered);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -49,9 +43,7 @@ check_expired(struct fps_counter *counter) {
|
||||
uint32_t elapsed_slices = (now - counter->slice_start) / 1000;
|
||||
counter->slice_start += 1000 * elapsed_slices;
|
||||
counter->nr_rendered = 0;
|
||||
#ifdef SKIP_FRAMES
|
||||
counter->nr_skipped = 0;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,10 +53,8 @@ fps_counter_add_rendered_frame(struct fps_counter *counter) {
|
||||
++counter->nr_rendered;
|
||||
}
|
||||
|
||||
#ifdef SKIP_FRAMES
|
||||
void
|
||||
fps_counter_add_skipped_frame(struct fps_counter *counter) {
|
||||
check_expired(counter);
|
||||
++counter->nr_skipped;
|
||||
}
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user