buffer: add wlr_client_buffer_get
This commit is contained in:
parent
b0a663d39d
commit
0b40d09a21
|
@ -103,6 +103,11 @@ struct wlr_client_buffer {
|
||||||
|
|
||||||
struct wlr_renderer;
|
struct wlr_renderer;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a client buffer from a generic buffer. If the buffer isn't a client
|
||||||
|
* buffer, returns NULL.
|
||||||
|
*/
|
||||||
|
struct wlr_client_buffer *wlr_client_buffer_get(struct wlr_buffer *buffer);
|
||||||
/**
|
/**
|
||||||
* Check if a resource is a wl_buffer resource.
|
* Check if a resource is a wl_buffer resource.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -96,10 +96,18 @@ bool wlr_resource_get_buffer_size(struct wl_resource *resource,
|
||||||
|
|
||||||
static const struct wlr_buffer_impl client_buffer_impl;
|
static const struct wlr_buffer_impl client_buffer_impl;
|
||||||
|
|
||||||
|
struct wlr_client_buffer *wlr_client_buffer_get(struct wlr_buffer *buffer) {
|
||||||
|
if (buffer->impl != &client_buffer_impl) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
return (struct wlr_client_buffer *)buffer;
|
||||||
|
}
|
||||||
|
|
||||||
static struct wlr_client_buffer *client_buffer_from_buffer(
|
static struct wlr_client_buffer *client_buffer_from_buffer(
|
||||||
struct wlr_buffer *buffer) {
|
struct wlr_buffer *buffer) {
|
||||||
assert(buffer->impl == &client_buffer_impl);
|
struct wlr_client_buffer *client_buffer = wlr_client_buffer_get(buffer);
|
||||||
return (struct wlr_client_buffer *) buffer;
|
assert(client_buffer != NULL);
|
||||||
|
return client_buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void client_buffer_destroy(struct wlr_buffer *_buffer) {
|
static void client_buffer_destroy(struct wlr_buffer *_buffer) {
|
||||||
|
|
Loading…
Reference in New Issue