euv-core 0.48.3

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

/// QuartzCore `CAFrameRateRange` ABI struct for iOS 15+ ProMotion `CADisplayLink` pacing.
#[repr(C)]
#[derive(Clone, Copy, Debug)]
pub(crate) struct CaFrameRateRange {
    /// Minimum adaptive refresh rate in Hertz.
    pub(crate) minimum: f32,
    /// Maximum adaptive refresh rate in Hertz.
    pub(crate) maximum: f32,
    /// Preferred target refresh rate in Hertz.
    pub(crate) preferred: f32,
}

/// Native iOS / iPadOS UIKit window record supporting iPhone safe areas and iPadOS Stage Manager multi-window.
#[derive(Clone, Data, Debug)]
pub struct IosWindowRecord {
    /// Declarative window configuration.
    pub(crate) config: WindowConfig,
    /// Live window state and safe-area metrics.
    #[get(type(copy))]
    pub(crate) state: WindowState,
    /// Raw `UIWindow*` pointer.
    #[get(type(copy))]
    pub(crate) ui_window: usize,
    /// Raw `UIView*` pointer.
    #[get(type(copy))]
    pub(crate) ui_view: usize,
    /// Raw `CAMetalLayer*` pointer.
    #[get(type(copy))]
    pub(crate) metal_layer: usize,
    /// True when executing on iPadOS (`UIUserInterfaceIdiomPad`).
    #[get(type(copy))]
    pub(crate) is_ipad: bool,
}

/// iOS / iPadOS `CADisplayLink` and `MTLDrawable.addPresentedHandler` telemetry with honest simulator unobservability tracking.
#[derive(Clone, Copy, Data, Debug, Default, PartialEq)]
pub struct IosPresentTelemetry {
    /// Core cross-platform mobile presentation telemetry metrics.
    #[get(type(copy))]
    pub(crate) base: MobilePresentTelemetry,
    /// Most recent `CADisplayLink.timestamp` converted to nanoseconds.
    #[get(type(copy))]
    pub(crate) display_link_timestamp_ns: u64,
    /// Most recent `CADisplayLink.targetTimestamp` converted to nanoseconds (`None` when unavailable).
    #[get(type(copy))]
    pub(crate) display_link_target_timestamp_ns: Option<u64>,
    /// Most recent physical-device `MTLDrawable.presentedTime` in nanoseconds (`None` on simulator or when unobservable).
    #[get(type(copy))]
    pub(crate) metal_presented_time_ns: Option<u64>,
    /// Most recent Metal GPU execution time in microseconds (`GPUEndTime - GPUStartTime`).
    #[get(type(copy))]
    pub(crate) metal_gpu_exec_us: u64,
    /// True when executing on an iOS / iPadOS Simulator target where hardware `presentedTime` is unobservable.
    #[get(type(copy))]
    pub(crate) is_simulator: bool,
    /// Cumulative frames rendered directly onto `CAMetalDrawable` via MSL uber-shader (`cpu_mirror_active = false`).
    #[get(type(copy))]
    pub(crate) direct_gpu_frames: u64,
    /// Cumulative fallback frames rendered via Metal texture upload (`cpu_mirror_active = true`).
    #[get(type(copy))]
    pub(crate) gpu_upload_frames: u64,
    /// Cumulative fallback frames rendered via CoreGraphics `CGImage` / `CALayer` (`cpu_mirror_active = true`).
    #[get(type(copy))]
    pub(crate) software_cg_frames: u64,
}

/// Direct iOS & iPadOS UIKit / CoreGraphics / Metal platform backend.
#[derive(Clone, Data, Debug)]
pub struct IosPlatform {
    /// Dynamically resolved platform kind (`PlatformKind::Ios` or `PlatformKind::IpadOs`).
    #[get(type(copy))]
    pub(crate) resolved_kind: PlatformKind,
    /// Monotonic window ID counter.
    #[get(pub(crate), type(copy))]
    #[get_mut(pub(crate))]
    #[set(pub(crate))]
    pub(crate) next_id: u64,
    /// Active UIKit windows (supports multiple scenes on iPadOS Stage Manager / Split View).
    pub(crate) windows: HashMap<WindowId, IosWindowRecord>,
    /// Queued UIKit touch, Apple Pencil, hardware keyboard, and safe-area events.
    pub(crate) pending_events: Vec<WindowEvent>,
    /// Clipboard cache synchronized with `UIPasteboard`.
    #[get(skip)]
    pub(crate) clipboard_cache: Option<String>,
    /// Optional attached `CADisplayLink*` pointer paused automatically while in background.
    #[get(pub(crate), type(copy))]
    #[set(pub(crate))]
    pub(crate) display_link: usize,
    /// Detected `UIScreen.mainScreen.maximumFramesPerSecond` refresh rate in Hertz (`120.0` on ProMotion).
    #[get(pub(crate), type(copy))]
    #[get_mut(pub(crate))]
    #[set(pub(crate))]
    pub(crate) refresh_rate_hz: f32,
    /// Whether the UIKit `CADisplayLink` frame pump is currently paused for background freeze.
    #[get(pub(crate), type(copy))]
    #[set(pub(crate))]
    pub(crate) pump_paused: bool,
    /// Cached `CGColorSpaceRef` reused across all frame presentations (avoids per-frame CoreGraphics alloc).
    #[get(pub(crate), type(copy))]
    #[set(pub(crate))]
    pub(crate) cached_color_space: usize,
    /// Live `CADisplayLink`, Metal `presentedTime`, upload strategy, and failover telemetry.
    #[get(type(copy))]
    pub(crate) present_telemetry: IosPresentTelemetry,
    /// Immediate zero-blank-frame failover controller (`GpuDirect` -> `GpuUpload` -> `Software`).
    #[get(type(copy))]
    pub(crate) failover: MobileFailoverController,
}