Checkpoint: Glyphs rendering how I'd like
This commit is contained in:
parent
550d9a9f71
commit
c57e19c8fa
6 changed files with 8 additions and 14 deletions
|
@ -147,10 +147,10 @@ impl Atlas {
|
||||||
bounds.size().y() as u64,
|
bounds.size().y() as u64,
|
||||||
);
|
);
|
||||||
self.texture.replace_region(
|
self.texture.replace_region(
|
||||||
dbg!(region),
|
region,
|
||||||
0,
|
0,
|
||||||
bytes.as_ptr() as *const _,
|
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,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -633,7 +633,6 @@ impl Renderer {
|
||||||
// Snap sprite to pixel grid.
|
// Snap sprite to pixel grid.
|
||||||
let origin = (glyph.origin * scale_factor).floor() + sprite.offset.to_f32();
|
let origin = (glyph.origin * scale_factor).floor() + sprite.offset.to_f32();
|
||||||
|
|
||||||
dbg!(origin);
|
|
||||||
sprites_by_atlas
|
sprites_by_atlas
|
||||||
.entry(sprite.atlas_id)
|
.entry(sprite.atlas_id)
|
||||||
.or_insert_with(Vec::new)
|
.or_insert_with(Vec::new)
|
||||||
|
|
|
@ -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.
|
const INSTANCE_BUFFER_SIZE: usize = 8192 * 1024; // This is an arbitrary decision. There's probably a more optimal value.
|
||||||
|
|
||||||
pub struct MetalRenderer {
|
pub struct MetalRenderer {
|
||||||
device: metal::Device,
|
|
||||||
layer: metal::MetalLayer,
|
layer: metal::MetalLayer,
|
||||||
command_queue: CommandQueue,
|
command_queue: CommandQueue,
|
||||||
quads_pipeline_state: metal::RenderPipelineState,
|
quads_pipeline_state: metal::RenderPipelineState,
|
||||||
|
@ -145,7 +144,6 @@ impl MetalRenderer {
|
||||||
));
|
));
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
device,
|
|
||||||
layer,
|
layer,
|
||||||
command_queue,
|
command_queue,
|
||||||
quads_pipeline_state,
|
quads_pipeline_state,
|
||||||
|
|
|
@ -192,14 +192,14 @@ impl<'a, 'w> WindowContext<'a, 'w> {
|
||||||
let raster_bounds = self.text_system().raster_bounds(¶ms)?;
|
let raster_bounds = self.text_system().raster_bounds(¶ms)?;
|
||||||
if !raster_bounds.is_zero() {
|
if !raster_bounds.is_zero() {
|
||||||
let layer_id = self.current_layer_id();
|
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
|
let tile = self
|
||||||
.window
|
.window
|
||||||
.glyph_atlas
|
.glyph_atlas
|
||||||
.get_or_insert_with(¶ms, &mut || self.text_system().rasterize_glyph(¶ms))?;
|
.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(
|
self.window.scene.insert(
|
||||||
layer_id,
|
layer_id,
|
||||||
|
|
|
@ -26,7 +26,7 @@ impl WorkspaceElement {
|
||||||
.font("Helvetica")
|
.font("Helvetica")
|
||||||
.text_base()
|
.text_base()
|
||||||
.text_color(black())
|
.text_color(black())
|
||||||
.child("Hey");
|
.child("The quick brown fox ran over the lazy dog.");
|
||||||
|
|
||||||
// div()
|
// div()
|
||||||
// .size_full()
|
// .size_full()
|
||||||
|
|
|
@ -33,14 +33,11 @@ impl Workspace {
|
||||||
.text_base()
|
.text_base()
|
||||||
.fill(white())
|
.fill(white())
|
||||||
.text_color(black())
|
.text_color(black())
|
||||||
.child("Hey")
|
.child("The quick brown fox ran over the lazy dog.")
|
||||||
|
|
||||||
// TODO: Implement style.
|
// TODO: Implement style.
|
||||||
//.size_full().fill(gpui3::hsla(0.83, 1., 0.5, 1.))
|
//.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| {
|
// themed(rose_pine_dawn(), cx, |cx| {
|
||||||
// div()
|
// div()
|
||||||
// .size_full()
|
// .size_full()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue