diff --git a/src/render.rs b/src/render.rs index 2df0f44..2961084 100644 --- a/src/render.rs +++ b/src/render.rs @@ -54,7 +54,8 @@ pub struct Renderer { surfaces: S, fps: RealTimeRunningAverage, fps_display: Periodically, - frame: usize + frame: usize, + frame_count: usize } impl Renderer { @@ -64,7 +65,8 @@ impl Renderer { surfaces: surfaces, fps: RealTimeRunningAverage::default(), fps_display: Periodically::new_every_n_seconds(5), - frame: 0 + frame: 0, + frame_count: 0 } } } @@ -81,10 +83,12 @@ impl Task for Renderer { self.output.commit(); - self.fps.insert(1); self.frame += 1; self.fps_display.run(|| { - log::info!("FPS: {}", self.fps.measurement()); + self.fps.insert((self.frame - self.frame_count) as u32); + self.frame_count = self.frame; + let fps = self.fps.measurement(); + bus.push(Event::new_property_change("output.fps", fps.rate() as u32)); }); }, _ => self.output.on_event(event)