euv-core 0.52.0

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

/// Containment boundary marking a candidate subtree root for CPU/GPU mixed co-execution partitioning.
#[derive(Clone, Copy, Data, Debug, Default, Eq, Hash, New, PartialEq)]
pub struct LayoutBoundary {
    /// Root `NodeId` of the contained layout subtree.
    #[get(type(copy))]
    pub(crate) root_node: NodeId,
    /// Placement hint influencing CPU vs GPU subtree assignment.
    #[get(type(copy))]
    pub(crate) hint: LayoutBoundaryHint,
    /// Whether the boundary has an explicit outer width constraint independent of descendant content.
    #[get(type(copy))]
    pub(crate) fixed_width_constraint: bool,
    /// Whether the boundary has an explicit outer height constraint independent of descendant content.
    #[get(type(copy))]
    pub(crate) fixed_height_constraint: bool,
}

/// Configurable thresholds and device state governing `SubtreePartitionPlanner`.
#[derive(Clone, Copy, Data, Debug, PartialEq)]
pub struct SubtreePartitionConfig {
    /// Minimum node count required for GPU compute promotion (`512` default).
    #[get(type(copy))]
    pub(crate) min_gpu_nodes: usize,
    /// Maximum allowed ratio of wrapping text nodes in `[0.0, 1.0]` (`0.15` default).
    #[get(type(copy))]
    pub(crate) max_text_wrap_ratio: f32,
    /// Maximum tree depth allowed for level-synchronous GPU compute passes (`32` default).
    #[get(type(copy))]
    pub(crate) max_gpu_depth: usize,
    /// True when the active backend supports real hardware GPU compute shaders.
    #[get(type(copy))]
    pub(crate) hardware_compute_ready: bool,
    /// True when thermal telemetry requests avoiding sustained GPU compute bursts.
    #[get(type(copy))]
    pub(crate) thermal_throttled: bool,
}

/// Measured structural and text-complexity metrics for a candidate layout subtree.
#[derive(Clone, Copy, Data, Debug, Default, PartialEq)]
pub struct SubtreePartitionMetrics {
    /// Total live nodes inside the subtree (including its root).
    #[get(type(copy))]
    pub(crate) total_nodes: usize,
    /// Number of nodes inside the subtree currently marked layout-dirty.
    #[get(type(copy))]
    pub(crate) dirty_nodes: usize,
    /// Number of wrapping `NodeKind::Text` nodes inside the subtree.
    #[get(type(copy))]
    pub(crate) wrapping_text_nodes: usize,
    /// Number of nodes using layout modes or node kinds ineligible for GPU compute.
    #[get(type(copy))]
    pub(crate) unsupported_mode_nodes: usize,
    /// Maximum tree depth measured from the subtree root (`0` for leaf).
    #[get(type(copy))]
    pub(crate) max_depth: usize,
    /// Fraction of wrapping text nodes (`wrapping_text_nodes / total_nodes`).
    #[get(type(copy))]
    pub(crate) wrapping_text_ratio: f32,
}

/// Partition assignment decision for one subtree root.
#[derive(Clone, Copy, Data, Debug, PartialEq)]
pub struct SubtreePartitionEntry {
    /// Root `NodeId` of the evaluated subtree.
    #[get(type(copy))]
    pub(crate) root_node: NodeId,
    /// Chosen execution lane (`CpuSubtree` or `GpuSubtree`).
    #[get(type(copy))]
    pub(crate) lane: SubtreeLane,
    /// Measured metrics backing the assignment decision.
    #[get(type(copy))]
    pub(crate) metrics: SubtreePartitionMetrics,
    /// Optional rejection reason when `lane == SubtreeLane::CpuSubtree`.
    #[get(skip)]
    #[get_mut(skip)]
    #[set(skip)]
    pub(crate) reject_reason: Option<GpuSubtreeRejectReason>,
}

/// Complete mixed CPU+GPU subtree partition plan produced for one `SceneTree` frame.
#[derive(Clone, Data, Debug, Default, PartialEq)]
pub struct SubtreePartitionPlan {
    /// Ordered subtree partition decisions (top-down containment roots).
    pub(crate) entries: Vec<SubtreePartitionEntry>,
    /// Total nodes assigned to CPU execution lanes.
    #[get(type(copy))]
    pub(crate) cpu_node_count: usize,
    /// Total nodes assigned to GPU compute layout lanes.
    #[get(type(copy))]
    pub(crate) gpu_node_count: usize,
    /// Number of subtrees assigned to CPU.
    #[get(type(copy))]
    pub(crate) cpu_subtree_count: usize,
    /// Number of subtrees assigned to GPU compute.
    #[get(type(copy))]
    pub(crate) gpu_subtree_count: usize,
    /// True when the plan contains both CPU chrome/text subtrees and at least one GPU compute subtree.
    #[get(type(copy))]
    pub(crate) requires_mixed_coexec: bool,
}

/// Subtree partitioner splitting a `SceneTree` into CPU chrome/prose subtrees and GPU compute subtrees.
#[derive(Clone, Data, Debug)]
pub struct SubtreePartitionPlanner {
    /// Active eligibility thresholds and device capability flags.
    #[get(type(copy))]
    pub(crate) config: SubtreePartitionConfig,
    /// Explicit containment boundaries registered by node identifier.
    pub(crate) boundaries: HashMap<NodeId, LayoutBoundary>,
}