2021-02-17 02:22:28 +01:00
|
|
|
#ifndef TYPES_WLR_BUFFER
|
|
|
|
#define TYPES_WLR_BUFFER
|
|
|
|
|
|
|
|
#include <wlr/types/wlr_buffer.h>
|
2021-04-26 19:48:35 +02:00
|
|
|
|
2021-04-14 19:11:35 +02:00
|
|
|
struct wlr_shm_client_buffer {
|
|
|
|
struct wlr_buffer base;
|
|
|
|
|
|
|
|
uint32_t format;
|
|
|
|
size_t stride;
|
|
|
|
|
|
|
|
// The following fields are NULL if the client has destroyed the wl_buffer
|
|
|
|
struct wl_resource *resource;
|
|
|
|
struct wl_shm_buffer *shm_buffer;
|
|
|
|
|
|
|
|
// This is used to keep the backing storage alive after the client has
|
|
|
|
// destroyed the wl_buffer
|
|
|
|
struct wl_shm_pool *saved_shm_pool;
|
|
|
|
void *saved_data;
|
|
|
|
|
|
|
|
struct wl_listener resource_destroy;
|
|
|
|
struct wl_listener release;
|
|
|
|
};
|
|
|
|
|
2022-09-16 18:32:22 +02:00
|
|
|
struct wlr_shm_client_buffer *shm_client_buffer_get_or_create(
|
|
|
|
struct wl_resource *resource);
|
|
|
|
|
2021-06-29 20:11:38 +02:00
|
|
|
/**
|
|
|
|
* A read-only buffer that holds a data pointer.
|
|
|
|
*
|
|
|
|
* This is suitable for passing raw pixel data to a function that accepts a
|
|
|
|
* wlr_buffer.
|
|
|
|
*/
|
|
|
|
struct wlr_readonly_data_buffer {
|
|
|
|
struct wlr_buffer base;
|
|
|
|
|
|
|
|
const void *data;
|
|
|
|
uint32_t format;
|
|
|
|
size_t stride;
|
|
|
|
|
|
|
|
void *saved_data;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Wraps a read-only data pointer into a wlr_buffer. The data pointer may be
|
|
|
|
* accessed until readonly_data_buffer_drop() is called.
|
|
|
|
*/
|
|
|
|
struct wlr_readonly_data_buffer *readonly_data_buffer_create(uint32_t format,
|
|
|
|
size_t stride, uint32_t width, uint32_t height, const void *data);
|
|
|
|
/**
|
|
|
|
* Drops ownership of the buffer (see wlr_buffer_drop() for more details) and
|
|
|
|
* perform a copy of the data pointer if a consumer still has the buffer locked.
|
|
|
|
*/
|
|
|
|
bool readonly_data_buffer_drop(struct wlr_readonly_data_buffer *buffer);
|
|
|
|
|
2021-06-29 21:01:11 +02:00
|
|
|
struct wlr_dmabuf_buffer {
|
|
|
|
struct wlr_buffer base;
|
|
|
|
struct wlr_dmabuf_attributes dmabuf;
|
|
|
|
bool saved;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Wraps a DMA-BUF into a wlr_buffer. The DMA-BUF may be accessed until
|
|
|
|
* dmabuf_buffer_drop() is called.
|
|
|
|
*/
|
|
|
|
struct wlr_dmabuf_buffer *dmabuf_buffer_create(
|
|
|
|
struct wlr_dmabuf_attributes *dmabuf);
|
|
|
|
/**
|
|
|
|
* Drops ownership of the buffer (see wlr_buffer_drop() for more details) and
|
|
|
|
* takes a reference to the DMA-BUF (by dup'ing its file descriptors) if a
|
|
|
|
* consumer still has the buffer locked.
|
|
|
|
*/
|
|
|
|
bool dmabuf_buffer_drop(struct wlr_dmabuf_buffer *buffer);
|
|
|
|
|
2022-06-16 14:43:24 +02:00
|
|
|
/**
|
|
|
|
* Check whether a buffer is fully opaque.
|
|
|
|
*
|
|
|
|
* When true is returned, the buffer is guaranteed to be fully opaque, but the
|
|
|
|
* reverse is not true: false may be returned in cases where the buffer is fully
|
|
|
|
* opaque.
|
|
|
|
*/
|
|
|
|
bool buffer_is_opaque(struct wlr_buffer *buffer);
|
|
|
|
|
2021-02-17 02:22:28 +01:00
|
|
|
#endif
|