From c57e19c8faa040fb9e165df9247a39026f154e99 Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Tue, 3 Oct 2023 17:29:36 -0600 Subject: [PATCH] Checkpoint: Glyphs rendering how I'd like --- crates/gpui/src/platform/mac/atlas.rs | 4 ++-- crates/gpui/src/platform/mac/renderer.rs | 1 - crates/gpui3/src/platform/mac/metal_renderer.rs | 2 -- crates/gpui3/src/window.rs | 8 ++++---- crates/storybook/src/workspace.rs | 2 +- crates/storybook2/src/workspace.rs | 5 +---- 6 files changed, 8 insertions(+), 14 deletions(-) diff --git a/crates/gpui/src/platform/mac/atlas.rs b/crates/gpui/src/platform/mac/atlas.rs index d73cc33513..57a137479d 100644 --- a/crates/gpui/src/platform/mac/atlas.rs +++ b/crates/gpui/src/platform/mac/atlas.rs @@ -147,10 +147,10 @@ impl Atlas { bounds.size().y() as u64, ); self.texture.replace_region( - dbg!(region), + region, 0, bytes.as_ptr() as *const _, - dbg!((bounds.size().x() * self.bytes_per_pixel() as i32) as u64), + (bounds.size().x() * self.bytes_per_pixel() as i32) as u64, ); } diff --git a/crates/gpui/src/platform/mac/renderer.rs b/crates/gpui/src/platform/mac/renderer.rs index 9ef46beaa5..85f0af1ffd 100644 --- a/crates/gpui/src/platform/mac/renderer.rs +++ b/crates/gpui/src/platform/mac/renderer.rs @@ -633,7 +633,6 @@ impl Renderer { // Snap sprite to pixel grid. let origin = (glyph.origin * scale_factor).floor() + sprite.offset.to_f32(); - dbg!(origin); sprites_by_atlas .entry(sprite.atlas_id) .or_insert_with(Vec::new) diff --git a/crates/gpui3/src/platform/mac/metal_renderer.rs b/crates/gpui3/src/platform/mac/metal_renderer.rs index b06d186f34..a7a63354ce 100644 --- a/crates/gpui3/src/platform/mac/metal_renderer.rs +++ b/crates/gpui3/src/platform/mac/metal_renderer.rs @@ -49,7 +49,6 @@ const SHADERS_METALLIB: &[u8] = include_bytes!(concat!(env!("OUT_DIR"), "/shader const INSTANCE_BUFFER_SIZE: usize = 8192 * 1024; // This is an arbitrary decision. There's probably a more optimal value. pub struct MetalRenderer { - device: metal::Device, layer: metal::MetalLayer, command_queue: CommandQueue, quads_pipeline_state: metal::RenderPipelineState, @@ -145,7 +144,6 @@ impl MetalRenderer { )); Self { - device, layer, command_queue, quads_pipeline_state, diff --git a/crates/gpui3/src/window.rs b/crates/gpui3/src/window.rs index d524a43fb1..9e9b4c36b6 100644 --- a/crates/gpui3/src/window.rs +++ b/crates/gpui3/src/window.rs @@ -192,14 +192,14 @@ impl<'a, 'w> WindowContext<'a, 'w> { let raster_bounds = self.text_system().raster_bounds(¶ms)?; if !raster_bounds.is_zero() { let layer_id = self.current_layer_id(); - let bounds = Bounds { - origin: glyph_origin.map(|px| px.floor()) + raster_bounds.origin.map(Into::into), - size: raster_bounds.size.map(Into::into), - }; let tile = self .window .glyph_atlas .get_or_insert_with(¶ms, &mut || self.text_system().rasterize_glyph(¶ms))?; + let bounds = Bounds { + origin: glyph_origin.map(|px| px.floor()) + raster_bounds.origin.map(Into::into), + size: tile.bounds.size.map(Into::into), + }; self.window.scene.insert( layer_id, diff --git a/crates/storybook/src/workspace.rs b/crates/storybook/src/workspace.rs index 64181b2bd7..c284ba1bca 100644 --- a/crates/storybook/src/workspace.rs +++ b/crates/storybook/src/workspace.rs @@ -26,7 +26,7 @@ impl WorkspaceElement { .font("Helvetica") .text_base() .text_color(black()) - .child("Hey"); + .child("The quick brown fox ran over the lazy dog."); // div() // .size_full() diff --git a/crates/storybook2/src/workspace.rs b/crates/storybook2/src/workspace.rs index f66f4832e8..cd13b19a8a 100644 --- a/crates/storybook2/src/workspace.rs +++ b/crates/storybook2/src/workspace.rs @@ -33,14 +33,11 @@ impl Workspace { .text_base() .fill(white()) .text_color(black()) - .child("Hey") + .child("The quick brown fox ran over the lazy dog.") // TODO: Implement style. //.size_full().fill(gpui3::hsla(0.83, 1., 0.5, 1.)) - // TODO: Debug font not font. - //.child("Is this thing on?") - // themed(rose_pine_dawn(), cx, |cx| { // div() // .size_full()