Struct smithay_client_toolkit::shm::AutoMemPool[][src]

pub struct AutoMemPool { /* fields omitted */ }

A wrapper handling an SHM memory pool backed by a shared memory file

This wrapper handles the creation of the shared memory file, its synchronization with the protocol, and the allocation of buffers within the pool.

AutoMemPool internally tracks the release of the buffers by the compositor. As such, creating a buffer that is not commited to a surface (and then never released by the server) would result in that memory being unavailble for the rest of the pool’s lifetime.

AutoMemPool will also handle the destruction of buffers; do not call destroy() on the returned WlBuffer objects.

Implementations

impl AutoMemPool[src]

pub fn new(shm: Attached<WlShm>) -> Result<AutoMemPool>[src]

Create a new memory pool associated with the given shm

pub fn resize(&mut self, new_size: usize) -> Result<()>[src]

Resize the memory pool

This is normally done automatically, but can be used to avoid multiple resizes.

pub fn buffer(
    &mut self,
    width: i32,
    height: i32,
    stride: i32,
    format: Format
) -> Result<(&mut [u8], WlBuffer)>
[src]

Create a new buffer in this pool

The parameters are:

  • width: the width of this buffer (in pixels)
  • height: the height of this buffer (in pixels)
  • stride: distance (in bytes) between the beginning of a row and the next one
  • format: the encoding format of the pixels. Using a format that was not advertised to the wl_shm global by the server is a protocol error and will terminate your connection

pub fn try_draw<F, E>(
    &mut self,
    width: i32,
    height: i32,
    stride: i32,
    format: Format,
    draw: F
) -> Result<WlBuffer, E> where
    F: FnOnce(&mut [u8]) -> Result<(), E>,
    E: From<Error>, 
[src]

Try drawing with the given closure

This is identical to buffer(), but will only actually create the WlBuffer if the draw closure succeeds. Otherwise, the buffer is freed immediately instead of waiting for a Release event that will never be sent if the WlBuffer is not used.

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

impl<T> From<T> for T[src]

pub fn from(t: T) -> T[src]

Performs the conversion.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

pub fn into(self) -> U[src]

Performs the conversion.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

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

Performs the conversion.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

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

Performs the conversion.