Skip to main content

GpuCapture

Struct GpuCapture 

Source
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: OverlayState

The 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: CaptureSettings

The live session: its geometry is what is captured and encoded, and its rate and quality fields follow the cross-thread controls.

§request: CaptureSettings

The 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

Source

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.

Source

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.

Source

fn free_buffers(&mut self)

Source

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.

Source

fn enc(&mut self) -> &mut FrameEncoder

Source

fn backend(&self) -> &'static str

The encoder’s name for the logs.

Source

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.

Source

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.

Source

fn detach_semaphore(&mut self)

Source

fn pointer(&self) -> Option<(i16, i16)>

Where the pointer is on the root, or None where the server does not answer.

Source

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.

Source

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.

Source

fn composite_cursor(&mut self, idx: usize) -> Result<(), String>

Draw the XFixes cursor over the freshly blitted frame, uploading its image only when the cursor changed. The server paints it through Render, on the GPU.

Trait Implementations§

Source§

impl Drop for GpuCapture

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<T> Downcast for T
where T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert 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>

Convert 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)

Convert &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)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

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
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more