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>
impl<'a> Frame<'a>
Sourcepub fn new(
pixels: &'a mut [u32],
size: Size,
stride: u32,
format: PixelFormat,
age: BufferAge,
) -> Result<Self, SurfaceError>
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.
Sourcepub const fn format(&self) -> PixelFormat
pub const fn format(&self) -> PixelFormat
Word layout of the buffer.
Sourcepub const fn age(&self) -> BufferAge
pub const fn age(&self) -> BufferAge
How stale these contents are. Feed to crate::DamageTracker::resolve.
Sourcepub fn pixels_mut(&mut self) -> &mut [u32]
pub fn pixels_mut(&mut self) -> &mut [u32]
Full backing slice, including any inter-row padding.
Sourcepub fn row(&self, y: u32) -> Option<&[u32]>
pub fn row(&self, y: u32) -> Option<&[u32]>
One row, trimmed to the visible width. Returns None past the bottom edge.