blob: 5a17ce5431cfb2c12195c1dbf76d956ff322867d [file]
// Copyright 2026 the Vello Authors
// SPDX-License-Identifier: Apache-2.0 OR MIT
//! Persistent renderer resources shared across frames.
#[cfg(feature = "text")]
use crate::text::GlyphAtlasResources;
#[cfg(feature = "text")]
use glifo::GlyphPrepCache;
use vello_common::image_cache::ImageCache;
use vello_common::multi_atlas::AtlasConfig;
/// Persistent resources required by Vello Hybrid for rendering.
#[derive(Debug)]
pub struct Resources {
pub(crate) image_cache: ImageCache,
#[cfg(feature = "text")]
pub(crate) glyph_prep_cache: GlyphPrepCache,
#[cfg(feature = "text")]
pub(crate) glyph_resources: Option<GlyphAtlasResources>,
}
impl Resources {
/// Create a new set of renderer resources.
pub fn new() -> Self {
Self {
image_cache: ImageCache::new_with_config(AtlasConfig::default()),
#[cfg(feature = "text")]
glyph_prep_cache: GlyphPrepCache::default(),
// Will be initialized lazily.
#[cfg(feature = "text")]
glyph_resources: None,
}
}
}
impl Default for Resources {
fn default() -> Self {
Self::new()
}
}