Skip to main content

Presenter

Struct Presenter 

Source
pub struct Presenter<'a> {
    canvas: Surface<'a>,
    min_ticks: u64,
    last_present_tick: u64,
    presented: bool,
}
Expand description

Frame presentation: owns the scanout surface and rate-limits the flush.

The presenter is the only place that knows about write-combining memory and about PRESENT_MIN_TICKS. A Canvas does not rate-limit anything; it only records damage.

The usual layout is one back surface (drawn by the console, the compositor or a kernel demo) and one presenter over the physical framebuffer:

draw into back  ->  back.dirty()  ->  Presenter::present(now, &mut back)
                                             |
                                             +-> blit damaged rects to scanout

Fields§

§canvas: Surface<'a>§min_ticks: u64§last_present_tick: u64§presented: bool

False until the first successful present, so the first frame is not dropped by the rate limiter when the tick counter starts near zero.

Implementations§

Source§

impl<'a> Presenter<'a>

Source

pub fn new(canvas: Surface<'a>) -> Self

Wrap a scanout surface. The first release is always immediate.

Source

pub unsafe fn from_fb( base: NonNull<u8>, dims: Dims, pitch: usize, format: Format, ops: FramebufferOps, ) -> Result<Self, Error>

Build a presenter over a physical framebuffer.

§Safety

Same contract as surface_from_fb, plus exclusive ownership of the scanout for 'a.

Source

pub fn canvas(&self) -> &Surface<'a>

Source

pub fn canvas_mut(&mut self) -> &mut Surface<'a>

Mutable access to the scanout surface. Draw here only for content that must survive without a back buffer (cursor, early console).

Source

pub fn min_ticks(&self) -> u64

Source

pub fn set_min_ticks(&mut self, ticks: u64)

Override the refresh floor. Zero disables rate limiting.

Source

pub fn invalidate(&mut self)

Force the next Self::present to flush even if the minimum tick interval has not elapsed (mode change, panic console takeover).

Source

pub fn present( &mut self, now_ticks: u64, back: &mut Surface<'_>, ) -> RectSet<MAX_DIRTY_RECTS>

Flush the damaged rectangles of back to the scanout.

Returns the damage that was actually presented (empty when the rate limiter suppressed the frame, or when nothing was damaged). The caller keeps ownership of back; its damage set is cleared.

Both surfaces must share the same format. On a mismatch the frame is skipped without consuming the damage, rather than panicking or silently swapping channels: presentation must never take the kernel down.

Source

pub fn present_owned( &mut self, now_ticks: u64, back: &mut OwnedSurface<KernelOps>, ) -> RectSet<MAX_DIRTY_RECTS>

Same contract as Self::present, for a heap back buffer.

Source

pub fn present_full(&mut self, now_ticks: u64, back: &mut Surface<'_>)

Present the whole surface, ignoring damage. Used on the first frame, after a resolution change, or when coming back from a blank screen.

Source

pub fn present_full_owned( &mut self, now_ticks: u64, back: &mut OwnedSurface<KernelOps>, )

Same contract as Self::present_full, for a heap back buffer.

Source

fn due(&self, now_ticks: u64) -> bool

True when the refresh floor allows a flush now.

Source

fn format_matches<S: Source + ?Sized>(&self, back: &S) -> bool

Source

fn flush<S: Source + ?Sized>( &mut self, now_ticks: u64, damage: &RectSet<MAX_DIRTY_RECTS>, back: &S, ) -> RectSet<MAX_DIRTY_RECTS>

Common tail of both present paths: choose full-frame or per-rect presentation, flush the write-combining stores and update the clock.

Source

fn blit_damage<S: Source + ?Sized>( &mut self, damage: &RectSet<MAX_DIRTY_RECTS>, back: &S, )

Copy one rectangle of back per damage entry.

Source

fn full<S: Source + ?Sized>(&mut self, back: &S)

Copy the whole overlap between the scanout and back.

Auto Trait Implementations§

§

impl<'a> !Sync for Presenter<'a>

§

impl<'a> !UnwindSafe for Presenter<'a>

§

impl<'a> Forget for Presenter<'a>

§

impl<'a> Freeze for Presenter<'a>

§

impl<'a> Move for Presenter<'a>

§

impl<'a> RefUnwindSafe for Presenter<'a>

§

impl<'a> Send for Presenter<'a>

§

impl<'a> Unpin for Presenter<'a>

§

impl<'a> UnsafeUnpin for Presenter<'a>

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
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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.