aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Ser <contact@emersion.fr>2022-12-09 18:35:02 +0100
committerSimon Zeni <simon@bl4ckb0ne.ca>2023-02-06 19:14:15 +0000
commit8c5713bd7a37e3b32ee3df0df0ddc59f3d32efd2 (patch)
treedcaf6579fd4c4ebb838ee5c14d7d0bd025f78d65
parent0c966f102c1d1940718cf96888036605e35074fb (diff)
linux-dmabuf-v1: use wlr_linux_dmabuf_feedback_v1_init_with_options()
-rw-r--r--types/wlr_linux_dmabuf_v1.c47
1 files changed, 9 insertions, 38 deletions
diff --git a/types/wlr_linux_dmabuf_v1.c b/types/wlr_linux_dmabuf_v1.c
index 8098be22..85e590eb 100644
--- a/types/wlr_linux_dmabuf_v1.c
+++ b/types/wlr_linux_dmabuf_v1.c
@@ -636,34 +636,6 @@ static void compiled_feedback_destroy(
free(feedback);
}
-static bool feedback_tranche_init_with_renderer(
- struct wlr_linux_dmabuf_feedback_v1_tranche *tranche,
- struct wlr_renderer *renderer) {
- memset(tranche, 0, sizeof(*tranche));
-
- int drm_fd = wlr_renderer_get_drm_fd(renderer);
- if (drm_fd < 0) {
- wlr_log(WLR_ERROR, "Failed to get DRM FD from renderer");
- return false;
- }
-
- struct stat stat;
- if (fstat(drm_fd, &stat) != 0) {
- wlr_log_errno(WLR_ERROR, "fstat failed");
- return false;
- }
- tranche->target_device = stat.st_rdev;
-
- const struct wlr_drm_format_set *formats = wlr_renderer_get_dmabuf_texture_formats(renderer);
- if (formats == NULL) {
- wlr_log(WLR_ERROR, "Failed to get renderer DMA-BUF texture formats");
- return false;
- }
- tranche->formats = *formats;
-
- return true;
-}
-
static void feedback_tranche_send(
const struct wlr_linux_dmabuf_feedback_v1_compiled_tranche *tranche,
struct wl_resource *resource) {
@@ -1015,18 +987,17 @@ error_linux_dmabuf:
struct wlr_linux_dmabuf_v1 *wlr_linux_dmabuf_v1_create_with_renderer(struct wl_display *display,
uint32_t version, struct wlr_renderer *renderer) {
- struct wlr_linux_dmabuf_feedback_v1_tranche tranche = {0};
- if (!feedback_tranche_init_with_renderer(&tranche, renderer)) {
+ const struct wlr_linux_dmabuf_feedback_v1_init_options options = {
+ .main_renderer = renderer,
+ };
+ struct wlr_linux_dmabuf_feedback_v1 feedback = {0};
+ if (!wlr_linux_dmabuf_feedback_v1_init_with_options(&feedback, &options)) {
return NULL;
}
- const struct wlr_linux_dmabuf_feedback_v1 feedback = {
- .main_device = tranche.target_device,
- .tranches = {
- .data = &tranche,
- .size = sizeof(tranche),
- },
- };
- return wlr_linux_dmabuf_v1_create(display, version, &feedback);
+ struct wlr_linux_dmabuf_v1 *linux_dmabuf =
+ wlr_linux_dmabuf_v1_create(display, version, &feedback);
+ wlr_linux_dmabuf_feedback_v1_finish(&feedback);
+ return linux_dmabuf;
}
bool wlr_linux_dmabuf_v1_set_surface_feedback(