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]
impl AutoMemPool
[src]pub fn new(shm: Attached<WlShm>) -> Result<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]
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]
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 oneformat
: the encoding format of the pixels. Using a format that was not advertised to thewl_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]
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.