frame_times::draw_plot now receives the duration indices directly.

This commit is contained in:
Filipe Rodrigues 2025-09-18 00:37:50 +01:00
parent fff2887cba
commit b9e0e4b7f7
Signed by: zenithsiz
SSH Key Fingerprint: SHA256:Mb5ppb3Sh7IarBO/sBTXLHbYEOz37hJAlslLQPPAPaU
3 changed files with 12 additions and 13 deletions

View File

@ -13,7 +13,11 @@ use {
};
/// Draws a frame time's plot
fn draw_plot(ui: &mut egui::Ui, display: &FrameTimesDisplay, charts: impl IntoIterator<Item = egui_plot::BarChart>) {
fn draw_plot<T, I, D>(ui: &mut egui::Ui, frame_times: &FrameTimes<T>, display: &FrameTimesDisplay, duration_idxs: I)
where
I: IntoIterator<Item = D>,
D: DurationIdx<T>,
{
let legend = egui_plot::Legend::default().follow_insertion_order(true);
let plot = egui_plot::Plot::new("Render frame times")
@ -26,6 +30,11 @@ fn draw_plot(ui: &mut egui::Ui, display: &FrameTimesDisplay, charts: impl IntoIt
};
plot.show(ui, |plot_ui| {
let mut prev_heights = vec![0.0; frame_times.len()];
let charts = duration_idxs.into_iter().map(move |duration_idx| {
self::create_frame_time_chart(frame_times, display, &mut prev_heights, &duration_idx)
});
for chart in charts {
plot_ui.bar_chart(chart);
}

View File

@ -11,12 +11,7 @@ use {
pub fn draw(ui: &mut egui::Ui, render_frame_times: &mut FrameTimes<RenderFrameTime>) {
let display = super::draw_display_settings(ui, render_frame_times);
let mut prev_heights = vec![0.0; render_frame_times.len()];
let charts = DurationIdx::iter().map(|duration_idx| {
super::create_frame_time_chart(render_frame_times, &display, &mut prev_heights, &duration_idx)
});
super::draw_plot(ui, &display, charts);
super::draw_plot(ui, render_frame_times, &display, DurationIdx::iter());
}
#[derive(PartialEq, Eq, Clone, Copy, Debug)]

View File

@ -95,12 +95,7 @@ pub fn draw(ui: &mut egui::Ui, render_frame_times: &mut FrameTimes<RenderPanelsF
)
.sorted();
let mut prev_heights = vec![0.0; render_frame_times.len()];
let charts = duration_idxs.map(|duration_idx| {
super::create_frame_time_chart(render_frame_times, &display, &mut prev_heights, &duration_idx)
});
super::draw_plot(ui, &display, charts);
super::draw_plot(ui, render_frame_times, &display, duration_idxs);
}
#[derive(PartialEq, Eq, PartialOrd, Ord, Clone, Copy, Hash, Debug)]