euv-core 0.48.2

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::*;

/// Active adaptive spin-loop iterations performed by band workers during animation/scroll before parking (~30-60us).
#[cfg(not(target_arch = "wasm32"))]
pub const BAND_WORKER_SPIN_LIMIT_ACTIVE: u32 = 3_072;

/// Idle spin-loop iterations performed by band workers when no active animation/scroll is running (`0` = immediate park).
#[cfg(not(target_arch = "wasm32"))]
pub const BAND_WORKER_SPIN_LIMIT_IDLE: u32 = 0;

/// Half-domain extent in standard deviations covered by `GAUSSIAN_ERFC_LUT` (`[-3.2σ, +3.2σ]`).
pub(crate) const GAUSSIAN_LUT_RANGE: f32 = 3.2;

/// Number of intervals inside `GAUSSIAN_ERFC_LUT` (`512` intervals, `513` sample points).
pub(crate) const GAUSSIAN_LUT_SEGMENTS: usize = 512;

/// Inverse spacing `(512.0 / 6.4) = 80.0` mapping `u + 3.2` into table index space.
pub(crate) const GAUSSIAN_LUT_STEP_INV: f32 =
    (GAUSSIAN_LUT_SEGMENTS as f32) / (GAUSSIAN_LUT_RANGE * 2.0);

/// Compile-time 2 KB analytical Gaussian `0.5 * erfc(u / sqrt(2))` lookup table eliminating per-pixel `exp()` calls.
pub(crate) const GAUSSIAN_ERFC_LUT: [f32; 513] = build_gaussian_erfc_lut();

/// Maximum cached `TextLayoutResult` entries retained by `SoftwareRenderer` between frames.
pub(crate) const TEXT_LAYOUT_CACHE_LIMIT: usize = 512;

/// Default resident memory budget for `TextLayoutCache` (2 MiB) before LRU eviction trims cold entries.
pub(crate) const TEXT_LAYOUT_CACHE_BUDGET_BYTES: usize = 2 * 1024 * 1024;

/// Fixed per-entry metadata overhead counted toward `TextLayoutCache::resident_bytes`.
pub(crate) const TEXT_LAYOUT_ENTRY_OVERHEAD_BYTES: usize = 64;

/// Fixed per-line `TextLine` struct overhead counted toward `TextLayoutCache::resident_bytes`.
pub(crate) const TEXT_LINE_OVERHEAD_BYTES: usize = 32;

/// Initial power-of-two slot table size for `TextLayoutCache` (load factor `<= 0.5` at `TEXT_LAYOUT_CACHE_LIMIT`).
pub(crate) const TEXT_LAYOUT_CACHE_SLOTS: usize = 1024;

/// 64-bit FxHash mixing multiplier for fast SipHash-free cache hashing and slot indexing.
pub(crate) const FX_HASH_K64: u64 = 0x517C_C1B7_2722_0A95;

/// Sentinel empty slot for `TextLayoutCache` open-addressed probing.
pub(crate) const EMPTY_TEXT_LAYOUT_SLOT: TextLayoutSlot = TextLayoutSlot {
    key_hash: 0,
    width_key: 0,
    entry_idx: u32::MAX,
};

/// Maximum cached `PositionedGlyphRun` entries retained across scroll/animation frames.
pub(crate) const POSITIONED_RUN_CACHE_LIMIT: usize = 512;

/// Initial power-of-two slot table size for `PositionedGlyphRunCache`.
pub(crate) const POSITIONED_RUN_CACHE_SLOTS: usize = 1024;

/// Maximum UTF-8 byte length eligible for whole-run `PositionedGlyphRun` caching (prevents rasterizing giant off-screen blocks).
pub(crate) const POSITIONED_RUN_MAX_TEXT_LEN: usize = 1024;

/// Fixed flat glyph slab capacity retained by `PositionedGlyphRunCache` for zero-allocation steady-state inserts and LRU compactions.
pub(crate) const POSITIONED_RUN_GLYPH_SLAB_CAP: usize = 16_384;

/// Sentinel empty slot for `PositionedGlyphRunCache` open-addressed probing.
pub(crate) const EMPTY_POSITIONED_RUN_SLOT: PositionedGlyphRunSlot = PositionedGlyphRunSlot {
    key_hash: 0,
    width_bits: 0,
    phys_scale_milli: 0,
    entry_idx: u32::MAX,
};

/// Maximum stack-cached width in physical pixels for precomputed 1D vertical rounded-rect edge strips.
pub(crate) const ROUNDED_EDGE_STRIP_CAP: usize = 16;

/// Maximum cached rounded-clip corner side length in physical pixels (`dim = ceil(r + 1)`).
pub(crate) const CORNER_MASK_MAX_DIM: u32 = 96;

/// Maximum cached quadrant corner coverage masks retained by `SoftwareRenderer` between frames.
pub(crate) const CORNER_MASK_CACHE_LIMIT: usize = 128;

/// Thread name prefix assigned to persistent horizontal-band rasterization workers.
#[cfg(not(target_arch = "wasm32"))]
pub(crate) const BAND_WORKER_THREAD_PREFIX: &str = "euv-band";

/// Background initializer thread name warming `BandWorkerPool` asynchronously after Frame 1.
#[cfg(not(target_arch = "wasm32"))]
pub(crate) const BAND_POOL_INIT_THREAD_NAME: &str = "euv-band-init";

/// Maximum total rasterizer threads (caller plus background workers) in `BandWorkerPool`.
#[cfg(not(target_arch = "wasm32"))]
pub(crate) const BAND_WORKER_MAX_THREADS: usize = 16;

/// Active spin-loop iterations performed by the calling thread before parking on `wake_caller`.
#[cfg(not(target_arch = "wasm32"))]
pub(crate) const BAND_CALLER_SPIN_LIMIT_ACTIVE: u32 = 3_072;

/// Idle spin-loop iterations performed by the calling thread before parking on `wake_caller`.
#[cfg(not(target_arch = "wasm32"))]
pub(crate) const BAND_CALLER_SPIN_LIMIT_IDLE: u32 = 64;

/// Atomic state value indicating `BAND_WORKER_POOL` has not yet been requested.
#[cfg(not(target_arch = "wasm32"))]
pub(crate) const BAND_POOL_UNINITIALIZED: usize = 0;

/// Atomic state value indicating `BAND_WORKER_POOL` is warming asynchronously on a background thread.
#[cfg(not(target_arch = "wasm32"))]
pub(crate) const BAND_POOL_SPAWNING: usize = 1;

/// Atomic state value indicating `BAND_WORKER_POOL` is warm and ready for lock-free dispatch.
#[cfg(not(target_arch = "wasm32"))]
pub(crate) const BAND_POOL_READY: usize = 2;

/// Maximum damaged pixel area executed directly on the calling thread without touching `BandWorkerPool`.
#[cfg(not(target_arch = "wasm32"))]
pub(crate) const SMALL_DAMAGE_SINGLE_THREAD_PIXELS: usize = 32_768;

/// Minimum prepared command count before waking `BandWorkerPool` for mid-sized single-row dirty rects.
#[cfg(not(target_arch = "wasm32"))]
pub(crate) const BAND_DISPATCH_MIN_CMDS: usize = 6;

/// Minimum damaged pixel area required before splitting horizontal bands across background worker threads.
#[cfg(not(target_arch = "wasm32"))]
pub(crate) const BAND_DISPATCH_MIN_PIXELS: usize = 65_536;

/// Minimum vertical height in physical rows required for multi-threaded band dispatch.
#[cfg(not(target_arch = "wasm32"))]
pub(crate) const BAND_DISPATCH_MIN_HEIGHT: u32 = 64;

/// Minimum blur area in physical pixels before splitting separable `BackdropBlur` passes across `BandWorkerPool`.
#[cfg(not(target_arch = "wasm32"))]
pub(crate) const BLUR_PARALLEL_MIN_PIXELS: usize = 16_384;

/// Minimum blur height in physical rows before splitting separable `BackdropBlur` passes across `BandWorkerPool`.
#[cfg(not(target_arch = "wasm32"))]
pub(crate) const BLUR_PARALLEL_MIN_HEIGHT: u32 = 32;

/// Lower bound in physical pixels for the adaptive serial-vs-parallel stripe threshold.
#[cfg(not(target_arch = "wasm32"))]
pub(crate) const ADAPTIVE_PARALLEL_MIN_PIXELS: usize = 32_768;

/// Default starting threshold in physical pixels before switching small dirty rects from serial to parallel stripes.
pub(crate) const ADAPTIVE_PARALLEL_DEFAULT_PIXELS: usize = 49_152;

/// Upper bound in physical pixels for the adaptive serial-vs-parallel stripe threshold.
#[cfg(not(target_arch = "wasm32"))]
pub(crate) const ADAPTIVE_PARALLEL_MAX_PIXELS: usize = 524_288;

/// Maximum opaque occluder rectangles tracked concurrently during order-preserving occlusion culling.
pub(crate) const OCCLUSION_MAX_OCCLUDERS: usize = 16;

/// Coarse 8x8 viewport tile grid dimension for 64-bit bitmask union occlusion tests.
pub(crate) const OCCLUSION_TILE_GRID_DIM: u32 = 8;