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

/// Android NDK `ARect` dirty-bounds ABI struct for `ANativeWindow_lock`.
#[repr(C)]
#[derive(Clone, Copy, Debug, Default)]
pub(crate) struct AndroidRect {
    /// Left inclusive pixel coordinate.
    pub(crate) left: i32,
    /// Top inclusive pixel coordinate.
    pub(crate) top: i32,
    /// Right exclusive pixel coordinate.
    pub(crate) right: i32,
    /// Bottom exclusive pixel coordinate.
    pub(crate) bottom: i32,
}

/// Decoded single touch sample packed in the direct `ByteBuffer` JNI batch ring (20 bytes per record).
#[repr(C)]
#[derive(Clone, Copy, Data, Debug, Default, PartialEq)]
pub struct AndroidTouchBatchEntry {
    /// Masked Android `MotionEvent` action code (`ACTION_DOWN`, `ACTION_MOVE`, `ACTION_UP`, etc.).
    #[get(type(copy))]
    pub(crate) action: i32,
    /// Pointer index within the multi-touch action batch.
    #[get(type(copy))]
    pub(crate) action_index: i32,
    /// Stable Android hardware pointer identifier.
    #[get(type(copy))]
    pub(crate) pointer_id: i32,
    /// Surface-local horizontal coordinate in logical or physical pixels.
    #[get(type(copy))]
    pub(crate) x: f32,
    /// Surface-local vertical coordinate in logical or physical pixels.
    #[get(type(copy))]
    pub(crate) y: f32,
}

/// Android NDK `ANativeWindow_Buffer` ABI struct.
#[repr(C)]
#[derive(Clone, Copy, Debug)]
pub(crate) struct ANativeWindowBuffer {
    /// Pixel width of locked buffer.
    pub(crate) width: i32,
    /// Pixel height of locked buffer.
    pub(crate) height: i32,
    /// Row stride in pixels (may exceed `width`).
    pub(crate) stride: i32,
    /// Pixel format discriminant (`ANDROID_WINDOW_FORMAT_RGBA_8888`).
    pub(crate) format: i32,
    /// Mutable pointer to locked pixel memory.
    pub(crate) bits: *mut c_void,
    /// NDK reserved padding words.
    pub(crate) reserved: [u32; 6],
}

/// Native Android NDK window record bound to an `ANativeWindow*`.
#[derive(Clone, Data, Debug)]
pub struct AndroidWindowRecord {
    /// Declarative window configuration.
    pub(crate) config: WindowConfig,
    /// Live window state and cutout safe-area metrics.
    #[get(type(copy))]
    pub(crate) state: WindowState,
    /// Raw `ANativeWindow*` pointer provided by `NativeActivity` / `SurfaceView`.
    #[get(type(copy))]
    pub(crate) native_window: usize,
    /// Last configured `ANativeWindow` buffer width to skip redundant `setBuffersGeometry` calls.
    #[get(pub(crate), type(copy))]
    #[get_mut(pub(crate))]
    #[set(pub(crate))]
    pub(crate) surface_width: u32,
    /// Last configured `ANativeWindow` buffer height to skip redundant `setBuffersGeometry` calls.
    #[get(pub(crate), type(copy))]
    #[get_mut(pub(crate))]
    #[set(pub(crate))]
    pub(crate) surface_height: u32,
}

/// Android Choreographer, EGL presentation timing, upload strategy, and failover telemetry ready for `AdaptiveRenderRouter` and `report-v1` JSON.
#[derive(Clone, Copy, Data, Debug, Default, PartialEq)]
pub struct AndroidPresentTelemetry {
    /// Core cross-platform mobile presentation telemetry metrics.
    #[get(type(copy))]
    pub(crate) base: MobilePresentTelemetry,
    /// Most recent Android `Choreographer.FrameCallback.doFrame(frameTimeNanos)` timestamp in nanoseconds.
    #[get(type(copy))]
    pub(crate) choreographer_frame_time_ns: u64,
    /// Most recent `eglPresentationTimeANDROID` / swap completion monotonic timestamp (`None` when unobservable).
    #[get(type(copy))]
    pub(crate) egl_presentation_time_ns: Option<u64>,
    /// Most recent EGL swap or direct-draw submission duration in microseconds.
    #[get(type(copy))]
    pub(crate) egl_swap_duration_us: u64,
    /// True when the active EGL driver exposes `eglPresentationTimeANDROID`.
    #[get(type(copy))]
    pub(crate) egl_extension_present_time: bool,
    /// True when the active EGL driver exposes `eglSwapBuffersWithDamageKHR`.
    #[get(type(copy))]
    pub(crate) egl_extension_swap_damage: bool,
    /// Cumulative frames presented via zero-CPU-mirror GLES 3.0 direct GPU draw (`cpu_mirror_active = false`).
    #[get(type(copy))]
    pub(crate) direct_gpu_frames: u64,
    /// Cumulative fallback frames uploaded via `MobileUploadStrategy::MultiRect`.
    #[get(type(copy))]
    pub(crate) multi_rect_uploads: u64,
    /// Cumulative fallback frames uploaded via `MobileUploadStrategy::MergedBbox`.
    #[get(type(copy))]
    pub(crate) merged_bbox_uploads: u64,
    /// Cumulative fallback frames uploaded via `MobileUploadStrategy::FullFrame`.
    #[get(type(copy))]
    pub(crate) full_frame_uploads: u64,
}

/// Direct Android NDK (`ANativeWindow` / `AInput` / Vulkan / OpenGL ES) platform backend.
#[derive(Clone, Data, Debug)]
pub struct AndroidPlatform {
    /// Monotonic window handle generator.
    #[get(pub(crate), type(copy))]
    #[get_mut(pub(crate))]
    #[set(pub(crate))]
    pub(crate) next_id: u64,
    /// Attached `ANativeWindow*` pointer supplied by the Android NDK lifecycle callback.
    #[get(type(copy))]
    pub(crate) attached_native_window: usize,
    /// Detected display density scale factor (`dpi / 160.0`).
    #[get(type(copy))]
    pub(crate) density_scale: f32,
    /// Active hardware display refresh rate in Hertz (`90.0`/`120.0`/`144.0`+ on high-refresh phones).
    #[get(pub(crate), type(copy))]
    #[get_mut(pub(crate))]
    #[set(pub(crate))]
    pub(crate) refresh_rate_hz: f32,
    /// Active Android surface window records.
    pub(crate) windows: HashMap<WindowId, AndroidWindowRecord>,
    /// Queued touch, key, IME, and lifecycle events.
    pub(crate) pending_events: Vec<WindowEvent>,
    /// Clipboard cache synchronized through JNI bridge.
    #[get(skip)]
    pub(crate) clipboard_cache: Option<String>,
    /// Whether the Android Choreographer / render pump is paused for background freeze.
    #[get(pub(crate), type(copy))]
    #[set(pub(crate))]
    pub(crate) pump_paused: bool,
    /// Live Choreographer, EGL presentation timing, upload bytes, and failure telemetry.
    #[get(type(copy))]
    pub(crate) present_telemetry: AndroidPresentTelemetry,
    /// Immediate zero-blank-frame context-loss failover controller (`GpuDirect` -> `GpuUpload` -> `Software`).
    #[get(type(copy))]
    pub(crate) failover: MobileFailoverController,
}