Compare commits
5 commits
5e16f105e0
...
4444857c7f
| Author | SHA1 | Date | |
|---|---|---|---|
| 4444857c7f | |||
|
|
2e9ec6ec42 | ||
|
|
e429a025df | ||
|
|
1d68895e9c | ||
|
|
3836ca7a17 |
6 changed files with 16 additions and 22 deletions
|
|
@ -8,9 +8,9 @@ repository = "https://github.com/iced-rs/cryoglyph"
|
||||||
license = "MIT OR Apache-2.0 OR Zlib"
|
license = "MIT OR Apache-2.0 OR Zlib"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
wgpu = { version = "27", default-features = false, features = ["wgsl"] }
|
wgpu = { version = "28", default-features = false, features = ["wgsl"] }
|
||||||
etagere = "0.2"
|
etagere = "0.2"
|
||||||
cosmic-text = "0.16"
|
cosmic-text = { path = "../cosmic-text" }
|
||||||
lru = { version = "0.16", default-features = false }
|
lru = { version = "0.16", default-features = false }
|
||||||
rustc-hash = "2"
|
rustc-hash = "2"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -73,8 +73,8 @@ fn run_bench(ctx: &mut Criterion) {
|
||||||
.copied()
|
.copied()
|
||||||
.map(|s| {
|
.map(|s| {
|
||||||
let mut text_buffer = Buffer::new(&mut font_system, Metrics::relative(1.0, 10.0));
|
let mut text_buffer = Buffer::new(&mut font_system, Metrics::relative(1.0, 10.0));
|
||||||
text_buffer.set_size(&mut font_system, Some(20.0), None);
|
text_buffer.set_size(Some(20.0), None);
|
||||||
text_buffer.set_text(&mut font_system, s, &attrs, shaping, None);
|
text_buffer.set_text(s, &attrs, shaping, None);
|
||||||
text_buffer.shape_until_scroll(&mut font_system, false);
|
text_buffer.shape_until_scroll(&mut font_system, false);
|
||||||
text_buffer
|
text_buffer
|
||||||
})
|
})
|
||||||
|
|
@ -85,7 +85,7 @@ fn run_bench(ctx: &mut Criterion) {
|
||||||
let text_areas: Vec<TextArea> = buffers
|
let text_areas: Vec<TextArea> = buffers
|
||||||
.iter()
|
.iter()
|
||||||
.map(|b| TextArea {
|
.map(|b| TextArea {
|
||||||
buffer: b,
|
text: b.layout_runs(),
|
||||||
left: 0.0,
|
left: 0.0,
|
||||||
top: 0.0,
|
top: 0.0,
|
||||||
scale: 1.0,
|
scale: 1.0,
|
||||||
|
|
|
||||||
|
|
@ -82,12 +82,8 @@ impl WindowState {
|
||||||
let physical_width = (physical_size.width as f64 * scale_factor) as f32;
|
let physical_width = (physical_size.width as f64 * scale_factor) as f32;
|
||||||
let physical_height = (physical_size.height as f64 * scale_factor) as f32;
|
let physical_height = (physical_size.height as f64 * scale_factor) as f32;
|
||||||
|
|
||||||
text_buffer.set_size(
|
text_buffer.set_size(Some(physical_width), Some(physical_height));
|
||||||
&mut font_system,
|
text_buffer.set_text("Hello world! 👋\nThis is rendered with 🦅 glyphon 🦁\nThe text below should be partially clipped.\na b c d e f g h i j k l m n o p q r s t u v w x y z", &Attrs::new().family(Family::SansSerif), Shaping::Advanced, None);
|
||||||
Some(physical_width),
|
|
||||||
Some(physical_height),
|
|
||||||
);
|
|
||||||
text_buffer.set_text(&mut font_system, "Hello world! 👋\nThis is rendered with 🦅 glyphon 🦁\nThe text below should be partially clipped.\na b c d e f g h i j k l m n o p q r s t u v w x y z", &Attrs::new().family(Family::SansSerif), Shaping::Advanced, None);
|
|
||||||
text_buffer.shape_until_scroll(&mut font_system, false);
|
text_buffer.shape_until_scroll(&mut font_system, false);
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
|
|
@ -179,7 +175,7 @@ impl winit::application::ApplicationHandler for Application {
|
||||||
atlas,
|
atlas,
|
||||||
viewport,
|
viewport,
|
||||||
[TextArea {
|
[TextArea {
|
||||||
buffer: text_buffer,
|
text: text_buffer.layout_runs(),
|
||||||
left: 10.0,
|
left: 10.0,
|
||||||
top: 10.0,
|
top: 10.0,
|
||||||
scale: 1.0,
|
scale: 1.0,
|
||||||
|
|
@ -213,6 +209,7 @@ impl winit::application::ApplicationHandler for Application {
|
||||||
depth_stencil_attachment: None,
|
depth_stencil_attachment: None,
|
||||||
timestamp_writes: None,
|
timestamp_writes: None,
|
||||||
occlusion_query_set: None,
|
occlusion_query_set: None,
|
||||||
|
multiview_mask: None,
|
||||||
});
|
});
|
||||||
|
|
||||||
text_renderer.render(&atlas, &viewport, &mut pass).unwrap();
|
text_renderer.render(&atlas, &viewport, &mut pass).unwrap();
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,7 @@ impl Cache {
|
||||||
label: Some("glyphon sampler"),
|
label: Some("glyphon sampler"),
|
||||||
min_filter: FilterMode::Nearest,
|
min_filter: FilterMode::Nearest,
|
||||||
mag_filter: FilterMode::Nearest,
|
mag_filter: FilterMode::Nearest,
|
||||||
mipmap_filter: FilterMode::Nearest,
|
mipmap_filter: wgpu::MipmapFilterMode::Nearest,
|
||||||
lod_min_clamp: 0f32,
|
lod_min_clamp: 0f32,
|
||||||
lod_max_clamp: 0f32,
|
lod_max_clamp: 0f32,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
|
|
@ -139,7 +139,7 @@ impl Cache {
|
||||||
let pipeline_layout = device.create_pipeline_layout(&PipelineLayoutDescriptor {
|
let pipeline_layout = device.create_pipeline_layout(&PipelineLayoutDescriptor {
|
||||||
label: None,
|
label: None,
|
||||||
bind_group_layouts: &[&atlas_layout, &uniforms_layout],
|
bind_group_layouts: &[&atlas_layout, &uniforms_layout],
|
||||||
push_constant_ranges: &[],
|
immediate_size: 0,
|
||||||
});
|
});
|
||||||
|
|
||||||
Self(Arc::new(Inner {
|
Self(Arc::new(Inner {
|
||||||
|
|
@ -237,7 +237,7 @@ impl Cache {
|
||||||
},
|
},
|
||||||
depth_stencil: depth_stencil.clone(),
|
depth_stencil: depth_stencil.clone(),
|
||||||
multisample,
|
multisample,
|
||||||
multiview: None,
|
multiview_mask: None,
|
||||||
cache: None,
|
cache: None,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -102,10 +102,9 @@ impl Default for TextBounds {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A text area containing text to be rendered along with its overflow behavior.
|
/// A text area containing text to be rendered along with its overflow behavior.
|
||||||
#[derive(Clone)]
|
|
||||||
pub struct TextArea<'a> {
|
pub struct TextArea<'a> {
|
||||||
/// The buffer containing the text to be rendered.
|
/// The buffer containing the text to be rendered.
|
||||||
pub buffer: &'a Buffer,
|
pub text: LayoutRunIter<'a>,
|
||||||
/// The left edge of the buffer.
|
/// The left edge of the buffer.
|
||||||
pub left: f32,
|
pub left: f32,
|
||||||
/// The top edge of the buffer.
|
/// The top edge of the buffer.
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,7 @@ impl TextRenderer {
|
||||||
let pipeline = atlas.get_or_create_pipeline(device, multisample, depth_stencil);
|
let pipeline = atlas.get_or_create_pipeline(device, multisample, depth_stencil);
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
staging_belt: StagingBelt::new(vertex_buffer_size),
|
staging_belt: StagingBelt::new(device.clone(), vertex_buffer_size),
|
||||||
vertex_buffer,
|
vertex_buffer,
|
||||||
vertex_buffer_size,
|
vertex_buffer_size,
|
||||||
pipeline,
|
pipeline,
|
||||||
|
|
@ -81,8 +81,7 @@ impl TextRenderer {
|
||||||
};
|
};
|
||||||
|
|
||||||
let layout_runs = text_area
|
let layout_runs = text_area
|
||||||
.buffer
|
.text
|
||||||
.layout_runs()
|
|
||||||
.skip_while(|run| !is_run_visible(run))
|
.skip_while(|run| !is_run_visible(run))
|
||||||
.take_while(is_run_visible);
|
.take_while(is_run_visible);
|
||||||
|
|
||||||
|
|
@ -295,7 +294,6 @@ impl TextRenderer {
|
||||||
&self.vertex_buffer,
|
&self.vertex_buffer,
|
||||||
0,
|
0,
|
||||||
NonZeroU64::new(vertices_raw.len() as u64).expect("Non-empty vertices"),
|
NonZeroU64::new(vertices_raw.len() as u64).expect("Non-empty vertices"),
|
||||||
device,
|
|
||||||
)
|
)
|
||||||
.copy_from_slice(vertices_raw);
|
.copy_from_slice(vertices_raw);
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -312,7 +310,7 @@ impl TextRenderer {
|
||||||
self.vertex_buffer_size = buffer_size;
|
self.vertex_buffer_size = buffer_size;
|
||||||
|
|
||||||
self.staging_belt.finish();
|
self.staging_belt.finish();
|
||||||
self.staging_belt = StagingBelt::new(buffer_size);
|
self.staging_belt = StagingBelt::new(device.clone(), buffer_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
self.staging_belt.finish();
|
self.staging_belt.finish();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue