Merge craft/vello-flush

This commit is contained in:
aiongg committed 2026-10-21 06:54:30 +00:00
commit d30fd0ee54
3 files changed
+44 -2

No files matched your search

+22
View File
@@ -3412,6 +3412,15 @@ dependencies = [
"libredox",
]
[[package]]
name = "ordered-channel"
version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "95be4d57809897b5a7539fc15a7dfe0e84141bc3dfaa2e9b1b27caa90acf61ab"
dependencies = [
"crossbeam-channel",
]
[[package]]
name = "ordered-float"
version = "5.5.0"
@@ -4889,6 +4898,15 @@ dependencies = [
"syn 3.0.5",
]
[[package]]
name = "thread_local"
version = "1.1.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1ad99c4c6d32803332c548b1af0540b357b3f5fc0be8f6c6bfe8b2e6ae784070"
dependencies = [
"cfg-if",
]
[[package]]
name = "tiff"
version = "0.11.3"
@@ -5347,9 +5365,13 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ace506ca414548966fcf3c283be94eb1cad8254de488791ee698bf438b0890a9"
dependencies = [
"bytemuck",
"crossbeam-channel",
"glifo",
"hashbrown 0.17.1",
"ordered-channel",
"png 0.18.1",
"rayon",
"thread_local",
"vello_common",
]
+4
View File
@@ -118,6 +118,10 @@ criterion.workspace = true
mimalloc.workspace = true
similar-asserts.workspace = true
# Runs the glyph rasterizer through vello_cpu's multi-threaded dispatcher, which apps can turn on.
[target.'cfg(not(target_arch = "wasm32"))'.dev-dependencies]
vello_cpu = { workspace = true, features = ["multithreading"] }
[[bench]]
name = "benchmark"
+18 -2
View File
@@ -178,7 +178,7 @@ impl FontCell {
return None;
}
let mut ctx = vello_cpu::RenderContext::new(width, height);
let mut ctx = glyph_render_context(width, height);
ctx.set_transform(kurbo::Affine::translate((-bounds.x0, -bounds.y0)));
ctx.set_paint(color::OpaqueColor::<color::Srgb>::WHITE);
ctx.fill_path(&path);
@@ -251,7 +251,7 @@ impl FontCell {
);
let coords: Vec<i16> = location.coords().iter().map(|c| c.to_bits()).collect();
let mut ctx = vello_cpu::RenderContext::new(canvas_size, canvas_size);
let mut ctx = glyph_render_context(canvas_size, canvas_size);
let mut resources = vello_cpu::Resources::new();
ctx.set_paint(color::OpaqueColor::<color::Srgb>::WHITE);
ctx.glyph_run(&mut resources, &font)
@@ -767,3 +767,19 @@ pub(crate) struct ShapedCluster<'a> {
/// See [`ShapedGlyph::is_cjk`].
pub is_cjk: bool,
}
/// A single-threaded vello context for one glyph.
///
/// `RenderContext::new` uses worker threads when another crate in the build turns on `vello_cpu`'s
/// `multithreading` feature: that builds a thread pool per glyph and panics in `render` without a
/// `flush` first.
fn glyph_render_context(width: u16, height: u16) -> vello_cpu::RenderContext {
vello_cpu::RenderContext::new_with(
width,
height,
vello_cpu::RenderSettings {
num_threads: 0,
..Default::default()
},
)
}