mirror of
https://gitlab.freedesktop.org/wlroots/wlroots.git
synced 2025-12-16 08:56:26 -05:00
backend: create renderer and allocator in wlr_backend_autocreate
Instead of ensuring the renderer and allocator are initialized in each backend, do it in wlr_backend_autocreate. This allows compositors to create backends without any renderer/allocator if they side-step wlr_backend_autocreate. Since the wlr_backend_get_renderer and backend_get_allocator end up calling wlr_renderer_autocreate and wlr_allocator_autocreate, it sounds like a good idea to centralize all of the opimionated bits in one place.
This commit is contained in:
parent
20d9448257
commit
3d0848daae
5 changed files with 19 additions and 35 deletions
|
|
@ -209,6 +209,21 @@ static size_t parse_outputs_env(const char *name) {
|
|||
return outputs;
|
||||
}
|
||||
|
||||
static struct wlr_backend *ensure_backend_renderer_and_allocator(
|
||||
struct wlr_backend *backend) {
|
||||
struct wlr_renderer *renderer = wlr_backend_get_renderer(backend);
|
||||
if (renderer == NULL) {
|
||||
wlr_backend_destroy(backend);
|
||||
return NULL;
|
||||
}
|
||||
struct wlr_allocator *allocator = backend_get_allocator(backend);
|
||||
if (allocator == NULL) {
|
||||
wlr_backend_destroy(backend);
|
||||
return NULL;
|
||||
}
|
||||
return backend;
|
||||
}
|
||||
|
||||
static struct wlr_backend *attempt_wl_backend(struct wl_display *display) {
|
||||
struct wlr_backend *backend = wlr_wl_backend_create(display, NULL);
|
||||
if (backend == NULL) {
|
||||
|
|
@ -220,7 +235,7 @@ static struct wlr_backend *attempt_wl_backend(struct wl_display *display) {
|
|||
wlr_wl_output_create(backend);
|
||||
}
|
||||
|
||||
return backend;
|
||||
return ensure_backend_renderer_and_allocator(backend);
|
||||
}
|
||||
|
||||
#if WLR_HAS_X11_BACKEND
|
||||
|
|
@ -236,7 +251,7 @@ static struct wlr_backend *attempt_x11_backend(struct wl_display *display,
|
|||
wlr_x11_output_create(backend);
|
||||
}
|
||||
|
||||
return backend;
|
||||
return ensure_backend_renderer_and_allocator(backend);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
@ -252,7 +267,7 @@ static struct wlr_backend *attempt_headless_backend(
|
|||
wlr_headless_add_output(backend, 1280, 720);
|
||||
}
|
||||
|
||||
return backend;
|
||||
return ensure_backend_renderer_and_allocator(backend);
|
||||
}
|
||||
|
||||
static struct wlr_backend *attempt_noop_backend(struct wl_display *display) {
|
||||
|
|
@ -297,7 +312,7 @@ static struct wlr_backend *attempt_drm_backend(struct wl_display *display,
|
|||
wlr_multi_backend_add(backend, drm);
|
||||
}
|
||||
|
||||
return primary_drm;
|
||||
return ensure_backend_renderer_and_allocator(primary_drm);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue