libweston: allow loading multiple backends
Before loading a backend, clear the weston_compositor::backend pointer to check whether the backend supports multi-backend operation and adds itself to the weston_compositor::backend_list. Keep weston_compositor::backend pointing to the last loaded backend either way, to allow the calling compositor code to store it away for later, to check whether a head belongs to a given backend in the output configuration code. This workaround can be removed after all backends are converted to be multi-backend aware. Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
This commit is contained in:
parent
3d50069afc
commit
20c5b4527c
@ -1480,6 +1480,9 @@ struct weston_compositor {
|
||||
/* Whether to let the compositor run without any input device. */
|
||||
bool require_input;
|
||||
|
||||
/* Whether to load multiple backends. */
|
||||
bool multi_backend;
|
||||
|
||||
/* Test suite data */
|
||||
struct weston_testsuite_data test_data;
|
||||
|
||||
|
@ -9545,14 +9545,12 @@ weston_compositor_load_backend(struct weston_compositor *compositor,
|
||||
int (*backend_init)(struct weston_compositor *c,
|
||||
struct weston_backend_config *config_base);
|
||||
|
||||
if (compositor->backend) {
|
||||
weston_log("Error: attempt to load a backend when one is already loaded\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (backend >= ARRAY_LENGTH(backend_map))
|
||||
return -1;
|
||||
|
||||
/* Clear backend pointer to catch multi-backend incapable backends. */
|
||||
compositor->backend = NULL;
|
||||
|
||||
backend_init = weston_load_module(backend_map[backend],
|
||||
"weston_backend_init",
|
||||
LIBWESTON_MODULEDIR);
|
||||
@ -9564,7 +9562,19 @@ weston_compositor_load_backend(struct weston_compositor *compositor,
|
||||
return -1;
|
||||
}
|
||||
|
||||
wl_list_insert(&compositor->backend_list, &compositor->backend->link);
|
||||
/* Multi-backend capable backends add themselves to the backend_list. */
|
||||
if (compositor->backend) {
|
||||
if (compositor->multi_backend) {
|
||||
weston_log("error: backend does not support multi-backend operation\n");
|
||||
return -1;
|
||||
}
|
||||
wl_list_insert(&compositor->backend_list,
|
||||
&compositor->backend->link);
|
||||
}
|
||||
|
||||
/* Point compositor->backend to the last loaded backend. */
|
||||
compositor->backend = wl_container_of(compositor->backend_list.next,
|
||||
compositor->backend, link);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user