pub struct AutoMemPool { /* private fields */ }
Expand description

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 committed to a surface (and then never released by the server) would result in that memory being unavailable 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.

The default alignment of returned buffers is 16 bytes; this can be changed by using the explicit with_min_align constructor.

Implementations

Create a new memory pool associated with the given shm

Create a new memory pool associated with the given shm.

All buffers will be aligned to at least the value of (align), which must be a power of two not greater than 4096.

Resize the memory pool

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

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

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.

Trait Implementations

Formats the value using the given formatter. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.