aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/wlr/types/wlr_linux_dmabuf_v1.h2
-rw-r--r--types/wlr_linux_dmabuf_v1.c29
2 files changed, 23 insertions, 8 deletions
diff --git a/include/wlr/types/wlr_linux_dmabuf_v1.h b/include/wlr/types/wlr_linux_dmabuf_v1.h
index 960cbb2c..93413f72 100644
--- a/include/wlr/types/wlr_linux_dmabuf_v1.h
+++ b/include/wlr/types/wlr_linux_dmabuf_v1.h
@@ -14,6 +14,7 @@
#include <wayland-server-core.h>
#include <wlr/types/wlr_buffer.h>
#include <wlr/render/dmabuf.h>
+#include <wlr/render/drm_format_set.h>
struct wlr_surface;
@@ -65,6 +66,7 @@ struct wlr_linux_dmabuf_v1 {
// private state
struct wlr_linux_dmabuf_feedback_v1_compiled *default_feedback;
+ struct wlr_drm_format_set default_formats; // for legacy clients
struct wl_list surfaces; // wlr_linux_dmabuf_v1_surface.link
int main_device_fd; // to sanity check FDs sent by clients
diff --git a/types/wlr_linux_dmabuf_v1.c b/types/wlr_linux_dmabuf_v1.c
index eb0a1534..f4d5a0fd 100644
--- a/types/wlr_linux_dmabuf_v1.c
+++ b/types/wlr_linux_dmabuf_v1.c
@@ -844,14 +844,8 @@ static void linux_dmabuf_send_modifiers(struct wl_resource *resource,
static void linux_dmabuf_send_formats(struct wlr_linux_dmabuf_v1 *linux_dmabuf,
struct wl_resource *resource) {
- const struct wlr_drm_format_set *formats =
- wlr_renderer_get_dmabuf_texture_formats(linux_dmabuf->renderer);
- if (formats == NULL) {
- return;
- }
-
- for (size_t i = 0; i < formats->len; i++) {
- const struct wlr_drm_format *fmt = formats->formats[i];
+ for (size_t i = 0; i < linux_dmabuf->default_formats.len; i++) {
+ const struct wlr_drm_format *fmt = linux_dmabuf->default_formats.formats[i];
linux_dmabuf_send_modifiers(resource, fmt);
}
}
@@ -895,6 +889,7 @@ static void linux_dmabuf_v1_destroy(struct wlr_linux_dmabuf_v1 *linux_dmabuf) {
}
compiled_feedback_destroy(linux_dmabuf->default_feedback);
+ wlr_drm_format_set_finish(&linux_dmabuf->default_formats);
close(linux_dmabuf->main_device_fd);
wl_list_remove(&linux_dmabuf->display_destroy.link);
@@ -947,6 +942,19 @@ static bool set_default_feedback(struct wlr_linux_dmabuf_v1 *linux_dmabuf,
goto error_compiled;
}
+ struct wlr_drm_format_set formats = {0};
+ for (size_t i = 0; i < feedback->tranches_len; i++) {
+ const struct wlr_linux_dmabuf_feedback_v1_tranche *tranche = &feedback->tranches[i];
+ for (size_t j = 0; j < tranche->formats->len; j++) {
+ const struct wlr_drm_format *fmt = tranche->formats->formats[j];
+ for (size_t k = 0; k < fmt->len; k++) {
+ if (!wlr_drm_format_set_add(&formats, fmt->format, fmt->modifiers[k])) {
+ goto error_formats;
+ }
+ }
+ }
+ }
+
compiled_feedback_destroy(linux_dmabuf->default_feedback);
linux_dmabuf->default_feedback = compiled;
@@ -955,8 +963,13 @@ static bool set_default_feedback(struct wlr_linux_dmabuf_v1 *linux_dmabuf,
}
linux_dmabuf->main_device_fd = main_device_fd;
+ wlr_drm_format_set_finish(&linux_dmabuf->default_formats);
+ linux_dmabuf->default_formats = formats;
+
return true;
+error_formats:
+ wlr_drm_format_set_finish(&formats);
error_compiled:
compiled_feedback_destroy(compiled);
return false;