struct GpuCapture {Show 18 fields
encoder: Option<FrameEncoder>,
buffers: Vec<GpuBuffer>,
cursor: Option<CursorSprite>,
cursor_drawn: Option<Rectangle<i32, Physical>>,
overlay: OverlayState,
watermark: Option<Sprite>,
x: XScreen,
gbm: Device<File>,
_egl: Option<EGLDisplay>,
egl_display: *const c_void,
next: usize,
settings: CaptureSettings,
request: CaptureSettings,
cap_x: i16,
cap_y: i16,
root_w: u16,
root_h: u16,
blit_semaphore: Option<u32>,
}Expand description
A running zero-copy capture, on the thread that owns every context in it.
Field order is drop order: the encoder releases its imports before the buffers they describe go, and both go before the GBM device and EGL display they were made on.
Fields§
§encoder: Option<FrameEncoder>None only while a rebuild is replacing the session; a rebuild that fails ends the
capture before another frame is encoded.
buffers: Vec<GpuBuffer>§cursor: Option<CursorSprite>§cursor_drawn: Option<Rectangle<i32, Physical>>Where the last grab drew the cursor, in the frame’s coordinates.
overlay: OverlayStateThe watermark image and where it sits, and the pixmap the server composites it from. Held rather than blended into host pixels, which is what keeps this path zero-copy.
watermark: Option<Sprite>§x: XScreen§gbm: Device<File>§_egl: Option<EGLDisplay>§egl_display: *const c_void§next: usize§settings: CaptureSettingsThe live session: its geometry is what is captured and encoded, and its rate and quality fields follow the cross-thread controls.
request: CaptureSettingsThe geometry that was asked for, which a region change updates and every region is
resolved from, kept apart from settings so a capture following the root keeps following.
cap_x: i16§cap_y: i16§root_w: u16§root_h: u16§blit_semaphore: Option<u32>The server’s id for the encoder’s blit semaphore, which it signals after each blit for
the encode to wait on; None waits for each blit with a GetImage.
Implementations§
Source§impl GpuCapture
impl GpuCapture
Sourcefn alloc_bo(&mut self, w: u16, h: u16) -> Result<BufferObject<()>, String>
fn alloc_bo(&mut self, w: u16, h: u16) -> Result<BufferObject<()>, String>
One buffer of the pool: a single-plane allocation the server and the encoder both describe with one fd, stride, and offset. A modifier that spreads the buffer over auxiliary planes (a compressed layout) is dropped from the server’s list and the allocation retried, down to the driver’s own choice.
Sourcefn alloc_buffers(&mut self, w: u16, h: u16) -> Result<(), String>
fn alloc_buffers(&mut self, w: u16, h: u16) -> Result<(), String>
Allocate the buffer pool at w x h and hand each buffer to the server as a pixmap.
fn free_buffers(&mut self)
Sourcefn reshape(&mut self, w: u16, h: u16) -> Result<(), String>
fn reshape(&mut self, w: u16, h: u16) -> Result<(), String>
Bring the pool and the encoder to a new capture size. NVENC follows in place; a session that cannot is rebuilt through the same ladder that chose it.
fn enc(&mut self) -> &mut FrameEncoder
Sourcefn rebuild_encoder(&mut self) -> Result<(), String>
fn rebuild_encoder(&mut self) -> Result<(), String>
Replace the encoder with the startup construction, releasing the old session first so the two never hold device memory at once.
Sourcefn attach_semaphore(&mut self)
fn attach_semaphore(&mut self)
Give the server the encoder’s blit semaphore, where it offers SELKIES-SEMAPHORE and the encoder can wait on one; otherwise each blit is waited for with a GetImage.
fn detach_semaphore(&mut self)
Sourcefn pointer(&self) -> Option<(i16, i16)>
fn pointer(&self) -> Option<(i16, i16)>
Where the pointer is on the root, or None where the server does not answer.
Sourcefn grab(&mut self, with_cursor: bool) -> Result<(usize, bool), String>
fn grab(&mut self, with_cursor: bool) -> Result<(usize, bool), String>
Blit the capture region into the next pool buffer, composite the cursor if asked, and either have the server signal the blit semaphore after it or wait for it to land. Returns the buffer to encode and whether its encode has to wait on the semaphore.
Sourcefn composite_watermark(&mut self, idx: usize) -> Result<(), String>
fn composite_watermark(&mut self, idx: usize) -> Result<(), String>
Draw the watermark over the freshly blitted frame, on the GPU. The image is uploaded on its first frame and composited by the server after that, so the CPU never sees the pixels it is drawn on; an animated location only moves where it is composited.
Trait Implementations§
Source§impl Drop for GpuCapture
impl Drop for GpuCapture
Auto Trait Implementations§
impl !Freeze for GpuCapture
impl !RefUnwindSafe for GpuCapture
impl !Send for GpuCapture
impl !Sync for GpuCapture
impl !UnwindSafe for GpuCapture
impl Unpin for GpuCapture
impl UnsafeUnpin for GpuCapture
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
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§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.§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.§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.§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.§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
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> ⓘ
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> ⓘ
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