linux-dmabuf-v1: add version arg to create()

To be able to add support for newer versions without breaking
changes.
This commit is contained in:
Simon Ser 2022-11-24 10:07:19 +01:00
parent 444d94ef89
commit c99c60090c
3 changed files with 7 additions and 6 deletions

View file

@ -77,7 +77,7 @@ struct wlr_linux_dmabuf_v1 {
* The default DMA-BUF feedback is initialized from the struct wlr_renderer. * The default DMA-BUF feedback is initialized from the struct wlr_renderer.
*/ */
struct wlr_linux_dmabuf_v1 *wlr_linux_dmabuf_v1_create_with_renderer(struct wl_display *display, struct wlr_linux_dmabuf_v1 *wlr_linux_dmabuf_v1_create_with_renderer(struct wl_display *display,
struct wlr_renderer *renderer); uint32_t version, struct wlr_renderer *renderer);
/** /**
* Set a surface's DMA-BUF feedback. * Set a surface's DMA-BUF feedback.

View file

@ -232,7 +232,7 @@ bool wlr_renderer_init_wl_display(struct wlr_renderer *r,
wlr_log(WLR_INFO, "Cannot get renderer DRM FD, disabling wl_drm"); wlr_log(WLR_INFO, "Cannot get renderer DRM FD, disabling wl_drm");
} }
if (wlr_linux_dmabuf_v1_create_with_renderer(wl_display, r) == NULL) { if (wlr_linux_dmabuf_v1_create_with_renderer(wl_display, 4, r) == NULL) {
return false; return false;
} }
} }

View file

@ -927,7 +927,9 @@ static void handle_renderer_destroy(struct wl_listener *listener, void *data) {
} }
struct wlr_linux_dmabuf_v1 *wlr_linux_dmabuf_v1_create_with_renderer(struct wl_display *display, struct wlr_linux_dmabuf_v1 *wlr_linux_dmabuf_v1_create_with_renderer(struct wl_display *display,
struct wlr_renderer *renderer) { uint32_t version, struct wlr_renderer *renderer) {
assert(version <= LINUX_DMABUF_VERSION);
struct wlr_linux_dmabuf_v1 *linux_dmabuf = struct wlr_linux_dmabuf_v1 *linux_dmabuf =
calloc(1, sizeof(struct wlr_linux_dmabuf_v1)); calloc(1, sizeof(struct wlr_linux_dmabuf_v1));
if (linux_dmabuf == NULL) { if (linux_dmabuf == NULL) {
@ -939,9 +941,8 @@ struct wlr_linux_dmabuf_v1 *wlr_linux_dmabuf_v1_create_with_renderer(struct wl_d
wl_list_init(&linux_dmabuf->surfaces); wl_list_init(&linux_dmabuf->surfaces);
wl_signal_init(&linux_dmabuf->events.destroy); wl_signal_init(&linux_dmabuf->events.destroy);
linux_dmabuf->global = linux_dmabuf->global = wl_global_create(display, &zwp_linux_dmabuf_v1_interface,
wl_global_create(display, &zwp_linux_dmabuf_v1_interface, version, linux_dmabuf, linux_dmabuf_bind);
LINUX_DMABUF_VERSION, linux_dmabuf, linux_dmabuf_bind);
if (!linux_dmabuf->global) { if (!linux_dmabuf->global) {
wlr_log(WLR_ERROR, "could not create linux dmabuf v1 wl global"); wlr_log(WLR_ERROR, "could not create linux dmabuf v1 wl global");
free(linux_dmabuf); free(linux_dmabuf);