Skip to main content

Frame

Struct Frame 

Source
pub struct Frame<'a> { /* private fields */ }
Expand description

A borrowed, writable pixel buffer for exactly one frame.

Obtained from Surface::acquire and released by dropping it, after which the same surface must be told what changed via Surface::present.

stride is in pixels, not bytes, and may exceed size.width: DRM framebuffers are pitch-aligned (64 bytes on vc4, more elsewhere) and fbdev has its own line_length. Never assume stride == width — index rows through Frame::row_mut or Frame::rows_mut.

Implementations§

Source§

impl<'a> Frame<'a>

Source

pub fn new( pixels: &'a mut [u32], size: Size, stride: u32, format: PixelFormat, age: BufferAge, ) -> Result<Self, SurfaceError>

Wraps a backend buffer.

Returns SurfaceError::BufferTooSmall unless stride >= size.width and pixels covers stride * (height - 1) + width words.

Source

pub const fn size(&self) -> Size

Visible extent in physical pixels.

Source

pub const fn stride(&self) -> u32

Distance between the starts of consecutive rows, in pixels.

Source

pub const fn format(&self) -> PixelFormat

Word layout of the buffer.

Source

pub const fn age(&self) -> BufferAge

How stale these contents are. Feed to crate::DamageTracker::resolve.

Source

pub fn pixels(&self) -> &[u32]

Full backing slice, including any inter-row padding.

Source

pub fn pixels_mut(&mut self) -> &mut [u32]

Full backing slice, including any inter-row padding.

Source

pub fn row(&self, y: u32) -> Option<&[u32]>

One row, trimmed to the visible width. Returns None past the bottom edge.

Source

pub fn row_mut(&mut self, y: u32) -> Option<&mut [u32]>

One row, trimmed to the visible width. Returns None past the bottom edge.

Source

pub fn rows_mut(&mut self) -> impl Iterator<Item = &mut [u32]>

Every visible row, top to bottom, each trimmed to the visible width.

Trait Implementations§

Source§

impl<'a> Debug for Frame<'a>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

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

§

impl<'a> Freeze for Frame<'a>

§

impl<'a> RefUnwindSafe for Frame<'a>

§

impl<'a> Send for Frame<'a>

§

impl<'a> Sync for Frame<'a>

§

impl<'a> Unpin for Frame<'a>

§

impl<'a> UnsafeUnpin for Frame<'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
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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.