mirror of
https://gitlab.freedesktop.org/wlroots/wlroots.git
synced 2025-11-17 06:59:43 -05:00
Introduce wlr_client_buffer
Split out the client/resource handling out of wlr_buffer by introducing
wlr_client_buffer. Make wlr_buffer an interface so that compositors can
create their own wlr_buffers (e.g. backed by GBM, like glider [1]).
[1]: c66847dd1c/include/gbm_allocator.h (L7)
This commit is contained in:
parent
8d2e8d8a06
commit
8afc1ed68c
4 changed files with 154 additions and 85 deletions
|
|
@ -13,14 +13,52 @@
|
|||
#include <wayland-server-core.h>
|
||||
#include <wlr/render/dmabuf.h>
|
||||
|
||||
struct wlr_buffer;
|
||||
|
||||
struct wlr_buffer_impl {
|
||||
void (*destroy)(struct wlr_buffer *buffer);
|
||||
bool (*get_dmabuf)(struct wlr_buffer *buffer,
|
||||
struct wlr_dmabuf_attributes *attribs);
|
||||
};
|
||||
|
||||
struct wlr_buffer {
|
||||
const struct wlr_buffer_impl *impl;
|
||||
|
||||
size_t n_refs;
|
||||
};
|
||||
|
||||
void wlr_buffer_init(struct wlr_buffer *buffer,
|
||||
const struct wlr_buffer_impl *impl);
|
||||
/**
|
||||
* Reference the buffer.
|
||||
*/
|
||||
struct wlr_buffer *wlr_buffer_ref(struct wlr_buffer *buffer);
|
||||
/**
|
||||
* Unreference the buffer. After this call, `buffer` may not be accessed
|
||||
* anymore.
|
||||
*/
|
||||
void wlr_buffer_unref(struct wlr_buffer *buffer);
|
||||
/**
|
||||
* Reads the DMA-BUF attributes of the buffer. If this buffer isn't a DMA-BUF,
|
||||
* returns false.
|
||||
*/
|
||||
bool wlr_buffer_get_dmabuf(struct wlr_buffer *buffer,
|
||||
struct wlr_dmabuf_attributes *attribs);
|
||||
|
||||
/**
|
||||
* A client buffer.
|
||||
*/
|
||||
struct wlr_buffer {
|
||||
struct wlr_client_buffer {
|
||||
struct wlr_buffer base;
|
||||
|
||||
/**
|
||||
* The buffer resource, if any. Will be NULL if the client destroys it.
|
||||
*/
|
||||
struct wl_resource *resource;
|
||||
/**
|
||||
* Whether a release event has been sent to the resource.
|
||||
*/
|
||||
bool resource_released;
|
||||
/**
|
||||
* The buffer's texture, if any. A buffer will not have a texture if the
|
||||
* client destroys the buffer before it has been released.
|
||||
|
|
@ -41,23 +79,13 @@ bool wlr_resource_is_buffer(struct wl_resource *resource);
|
|||
/**
|
||||
* Get the size of a wl_buffer resource.
|
||||
*/
|
||||
bool wlr_buffer_get_resource_size(struct wl_resource *resource,
|
||||
bool wlr_resource_get_buffer_size(struct wl_resource *resource,
|
||||
struct wlr_renderer *renderer, int *width, int *height);
|
||||
|
||||
/**
|
||||
* Upload a buffer to the GPU and reference it.
|
||||
*/
|
||||
struct wlr_buffer *wlr_buffer_create(struct wlr_renderer *renderer,
|
||||
struct wl_resource *resource);
|
||||
/**
|
||||
* Reference the buffer.
|
||||
*/
|
||||
struct wlr_buffer *wlr_buffer_ref(struct wlr_buffer *buffer);
|
||||
/**
|
||||
* Unreference the buffer. After this call, `buffer` may not be accessed
|
||||
* anymore.
|
||||
*/
|
||||
void wlr_buffer_unref(struct wlr_buffer *buffer);
|
||||
struct wlr_client_buffer *wlr_client_buffer_create(
|
||||
struct wlr_renderer *renderer, struct wl_resource *resource);
|
||||
/**
|
||||
* Try to update the buffer's content. On success, returns the updated buffer
|
||||
* and destroys the provided `buffer`. On error, `buffer` is intact and NULL is
|
||||
|
|
@ -66,13 +94,8 @@ void wlr_buffer_unref(struct wlr_buffer *buffer);
|
|||
* Fails if there's more than one reference to the buffer or if the texture
|
||||
* isn't mutable.
|
||||
*/
|
||||
struct wlr_buffer *wlr_buffer_apply_damage(struct wlr_buffer *buffer,
|
||||
struct wl_resource *resource, pixman_region32_t *damage);
|
||||
/**
|
||||
* Reads the DMA-BUF attributes of the buffer. If this buffer isn't a DMA-BUF,
|
||||
* returns false.
|
||||
*/
|
||||
bool wlr_buffer_get_dmabuf(struct wlr_buffer *buffer,
|
||||
struct wlr_dmabuf_attributes *attribs);
|
||||
struct wlr_client_buffer *wlr_client_buffer_apply_damage(
|
||||
struct wlr_client_buffer *buffer, struct wl_resource *resource,
|
||||
pixman_region32_t *damage);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ struct wlr_surface {
|
|||
* have a buffer if it has never committed one, has committed a null buffer,
|
||||
* or something went wrong with uploading the buffer.
|
||||
*/
|
||||
struct wlr_buffer *buffer;
|
||||
struct wlr_client_buffer *buffer;
|
||||
/**
|
||||
* The buffer position, in surface-local units.
|
||||
*/
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue