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

/// Authoritative lossless viewport metrics separating exact logical CSS/point bounds from exact physical backing pixels and DPI scale.
#[derive(Clone, Copy, Debug, Getter, PartialEq)]
pub struct ViewportMetrics {
    /// Exact logical viewport width in CSS/point coordinates without integer truncation.
    #[get(type(copy))]
    pub(crate) logical_width: f64,
    /// Exact logical viewport height in CSS/point coordinates without integer truncation.
    #[get(type(copy))]
    pub(crate) logical_height: f64,
    /// Authoritative physical backing surface width in device pixels.
    #[get(type(copy))]
    pub(crate) physical_width: u32,
    /// Authoritative physical backing surface height in device pixels.
    #[get(type(copy))]
    pub(crate) physical_height: u32,
    /// Active display DPI scale multiplier clamped strictly to `[VIEWPORT_SCALE_MIN, VIEWPORT_SCALE_MAX]`.
    #[get(type(copy))]
    pub(crate) scale_factor: f32,
}

/// Hardware or browser single-surface dimension and pixel-area limits driving lossless tile partitioning.
#[derive(Clone, Copy, Debug, Eq, Getter, PartialEq)]
pub struct SurfaceTileLimit {
    /// Maximum supported texture or drawing-buffer extent along a single axis in physical pixels.
    #[get(type(copy))]
    pub(crate) max_texture_dim: u32,
    /// Maximum supported single drawing-buffer pixel area (`width * height`) in physical pixels.
    #[get(type(copy))]
    pub(crate) max_surface_area: u64,
}

/// Single 1:1 physical surface tile mapped to its exact logical CSS/point bounds with zero resampling.
#[derive(Clone, Copy, Debug, Getter, PartialEq)]
pub struct SurfaceTileRect {
    /// Zero-based horizontal tile column index.
    #[get(type(copy))]
    pub(crate) tile_col: u32,
    /// Zero-based vertical tile row index.
    #[get(type(copy))]
    pub(crate) tile_row: u32,
    /// Inclusive starting physical X coordinate in device pixels.
    #[get(type(copy))]
    pub(crate) physical_x: u32,
    /// Inclusive starting physical Y coordinate in device pixels.
    #[get(type(copy))]
    pub(crate) physical_y: u32,
    /// Exact tile width in physical device pixels (`1:1` with backing pixels).
    #[get(type(copy))]
    pub(crate) physical_width: u32,
    /// Exact tile height in physical device pixels (`1:1` with backing pixels).
    #[get(type(copy))]
    pub(crate) physical_height: u32,
    /// Exact logical X origin in CSS/point coordinates.
    #[get(type(copy))]
    pub(crate) logical_x: f64,
    /// Exact logical Y origin in CSS/point coordinates.
    #[get(type(copy))]
    pub(crate) logical_y: f64,
    /// Exact logical width in CSS/point coordinates.
    #[get(type(copy))]
    pub(crate) logical_width: f64,
    /// Exact logical height in CSS/point coordinates.
    #[get(type(copy))]
    pub(crate) logical_height: f64,
}

/// Complete lossless surface partitioning plan covering 100% of a viewport at full 1:1 physical DPI without dropping scale.
#[derive(Clone, Debug, Getter, PartialEq)]
pub struct TiledSurfacePlan {
    /// Authoritative source viewport metrics covered by this plan.
    #[get(type(copy))]
    pub(crate) viewport: ViewportMetrics,
    /// Hardware single-surface limits enforced on every generated tile.
    #[get(type(copy))]
    pub(crate) limits: SurfaceTileLimit,
    /// Number of horizontal tile columns (`1` when untiled).
    #[get(type(copy))]
    pub(crate) columns: u32,
    /// Number of vertical tile rows (`1` when untiled).
    #[get(type(copy))]
    pub(crate) rows: u32,
    /// Whether the viewport exceeded hardware single-surface limits and required multi-tile partitioning.
    #[get(type(copy))]
    pub(crate) tiled: bool,
    /// Row-major ordered list of non-overlapping tiles whose union equals the exact physical viewport.
    pub(crate) tiles: Vec<SurfaceTileRect>,
}

/// Pointer hit-test resolution mapping a logical viewport coordinate onto an exact owning surface tile and physical pixel position.
#[derive(Clone, Copy, Debug, Getter, PartialEq)]
pub struct TileHitResult {
    /// Row-major index into `TiledSurfacePlan::tiles`.
    #[get(type(copy))]
    pub(crate) tile_index: usize,
    /// Zero-based horizontal column index of the hit tile.
    #[get(type(copy))]
    pub(crate) tile_col: u32,
    /// Zero-based vertical row index of the hit tile.
    #[get(type(copy))]
    pub(crate) tile_row: u32,
    /// Tile-local physical X coordinate in device pixels.
    #[get(type(copy))]
    pub(crate) local_physical_x: f64,
    /// Tile-local physical Y coordinate in device pixels.
    #[get(type(copy))]
    pub(crate) local_physical_y: f64,
    /// Global viewport physical X coordinate in device pixels.
    #[get(type(copy))]
    pub(crate) global_physical_x: f64,
    /// Global viewport physical Y coordinate in device pixels.
    #[get(type(copy))]
    pub(crate) global_physical_y: f64,
}