aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--types/buffer/resource.c7
-rw-r--r--types/wlr_linux_dmabuf_v1.c14
2 files changed, 15 insertions, 6 deletions
diff --git a/types/buffer/resource.c b/types/buffer/resource.c
index 8d39b6b9..4e16fd83 100644
--- a/types/buffer/resource.c
+++ b/types/buffer/resource.c
@@ -3,7 +3,6 @@
#include <wayland-server.h>
#include <wlr/interfaces/wlr_buffer.h>
#include <wlr/types/wlr_drm.h>
-#include <wlr/types/wlr_linux_dmabuf_v1.h>
#include <wlr/util/log.h>
#include "types/wlr_buffer.h"
@@ -49,11 +48,7 @@ struct wlr_buffer *wlr_buffer_from_resource(struct wl_resource *resource) {
assert(resource && wlr_resource_is_buffer(resource));
struct wlr_buffer *buffer;
- if (wlr_dmabuf_v1_resource_is_buffer(resource)) {
- struct wlr_dmabuf_v1_buffer *dmabuf =
- wlr_dmabuf_v1_buffer_from_buffer_resource(resource);
- buffer = wlr_buffer_lock(&dmabuf->base);
- } else if (wlr_drm_buffer_is_resource(resource)) {
+ if (wlr_drm_buffer_is_resource(resource)) {
struct wlr_drm_buffer *drm_buffer =
wlr_drm_buffer_from_resource(resource);
buffer = wlr_buffer_lock(&drm_buffer->base);
diff --git a/types/wlr_linux_dmabuf_v1.c b/types/wlr_linux_dmabuf_v1.c
index 7480b9e1..d6b2d8ef 100644
--- a/types/wlr_linux_dmabuf_v1.c
+++ b/types/wlr_linux_dmabuf_v1.c
@@ -885,6 +885,18 @@ static void linux_dmabuf_bind(struct wl_client *client, void *data,
}
}
+static struct wlr_buffer *buffer_from_resource(struct wl_resource *resource) {
+ struct wlr_dmabuf_v1_buffer *buffer =
+ wlr_dmabuf_v1_buffer_from_buffer_resource(resource);
+ return &buffer->base;
+}
+
+static const struct wlr_buffer_resource_interface buffer_resource_interface = {
+ .name = "wlr_dmabuf_v1_buffer",
+ .is_instance = wlr_dmabuf_v1_resource_is_buffer,
+ .from_resource = buffer_from_resource,
+};
+
static void linux_dmabuf_v1_destroy(struct wlr_linux_dmabuf_v1 *linux_dmabuf) {
wl_signal_emit_mutable(&linux_dmabuf->events.destroy, linux_dmabuf);
@@ -950,6 +962,8 @@ struct wlr_linux_dmabuf_v1 *wlr_linux_dmabuf_v1_create(struct wl_display *displa
linux_dmabuf->renderer_destroy.notify = handle_renderer_destroy;
wl_signal_add(&renderer->events.destroy, &linux_dmabuf->renderer_destroy);
+ wlr_buffer_register_resource_interface(&buffer_resource_interface);
+
return linux_dmabuf;
}