pub struct Frame { /* private fields */ }Expand description
Rendered frame containing pixel data.
The pixel buffer is reference-counted (Arc) so that cloning a frame — e.g.
returning a cached static frame for a new timestamp — is O(1) and shares the
pixels. Mutating accessors use copy-on-write, so an exclusively-owned frame is
still mutated in place.
Implementations§
Source§impl Frame
impl Frame
Sourcepub fn new(buffer: Vec<u8>, width: u32, height: u32, timestamp: u32) -> Self
pub fn new(buffer: Vec<u8>, width: u32, height: u32, timestamp: u32) -> Self
Create a new frame with the given buffer
Sourcepub fn from_rgba(buffer: Vec<u8>, width: u32, height: u32) -> Self
pub fn from_rgba(buffer: Vec<u8>, width: u32, height: u32) -> Self
Create a frame from RGBA data
Sourcepub fn with_format(
buffer: Vec<u8>,
width: u32,
height: u32,
timestamp: u32,
format: PixelFormat,
) -> Self
pub fn with_format( buffer: Vec<u8>, width: u32, height: u32, timestamp: u32, format: PixelFormat, ) -> Self
Create a new frame with specific pixel format
Sourcepub fn empty(width: u32, height: u32, timestamp: u32) -> Self
pub fn empty(width: u32, height: u32, timestamp: u32) -> Self
Create an empty frame (transparent)
Sourcepub fn with_timestamp(&self, timestamp: u32) -> Self
pub fn with_timestamp(&self, timestamp: u32) -> Self
Clone this frame sharing its pixel buffer (O(1)) but with a new timestamp. Used to serve a cached static frame for the current time without copying.
Sourcepub fn data_mut(&mut self) -> &mut [u8] ⓘ
pub fn data_mut(&mut self) -> &mut [u8] ⓘ
Get mutable frame buffer data (copy-on-write if the buffer is shared)
Sourcepub fn into_buffer(self) -> Vec<u8> ⓘ
pub fn into_buffer(self) -> Vec<u8> ⓘ
Take ownership of the buffer (clones only if the buffer is still shared)
Sourcepub fn bytes_per_pixel(&self) -> usize
pub fn bytes_per_pixel(&self) -> usize
Get bytes per pixel
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Frame
impl RefUnwindSafe for Frame
impl Send for Frame
impl Sync for Frame
impl Unpin for Frame
impl UnsafeUnpin for Frame
impl UnwindSafe for Frame
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
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 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>
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