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
impl PlatformViewState
Sourcepub fn ingest(
&mut self,
frames: &[PlatformViewFrame],
input_shields: &[Rect],
) -> bool
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.
Sourcepub fn suspend_all(&mut self) -> bool
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.
Sourcepub fn retire(&mut self, slot_id: u64) -> bool
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).
Sourcepub fn reset_for_surface_recreate(&mut self) -> bool
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.
Sourcepub fn commands(&self) -> (u64, &[ViewCommand])
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.
Sourcepub fn commands_up_to(&self, max_generation: u64) -> (u64, &[ViewCommand])
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.
Sourcepub fn acknowledge(&mut self, generation: u64)
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.