From 101cedb5f7e1cbe86e8340a428870081c59c39a5 Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Thu, 11 Jan 2024 16:59:33 +0100 Subject: [PATCH] :lipstick: --- crates/gpui/src/text_system.rs | 8 ++------ crates/gpui/src/text_system/line_layout.rs | 2 +- crates/gpui/src/window.rs | 12 ++++++------ 3 files changed, 9 insertions(+), 13 deletions(-) diff --git a/crates/gpui/src/text_system.rs b/crates/gpui/src/text_system.rs index 093ef3a7d5..7c5adef12d 100644 --- a/crates/gpui/src/text_system.rs +++ b/crates/gpui/src/text_system.rs @@ -364,12 +364,8 @@ impl TextSystem { Ok(lines) } - pub fn start_frame(&self) { - self.line_layout_cache.start_frame(); - } - - pub fn end_frame(&self, reused_views: &FxHashSet) { - self.line_layout_cache.end_frame(reused_views) + pub fn finish_frame(&self, reused_views: &FxHashSet) { + self.line_layout_cache.finish_frame(reused_views) } pub fn line_wrapper( diff --git a/crates/gpui/src/text_system/line_layout.rs b/crates/gpui/src/text_system/line_layout.rs index 909f051346..6c466f9680 100644 --- a/crates/gpui/src/text_system/line_layout.rs +++ b/crates/gpui/src/text_system/line_layout.rs @@ -256,7 +256,7 @@ impl LineLayoutCache { } } - pub fn end_frame(&self, reused_views: &FxHashSet) { + pub fn finish_frame(&self, reused_views: &FxHashSet) { debug_assert_eq!(self.view_stack.lock().len(), 0); let mut prev_frame = self.previous_frame.lock(); diff --git a/crates/gpui/src/window.rs b/crates/gpui/src/window.rs index 00d42144c7..02683d655d 100644 --- a/crates/gpui/src/window.rs +++ b/crates/gpui/src/window.rs @@ -361,7 +361,7 @@ impl Frame { .unwrap_or_default() } - fn reuse_views(&mut self, prev_frame: &mut Self) { + fn finish(&mut self, prev_frame: &mut Self) { // Reuse mouse listeners that didn't change since the last frame. for (type_id, listeners) in &mut prev_frame.mouse_listeners { let next_listeners = self.mouse_listeners.entry(*type_id).or_default(); @@ -390,6 +390,7 @@ impl Frame { // Reuse geometry that didn't change since the last frame. self.scene .reuse_views(&self.reused_views, &mut prev_frame.scene); + self.scene.finish(); } } @@ -1532,13 +1533,12 @@ impl<'a> WindowContext<'a> { } } - self.window - .next_frame - .reuse_views(&mut self.window.rendered_frame); - self.window.next_frame.scene.finish(); self.window.layout_engine.as_mut().unwrap().clear(); self.text_system() - .end_frame(&self.window.next_frame.reused_views); + .finish_frame(&self.window.next_frame.reused_views); + self.window + .next_frame + .finish(&mut self.window.rendered_frame); ELEMENT_ARENA.with_borrow_mut(|element_arena| element_arena.clear()); self.window.refreshing = false;