From 1e4d8ae943004689a9d2b7310853e10470b66ce3 Mon Sep 17 00:00:00 2001 From: Emil Ernerfeldt Date: Tue, 25 Jan 2022 01:08:10 +0100 Subject: [PATCH] Remove warm-up of demo app Since https://github.com/emilk/egui/pull/1149 we only update the region of the font atlas that has changes, so loading new glyphs is much cheaper. This means warm-up is much less needed. There is now a small delay when opening the font book, but not when opening anything else. --- egui_demo_lib/src/wrap_app.rs | 5 ----- epi/src/lib.rs | 23 ++++++++++++----------- 2 files changed, 12 insertions(+), 16 deletions(-) diff --git a/egui_demo_lib/src/wrap_app.rs b/egui_demo_lib/src/wrap_app.rs index e277e58c..d07bc072 100644 --- a/egui_demo_lib/src/wrap_app.rs +++ b/egui_demo_lib/src/wrap_app.rs @@ -67,11 +67,6 @@ impl epi::App for WrapApp { egui::Rgba::TRANSPARENT // we set a `CentralPanel` fill color in `demo_windows.rs` } - fn warm_up_enabled(&self) -> bool { - // The example windows use a lot of emojis. Pre-cache them by running one frame where everything is open - cfg!(not(debug_assertions)) - } - fn update(&mut self, ctx: &egui::Context, frame: &epi::Frame) { if let Some(web_info) = frame.info().web_info.as_ref() { if let Some(anchor) = web_info.web_location_hash.strip_prefix('#') { diff --git a/epi/src/lib.rs b/epi/src/lib.rs index a7a15b49..bc1b5ea1 100644 --- a/epi/src/lib.rs +++ b/epi/src/lib.rs @@ -120,17 +120,6 @@ pub trait App { /// Also allows you to restore state, if there is a storage (required the "persistence" feature). fn setup(&mut self, _ctx: &egui::Context, _frame: &Frame, _storage: Option<&dyn Storage>) {} - /// If `true` a warm-up call to [`Self::update`] will be issued where - /// `ctx.memory().everything_is_visible()` will be set to `true`. - /// - /// This will help pre-caching all text, preventing stutter when - /// opening a window containing new glyphs. - /// - /// In this warm-up call, all painted shapes will be ignored. - fn warm_up_enabled(&self) -> bool { - false - } - /// Called on shutdown, and perhaps at regular intervals. Allows you to save state. /// /// Only called when the "persistence" feature is enabled. @@ -203,6 +192,18 @@ pub trait App { fn persist_egui_memory(&self) -> bool { true } + + /// If `true` a warm-up call to [`Self::update`] will be issued where + /// `ctx.memory().everything_is_visible()` will be set to `true`. + /// + /// This can help pre-caching resources loaded by different parts of the UI, preventing stutter later on. + /// + /// In this warm-up call, all painted shapes will be ignored. + /// + /// The default is `false`, and it is unlikely you will want to change this. + fn warm_up_enabled(&self) -> bool { + false + } } /// Options controlling the behavior of a native window.