euv-core 0.47.1

Core cross-platform runtime for euv featuring arena-based fine-grained reactivity, deterministic layout, flat scene graph, multi-mode rendering, and direct OS platform adapters.
Documentation
use super::*;

/// Fast 128-entry ASCII glyph slot lookup table bound to one quantized style signature.
#[derive(Clone, Debug)]
pub(crate) struct AsciiGlyphStyleTable {
    /// Packed `(size_tenths | bold<<16 | monospace<<17 | italic<<18)` style signature.
    pub(crate) style_sig: u32,
    /// Direct slot indices into `GlyphAtlas::entries` for ASCII codepoints `0..128` (`u32::MAX` when uncached).
    pub(crate) slots: [u32; 128],
}

/// Memoized glyph rasterization cache shared across frames with O(1) slot indexing, ASCII direct tables, bounded LRU budget, and hit/miss telemetry.
#[derive(Clone, Data, Debug, Default)]
pub struct GlyphAtlas {
    /// Open-addressed power-of-two lookup table packing `(slot << 40) | packed_key` (`u64::MAX` when empty).
    #[get(pub(crate))]
    #[get_mut(pub(crate))]
    #[set(pub(crate))]
    pub(crate) glyph_index: Vec<u64>,
    /// Contiguous flat arena of `(GlyphKey, RasterizedGlyph)` pairs indexed directly by `u32` slot.
    #[get(pub(crate))]
    #[get_mut(pub(crate))]
    #[set(pub(crate))]
    pub(crate) entries: Vec<(GlyphKey, RasterizedGlyph)>,
    /// Per-entry monotonic access ticks aligned 1:1 with `entries` for bounded LRU eviction.
    #[get(skip)]
    #[get_mut(skip)]
    #[set(skip)]
    pub(crate) entry_last_used: Vec<u64>,
    /// Compact per-style `[u32; 128]` ASCII lookup tables eliminating hash probes on ASCII text runs.
    #[get(pub(crate))]
    #[get_mut(pub(crate))]
    #[set(pub(crate))]
    pub(crate) ascii_tables: Vec<AsciiGlyphStyleTable>,
    /// Most recently matched ASCII style signature for 1-branch hot-run table lookup.
    #[get(skip)]
    #[get_mut(skip)]
    #[set(skip)]
    pub(crate) last_ascii_style_sig: u32,
    /// Table index inside `ascii_tables` corresponding to `last_ascii_style_sig`.
    #[get(skip)]
    #[get_mut(skip)]
    #[set(skip)]
    pub(crate) last_ascii_table_idx: usize,
    /// Monotonic counter incremented when new glyphs are inserted or evicted for GPU texture sync.
    #[get(type(copy))]
    #[get_mut(pub(crate))]
    #[set(pub(crate))]
    pub(crate) revision: u64,
    /// Configured resident memory budget in bytes (`0` selects `GLYPH_ATLAS_DEFAULT_BUDGET_BYTES`).
    #[get(type(copy))]
    #[get_mut(skip)]
    #[set(pub(crate))]
    pub(crate) budget_bytes: usize,
    /// Current resident memory usage in bytes across all cached glyph bitmaps and metadata.
    #[get(type(copy))]
    #[get_mut(skip)]
    #[set(skip)]
    pub(crate) resident_bytes: usize,
    /// Monotonic logical clock incremented on cache accesses for LRU ordering.
    #[get(skip)]
    #[get_mut(skip)]
    #[set(skip)]
    pub(crate) lru_clock: u64,
    /// Cumulative number of cache hits served without rasterizing.
    #[get(type(copy))]
    #[get_mut(skip)]
    #[set(skip)]
    pub(crate) cache_hits: u64,
    /// Cumulative number of cache misses requiring rasterization.
    #[get(type(copy))]
    #[get_mut(skip)]
    #[set(skip)]
    pub(crate) cache_misses: u64,
    /// Cumulative number of cold glyphs evicted to stay within `budget_bytes`.
    #[get(type(copy))]
    #[get_mut(skip)]
    #[set(skip)]
    pub(crate) evictions: u64,
    /// Guard pinning arena slot indices for the duration of a single frame's `prepare_frame_range`.
    #[get(pub(crate), type(copy))]
    #[get_mut(skip)]
    #[set(pub(crate))]
    pub(crate) slots_pinned: bool,
    /// Active DPI scale IEEE-754 bits bound to currently rasterized atlas bitmaps (`0` before first bind).
    #[get(type(copy))]
    #[get_mut(skip)]
    #[set(skip)]
    pub(crate) active_dpi_scale_bits: u32,
    /// Active anti-aliasing policy bound to currently rasterized atlas bitmaps.
    #[get(type(copy))]
    #[get_mut(skip)]
    #[set(skip)]
    pub(crate) active_aa_mode: AntialiasingMode,
    /// Active font fallback chain revision bound to currently rasterized atlas bitmaps.
    #[get(type(copy))]
    #[get_mut(skip)]
    #[set(skip)]
    pub(crate) font_chain_revision: u64,
    /// Current in-flight GPU submission fence tagged onto touched glyph entries.
    #[get(type(copy))]
    #[get_mut(skip)]
    #[set(skip)]
    pub(crate) active_fence_id: u64,
    /// Highest GPU submission fence known to have completed on the device.
    #[get(type(copy))]
    #[get_mut(skip)]
    #[set(skip)]
    pub(crate) completed_fence_id: u64,
    /// Per-entry last-referenced GPU fence identifier aligned 1:1 with `entries` for fence-deferred reclamation.
    #[get(skip)]
    #[get_mut(skip)]
    #[set(skip)]
    pub(crate) entry_fence_ids: Vec<u64>,
    /// Evicted glyph bitmap allocations waiting for `(retire_fence_id, byte_size)` GPU fence completion.
    #[get(skip)]
    #[get_mut(skip)]
    #[set(skip)]
    pub(crate) pending_reclaim: Vec<(u64, usize)>,
    /// Aggregate bytes currently awaiting GPU fence completion before final release.
    #[get(type(copy))]
    #[get_mut(skip)]
    #[set(skip)]
    pub(crate) pending_reclaim_bytes: usize,
    /// Cumulative count of evicted glyph allocations reclaimed after GPU fence completion.
    #[get(type(copy))]
    #[get_mut(skip)]
    #[set(skip)]
    pub(crate) reclaimed_entries: u64,
}