pub enum PixelData {
Bgra(Arc<Vec<u8>>),
Rgba(Arc<Vec<u8>>),
Nv12 {
data: Arc<Vec<u8>>,
y_stride: usize,
uv_stride: usize,
},
DmaBuf {
fd: Arc<OwnedFd>,
fourcc: u32,
modifier: u64,
stride: u32,
offset: u32,
},
}Expand description
Pixel data in its native format, avoiding unnecessary colorspace conversions.
The inner buffers are wrapped in Arc so that cloning PixelData is O(1)
(refcount bump) rather than a multi-megabyte memcpy.
Variants§
Bgra(Arc<Vec<u8>>)
BGRA packed pixels (from Wayland SHM buffers). Layout: [B, G, R, A] per pixel, row-major, no padding.
Rgba(Arc<Vec<u8>>)
RGBA packed pixels (legacy path / capture conversions). Layout: [R, G, B, A] per pixel, row-major, no padding.
Nv12
NV12 planar: Y plane followed by interleaved UV plane.
y_stride and uv_stride may differ from width (DMA-BUF padding).
Stored contiguously: data[..y_stride*height] is Y,
data[y_stride*height..] is UV.
DmaBuf
DMA-BUF file descriptor for zero-copy GPU encoding.
The fd is dup’d from the Wayland buffer — the original wl_buffer has been released, but this fd keeps the DMA-BUF kernel object alive. The encoder imports this directly into GPU memory (VA-API VPP or CUDA-EGL) without any CPU-side pixel copies.
Implementations§
Source§impl PixelData
impl PixelData
Sourcepub fn to_rgba(&self, width: u32, height: u32) -> Vec<u8> ⓘ
pub fn to_rgba(&self, width: u32, height: u32) -> Vec<u8> ⓘ
Convert to RGBA for consumers that require it (screenshots, etc.). Panics for DmaBuf variant — callers must handle that case separately.
Sourcepub fn to_bgra_vec(&self, width: u32, height: u32) -> Vec<u8> ⓘ
pub fn to_bgra_vec(&self, width: u32, height: u32) -> Vec<u8> ⓘ
Return the pixel data as BGRA bytes (for compositing). For DmaBuf, attempts mmap readback. Returns empty on failure.
pub fn is_empty(&self) -> bool
Trait Implementations§
Auto Trait Implementations§
impl Freeze for PixelData
impl RefUnwindSafe for PixelData
impl Send for PixelData
impl Sync for PixelData
impl Unpin for PixelData
impl UnsafeUnpin for PixelData
impl UnwindSafe for PixelData
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.