Skip to main content

PingPong

Struct PingPong 

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

Which of two cursor buffers is live.

Implementations§

Source§

impl PingPong

Source

pub const fn new() -> Self

A fresh pair, buffer 0 live.

Source

pub const fn single() -> Self

A single buffer, for the legacy path.

The legacy ioctls take one buffer handle and have no flip to alternate on, so a second buffer buys nothing there.

Source

pub const fn active(self) -> usize

The buffer scanout is reading.

Source

pub const fn draw_target(self) -> usize

The buffer to draw the next frame into.

The one that is not on screen, so drawing cannot tear. With a single buffer there is no choice, and the tear is accepted: the legacy path redraws the buffer the CRTC is showing, which only a new shape or an animation frame does.

Source

pub const fn commit_target(self) -> usize

The buffer the next commit should publish.

Whatever was just drawn, if anything was. A commit that only moves the cursor re-publishes the buffer already on screen rather than flipping to a stale one.

Source

pub const fn mark_drawn(&mut self)

Note that a frame has been drawn into PingPong::draw_target.

Source

pub const fn has_undrawn(self) -> bool

Whether a draw is waiting to reach the screen.

Source

pub const fn published(&mut self)

Note that a commit published PingPong::commit_target.

The buffer just published becomes the live one, so the next draw goes to the one now safely off screen.

Call this on a commit that landed. Where the caller owns the commit there is no way to know, and calling it optimistically is the right trade: if their commit failed, scanout is still reading the buffer this just marked as the draw target, and the next draw there can tear — which is exactly what a single buffer does all the time. A successful commit, the overwhelmingly common case, is tear-free.

Trait Implementations§

Source§

impl Clone for PingPong

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for PingPong

Source§

impl Debug for PingPong

Source§

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

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

impl Default for PingPong

Source§

fn default() -> Self

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

impl Eq for PingPong

Source§

impl PartialEq for PingPong

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for PingPong

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.