diff --git a/Cargo.lock b/Cargo.lock index 4dc34e3e6..99d6a7832 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5329,7 +5329,7 @@ dependencies = [ [[package]] name = "ecolor" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=bcdeb7bb828147c04969f580291654924f1f3f4d#bcdeb7bb828147c04969f580291654924f1f3f4d" +source = "git+https://github.com/aiongg/egui.git?rev=dd086c7f29f74478009ba98fcddf7d36bd0368e8#dd086c7f29f74478009ba98fcddf7d36bd0368e8" dependencies = [ "bytemuck", "emath", @@ -5385,7 +5385,7 @@ dependencies = [ [[package]] name = "eframe" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=bcdeb7bb828147c04969f580291654924f1f3f4d#bcdeb7bb828147c04969f580291654924f1f3f4d" +source = "git+https://github.com/aiongg/egui.git?rev=dd086c7f29f74478009ba98fcddf7d36bd0368e8#dd086c7f29f74478009ba98fcddf7d36bd0368e8" dependencies = [ "ahash", "bytemuck", @@ -5420,7 +5420,7 @@ dependencies = [ [[package]] name = "egui" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=bcdeb7bb828147c04969f580291654924f1f3f4d#bcdeb7bb828147c04969f580291654924f1f3f4d" +source = "git+https://github.com/aiongg/egui.git?rev=dd086c7f29f74478009ba98fcddf7d36bd0368e8#dd086c7f29f74478009ba98fcddf7d36bd0368e8" dependencies = [ "accesskit", "ahash", @@ -5439,7 +5439,7 @@ dependencies = [ [[package]] name = "egui-wgpu" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=bcdeb7bb828147c04969f580291654924f1f3f4d#bcdeb7bb828147c04969f580291654924f1f3f4d" +source = "git+https://github.com/aiongg/egui.git?rev=dd086c7f29f74478009ba98fcddf7d36bd0368e8#dd086c7f29f74478009ba98fcddf7d36bd0368e8" dependencies = [ "ahash", "bytemuck", @@ -5458,7 +5458,7 @@ dependencies = [ [[package]] name = "egui-winit" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=bcdeb7bb828147c04969f580291654924f1f3f4d#bcdeb7bb828147c04969f580291654924f1f3f4d" +source = "git+https://github.com/aiongg/egui.git?rev=dd086c7f29f74478009ba98fcddf7d36bd0368e8#dd086c7f29f74478009ba98fcddf7d36bd0368e8" dependencies = [ "block2 0.6.2", "bytemuck", @@ -5478,7 +5478,7 @@ dependencies = [ [[package]] name = "egui_glow" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=bcdeb7bb828147c04969f580291654924f1f3f4d#bcdeb7bb828147c04969f580291654924f1f3f4d" +source = "git+https://github.com/aiongg/egui.git?rev=dd086c7f29f74478009ba98fcddf7d36bd0368e8#dd086c7f29f74478009ba98fcddf7d36bd0368e8" dependencies = [ "bytemuck", "egui", @@ -5491,7 +5491,7 @@ dependencies = [ [[package]] name = "egui_kittest" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=bcdeb7bb828147c04969f580291654924f1f3f4d#bcdeb7bb828147c04969f580291654924f1f3f4d" +source = "git+https://github.com/aiongg/egui.git?rev=dd086c7f29f74478009ba98fcddf7d36bd0368e8#dd086c7f29f74478009ba98fcddf7d36bd0368e8" dependencies = [ "eframe", "egui", @@ -5568,7 +5568,7 @@ dependencies = [ [[package]] name = "emath" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=bcdeb7bb828147c04969f580291654924f1f3f4d#bcdeb7bb828147c04969f580291654924f1f3f4d" +source = "git+https://github.com/aiongg/egui.git?rev=dd086c7f29f74478009ba98fcddf7d36bd0368e8#dd086c7f29f74478009ba98fcddf7d36bd0368e8" dependencies = [ "bytemuck", ] @@ -5641,7 +5641,7 @@ dependencies = [ [[package]] name = "epaint" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=bcdeb7bb828147c04969f580291654924f1f3f4d#bcdeb7bb828147c04969f580291654924f1f3f4d" +source = "git+https://github.com/aiongg/egui.git?rev=dd086c7f29f74478009ba98fcddf7d36bd0368e8#dd086c7f29f74478009ba98fcddf7d36bd0368e8" dependencies = [ "ahash", "bytemuck", @@ -5667,7 +5667,7 @@ dependencies = [ [[package]] name = "epaint_default_fonts" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=bcdeb7bb828147c04969f580291654924f1f3f4d#bcdeb7bb828147c04969f580291654924f1f3f4d" +source = "git+https://github.com/aiongg/egui.git?rev=dd086c7f29f74478009ba98fcddf7d36bd0368e8#dd086c7f29f74478009ba98fcddf7d36bd0368e8" [[package]] name = "equator" @@ -14991,19 +14991,19 @@ dependencies = [ [[patch.unused]] name = "egui_demo_lib" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=bcdeb7bb828147c04969f580291654924f1f3f4d#bcdeb7bb828147c04969f580291654924f1f3f4d" +source = "git+https://github.com/aiongg/egui.git?rev=dd086c7f29f74478009ba98fcddf7d36bd0368e8#dd086c7f29f74478009ba98fcddf7d36bd0368e8" [[patch.unused]] name = "egui_extras" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=bcdeb7bb828147c04969f580291654924f1f3f4d#bcdeb7bb828147c04969f580291654924f1f3f4d" +source = "git+https://github.com/aiongg/egui.git?rev=dd086c7f29f74478009ba98fcddf7d36bd0368e8#dd086c7f29f74478009ba98fcddf7d36bd0368e8" [[patch.unused]] name = "egui_inspection" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=bcdeb7bb828147c04969f580291654924f1f3f4d#bcdeb7bb828147c04969f580291654924f1f3f4d" +source = "git+https://github.com/aiongg/egui.git?rev=dd086c7f29f74478009ba98fcddf7d36bd0368e8#dd086c7f29f74478009ba98fcddf7d36bd0368e8" [[patch.unused]] name = "egui_system_font_provider" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=bcdeb7bb828147c04969f580291654924f1f3f4d#bcdeb7bb828147c04969f580291654924f1f3f4d" +source = "git+https://github.com/aiongg/egui.git?rev=dd086c7f29f74478009ba98fcddf7d36bd0368e8#dd086c7f29f74478009ba98fcddf7d36bd0368e8" diff --git a/Cargo.toml b/Cargo.toml index 2319c6b13..f02e4cfa0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -295,20 +295,20 @@ hayro-jbig2 = { path = "vendor/hayro-jbig2" } hayro-cmap = { path = "vendor/hayro-cmap" } hayro-postscript = { path = "vendor/hayro-postscript" } linesweeper = { path = "vendor/linesweeper" } -ecolor = { git = "https://github.com/storytold/egui.git", rev = "bcdeb7bb828147c04969f580291654924f1f3f4d" } -emath = { git = "https://github.com/storytold/egui.git", rev = "bcdeb7bb828147c04969f580291654924f1f3f4d" } -epaint = { git = "https://github.com/storytold/egui.git", rev = "bcdeb7bb828147c04969f580291654924f1f3f4d" } -epaint_default_fonts = { git = "https://github.com/storytold/egui.git", rev = "bcdeb7bb828147c04969f580291654924f1f3f4d" } -egui = { git = "https://github.com/storytold/egui.git", rev = "bcdeb7bb828147c04969f580291654924f1f3f4d" } -egui-winit = { git = "https://github.com/storytold/egui.git", rev = "bcdeb7bb828147c04969f580291654924f1f3f4d" } -egui-wgpu = { git = "https://github.com/storytold/egui.git", rev = "bcdeb7bb828147c04969f580291654924f1f3f4d" } -egui_glow = { git = "https://github.com/storytold/egui.git", rev = "bcdeb7bb828147c04969f580291654924f1f3f4d" } -egui_extras = { git = "https://github.com/storytold/egui.git", rev = "bcdeb7bb828147c04969f580291654924f1f3f4d" } -egui_kittest = { git = "https://github.com/storytold/egui.git", rev = "bcdeb7bb828147c04969f580291654924f1f3f4d" } -egui_system_font_provider = { git = "https://github.com/storytold/egui.git", rev = "bcdeb7bb828147c04969f580291654924f1f3f4d" } -eframe = { git = "https://github.com/storytold/egui.git", rev = "bcdeb7bb828147c04969f580291654924f1f3f4d" } -egui_demo_lib = { git = "https://github.com/storytold/egui.git", rev = "bcdeb7bb828147c04969f580291654924f1f3f4d" } -egui_inspection = { git = "https://github.com/storytold/egui.git", rev = "bcdeb7bb828147c04969f580291654924f1f3f4d" } +ecolor = { git = "https://github.com/aiongg/egui.git", rev = "dd086c7f29f74478009ba98fcddf7d36bd0368e8" } +emath = { git = "https://github.com/aiongg/egui.git", rev = "dd086c7f29f74478009ba98fcddf7d36bd0368e8" } +epaint = { git = "https://github.com/aiongg/egui.git", rev = "dd086c7f29f74478009ba98fcddf7d36bd0368e8" } +epaint_default_fonts = { git = "https://github.com/aiongg/egui.git", rev = "dd086c7f29f74478009ba98fcddf7d36bd0368e8" } +egui = { git = "https://github.com/aiongg/egui.git", rev = "dd086c7f29f74478009ba98fcddf7d36bd0368e8" } +egui-winit = { git = "https://github.com/aiongg/egui.git", rev = "dd086c7f29f74478009ba98fcddf7d36bd0368e8" } +egui-wgpu = { git = "https://github.com/aiongg/egui.git", rev = "dd086c7f29f74478009ba98fcddf7d36bd0368e8" } +egui_glow = { git = "https://github.com/aiongg/egui.git", rev = "dd086c7f29f74478009ba98fcddf7d36bd0368e8" } +egui_extras = { git = "https://github.com/aiongg/egui.git", rev = "dd086c7f29f74478009ba98fcddf7d36bd0368e8" } +egui_kittest = { git = "https://github.com/aiongg/egui.git", rev = "dd086c7f29f74478009ba98fcddf7d36bd0368e8" } +egui_system_font_provider = { git = "https://github.com/aiongg/egui.git", rev = "dd086c7f29f74478009ba98fcddf7d36bd0368e8" } +eframe = { git = "https://github.com/aiongg/egui.git", rev = "dd086c7f29f74478009ba98fcddf7d36bd0368e8" } +egui_demo_lib = { git = "https://github.com/aiongg/egui.git", rev = "dd086c7f29f74478009ba98fcddf7d36bd0368e8" } +egui_inspection = { git = "https://github.com/aiongg/egui.git", rev = "dd086c7f29f74478009ba98fcddf7d36bd0368e8" } winit = { git = "https://github.com/storytold/winit.git", rev = "a517b3846ee8457d84ee4975110bfda6797c44dc" } # symphonia's FLAC decoder restores LPC samples as `residual + (prediction as i32)`. In a valid diff --git a/crates/ui-contract/src/contract/lazy.rs b/crates/ui-contract/src/contract/lazy.rs index 373d04a52..d0db84761 100644 --- a/crates/ui-contract/src/contract/lazy.rs +++ b/crates/ui-contract/src/contract/lazy.rs @@ -112,6 +112,7 @@ impl Lazy { layer: ui.layer_id(), layout, pixels_per_point: ctx.pixels_per_point(), + atlas: ctx.fonts(|fonts| fonts.atlas_generation()), env: Env::of(ui).key, }; let memo = matches!(key, Key::Memo(_)); diff --git a/crates/ui-contract/src/runtime/lazy.rs b/crates/ui-contract/src/runtime/lazy.rs index 449bfeee9..711eb7232 100644 --- a/crates/ui-contract/src/runtime/lazy.rs +++ b/crates/ui-contract/src/runtime/lazy.rs @@ -174,6 +174,9 @@ pub(crate) struct Place { pub(crate) layer: Layer, pub(crate) layout: Layout, pub(crate) pixels_per_point: f32, + /// The font atlas the run's text points into (`Fonts::atlas_generation`): egui clears the atlas when it fills up + /// and rebuilds it for new text options, and a kept galley's glyphs then name other glyphs. + pub(crate) atlas: u64, /// The scope's environment (`Env::key`): its tokens (theme, density), scale, direction, language and whether the /// window is active. pub(crate) env: EnvKey, @@ -188,9 +191,9 @@ struct Moved { impl Place { /// How a run at this place that took `rect` replays at `now`, or `None` when it cannot. The room may have moved; its - /// size, the layer, layout, scale and environment are the ones the run had. The record moves by the room's move - /// when that is a whole step of egui's UI rounding (a run rounds its rects to it, so a moved record is what a run - /// there gives) and, for a move, the record holds nothing a move cannot place (`movable`: no paint callback) on an + /// size, the layer, layout, scale, font atlas and environment are the ones the run had. The record moves by the + /// room's move when that is a whole step of egui's UI rounding (a run rounds its rects to it, so a moved record is + /// what a run there gives) and, for a move, the record holds nothing a move cannot place (`movable`: no paint callback) on an /// untransformed layer (`transformed`: egui's AccessKit bounds are layer space only there). Its clip rects follow /// the clip when either: /// - the clip moved with the room (`with_clip`): every rect and clip moves exactly, whatever the clip cut; @@ -205,6 +208,7 @@ impl Place { && now.layer == self.layer && now.layout == self.layout && now.pixels_per_point == self.pixels_per_point + && now.atlas == self.atlas && now.env == self.env; let placeable = offset == Vec2::ZERO || (offset == offset.round_ui() && movable && !transformed); if !same || !placeable { diff --git a/crates/ui-widgets/tests/it/body/memo_view.rs b/crates/ui-widgets/tests/it/body/memo_view.rs index 04c464b55..ccafdd3f5 100644 --- a/crates/ui-widgets/tests/it/body/memo_view.rs +++ b/crates/ui-widgets/tests/it/body/memo_view.rs @@ -232,6 +232,31 @@ fn a_pass_egui_will_discard_keeps_no_record_and_replays_settled_views() { assert_eq!(frame(&mut frames, "B", false), (1, 0), "then it replays the shown pass's run"); } +/// A kept run's text points into egui's font atlas; when egui rebuilds the atlas (it filled up, or the text options +/// changed) the kept glyphs name other glyphs, so a settled view runs in place of replaying, then settles again. +#[trial] +fn a_settled_view_runs_after_the_font_atlas_is_rebuilt() { + let mut frames = Frames::new(); + let frame = |frames: &mut Frames| { + frames.frame(vec![], |ui| { + in_region(ui, region(0), |ui| MemoView::new("title", Title { title: "Atlas".to_owned() }, title).show(ui)); + }); + title_runs() + }; + for _ in 0..WARM { + frame(&mut frames); + } + assert_eq!(frame(&mut frames), 0, "a settled view replays"); + let before = frames.ctx.fonts(|fonts| fonts.atlas_generation()); + frames.ctx.all_styles_mut(|style| style.visuals.text_options.font_hinting = !style.visuals.text_options.font_hinting); + assert!(frame(&mut frames) > 0, "the view runs in the first frame on the rebuilt atlas"); + assert_ne!(frames.ctx.fonts(|fonts| fonts.atlas_generation()), before, "the atlas was rebuilt"); + for _ in 0..WARM { + frame(&mut frames); + } + assert_eq!(frame(&mut frames), 0, "then it replays again"); +} + /// A view that writes its own `&mut Tracked` runs twice for the change that asked for the write, the writing run and /// one that reads the written value, then replays. #[trial]