backend/x11: implement get_dmabuf_primary_formats

This commit is contained in:
Simon Ser 2020-12-19 15:30:25 +01:00
parent 44feb832f9
commit 68c4f15958
3 changed files with 39 additions and 0 deletions

View file

@ -198,6 +198,8 @@ static void backend_destroy(struct wlr_backend *backend) {
}
wl_list_remove(&x11->display_destroy.link);
wlr_drm_format_set_finish(&x11->primary_dri3_formats);
wlr_drm_format_set_finish(&x11->primary_shm_formats);
wlr_drm_format_set_finish(&x11->dri3_formats);
wlr_drm_format_set_finish(&x11->shm_formats);
free(x11->drm_format);
@ -658,6 +660,26 @@ struct wlr_backend *wlr_x11_backend_create(struct wl_display *display,
return false;
}
// Windows can only display buffers with the depth they were created with
// TODO: look into changing the window's depth at runtime
const struct wlr_drm_format *dri3_format =
wlr_drm_format_set_get(&x11->dri3_formats, x11->x11_format->drm);
if (x11->have_dri3 && dri3_format != NULL) {
wlr_drm_format_set_add(&x11->primary_dri3_formats,
dri3_format->format, DRM_FORMAT_MOD_INVALID);
for (size_t i = 0; i < dri3_format->len; i++) {
wlr_drm_format_set_add(&x11->primary_dri3_formats,
dri3_format->format, dri3_format->modifiers[i]);
}
}
const struct wlr_drm_format *shm_format =
wlr_drm_format_set_get(&x11->shm_formats, x11->x11_format->drm);
if (x11->have_shm && shm_format != NULL) {
wlr_drm_format_set_add(&x11->primary_shm_formats,
shm_format->format, DRM_FORMAT_MOD_INVALID);
}
#if HAS_XCB_ERRORS
if (xcb_errors_context_new(x11->xcb, &x11->errors_context) != 0) {
wlr_log(WLR_ERROR, "Failed to create error context");