single-pixel-buffer: send wl_buffer.release

This commit is contained in:
Kirill Primak 2024-01-18 21:19:26 +03:00
parent 58bb49a00b
commit 0b090c83fb

View file

@ -19,6 +19,8 @@ struct wlr_single_pixel_buffer_v1 {
struct wl_resource *resource;
uint32_t r, g, b, a;
uint8_t argb8888[4]; // packed little-endian DRM_FORMAT_ARGB8888
struct wl_listener release;
};
static void destroy_resource(struct wl_client *client,
@ -60,6 +62,7 @@ static void buffer_destroy(struct wlr_buffer *wlr_buffer) {
if (buffer->resource != NULL) {
wl_resource_set_user_data(buffer->resource, NULL);
}
wl_list_remove(&buffer->release.link);
free(buffer);
}
@ -92,6 +95,13 @@ static void buffer_handle_resource_destroy(struct wl_resource *resource) {
wlr_buffer_drop(&buffer->base);
}
static void buffer_handle_release(struct wl_listener *listener, void *data) {
struct wlr_single_pixel_buffer_v1 *buffer = wl_container_of(listener, buffer, release);
if (buffer->resource != NULL) {
wl_buffer_send_release(buffer->resource);
}
}
static void manager_handle_create_u32_rgba_buffer(struct wl_client *client,
struct wl_resource *resource, uint32_t id, uint32_t r, uint32_t g,
uint32_t b, uint32_t a) {
@ -122,6 +132,9 @@ static void manager_handle_create_u32_rgba_buffer(struct wl_client *client,
buffer->argb8888[1] = (uint8_t)((double)buffer->g * f);
buffer->argb8888[2] = (uint8_t)((double)buffer->r * f);
buffer->argb8888[3] = (uint8_t)((double)buffer->a * f);
buffer->release.notify = buffer_handle_release;
wl_signal_add(&buffer->base.events.release, &buffer->release);
}
static const struct wp_single_pixel_buffer_manager_v1_interface manager_impl = {