mirror of
https://github.com/hyprwm/wlroots-hyprland.git
synced 2024-11-22 04:45:58 +01:00
linux-dmabuf-v1: use resource interface
Instead of hardcoding builtin resource types in wlr_buffer_from_resource(), use the modular resource interface.
This commit is contained in:
parent
236918d52e
commit
772066a174
2 changed files with 15 additions and 6 deletions
|
@ -3,7 +3,6 @@
|
||||||
#include <wayland-server.h>
|
#include <wayland-server.h>
|
||||||
#include <wlr/interfaces/wlr_buffer.h>
|
#include <wlr/interfaces/wlr_buffer.h>
|
||||||
#include <wlr/types/wlr_drm.h>
|
#include <wlr/types/wlr_drm.h>
|
||||||
#include <wlr/types/wlr_linux_dmabuf_v1.h>
|
|
||||||
#include <wlr/util/log.h>
|
#include <wlr/util/log.h>
|
||||||
#include "types/wlr_buffer.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));
|
assert(resource && wlr_resource_is_buffer(resource));
|
||||||
|
|
||||||
struct wlr_buffer *buffer;
|
struct wlr_buffer *buffer;
|
||||||
if (wlr_dmabuf_v1_resource_is_buffer(resource)) {
|
if (wlr_drm_buffer_is_resource(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)) {
|
|
||||||
struct wlr_drm_buffer *drm_buffer =
|
struct wlr_drm_buffer *drm_buffer =
|
||||||
wlr_drm_buffer_from_resource(resource);
|
wlr_drm_buffer_from_resource(resource);
|
||||||
buffer = wlr_buffer_lock(&drm_buffer->base);
|
buffer = wlr_buffer_lock(&drm_buffer->base);
|
||||||
|
|
|
@ -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) {
|
static void linux_dmabuf_v1_destroy(struct wlr_linux_dmabuf_v1 *linux_dmabuf) {
|
||||||
wl_signal_emit_mutable(&linux_dmabuf->events.destroy, 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;
|
linux_dmabuf->renderer_destroy.notify = handle_renderer_destroy;
|
||||||
wl_signal_add(&renderer->events.destroy, &linux_dmabuf->renderer_destroy);
|
wl_signal_add(&renderer->events.destroy, &linux_dmabuf->renderer_destroy);
|
||||||
|
|
||||||
|
wlr_buffer_register_resource_interface(&buffer_resource_interface);
|
||||||
|
|
||||||
return linux_dmabuf;
|
return linux_dmabuf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue