pub struct WlFramePool<B = Vec<u8>> {
pub(crate) inner: Mutex<WlPoolInner<B>>,
pub(crate) cv: Condvar,
pub(crate) stop: AtomicBool,
}Expand description
Render->encode handoff for the Wayland readback paths, mirroring the X11 FramePool’s
single-slot non-dropping design with one deliberate difference: the calloop thread is also
the compositor + input dispatcher, so it must NEVER block on the pool. try_begin hands
out a buffer only while the publish slot is empty, so publish cannot block, and a
saturated encoder throttles capture by SKIPPING ticks (compositor damage accumulates via
buffer age, so nothing is lost). Every published frame is encoded, in order: the H.264
reference chain stays contiguous exactly as on X11.
The zero-copy session runs the same split on GPU buffers: the calloop composites into one of the pool’s render targets and publishes it, and the encode thread encodes it in place, so the compositor thread is free again as soon as the composite is.
Fields§
§inner: Mutex<WlPoolInner<B>>§cv: Condvar§stop: AtomicBoolImplementations§
Source§impl WlFramePool<Vec<u8>>
impl WlFramePool<Vec<u8>>
Source§impl<B> WlFramePool<B>
impl<B> WlFramePool<B>
Sourcepub(crate) fn of(buffers: Vec<B>) -> Self
pub(crate) fn of(buffers: Vec<B>) -> Self
A pool of the buffers given, all initially free, numbered in order.
Sourcepub(crate) fn try_begin(&self) -> Option<(usize, B)>
pub(crate) fn try_begin(&self) -> Option<(usize, B)>
Calloop: reserve a buffer for the next render/readback, NON-blocking. None means the
encoder is still behind (slot full or every buffer in flight) – skip this tick.
Because the calloop is the only producer, a successful reservation guarantees the
following publish finds the slot empty (the consumer only ever drains it).
Sourcepub(crate) fn publish(&self, frame: WlFrame<B>)
pub(crate) fn publish(&self, frame: WlFrame<B>)
Calloop: hand the filled buffer to the encode thread. Never blocks (see try_begin).
Sourcepub(crate) fn cancel(&self, id: usize, buf: B)
pub(crate) fn cancel(&self, id: usize, buf: B)
Calloop: return an unused reservation (render failed, readback skipped).
Sourcepub(crate) fn take(&self) -> Option<WlFrame<B>>
pub(crate) fn take(&self) -> Option<WlFrame<B>>
Encode: block until a frame is published (Some) or the pool shuts down (None). The
wait is bounded, re-checking stop as defense-in-depth against a lost wakeup.
Auto Trait Implementations§
impl<B = Vec<u8>> !Freeze for WlFramePool<B>
impl<B> RefUnwindSafe for WlFramePool<B>
impl<B> Send for WlFramePool<B>where
B: Send,
impl<B> Sync for WlFramePool<B>where
B: Send,
impl<B> Unpin for WlFramePool<B>where
B: Unpin,
impl<B> UnsafeUnpin for WlFramePool<B>where
B: UnsafeUnpin,
impl<B> UnwindSafe for WlFramePool<B>
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> DowncastSync for T
impl<T> DowncastSync for T
§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