mirror of
https://github.com/hyprwm/wlroots-hyprland.git
synced 2024-11-22 12:55:58 +01:00
parent
c46d3da976
commit
bfc42e0f62
2 changed files with 15 additions and 20 deletions
|
@ -29,17 +29,11 @@ struct wlr_dmabuf_v1_buffer {
|
||||||
struct wl_listener release;
|
struct wl_listener release;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns true if the given resource was created via the linux-dmabuf
|
|
||||||
* buffer protocol, false otherwise
|
|
||||||
*/
|
|
||||||
bool wlr_dmabuf_v1_resource_is_buffer(struct wl_resource *buffer_resource);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the struct wlr_dmabuf_buffer if the given resource was created
|
* Returns the struct wlr_dmabuf_buffer if the given resource was created
|
||||||
* via the linux-dmabuf buffer protocol.
|
* via the linux-dmabuf buffer protocol or NULL otherwise.
|
||||||
*/
|
*/
|
||||||
struct wlr_dmabuf_v1_buffer *wlr_dmabuf_v1_buffer_from_buffer_resource(
|
struct wlr_dmabuf_v1_buffer *wlr_dmabuf_v1_buffer_try_from_buffer_resource(
|
||||||
struct wl_resource *buffer_resource);
|
struct wl_resource *buffer_resource);
|
||||||
|
|
||||||
struct wlr_linux_dmabuf_feedback_v1 {
|
struct wlr_linux_dmabuf_feedback_v1 {
|
||||||
|
|
|
@ -72,18 +72,17 @@ static const struct wl_buffer_interface wl_buffer_impl = {
|
||||||
.destroy = buffer_handle_destroy,
|
.destroy = buffer_handle_destroy,
|
||||||
};
|
};
|
||||||
|
|
||||||
bool wlr_dmabuf_v1_resource_is_buffer(struct wl_resource *resource) {
|
static bool buffer_resource_is_instance(struct wl_resource *resource) {
|
||||||
if (!wl_resource_instance_of(resource, &wl_buffer_interface,
|
return wl_resource_instance_of(resource, &wl_buffer_interface,
|
||||||
&wl_buffer_impl)) {
|
&wl_buffer_impl);
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return wl_resource_get_user_data(resource) != NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct wlr_dmabuf_v1_buffer *wlr_dmabuf_v1_buffer_from_buffer_resource(
|
struct wlr_dmabuf_v1_buffer *wlr_dmabuf_v1_buffer_try_from_buffer_resource(
|
||||||
struct wl_resource *resource) {
|
struct wl_resource *resource) {
|
||||||
assert(wl_resource_instance_of(resource, &wl_buffer_interface,
|
if (!buffer_resource_is_instance(resource) ||
|
||||||
&wl_buffer_impl));
|
wl_resource_get_user_data(resource) == NULL) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
return wl_resource_get_user_data(resource);
|
return wl_resource_get_user_data(resource);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -195,7 +194,8 @@ static void params_add(struct wl_client *client,
|
||||||
|
|
||||||
static void buffer_handle_resource_destroy(struct wl_resource *buffer_resource) {
|
static void buffer_handle_resource_destroy(struct wl_resource *buffer_resource) {
|
||||||
struct wlr_dmabuf_v1_buffer *buffer =
|
struct wlr_dmabuf_v1_buffer *buffer =
|
||||||
wlr_dmabuf_v1_buffer_from_buffer_resource(buffer_resource);
|
wlr_dmabuf_v1_buffer_try_from_buffer_resource(buffer_resource);
|
||||||
|
assert(buffer != NULL);
|
||||||
buffer->resource = NULL;
|
buffer->resource = NULL;
|
||||||
wlr_buffer_drop(&buffer->base);
|
wlr_buffer_drop(&buffer->base);
|
||||||
}
|
}
|
||||||
|
@ -836,13 +836,14 @@ static void linux_dmabuf_bind(struct wl_client *client, void *data,
|
||||||
|
|
||||||
static struct wlr_buffer *buffer_from_resource(struct wl_resource *resource) {
|
static struct wlr_buffer *buffer_from_resource(struct wl_resource *resource) {
|
||||||
struct wlr_dmabuf_v1_buffer *buffer =
|
struct wlr_dmabuf_v1_buffer *buffer =
|
||||||
wlr_dmabuf_v1_buffer_from_buffer_resource(resource);
|
wlr_dmabuf_v1_buffer_try_from_buffer_resource(resource);
|
||||||
|
assert(buffer != NULL);
|
||||||
return &buffer->base;
|
return &buffer->base;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct wlr_buffer_resource_interface buffer_resource_interface = {
|
static const struct wlr_buffer_resource_interface buffer_resource_interface = {
|
||||||
.name = "wlr_dmabuf_v1_buffer",
|
.name = "wlr_dmabuf_v1_buffer",
|
||||||
.is_instance = wlr_dmabuf_v1_resource_is_buffer,
|
.is_instance = buffer_resource_is_instance,
|
||||||
.from_resource = buffer_from_resource,
|
.from_resource = buffer_from_resource,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue