From bfe2205ecbd24b8de9abc5dcf8b82e7431263d78 Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Tue, 26 Sep 2023 11:34:41 -0600 Subject: [PATCH] Checkpoint --- crates/gpui3/src/app.rs | 36 +++++++++++++++++++----------------- crates/gpui3/src/scene.rs | 3 ++- crates/gpui3/src/window.rs | 3 +++ 3 files changed, 24 insertions(+), 18 deletions(-) diff --git a/crates/gpui3/src/app.rs b/crates/gpui3/src/app.rs index 9e55a716dda08ce597cd0afc839f38105c0e69b5..de5c4274dd9009775be8f6adf9f27ac175ca478a 100644 --- a/crates/gpui3/src/app.rs +++ b/crates/gpui3/src/app.rs @@ -97,7 +97,7 @@ impl AppContext { let this = self.this.upgrade().unwrap(); self.platform.read(move |platform| { let cx = &mut *this.lock(); - f(platform, cx) + cx.update(|cx| f(platform, cx)) }) } @@ -122,22 +122,24 @@ impl AppContext { id: WindowId, update: impl FnOnce(&mut WindowContext) -> R, ) -> Result { - let mut window = self - .windows - .get_mut(id) - .ok_or_else(|| anyhow!("window not found"))? - .take() - .unwrap(); - - let result = update(&mut WindowContext::mutable(self, &mut window)); - window.dirty = true; - - self.windows - .get_mut(id) - .ok_or_else(|| anyhow!("window not found"))? - .replace(window); - - Ok(result) + self.update(|cx| { + let mut window = cx + .windows + .get_mut(id) + .ok_or_else(|| anyhow!("window not found"))? + .take() + .unwrap(); + + let result = update(&mut WindowContext::mutable(cx, &mut window)); + window.dirty = true; + + cx.windows + .get_mut(id) + .ok_or_else(|| anyhow!("window not found"))? + .replace(window); + + Ok(result) + }) } fn update(&mut self, update: impl FnOnce(&mut Self) -> R) -> R { diff --git a/crates/gpui3/src/scene.rs b/crates/gpui3/src/scene.rs index 3aeafd0eaefd79fdd493cc3359216211aa420586..78c3d87246aae0e2c39f86831d3d144449b86510 100644 --- a/crates/gpui3/src/scene.rs +++ b/crates/gpui3/src/scene.rs @@ -8,12 +8,13 @@ use collections::BTreeMap; // Exported to metal pub type PointF = Point; +#[derive(Debug)] pub struct Scene { layers: BTreeMap, pub(crate) scale_factor: f32, } -#[derive(Default)] +#[derive(Default, Debug)] pub struct SceneLayer { pub quads: Vec, } diff --git a/crates/gpui3/src/window.rs b/crates/gpui3/src/window.rs index 1e12ad67b337b2d6f9b15fbee196e6165e216b5d..58aebd9191cd0353c04a12564d7a1d8f6ce04c11 100644 --- a/crates/gpui3/src/window.rs +++ b/crates/gpui3/src/window.rs @@ -39,7 +39,9 @@ impl Window { let handle = handle; let cx = cx.to_async(); move |content_size, scale_factor| { + dbg!("!!!!!!!!!!!!"); cx.update_window(handle, |cx| { + dbg!("!!!!!!!!"); cx.window.scene = Scene::new(scale_factor); cx.window.content_size = content_size; cx.window.dirty = true; @@ -101,6 +103,7 @@ impl<'a, 'w> WindowContext<'a, 'w> { root_view.paint(layout, &mut (), &mut frame_state, cx)?; cx.window.root_view = Some(root_view); let scene = cx.window.scene.take(); + dbg!(&scene); let _ = cx.window.platform_window.read(|platform_window| { platform_window.draw(scene); future::ready(())