libweston: Let multiple backends register the Windowed Output API
The windowed output API is implemented by the Wayland, the X11 and the headless backends. It's currently not possible to create a secondary headless backend when the primary backend is Wayland or X11 because the windowed output API would be registered twice. This commit suffixes the windowed output API names with the backend name in order to avoid clashes: "weston_windowed_output_api_<backend>_v2". A use case for Wayland or X11 as primary backend and headless as secondary is for instance to request output captures on the headless backend to avoid read backs on the primary backend's render buffers. Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
This commit is contained in:
parent
1eae99b2ee
commit
f4c69abc57
@ -1669,10 +1669,11 @@ parse_simple_mode(struct weston_output *output,
|
||||
|
||||
static int
|
||||
wet_configure_windowed_output_from_config(struct weston_output *output,
|
||||
struct wet_output_config *defaults)
|
||||
struct wet_output_config *defaults,
|
||||
enum weston_windowed_output_type type)
|
||||
{
|
||||
const struct weston_windowed_output_api *api =
|
||||
weston_windowed_output_get_api(output->compositor);
|
||||
weston_windowed_output_get_api(output->compositor, type);
|
||||
|
||||
struct weston_config *wc = wet_get_config(output->compositor);
|
||||
struct weston_config_section *section = NULL;
|
||||
@ -3132,7 +3133,8 @@ headless_backend_output_configure(struct weston_output *output)
|
||||
if (wet_output_set_color_characteristics(output, wc, section) < 0)
|
||||
return -1;
|
||||
|
||||
return wet_configure_windowed_output_from_config(output, &defaults);
|
||||
return wet_configure_windowed_output_from_config(output, &defaults,
|
||||
WESTON_WINDOWED_OUTPUT_HEADLESS);
|
||||
}
|
||||
|
||||
static int
|
||||
@ -3207,7 +3209,7 @@ load_headless_backend(struct weston_compositor *c,
|
||||
return -1;
|
||||
|
||||
if (!no_outputs) {
|
||||
api = weston_windowed_output_get_api(c);
|
||||
api = weston_windowed_output_get_api(c, WESTON_WINDOWED_OUTPUT_HEADLESS);
|
||||
|
||||
if (!api) {
|
||||
weston_log("Cannot use weston_windowed_output_api.\n");
|
||||
@ -3596,7 +3598,8 @@ x11_backend_output_configure(struct weston_output *output)
|
||||
.transform = WL_OUTPUT_TRANSFORM_NORMAL
|
||||
};
|
||||
|
||||
return wet_configure_windowed_output_from_config(output, &defaults);
|
||||
return wet_configure_windowed_output_from_config(output, &defaults,
|
||||
WESTON_WINDOWED_OUTPUT_X11);
|
||||
}
|
||||
|
||||
static int
|
||||
@ -3655,7 +3658,7 @@ load_x11_backend(struct weston_compositor *c,
|
||||
if (!wb)
|
||||
return -1;
|
||||
|
||||
api = weston_windowed_output_get_api(c);
|
||||
api = weston_windowed_output_get_api(c, WESTON_WINDOWED_OUTPUT_X11);
|
||||
|
||||
if (!api) {
|
||||
weston_log("Cannot use weston_windowed_output_api.\n");
|
||||
@ -3715,7 +3718,8 @@ wayland_backend_output_configure(struct weston_output *output)
|
||||
.transform = WL_OUTPUT_TRANSFORM_NORMAL
|
||||
};
|
||||
|
||||
return wet_configure_windowed_output_from_config(output, &defaults);
|
||||
return wet_configure_windowed_output_from_config(output, &defaults,
|
||||
WESTON_WINDOWED_OUTPUT_WAYLAND);
|
||||
}
|
||||
|
||||
static int
|
||||
@ -3787,7 +3791,7 @@ load_wayland_backend(struct weston_compositor *c,
|
||||
if (!wb)
|
||||
return -1;
|
||||
|
||||
api = weston_windowed_output_get_api(c);
|
||||
api = weston_windowed_output_get_api(c, WESTON_WINDOWED_OUTPUT_WAYLAND);
|
||||
|
||||
if (api == NULL) {
|
||||
/* We will just assume if load_backend() finished cleanly and
|
||||
|
@ -35,7 +35,15 @@ extern "C" {
|
||||
struct weston_compositor;
|
||||
struct weston_output;
|
||||
|
||||
#define WESTON_WINDOWED_OUTPUT_API_NAME "weston_windowed_output_api_v2"
|
||||
#define WESTON_WINDOWED_OUTPUT_API_NAME_X11 "weston_windowed_output_api_x11_v2"
|
||||
#define WESTON_WINDOWED_OUTPUT_API_NAME_WAYLAND "weston_windowed_output_api_wayland_v2"
|
||||
#define WESTON_WINDOWED_OUTPUT_API_NAME_HEADLESS "weston_windowed_output_api_headless_v2"
|
||||
|
||||
enum weston_windowed_output_type {
|
||||
WESTON_WINDOWED_OUTPUT_X11 = 0,
|
||||
WESTON_WINDOWED_OUTPUT_WAYLAND,
|
||||
WESTON_WINDOWED_OUTPUT_HEADLESS,
|
||||
};
|
||||
|
||||
struct weston_windowed_output_api {
|
||||
/** Assign a given width and height to an output.
|
||||
@ -79,13 +87,20 @@ struct weston_windowed_output_api {
|
||||
};
|
||||
|
||||
static inline const struct weston_windowed_output_api *
|
||||
weston_windowed_output_get_api(struct weston_compositor *compositor)
|
||||
weston_windowed_output_get_api(struct weston_compositor *compositor,
|
||||
enum weston_windowed_output_type type)
|
||||
{
|
||||
const void *api;
|
||||
api = weston_plugin_api_get(compositor, WESTON_WINDOWED_OUTPUT_API_NAME,
|
||||
sizeof(struct weston_windowed_output_api));
|
||||
const char *api_names[] = {
|
||||
WESTON_WINDOWED_OUTPUT_API_NAME_X11,
|
||||
WESTON_WINDOWED_OUTPUT_API_NAME_WAYLAND,
|
||||
WESTON_WINDOWED_OUTPUT_API_NAME_HEADLESS,
|
||||
};
|
||||
|
||||
return (const struct weston_windowed_output_api *)api;
|
||||
if (type >= ARRAY_LENGTH(api_names))
|
||||
return NULL;
|
||||
|
||||
return weston_plugin_api_get(compositor, api_names[type],
|
||||
sizeof(struct weston_windowed_output_api));
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
@ -638,7 +638,8 @@ headless_backend_create(struct weston_compositor *compositor,
|
||||
goto err_input;
|
||||
}
|
||||
|
||||
ret = weston_plugin_api_register(compositor, WESTON_WINDOWED_OUTPUT_API_NAME,
|
||||
ret = weston_plugin_api_register(compositor,
|
||||
WESTON_WINDOWED_OUTPUT_API_NAME_HEADLESS,
|
||||
&api, sizeof(api));
|
||||
|
||||
if (ret < 0) {
|
||||
|
@ -3082,7 +3082,8 @@ weston_backend_init(struct weston_compositor *compositor,
|
||||
return 0;
|
||||
}
|
||||
|
||||
ret = weston_plugin_api_register(compositor, WESTON_WINDOWED_OUTPUT_API_NAME,
|
||||
ret = weston_plugin_api_register(compositor,
|
||||
WESTON_WINDOWED_OUTPUT_API_NAME_WAYLAND,
|
||||
&windowed_api, sizeof(windowed_api));
|
||||
|
||||
if (ret < 0) {
|
||||
|
@ -1986,7 +1986,8 @@ x11_backend_create(struct weston_compositor *compositor,
|
||||
" synchronization support failed.\n");
|
||||
}
|
||||
|
||||
ret = weston_plugin_api_register(compositor, WESTON_WINDOWED_OUTPUT_API_NAME,
|
||||
ret = weston_plugin_api_register(compositor,
|
||||
WESTON_WINDOWED_OUTPUT_API_NAME_X11,
|
||||
&api, sizeof(api));
|
||||
|
||||
if (ret < 0) {
|
||||
|
Loading…
Reference in New Issue
Block a user