Struct smithay_client_toolkit::shm::slot::Buffer
source · pub struct Buffer { /* private fields */ }
Expand description
A wrapper around a [wl_buffer::WlBuffer
] which has been allocated via a SlotPool.
When this object is dropped, the buffer will be destroyed immediately if it is not active, or upon the server’s release if it is.
Implementations§
source§impl Buffer
impl Buffer
sourcepub fn attach_to(&self, surface: &WlSurface) -> Result<(), ActivateSlotError>
pub fn attach_to(&self, surface: &WlSurface) -> Result<(), ActivateSlotError>
Attach a buffer to a surface.
This marks the slot as active until the server releases the buffer, which will happen automatically assuming the surface is committed without attaching a different buffer.
Note: if you need to ensure that canvas()
calls never return data that
could be attached to a surface in a multi-threaded client, make this call while you have
exclusive access to the corresponding SlotPool
.
pub fn height(&self) -> i32
pub fn stride(&self) -> i32
sourcepub fn canvas<'pool>(
&self,
pool: &'pool mut SlotPool,
) -> Option<&'pool mut [u8]>
pub fn canvas<'pool>( &self, pool: &'pool mut SlotPool, ) -> Option<&'pool mut [u8]>
Get the bytes corresponding to this buffer if drawing is permitted.
This may be smaller than the canvas associated with the slot.
sourcepub fn activate(&self) -> Result<(), ActivateSlotError>
pub fn activate(&self) -> Result<(), ActivateSlotError>
Manually mark a buffer as active.
An active buffer prevents drawing on its slot until a Release event is received or until manually deactivated.
sourcepub fn deactivate(&self) -> Result<(), ActivateSlotError>
pub fn deactivate(&self) -> Result<(), ActivateSlotError>
Manually mark a buffer as inactive.
This should be used when the buffer was manually marked as active or when a buffer was attached to a surface but not committed. Calling this function on a buffer that was committed to a surface risks making the surface contents undefined.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Buffer
impl !RefUnwindSafe for Buffer
impl Send for Buffer
impl Sync for Buffer
impl Unpin for Buffer
impl !UnwindSafe for Buffer
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<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.