From f4b6e6a241eb801d6ad98f8b6c6cc8046568dbf2 Mon Sep 17 00:00:00 2001 From: Nico Burns Date: Sat, 3 Oct 2026 21:13:47 +0000 Subject: [PATCH 1/2] Add opt-in glyph caching to vello_cpu and vello_hybrid backends Adds a `glyph_caching` cargo feature (sets the default) and runtime setters to enable Vello's experimental glyph atlas cache. Runs with a skewed, rotated, mirrored or non-uniformly scaled transform always bypass the cache: glifo 0.4 only validates the transform when inserting into the atlas, not when looking up, so such runs would otherwise be drawn from upright cache entries. --- crates/anyrender_vello_cpu/CHANGELOG.md | 8 ++ crates/anyrender_vello_cpu/Cargo.toml | 3 + .../anyrender_vello_cpu/src/image_renderer.rs | 9 +++ crates/anyrender_vello_cpu/src/scene.rs | 25 ++++++ .../tests/glyph_caching.rs | 81 +++++++++++++++++++ crates/anyrender_vello_hybrid/CHANGELOG.md | 8 ++ crates/anyrender_vello_hybrid/Cargo.toml | 3 + crates/anyrender_vello_hybrid/src/lib.rs | 3 + crates/anyrender_vello_hybrid/src/scene.rs | 26 ++++++ .../anyrender_vello_hybrid/src/webgl_scene.rs | 16 ++++ .../src/window_renderer.rs | 20 +++++ 11 files changed, 202 insertions(+) create mode 100644 crates/anyrender_vello_cpu/tests/glyph_caching.rs diff --git a/crates/anyrender_vello_cpu/CHANGELOG.md b/crates/anyrender_vello_cpu/CHANGELOG.md index 8f5819a..5e582dd 100644 --- a/crates/anyrender_vello_cpu/CHANGELOG.md +++ b/crates/anyrender_vello_cpu/CHANGELOG.md @@ -5,6 +5,14 @@ All notable changes to this crate are documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [Unreleased] + +### Added + +- Opt-in support for Vello's (experimental) glyph atlas cache, via the `glyph_caching` + cargo feature (which sets the default) and at runtime via + `VelloCpuScenePainter::set_glyph_caching` / `VelloCpuImageRenderer::set_glyph_caching`. + ## [0.18.0] - 2026-10-03 ### Changed diff --git a/crates/anyrender_vello_cpu/Cargo.toml b/crates/anyrender_vello_cpu/Cargo.toml index 8ef7b40..85bc8ac 100644 --- a/crates/anyrender_vello_cpu/Cargo.toml +++ b/crates/anyrender_vello_cpu/Cargo.toml @@ -18,6 +18,9 @@ log_frame_times = [ "pixels_window_renderer?/log_frame_times", ] filters = [] +# Cache rasterized glyphs in Vello's (experimental) glyph atlas by default. +# Can be overridden at runtime (see `VelloCpuImageRenderer::set_glyph_caching`). +glyph_caching = [] [dependencies] anyrender = { workspace = true } diff --git a/crates/anyrender_vello_cpu/src/image_renderer.rs b/crates/anyrender_vello_cpu/src/image_renderer.rs index 619d5d4..fcaee83 100644 --- a/crates/anyrender_vello_cpu/src/image_renderer.rs +++ b/crates/anyrender_vello_cpu/src/image_renderer.rs @@ -19,6 +19,15 @@ impl VelloCpuImageRenderer { } } + /// Enable or disable caching of rasterized glyphs in Vello's glyph atlas. + /// + /// Defaults to `false` unless the `glyph_caching` cargo feature is enabled. + /// + /// Note: Vello considers atlas-backed glyph caching experimental. + pub fn set_glyph_caching(&mut self, enabled: bool) { + self.scene.set_glyph_caching(enabled); + } + /// Drop all cached image conversions. pub fn clear_image_cache(&mut self) { self.scene.clear_image_cache(); diff --git a/crates/anyrender_vello_cpu/src/scene.rs b/crates/anyrender_vello_cpu/src/scene.rs index 58de81c..d355463 100644 --- a/crates/anyrender_vello_cpu/src/scene.rs +++ b/crates/anyrender_vello_cpu/src/scene.rs @@ -10,6 +10,16 @@ use crate::image_cache::{ImageCache, ImageCacheConfig}; const DEFAULT_TOLERANCE: f64 = 0.1; +/// Whether a glyph run drawn with the given transforms can use Vello's glyph atlas cache. +/// +/// Vello only supports caching glyphs that are drawn upright with a uniform scale. It checks +/// this itself when inserting a glyph into the atlas, but not when looking one up, so a skewed +/// (e.g. synthetic italic) or rotated run would otherwise be drawn using upright cached glyphs. +fn supports_glyph_caching(transform: Affine, glyph_transform: Option) -> bool { + let [a, b, c, d, _, _] = (transform * glyph_transform.unwrap_or_default()).as_coeffs(); + b == 0.0 && c == 0.0 && a == d && a > 0.0 +} + enum LayerKind { Layer, Clip, @@ -20,6 +30,7 @@ pub struct VelloCpuScenePainter { pub(crate) resources: vello_cpu::Resources, pub(crate) image_cache: ImageCache, layer_stack: Vec, + glyph_caching: bool, } impl VelloCpuScenePainter { @@ -33,9 +44,19 @@ impl VelloCpuScenePainter { resources: vello_cpu::Resources::new(), image_cache: ImageCache::new(config), layer_stack: Vec::new(), + glyph_caching: cfg!(feature = "glyph_caching"), } } + /// Enable or disable caching of rasterized glyphs in Vello's glyph atlas. + /// + /// Defaults to `false` unless the `glyph_caching` cargo feature is enabled. + /// + /// Note: Vello considers atlas-backed glyph caching experimental. + pub fn set_glyph_caching(&mut self, enabled: bool) { + self.glyph_caching = enabled; + } + fn convert_paint(&mut self, paint: PaintRef<'_>) -> PaintType { match paint { Paint::Solid(alpha_color) => PaintType::Solid(alpha_color), @@ -196,6 +217,8 @@ impl PaintScene for VelloCpuScenePainter { let paint = self.convert_paint(paint.into()); self.render_ctx.set_paint(paint); + let glyph_caching = + self.glyph_caching && supports_glyph_caching(transform, glyph_transform); let style: StyleRef<'a> = style.into(); match style { StyleRef::Fill(fill) => { @@ -203,6 +226,7 @@ impl PaintScene for VelloCpuScenePainter { let _ = self .render_ctx .glyph_run(&mut self.resources, font) + .atlas_cache(glyph_caching) .font_size(font_size) .hint(hint) .normalized_coords(normalized_coords) @@ -219,6 +243,7 @@ impl PaintScene for VelloCpuScenePainter { let _ = self .render_ctx .glyph_run(&mut self.resources, font) + .atlas_cache(glyph_caching) .font_size(font_size) .hint(hint) .normalized_coords(normalized_coords) diff --git a/crates/anyrender_vello_cpu/tests/glyph_caching.rs b/crates/anyrender_vello_cpu/tests/glyph_caching.rs new file mode 100644 index 0000000..4444310 --- /dev/null +++ b/crates/anyrender_vello_cpu/tests/glyph_caching.rs @@ -0,0 +1,81 @@ +use std::sync::Arc; + +use anyrender::{Glyph, ImageRenderer, PaintScene}; +use anyrender_vello_cpu::VelloCpuImageRenderer; +use kurbo::Affine; +use peniko::{Blob, Color, Fill, FontData}; + +const W: u32 = 400; +const H: u32 = 160; + +fn render(glyph_caching: bool, font: &FontData) -> Vec { + let mut renderer = VelloCpuImageRenderer::new(W, H); + renderer.set_glyph_caching(glyph_caching); + let mut buf = vec![0; (W * H * 4) as usize]; + let skew = Affine::skew(-0.5, 0.0); + // Render twice so that the second frame can be served from the atlas. + for _ in 0..2 { + renderer.reset(); + renderer.render( + |scene| { + // Upright in the top half, skewed in the bottom half. + for (y, glyph_transform) in [(60.0, None), (140.0, Some(skew))] { + scene.draw_glyphs( + font, + 40.0, + true, + &[], + Default::default(), + Fill::NonZero, + Color::WHITE, + 1.0, + Affine::translate((20.0, y)), + glyph_transform, + (0..8).map(|i| Glyph { + id: 40 + i, + x: i as f32 * 40.0, + y: 0.0, + }), + ); + } + }, + &mut buf, + ); + } + buf +} + +fn pixels(buf: &[u8]) -> &[[u8; 4]] { + buf.as_chunks().0 +} + +fn differing(a: &[u8], b: &[u8]) -> usize { + pixels(a) + .iter() + .zip(pixels(b)) + .filter(|(a, b)| a.iter().zip(*b).any(|(a, b)| a.abs_diff(*b) > 64)) + .count() +} + +/// Vello's glyph cache key doesn't include skew/rotation, so runs it can't cache must bypass it. +#[test] +fn skewed_glyphs_are_not_drawn_from_upright_cache_entries() { + static ROBOTO: &[u8] = include_bytes!("../../../assets/fonts/roboto/Roboto.ttf"); + let font = FontData::new(Blob::new(Arc::new(ROBOTO)), 0); + let off = render(false, &font); + let on = render(true, &font); + let (upright_off, skewed_off) = off.split_at(off.len() / 2); + let (upright_on, skewed_on) = on.split_at(on.len() / 2); + + let ink = |buf: &[u8]| { + buf.as_chunks::<4>() + .0 + .iter() + .filter(|px| px[3] > 128) + .count() + }; + assert!(ink(upright_off) > 500 && ink(skewed_off) > 500); + + assert_eq!(differing(upright_off, upright_on), 0); + assert_eq!(differing(skewed_off, skewed_on), 0); +} diff --git a/crates/anyrender_vello_hybrid/CHANGELOG.md b/crates/anyrender_vello_hybrid/CHANGELOG.md index 51ccfe9..6f21fcb 100644 --- a/crates/anyrender_vello_hybrid/CHANGELOG.md +++ b/crates/anyrender_vello_hybrid/CHANGELOG.md @@ -5,6 +5,14 @@ All notable changes to this crate are documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [Unreleased] + +### Added + +- Opt-in support for Vello's (experimental) glyph atlas cache, via the `glyph_caching` + cargo feature (which sets the default) and at runtime via + `VelloHybridRendererOptions::glyph_caching` / `VelloHybridScenePainter::with_glyph_caching` / `WebGlScenePainter::with_glyph_caching`. + ## [0.11.0] - 2026-10-03 ### Added diff --git a/crates/anyrender_vello_hybrid/Cargo.toml b/crates/anyrender_vello_hybrid/Cargo.toml index 495935c..58c2f77 100644 --- a/crates/anyrender_vello_hybrid/Cargo.toml +++ b/crates/anyrender_vello_hybrid/Cargo.toml @@ -11,6 +11,9 @@ edition.workspace = true [features] log_frame_times = ["debug_timer/enable"] webgl = ["vello_gpu/webgl"] +# Cache rasterized glyphs in Vello's (experimental) glyph atlas by default. +# Can be overridden at runtime (see `VelloHybridRendererOptions::glyph_caching`). +glyph_caching = [] [dependencies] anyrender = { workspace = true } diff --git a/crates/anyrender_vello_hybrid/src/lib.rs b/crates/anyrender_vello_hybrid/src/lib.rs index 20bbffb..28d544f 100644 --- a/crates/anyrender_vello_hybrid/src/lib.rs +++ b/crates/anyrender_vello_hybrid/src/lib.rs @@ -14,3 +14,6 @@ pub use webgl_scene::*; pub use window_renderer::*; pub use wgpu; + +/// Whether glyph caching is enabled when it is not explicitly configured. +pub(crate) const DEFAULT_GLYPH_CACHING: bool = cfg!(feature = "glyph_caching"); diff --git a/crates/anyrender_vello_hybrid/src/scene.rs b/crates/anyrender_vello_hybrid/src/scene.rs index df7784a..eec4bc7 100644 --- a/crates/anyrender_vello_hybrid/src/scene.rs +++ b/crates/anyrender_vello_hybrid/src/scene.rs @@ -16,6 +16,16 @@ use wgpu_context::DeviceHandle; const DEFAULT_TOLERANCE: f64 = 0.1; +/// Whether a glyph run drawn with the given transforms can use Vello's glyph atlas cache. +/// +/// Vello only supports caching glyphs that are drawn upright with a uniform scale. It checks +/// this itself when inserting a glyph into the atlas, but not when looking one up, so a skewed +/// (e.g. synthetic italic) or rotated run would otherwise be drawn using upright cached glyphs. +pub(crate) fn supports_glyph_caching(transform: Affine, glyph_transform: Option) -> bool { + let [a, b, c, d, _, _] = (transform * glyph_transform.unwrap_or_default()).as_coeffs(); + b == 0.0 && c == 0.0 && a == d && a > 0.0 +} + fn anyrender_paint_to_vello_hybrid_paint<'a>( paint: PaintRef<'a>, image_manager: &mut ImageManager<'_>, @@ -131,6 +141,7 @@ pub struct VelloHybridScenePainter<'s> { pub(crate) image_manager: ImageManager<'s>, pub(crate) texture_bindings: &'s mut FxHashMap, pub(crate) device_handle: &'s DeviceHandle, + pub(crate) glyph_caching: bool, } impl VelloHybridScenePainter<'_> { @@ -146,9 +157,20 @@ impl VelloHybridScenePainter<'_> { image_manager, texture_bindings, device_handle, + glyph_caching: crate::DEFAULT_GLYPH_CACHING, } } + /// Enable or disable caching of rasterized glyphs in Vello's glyph atlas. + /// + /// Defaults to `false` unless the `glyph_caching` cargo feature is enabled. + /// + /// Note: Vello considers atlas-backed glyph caching experimental. + pub fn with_glyph_caching(mut self, enabled: bool) -> Self { + self.glyph_caching = enabled; + self + } + fn convert_paint(&mut self, paint: PaintRef<'_>) -> PaintType { anyrender_paint_to_vello_hybrid_paint(paint, &mut self.image_manager, self.texture_bindings) } @@ -301,6 +323,8 @@ impl PaintScene for VelloHybridScenePainter<'_> { self.scene.reset_paint_transform(); self.scene.set_transform(transform); + let glyph_caching = + self.glyph_caching && supports_glyph_caching(transform, glyph_transform); let style: StyleRef<'a> = style.into(); match style { StyleRef::Fill(fill) => { @@ -308,6 +332,7 @@ impl PaintScene for VelloHybridScenePainter<'_> { let _ = self .scene .glyph_run(self.image_manager.resources, font) + .atlas_cache(glyph_caching) .font_size(font_size) .hint(hint) .normalized_coords(normalized_coords) @@ -324,6 +349,7 @@ impl PaintScene for VelloHybridScenePainter<'_> { let _ = self .scene .glyph_run(self.image_manager.resources, font) + .atlas_cache(glyph_caching) .font_size(font_size) .hint(hint) .normalized_coords(normalized_coords) diff --git a/crates/anyrender_vello_hybrid/src/webgl_scene.rs b/crates/anyrender_vello_hybrid/src/webgl_scene.rs index 8758dcf..0b78e38 100644 --- a/crates/anyrender_vello_hybrid/src/webgl_scene.rs +++ b/crates/anyrender_vello_hybrid/src/webgl_scene.rs @@ -62,6 +62,7 @@ pub struct WebGlScenePainter<'s> { scene: &'s mut vello_gpu::Scene, layer_stack: Vec, image_manager: WebGlImageManager<'s>, + glyph_caching: bool, } impl<'s> WebGlScenePainter<'s> { @@ -70,8 +71,19 @@ impl<'s> WebGlScenePainter<'s> { scene, layer_stack: Vec::with_capacity(16), image_manager, + glyph_caching: crate::DEFAULT_GLYPH_CACHING, } } + + /// Enable or disable caching of rasterized glyphs in Vello's glyph atlas. + /// + /// Defaults to `false` unless the `glyph_caching` cargo feature is enabled. + /// + /// Note: Vello considers atlas-backed glyph caching experimental. + pub fn with_glyph_caching(mut self, enabled: bool) -> Self { + self.glyph_caching = enabled; + self + } } impl WebGlScenePainter<'_> { @@ -212,6 +224,8 @@ impl PaintScene for WebGlScenePainter<'_> { self.scene.set_paint(paint); self.scene.set_transform(transform); + let glyph_caching = + self.glyph_caching && crate::scene::supports_glyph_caching(transform, glyph_transform); let style: StyleRef<'a> = style.into(); match style { StyleRef::Fill(fill) => { @@ -219,6 +233,7 @@ impl PaintScene for WebGlScenePainter<'_> { let _ = self .scene .glyph_run(self.image_manager.resources, font) + .atlas_cache(glyph_caching) .font_size(font_size) .hint(hint) .normalized_coords(normalized_coords) @@ -235,6 +250,7 @@ impl PaintScene for WebGlScenePainter<'_> { let _ = self .scene .glyph_run(self.image_manager.resources, font) + .atlas_cache(glyph_caching) .font_size(font_size) .hint(hint) .normalized_coords(normalized_coords) diff --git a/crates/anyrender_vello_hybrid/src/window_renderer.rs b/crates/anyrender_vello_hybrid/src/window_renderer.rs index cdfa1cd..23cf315 100644 --- a/crates/anyrender_vello_hybrid/src/window_renderer.rs +++ b/crates/anyrender_vello_hybrid/src/window_renderer.rs @@ -71,6 +71,12 @@ pub struct VelloHybridRendererOptions { /// lower values reduce memory usage and input latency at the cost of less /// buffering to absorb slow frames. pub desired_maximum_frame_latency: u32, + /// Whether to cache rasterized glyphs in Vello's glyph atlas. + /// + /// Defaults to `false` unless the `glyph_caching` cargo feature is enabled. + /// + /// Note: Vello considers atlas-backed glyph caching experimental. + pub glyph_caching: bool, } impl Default for VelloHybridRendererOptions { @@ -82,6 +88,7 @@ impl Default for VelloHybridRendererOptions { base_color: Color::WHITE, composite_alpha_mode: anyrender::CompositeAlphaMode::Auto, desired_maximum_frame_latency: 1, + glyph_caching: crate::DEFAULT_GLYPH_CACHING, } } } @@ -133,6 +140,18 @@ impl VelloHybridRendererOptions { ..self } } + + /// Enable or disable caching of rasterized glyphs in Vello's glyph atlas. + /// + /// Defaults to `false` unless the `glyph_caching` cargo feature is enabled. + /// + /// Note: Vello considers atlas-backed glyph caching experimental. + pub const fn glyph_caching(self, glyph_caching: bool) -> Self { + Self { + glyph_caching, + ..self + } + } } impl From for VelloHybridRendererOptions { @@ -498,6 +517,7 @@ impl WindowRenderer for VelloHybridWindowRenderer { image_manager, texture_bindings: &mut state.texture_bindings, device_handle: &render_surface.device_handle, + glyph_caching: self.config.glyph_caching, }; if self.config.base_color != Color::TRANSPARENT { scene_painter.fill( From a5bed242685b328c0cb7447cbb56e986fc7a1ea9 Mon Sep 17 00:00:00 2001 From: Nico Burns Date: Sat, 3 Oct 2026 22:09:48 +0000 Subject: [PATCH 2/2] Remove glyph_caching cargo feature (runtime flag only) --- crates/anyrender_vello_cpu/CHANGELOG.md | 3 +-- crates/anyrender_vello_cpu/Cargo.toml | 3 --- crates/anyrender_vello_cpu/src/image_renderer.rs | 2 +- crates/anyrender_vello_cpu/src/scene.rs | 4 ++-- crates/anyrender_vello_hybrid/CHANGELOG.md | 3 +-- crates/anyrender_vello_hybrid/Cargo.toml | 3 --- crates/anyrender_vello_hybrid/src/lib.rs | 3 --- crates/anyrender_vello_hybrid/src/scene.rs | 4 ++-- crates/anyrender_vello_hybrid/src/webgl_scene.rs | 4 ++-- crates/anyrender_vello_hybrid/src/window_renderer.rs | 6 +++--- 10 files changed, 12 insertions(+), 23 deletions(-) diff --git a/crates/anyrender_vello_cpu/CHANGELOG.md b/crates/anyrender_vello_cpu/CHANGELOG.md index 5e582dd..a4970a3 100644 --- a/crates/anyrender_vello_cpu/CHANGELOG.md +++ b/crates/anyrender_vello_cpu/CHANGELOG.md @@ -9,8 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added -- Opt-in support for Vello's (experimental) glyph atlas cache, via the `glyph_caching` - cargo feature (which sets the default) and at runtime via +- Opt-in support for Vello's (experimental) glyph atlas cache, enabled at runtime via `VelloCpuScenePainter::set_glyph_caching` / `VelloCpuImageRenderer::set_glyph_caching`. ## [0.18.0] - 2026-10-03 diff --git a/crates/anyrender_vello_cpu/Cargo.toml b/crates/anyrender_vello_cpu/Cargo.toml index 85bc8ac..8ef7b40 100644 --- a/crates/anyrender_vello_cpu/Cargo.toml +++ b/crates/anyrender_vello_cpu/Cargo.toml @@ -18,9 +18,6 @@ log_frame_times = [ "pixels_window_renderer?/log_frame_times", ] filters = [] -# Cache rasterized glyphs in Vello's (experimental) glyph atlas by default. -# Can be overridden at runtime (see `VelloCpuImageRenderer::set_glyph_caching`). -glyph_caching = [] [dependencies] anyrender = { workspace = true } diff --git a/crates/anyrender_vello_cpu/src/image_renderer.rs b/crates/anyrender_vello_cpu/src/image_renderer.rs index fcaee83..f331353 100644 --- a/crates/anyrender_vello_cpu/src/image_renderer.rs +++ b/crates/anyrender_vello_cpu/src/image_renderer.rs @@ -21,7 +21,7 @@ impl VelloCpuImageRenderer { /// Enable or disable caching of rasterized glyphs in Vello's glyph atlas. /// - /// Defaults to `false` unless the `glyph_caching` cargo feature is enabled. + /// Defaults to `false`. /// /// Note: Vello considers atlas-backed glyph caching experimental. pub fn set_glyph_caching(&mut self, enabled: bool) { diff --git a/crates/anyrender_vello_cpu/src/scene.rs b/crates/anyrender_vello_cpu/src/scene.rs index d355463..666344c 100644 --- a/crates/anyrender_vello_cpu/src/scene.rs +++ b/crates/anyrender_vello_cpu/src/scene.rs @@ -44,13 +44,13 @@ impl VelloCpuScenePainter { resources: vello_cpu::Resources::new(), image_cache: ImageCache::new(config), layer_stack: Vec::new(), - glyph_caching: cfg!(feature = "glyph_caching"), + glyph_caching: false, } } /// Enable or disable caching of rasterized glyphs in Vello's glyph atlas. /// - /// Defaults to `false` unless the `glyph_caching` cargo feature is enabled. + /// Defaults to `false`. /// /// Note: Vello considers atlas-backed glyph caching experimental. pub fn set_glyph_caching(&mut self, enabled: bool) { diff --git a/crates/anyrender_vello_hybrid/CHANGELOG.md b/crates/anyrender_vello_hybrid/CHANGELOG.md index 6f21fcb..795458e 100644 --- a/crates/anyrender_vello_hybrid/CHANGELOG.md +++ b/crates/anyrender_vello_hybrid/CHANGELOG.md @@ -9,8 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added -- Opt-in support for Vello's (experimental) glyph atlas cache, via the `glyph_caching` - cargo feature (which sets the default) and at runtime via +- Opt-in support for Vello's (experimental) glyph atlas cache, enabled at runtime via `VelloHybridRendererOptions::glyph_caching` / `VelloHybridScenePainter::with_glyph_caching` / `WebGlScenePainter::with_glyph_caching`. ## [0.11.0] - 2026-10-03 diff --git a/crates/anyrender_vello_hybrid/Cargo.toml b/crates/anyrender_vello_hybrid/Cargo.toml index 58c2f77..495935c 100644 --- a/crates/anyrender_vello_hybrid/Cargo.toml +++ b/crates/anyrender_vello_hybrid/Cargo.toml @@ -11,9 +11,6 @@ edition.workspace = true [features] log_frame_times = ["debug_timer/enable"] webgl = ["vello_gpu/webgl"] -# Cache rasterized glyphs in Vello's (experimental) glyph atlas by default. -# Can be overridden at runtime (see `VelloHybridRendererOptions::glyph_caching`). -glyph_caching = [] [dependencies] anyrender = { workspace = true } diff --git a/crates/anyrender_vello_hybrid/src/lib.rs b/crates/anyrender_vello_hybrid/src/lib.rs index 28d544f..20bbffb 100644 --- a/crates/anyrender_vello_hybrid/src/lib.rs +++ b/crates/anyrender_vello_hybrid/src/lib.rs @@ -14,6 +14,3 @@ pub use webgl_scene::*; pub use window_renderer::*; pub use wgpu; - -/// Whether glyph caching is enabled when it is not explicitly configured. -pub(crate) const DEFAULT_GLYPH_CACHING: bool = cfg!(feature = "glyph_caching"); diff --git a/crates/anyrender_vello_hybrid/src/scene.rs b/crates/anyrender_vello_hybrid/src/scene.rs index eec4bc7..850a038 100644 --- a/crates/anyrender_vello_hybrid/src/scene.rs +++ b/crates/anyrender_vello_hybrid/src/scene.rs @@ -157,13 +157,13 @@ impl VelloHybridScenePainter<'_> { image_manager, texture_bindings, device_handle, - glyph_caching: crate::DEFAULT_GLYPH_CACHING, + glyph_caching: false, } } /// Enable or disable caching of rasterized glyphs in Vello's glyph atlas. /// - /// Defaults to `false` unless the `glyph_caching` cargo feature is enabled. + /// Defaults to `false`. /// /// Note: Vello considers atlas-backed glyph caching experimental. pub fn with_glyph_caching(mut self, enabled: bool) -> Self { diff --git a/crates/anyrender_vello_hybrid/src/webgl_scene.rs b/crates/anyrender_vello_hybrid/src/webgl_scene.rs index 0b78e38..4be63ea 100644 --- a/crates/anyrender_vello_hybrid/src/webgl_scene.rs +++ b/crates/anyrender_vello_hybrid/src/webgl_scene.rs @@ -71,13 +71,13 @@ impl<'s> WebGlScenePainter<'s> { scene, layer_stack: Vec::with_capacity(16), image_manager, - glyph_caching: crate::DEFAULT_GLYPH_CACHING, + glyph_caching: false, } } /// Enable or disable caching of rasterized glyphs in Vello's glyph atlas. /// - /// Defaults to `false` unless the `glyph_caching` cargo feature is enabled. + /// Defaults to `false`. /// /// Note: Vello considers atlas-backed glyph caching experimental. pub fn with_glyph_caching(mut self, enabled: bool) -> Self { diff --git a/crates/anyrender_vello_hybrid/src/window_renderer.rs b/crates/anyrender_vello_hybrid/src/window_renderer.rs index 23cf315..89d63ba 100644 --- a/crates/anyrender_vello_hybrid/src/window_renderer.rs +++ b/crates/anyrender_vello_hybrid/src/window_renderer.rs @@ -73,7 +73,7 @@ pub struct VelloHybridRendererOptions { pub desired_maximum_frame_latency: u32, /// Whether to cache rasterized glyphs in Vello's glyph atlas. /// - /// Defaults to `false` unless the `glyph_caching` cargo feature is enabled. + /// Defaults to `false`. /// /// Note: Vello considers atlas-backed glyph caching experimental. pub glyph_caching: bool, @@ -88,7 +88,7 @@ impl Default for VelloHybridRendererOptions { base_color: Color::WHITE, composite_alpha_mode: anyrender::CompositeAlphaMode::Auto, desired_maximum_frame_latency: 1, - glyph_caching: crate::DEFAULT_GLYPH_CACHING, + glyph_caching: false, } } } @@ -143,7 +143,7 @@ impl VelloHybridRendererOptions { /// Enable or disable caching of rasterized glyphs in Vello's glyph atlas. /// - /// Defaults to `false` unless the `glyph_caching` cargo feature is enabled. + /// Defaults to `false`. /// /// Note: Vello considers atlas-backed glyph caching experimental. pub const fn glyph_caching(self, glyph_caching: bool) -> Self {