backend: replace get_buffer_caps hook with a struct field

Do the same as wlr_renderer: the supported buffer capabilities are
static for the lifetime of the backend.
This commit is contained in:
Simon Ser 2024-10-29 19:18:18 +01:00 committed by Kirill Primak
parent 9fdffba170
commit b908d865b1
14 changed files with 44 additions and 87 deletions

View file

@ -212,17 +212,10 @@ static int backend_get_drm_fd(struct wlr_backend *backend) {
return x11->drm_fd;
}
static uint32_t get_buffer_caps(struct wlr_backend *backend) {
struct wlr_x11_backend *x11 = get_x11_backend_from_backend(backend);
return (x11->have_dri3 ? WLR_BUFFER_CAP_DMABUF : 0)
| (x11->have_shm ? WLR_BUFFER_CAP_SHM : 0);
}
static const struct wlr_backend_impl backend_impl = {
.start = backend_start,
.destroy = backend_destroy,
.get_drm_fd = backend_get_drm_fd,
.get_buffer_caps = get_buffer_caps,
};
bool wlr_backend_is_x11(struct wlr_backend *backend) {
@ -573,6 +566,13 @@ struct wlr_backend *wlr_x11_backend_create(struct wl_event_loop *loop,
}
free(xi_reply);
if (x11->have_dri3) {
x11->backend.buffer_caps |= WLR_BUFFER_CAP_DMABUF;
}
if (x11->have_shm) {
x11->backend.buffer_caps |= WLR_BUFFER_CAP_SHM;
}
int fd = xcb_get_file_descriptor(x11->xcb);
uint32_t events = WL_EVENT_READABLE | WL_EVENT_ERROR | WL_EVENT_HANGUP;
x11->event_source = wl_event_loop_add_fd(loop, fd, events, x11_event, x11);