Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
gpui: Prepaint Div children with image cache (#46039)
Marco Mihai Condrachee57285fe3971
diff --git a/crates/gpui/src/elements/div.rs b/crates/gpui/src/elements/div.rsindex 952cef7f58e..8d75b23843b 100644--- a/crates/gpui/src/elements/div.rs+++ b/crates/gpui/src/elements/div.rs@@ -1425,6 +1425,11 @@ impl Element for Div {window: &mut Window,cx: &mut App,) -> Option<Hitbox> {+ let image_cache = self+ .image_cache+ .as_mut()+ .map(|provider| provider.provide(window, cx));+let has_prepaint_listener = self.prepaint_listener.is_some();let mut children_bounds = Vec::with_capacity(if has_prepaint_listener {request_layout.child_layout_ids.len()@@ -1479,16 +1484,18 @@ impl Element for Div {return hitbox;}- window.with_element_offset(scroll_offset, |window| {- for child in &mut self.children {- child.prepaint(window, cx);+ window.with_image_cache(image_cache, |window| {+ window.with_element_offset(scroll_offset, |window| {+ for child in &mut self.children {+ child.prepaint(window, cx);+ }+ });++ if let Some(listener) = self.prepaint_listener.as_ref() {+ listener(children_bounds, window, cx);}});- if let Some(listener) = self.prepaint_listener.as_ref() {- listener(children_bounds, window, cx);- }-hitbox},)