Skip to main content

PointerResampler

Struct PointerResampler 

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

Buffers raw pointer samples and emits frame-boundary-resampled events, one independent lane per PointerId. See the module docs for the interpolation/prediction contract; construct one per app handle and drive it from the shell’s touch and frame paths.

A lane opens with its contact’s first sample and ends once its Up/Cancel has been emitted. Each lane resamples exactly as a single-pointer resampler would; the events of several lanes are merged back into arrival order.

Implementations§

Source§

impl PointerResampler

Source

pub fn new() -> Self

A resampler honoring the NO_RESAMPLE_VAR kill switch — what every shell constructs. When the variable is set (compile-time --define or runtime env, any non-"0" value), this is equivalent to disabled.

Source

pub fn disabled() -> Self

A resampler that always delivers raw samples straight through — the explicit disabled/kill-switch form (and a test seam bypassing the env read). Mirrors Self::new’s behavior when NO_RESAMPLE_VAR is set.

Source

pub fn with_enabled(enabled: bool) -> Self

Construct with an explicit enabled flag, bypassing the env read — the test/advanced seam (mirrors crate::frame_gate::FrameGate::with_enabled).

Source

pub fn is_enabled(&self) -> bool

Whether resampling is active. false for a disabled resampler or when the kill switch is engaged — in which case the shell should deliver touches directly rather than buffering them here.

Source

pub fn has_pending(&self) -> bool

Whether any raw sample is still buffered, in any lane. The shell ORs this into its frame-gate input (events_since_last_frame) so a frame that could not yet drain a too-new sample still runs on the next tick — the “pending buffered input never starves the gate” contract (see docs/CODE_STANDARDS.md’s default-to-run rule).

Source

pub fn push(&mut self, sample: RawPointerSample)

Buffer one raw platform sample in its contact’s lane (a touch entry point calls this per contact). Each contact’s samples must be pushed in nondecreasing timestamp order (the natural arrival order of one pointer’s stream).

Source

pub fn resample( &mut self, frame_time_nanos: u64, out: &mut Vec<ResampledPointer>, )

Drain the buffered samples up to this frame’s sample instant into out, appending the resampled events — each tagged with its contact — that the shell should feed into the tree this frame, in order. out is appended to, not cleared — the caller owns/reuses the buffer.

frame_time_nanos is the frame’s sample query time in the shell’s chosen monotonic domain (the same domain push stamped with).

On a disabled resampler every buffered sample is emitted verbatim in arrival order (direct delivery). On an enabled one, each lane independently:

  • emits Down/Up/Cancel whose timestamp has reached the sample instant losslessly in order, each at its raw reported position;
  • coalesces a run of Move samples up to the sample instant into a single Move at the position interpolated at frame_time − SAMPLE_OFFSET_NANOS (or extrapolated within the PREDICTION_WINDOW_NANOS clamp when the finger has outrun its samples);
  • leaves samples still ahead of the sample instant buffered (see has_pending).

The lanes’ events are then merged by the arrival order of the samples they came from, so a second finger’s Down lands after the first finger’s Down that preceded it. A lane whose Up/Cancel was emitted and that has nothing left buffered is retired.

Trait Implementations§

Source§

impl Debug for PointerResampler

Source§

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

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

impl Default for PointerResampler

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.