pub struct FlipGate { /* private fields */ }Expand description
The presentation cap as a state machine, one call per VBlank edge: the
reference for what psx-rt’s VBlank handler does with a queued flip.
use psx_tick::{FlipGate, PresentCap};
let mut gate = FlipGate::new(PresentCap::HZ30);
// A flip wanted on every edge is granted on every second one.
let granted: Vec<bool> = (0..6).map(|_| gate.edge(true)).collect();
assert_eq!(granted, [true, false, true, false, true, false]);
assert_eq!(gate.histogram().below(2), 0);Implementations§
Source§impl FlipGate
impl FlipGate
Sourcepub const fn new(cap: PresentCap) -> FlipGate
pub const fn new(cap: PresentCap) -> FlipGate
A gate with cap, free to flip at the first edge.
Sourcepub fn edge(&mut self, flip_wanted: bool) -> bool
pub fn edge(&mut self, flip_wanted: bool) -> bool
One VBlank edge. flip_wanted is whether a finished frame is waiting to
be shown. Returns whether the flip was applied: it is held back while
fewer than the cap’s VBlanks have passed since the last one.
Sourcepub const fn histogram(&self) -> FlipHistogram
pub const fn histogram(&self) -> FlipHistogram
The flip intervals so far.
Trait Implementations§
impl Copy for FlipGate
impl Eq for FlipGate
impl StructuralPartialEq for FlipGate
Auto Trait Implementations§
impl Freeze for FlipGate
impl RefUnwindSafe for FlipGate
impl Send for FlipGate
impl Sync for FlipGate
impl Unpin for FlipGate
impl UnsafeUnpin for FlipGate
impl UnwindSafe for FlipGate
Blanket Implementations§
§impl<T> Any for Twhere
T: 'static + ?Sized,
impl<T> Any for Twhere
T: 'static + ?Sized,
§impl<T> Borrow<T> for Twhere
T: ?Sized,
impl<T> Borrow<T> for Twhere
T: ?Sized,
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
🔬This is a nightly-only experimental API. (
clone_to_uninit)