Improve framerate counting

The FPS counter was called only on new frames, so it could not print
values regularly, especially when there are very few FPS (when the
device surface does not change).

To the extreme, it was never able to display 0 fps.

Add a separate thread to print framerate every second.
This commit is contained in:
Romain Vimont
2019-06-07 16:55:19 +02:00
parent d104d3bda9
commit e2a272bf99
6 changed files with 207 additions and 52 deletions

View File

@@ -17,11 +17,12 @@ struct video_buffer {
bool interrupted;
SDL_cond *rendering_frame_consumed_cond;
bool rendering_frame_consumed;
struct fps_counter fps_counter;
struct fps_counter *fps_counter;
};
bool
video_buffer_init(struct video_buffer *vb, bool render_expired_frames);
video_buffer_init(struct video_buffer *vb, struct fps_counter *fps_counter,
bool render_expired_frames);
void
video_buffer_destroy(struct video_buffer *vb);