The wl_shm_pool interface

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. All objects created through the same pool 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. More...

## Macros

#define | WL_SHM_POOL_CREATE_BUFFER_SINCE_VERSION 1
#define | WL_SHM_POOL_DESTROY_SINCE_VERSION 1
#define | WL_SHM_POOL_RESIZE_SINCE_VERSION 1

## Functions

static void | wl_shm_pool_set_user_data (struct wl_shm_pool *wl_shm_pool, void *user_data)
static void * | wl_shm_pool_get_user_data (struct wl_shm_pool *wl_shm_pool)
static struct wl_buffer * | wl_shm_pool_create_buffer (struct wl_shm_pool *wl_shm_pool, int32_t offset, int32_t width, int32_t height, int32_t stride, uint32_t format)
static void | wl_shm_pool_destroy (struct wl_shm_pool *wl_shm_pool)
static void | wl_shm_pool_resize (struct wl_shm_pool *wl_shm_pool, int32_t size)

## Detailed Description

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. All objects created through the same pool 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.

## Macro Definition Documentation

## WL_SHM_POOL_CREATE_BUFFER_SINCE_VERSION

#define WL_SHM_POOL_CREATE_BUFFER_SINCE_VERSION 1

Definition at line 1225 of file wayland-client-protocol.h.

## WL_SHM_POOL_DESTROY_SINCE_VERSION

#define WL_SHM_POOL_DESTROY_SINCE_VERSION 1

Definition at line 1229 of file wayland-client-protocol.h.

## WL_SHM_POOL_RESIZE_SINCE_VERSION

#define WL_SHM_POOL_RESIZE_SINCE_VERSION 1

Definition at line 1233 of file wayland-client-protocol.h.

## Function Documentation

## wl_shm_pool_create_buffer()

static struct wl_buffer* wl_shm_pool_create_buffer | ( | struct wl_shm_pool * | wl_shm_pool,
|  | int32_t | offset,
|  | int32_t | width,
|  | int32_t | height,
|  | int32_t | stride,
|  | uint32_t | format
| ) |  |

inline static

Create a wl_buffer object from the pool.

The buffer is created offset bytes into the pool and has width and height as specified. The stride argument specifies the number of bytes from the 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.

Definition at line 1271 of file wayland-client-protocol.h.

{
struct wl_proxy *id;
id = wl_proxy_marshal_constructor((struct wl_proxy *) wl_shm_pool,
WL_SHM_POOL_CREATE_BUFFER, &wl_buffer_interface, NULL, offset, width, height, stride, format);
return (struct wl_buffer *) id;
}

References NULL, wl_buffer_interface, and WL_SHM_POOL_CREATE_BUFFER.

## wl_shm_pool_destroy()

static void wl_shm_pool_destroy | ( | struct wl_shm_pool * | wl_shm_pool | ) |

inline static

Destroy the shared memory pool.

The mmapped memory will be released when all buffers that have been created from this pool are gone.

Definition at line 1291 of file wayland-client-protocol.h.

{
wl_proxy_marshal((struct wl_proxy *) wl_shm_pool,
WL_SHM_POOL_DESTROY);
wl_proxy_destroy((struct wl_proxy *) wl_shm_pool);
}

References WL_SHM_POOL_DESTROY.

## wl_shm_pool_get_user_data()

static void* wl_shm_pool_get_user_data | ( | struct wl_shm_pool * | wl_shm_pool | ) |

inline static

Definition at line 1244 of file wayland-client-protocol.h.

{
return wl_proxy_get_user_data((struct wl_proxy *) wl_shm_pool);
}

## wl_shm_pool_resize()

static void wl_shm_pool_resize | ( | struct wl_shm_pool * | wl_shm_pool,
|  | int32_t | size
| ) |  |

inline static

This request will cause the server to remap the backing memory for the pool from the file descriptor passed when the pool was created, but using the new size. This request can only be used to make the pool bigger.

Definition at line 1308 of file wayland-client-protocol.h.

{
wl_proxy_marshal((struct wl_proxy *) wl_shm_pool,
WL_SHM_POOL_RESIZE, size);
}

References WL_SHM_POOL_RESIZE.

## wl_shm_pool_set_user_data()

static void wl_shm_pool_set_user_data | ( | struct wl_shm_pool * | wl_shm_pool,
|  | void * | user_data
| ) |  |

inline static

Definition at line 1237 of file wayland-client-protocol.h.

{
wl_proxy_set_user_data((struct wl_proxy *) wl_shm_pool, user_data);
}
format
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: SDL_opengl.h:1572
offset
GLintptr offset
Definition: SDL_opengl_glext.h:538
NULL
#define NULL
Definition: begin_code.h:167
width
GLint GLint GLsizei width
Definition: SDL_opengl.h:1572
WL_SHM_POOL_RESIZE
#define WL_SHM_POOL_RESIZE
Definition: wayland-client-protocol.h:1219
height
GLint GLint GLsizei GLsizei height
Definition: SDL_opengl.h:1572
wl_buffer_interface
const struct wl_interface wl_buffer_interface
Definition: wayland-protocol.c:235
size
GLsizeiptr size
Definition: SDL_opengl_glext.h:537
id
GLuint id
Definition: SDL_opengl_glext.h:528
WL_SHM_POOL_CREATE_BUFFER
#define WL_SHM_POOL_CREATE_BUFFER
Definition: wayland-client-protocol.h:1217
WL_SHM_POOL_DESTROY
#define WL_SHM_POOL_DESTROY
Definition: wayland-client-protocol.h:1218
stride
GLsizei stride
Definition: SDL_opengl_glext.h:378