pub struct GpuReadback { /* private fields */ }Expand description
Headless EGL/GLES context for reading a capture dma-buf back to CPU RGBA pixels.
The GPU capture path hands out a wl::DmabufFrame (zero-copy, meant for
display). Tools that ultimately need CPU pixels — screenshot encoding today,
video/timelapse on the roadmap — use this to import that dma-buf as a GL texture
and glReadPixels it into RGBA8. It runs without a window: a 1×1 pbuffer keeps
it portable across drivers that lack surfaceless contexts. Build one and reuse it
across frames (the EGL setup is not free).
Implementations§
Source§impl GpuReadback
impl GpuReadback
Sourcepub fn new() -> Result<Self>
pub fn new() -> Result<Self>
Create the offscreen context. Errors (rather than panicking, unlike
Gpu::new) since callers can fall back to the shm capture path.
Sourcepub fn readback(&mut self, frame: DmabufFrame) -> Result<CapturedImage>
pub fn readback(&mut self, frame: DmabufFrame) -> Result<CapturedImage>
Import frame’s dma-buf as a GL texture and read it back to RGBA8. Alpha is
forced opaque: captures are opaque and XRGB dma-bufs leave the X byte
undefined (mirrors the shm path’s handling of alpha-less formats).
Auto Trait Implementations§
impl !Send for GpuReadback
impl !Sync for GpuReadback
impl Freeze for GpuReadback
impl RefUnwindSafe for GpuReadback
impl Unpin for GpuReadback
impl UnsafeUnpin for GpuReadback
impl UnwindSafe for GpuReadback
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> 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.