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 scanoutFields§
§canvas: Surface<'a>§min_ticks: u64§last_present_tick: u64§presented: boolFalse 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>
impl<'a> Presenter<'a>
Sourcepub fn new(canvas: Surface<'a>) -> Self
pub fn new(canvas: Surface<'a>) -> Self
Wrap a scanout surface. The first release is always immediate.
Sourcepub unsafe fn from_fb(
base: NonNull<u8>,
dims: Dims,
pitch: usize,
format: Format,
ops: FramebufferOps,
) -> Result<Self, Error>
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.
pub fn canvas(&self) -> &Surface<'a>
Sourcepub fn canvas_mut(&mut self) -> &mut Surface<'a>
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).
pub fn min_ticks(&self) -> u64
Sourcepub fn set_min_ticks(&mut self, ticks: u64)
pub fn set_min_ticks(&mut self, ticks: u64)
Override the refresh floor. Zero disables rate limiting.
Sourcepub fn invalidate(&mut self)
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).
Sourcepub fn present(
&mut self,
now_ticks: u64,
back: &mut Surface<'_>,
) -> RectSet<MAX_DIRTY_RECTS>
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.
Sourcepub fn present_owned(
&mut self,
now_ticks: u64,
back: &mut OwnedSurface<KernelOps>,
) -> RectSet<MAX_DIRTY_RECTS>
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.
Sourcepub fn present_full(&mut self, now_ticks: u64, back: &mut Surface<'_>)
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.
Sourcepub fn present_full_owned(
&mut self,
now_ticks: u64,
back: &mut OwnedSurface<KernelOps>,
)
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.
fn format_matches<S: Source + ?Sized>(&self, back: &S) -> bool
Sourcefn flush<S: Source + ?Sized>(
&mut self,
now_ticks: u64,
damage: &RectSet<MAX_DIRTY_RECTS>,
back: &S,
) -> RectSet<MAX_DIRTY_RECTS>
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.
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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