Product SiteDocumentation Site

A.5. wl_shm_pool - a shared memory pool

The wl_shm_pool object encapsulates a piece of memory shared between the compositor and client. Through the wl_shm_pool object, the client can allocate shared memory wl_buffer objects. The objects will share the same underlying mapped memory. Reusing the mapped memory avoids the setup/teardown overhead and is useful when interactively resizing a surface or for many small buffers.

A.5.1. Requests provided by wl_shm_pool

A.5.1.1. wl_shm_pool::create_buffer - create wl_buffer from pool

Create a wl_buffer from the pool. The buffer is created a offset bytes into the pool and has width and height as specified. The stride arguments specifies the number of bytes from beginning of one row to the beginning of the next. The format is the pixel format of the buffer and must be one of those advertised through the wl_shm.format event.
A buffer will keep a reference to the pool it was created from so it is valid to destroy the pool immediately after creating a buffer from it.
wl_shm_pool::create_buffer arguments
id
Type: new_id
offset
Type: int
width
Type: int
height
Type: int
stride
Type: int
format
Type: uint

A.5.1.2. wl_shm_pool::destroy - destroy the pool

Destroy the pool.

A.5.1.3. wl_shm_pool::resize - change the size of the pool mapping

This request will cause the server to remap the backing memory for the pool from the fd passed when the pool was creating but using the new size.
wl_shm_pool::resize arguments
size
Type: int