linux-dmabuf-v1: don't use wlr_renderer to send legacy format list

The wlr_renderer field will go away in a subsequent commit.

Build the legacy device list from the default feedback instead.
This commit is contained in:
Simon Ser 2022-11-30 13:24:46 +01:00
parent d45cffb865
commit 88493d1f7c
2 changed files with 23 additions and 8 deletions

View file

@ -14,6 +14,7 @@
#include <wayland-server-core.h> #include <wayland-server-core.h>
#include <wlr/types/wlr_buffer.h> #include <wlr/types/wlr_buffer.h>
#include <wlr/render/dmabuf.h> #include <wlr/render/dmabuf.h>
#include <wlr/render/drm_format_set.h>
struct wlr_surface; struct wlr_surface;
@ -65,6 +66,7 @@ struct wlr_linux_dmabuf_v1 {
// private state // private state
struct wlr_linux_dmabuf_feedback_v1_compiled *default_feedback; 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 struct wl_list surfaces; // wlr_linux_dmabuf_v1_surface.link
int main_device_fd; // to sanity check FDs sent by clients int main_device_fd; // to sanity check FDs sent by clients

View file

@ -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, static void linux_dmabuf_send_formats(struct wlr_linux_dmabuf_v1 *linux_dmabuf,
struct wl_resource *resource) { struct wl_resource *resource) {
const struct wlr_drm_format_set *formats = for (size_t i = 0; i < linux_dmabuf->default_formats.len; i++) {
wlr_renderer_get_dmabuf_texture_formats(linux_dmabuf->renderer); const struct wlr_drm_format *fmt = linux_dmabuf->default_formats.formats[i];
if (formats == NULL) {
return;
}
for (size_t i = 0; i < formats->len; i++) {
const struct wlr_drm_format *fmt = formats->formats[i];
linux_dmabuf_send_modifiers(resource, fmt); 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); compiled_feedback_destroy(linux_dmabuf->default_feedback);
wlr_drm_format_set_finish(&linux_dmabuf->default_formats);
close(linux_dmabuf->main_device_fd); close(linux_dmabuf->main_device_fd);
wl_list_remove(&linux_dmabuf->display_destroy.link); 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; 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); compiled_feedback_destroy(linux_dmabuf->default_feedback);
linux_dmabuf->default_feedback = compiled; 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; linux_dmabuf->main_device_fd = main_device_fd;
wlr_drm_format_set_finish(&linux_dmabuf->default_formats);
linux_dmabuf->default_formats = formats;
return true; return true;
error_formats:
wlr_drm_format_set_finish(&formats);
error_compiled: error_compiled:
compiled_feedback_destroy(compiled); compiled_feedback_destroy(compiled);
return false; return false;