Skip to main content

PlatformViewState

Struct PlatformViewState 

Source
pub struct PlatformViewState { /* private fields */ }
Expand description

The differ: per-slot last-seen state plus the accumulated, not-yet-acknowledged ViewCommand backlog. See the module docs for the full semantics.

live is a BTreeMap (keyed by slot_id), not a HashMap — iteration order must be deterministic (ascending slot_id) for the “same ingest sequence ⇒ identical command stream” golden-test guarantee; a frame’s own Create+Update ordering is separately guaranteed by iterating frames itself in the caller’s given order.

Implementations§

Source§

impl PlatformViewState

Source

pub fn new() -> Self

A fresh differ with no live slots and generation 0.

Source

pub fn ingest( &mut self, frames: &[PlatformViewFrame], input_shields: &[Rect], ) -> bool

Feed one paint pass’s frames (RenderRoot::platform_view_frames()) and that same pass’s z-shield rects (RenderRoot::input_shields()). Returns true if this call produced at least one command (i.e. the generation advanced) — a caller that only cares “did anything change” can skip calling commands entirely when this is false.

input_shields is a flat, slot-agnostic list (core never associates a shield with a slot); this method owns the intersection rule — see the module docs’ Z-shields section. Pass &[] when a caller has no shield channel: every slot then ships only its own manually declared rects.

Do not call this on a gate-skipped frame — see the module docs’ Skip-safety section.

Source

pub fn suspend_all(&mut self) -> bool

Backgrounding path: synthesize Update { visible: false } for every currently-live, currently-visible slot immediately, regardless of its missing streak. A shell calls this on the platform’s backgrounding hook (Android’s onPause, iOS’s frust_pause) — while backgrounded, paint doesn’t run, so ingest is never called to drive the ordinary HIDE_AFTER_MISSING_FRAMES-streak Hide path; without this explicit call a backgrounded native sibling view would stay visible (and, depending on the platform, keep rendering/consuming resources) until the app resumes and repaints. A slot already hidden (last_visible == false) emits nothing for it, so calling this on an already-suspended state (or with no live slots) is a cheap no-op. The Update reuses each slot’s last-known rect/clip — no frames argument, unlike ingest — since backgrounding doesn’t produce a fresh paint pass to source one from.

Source

pub fn retire(&mut self, slot_id: u64) -> bool

Explicit retire: dispose slot_id right now regardless of its missing streak, for a shell with a real teardown signal (see the module docs’ Widget teardown detection). A no-op (returns false) if slot_id isn’t currently live (already disposed, or never created).

Source

pub fn reset_for_surface_recreate(&mut self) -> bool

Re-emit Create + Update for every currently-live slot, using each slot’s last-known state (including a currently-hidden slot’s visible: false) — the backgrounding/rotation replay a shell calls when it knows the native side just lost its whole view hierarchy (surface recreation) and needs every native sibling rebuilt from scratch, not just the ones that would otherwise change.

Source

pub fn commands(&self) -> (u64, &[ViewCommand])

Snapshot for a shell’s peek getter: the current generation plus the entire not-yet-acknowledged command backlog (not just the latest ingest’s batch) — see the module docs’ Generation/acknowledgement section.

Source

pub fn commands_up_to(&self, max_generation: u64) -> (u64, &[ViewCommand])

The prefix of the backlog whose generation is <= max_generation, plus that prefix’s own generation — the release-gate half of commands (see the module docs’ Frame pairing).

commands hands over the whole backlog immediately, which is what makes a hosted view’s geometry run ahead of the frust content it belongs to: the geometry lands in the window’s next frame while the frust buffer it matches is still queued behind the compositor. A shell that knows which frust frame produced each batch — and which frames have actually been presented (FramePairing) — releases only the batches whose frame is already on screen.

pending_gens is monotonically non-decreasing, so the prefix is a partition_point — the same boundary search acknowledge uses. The reported generation is the last released entry’s, not self.generation, so the native side’s acknowledgement round-trip stays exactly as truthful as before: it only ever acks what it was actually handed. An empty prefix reports the already-acknowledged generation, which a shell’s FFI glue reads as “no change” — the same cheap no-op poll as an unchanged frame.

Source

pub fn acknowledge(&mut self, generation: u64)

The native side has finished applying everything up through generation (an argument the shell round-trips from a prior commands call) — compacts the backlog, dropping every entry whose generation is <= generation. Acknowledging a generation older than (or equal to) one already acknowledged is a no-op.

Trait Implementations§

Source§

impl Debug for PlatformViewState

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for PlatformViewState

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> StorageAccess<T> for T

Source§

fn as_borrowed(&self) -> &T

Borrows the value.
Source§

fn into_taken(self) -> T

Takes the value.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.