This splits notedeck into: - notedeck - notedeck_chrome - notedeck_columns The `notedeck` crate is the library that `notedeck_chrome` and `notedeck_columns`, use. It contains common functionality related to notedeck apps such as the NoteCache, ImageCache, etc. The `notedeck_chrome` crate is the binary and ui chrome. It is responsible for managing themes, user accounts, signing, data paths, nostrdb, image caches etc. It will eventually have its own ui which has yet to be determined. For now it just manages the browser data, which is passed to apps via a new struct called `AppContext`. `notedeck_columns` is our columns app, with less responsibility now that more things are handled by `notedeck_chrome` There is still much work left to do before this is a proper browser: - process isolation - sandboxing - etc This is the beginning of a new era! We're just getting started. Signed-off-by: William Casarin <jb55@jb55.com>
51 lines
1.4 KiB
Rust
51 lines
1.4 KiB
Rust
/*
|
|
use egui::util::History;
|
|
|
|
pub struct FrameHistory {
|
|
frame_times: History<f32>,
|
|
}
|
|
|
|
impl Default for FrameHistory {
|
|
fn default() -> Self {
|
|
let max_age: f32 = 1.0;
|
|
let max_len = (max_age * 300.0).round() as usize;
|
|
Self {
|
|
frame_times: History::new(0..max_len, max_age),
|
|
}
|
|
}
|
|
}
|
|
|
|
impl FrameHistory {
|
|
// Called first
|
|
pub fn on_new_frame(&mut self, now: f64, previous_frame_time: Option<f32>) {
|
|
let previous_frame_time = previous_frame_time.unwrap_or_default();
|
|
if let Some(latest) = self.frame_times.latest_mut() {
|
|
*latest = previous_frame_time; // rewrite history now that we know
|
|
}
|
|
self.frame_times.add(now, previous_frame_time); // projected
|
|
}
|
|
|
|
#[allow(unused)]
|
|
pub fn mean_frame_time(&self) -> f32 {
|
|
self.frame_times.average().unwrap_or_default()
|
|
}
|
|
|
|
#[allow(unused)]
|
|
pub fn fps(&self) -> f32 {
|
|
1.0 / self.frame_times.mean_time_interval().unwrap_or_default()
|
|
}
|
|
|
|
pub fn _ui(&mut self, ui: &mut egui::Ui) {
|
|
ui.label(format!(
|
|
"Mean CPU usage: {:.2} ms / frame",
|
|
1e3 * self.mean_frame_time()
|
|
))
|
|
.on_hover_text(
|
|
"Includes egui layout and tessellation time.\n\
|
|
Does not include GPU usage, nor overhead for sending data to GPU.",
|
|
);
|
|
egui::warn_if_debug_build(ui);
|
|
}
|
|
}
|
|
*/
|