libweston: set backend pointer earlier

Change all backends to set the core backend pointer early.

This is necessary for libweston core to be able to access the backend
vfuncs before the backend init function returns. Particularly,
weston_output_init() will be needing to inspect the backend vfuncs to
see if the backend has been converted to a new API. Backends that create
outputs as part of their init would fail without setting the pointer
earlier.

For consistency, all backends are modified instead of just those that
could hit an issue.

Libweston core will take care of resetting the backend pointer to NULL
in case of error since "libweston: ensure backend is not loaded twice".

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Ian Ray <ian.ray@ge.com>
Acked-by Daniel Stone <daniels@collabora.com>
dev
Pekka Paalanen 7 years ago
parent d7e351189e
commit 7da9a3802f
  1. 4
      libweston/compositor-drm.c
  2. 2
      libweston/compositor-fbdev.c
  3. 4
      libweston/compositor-headless.c
  4. 4
      libweston/compositor-rdp.c
  5. 3
      libweston/compositor-wayland.c
  6. 4
      libweston/compositor-x11.c

@ -4025,6 +4025,8 @@ drm_backend_create(struct weston_compositor *compositor,
b->use_pixman = config->use_pixman; b->use_pixman = config->use_pixman;
b->pageflip_timeout = config->pageflip_timeout; b->pageflip_timeout = config->pageflip_timeout;
compositor->backend = &b->base;
if (parse_gbm_format(config->gbm_format, GBM_FORMAT_XRGB8888, &b->gbm_format) < 0) if (parse_gbm_format(config->gbm_format, GBM_FORMAT_XRGB8888, &b->gbm_format) < 0)
goto err_compositor; goto err_compositor;
@ -4141,8 +4143,6 @@ drm_backend_create(struct weston_compositor *compositor,
"support failed.\n"); "support failed.\n");
} }
compositor->backend = &b->base;
ret = weston_plugin_api_register(compositor, WESTON_DRM_OUTPUT_API_NAME, ret = weston_plugin_api_register(compositor, WESTON_DRM_OUTPUT_API_NAME,
&api, sizeof(api)); &api, sizeof(api));

@ -731,6 +731,7 @@ fbdev_backend_create(struct weston_compositor *compositor,
return NULL; return NULL;
backend->compositor = compositor; backend->compositor = compositor;
compositor->backend = &backend->base;
if (weston_compositor_set_presentation_clock_software( if (weston_compositor_set_presentation_clock_software(
compositor) < 0) compositor) < 0)
goto out_compositor; goto out_compositor;
@ -769,7 +770,6 @@ fbdev_backend_create(struct weston_compositor *compositor,
udev_input_init(&backend->input, compositor, backend->udev, udev_input_init(&backend->input, compositor, backend->udev,
seat_id, param->configure_device); seat_id, param->configure_device);
compositor->backend = &backend->base;
return backend; return backend;
out_launcher: out_launcher:

@ -277,6 +277,8 @@ headless_backend_create(struct weston_compositor *compositor,
return NULL; return NULL;
b->compositor = compositor; b->compositor = compositor;
compositor->backend = &b->base;
if (weston_compositor_set_presentation_clock_software(compositor) < 0) if (weston_compositor_set_presentation_clock_software(compositor) < 0)
goto err_free; goto err_free;
@ -291,8 +293,6 @@ headless_backend_create(struct weston_compositor *compositor,
if (!b->use_pixman && noop_renderer_init(compositor) < 0) if (!b->use_pixman && noop_renderer_init(compositor) < 0)
goto err_input; goto err_input;
compositor->backend = &b->base;
ret = weston_plugin_api_register(compositor, WESTON_WINDOWED_OUTPUT_API_NAME, ret = weston_plugin_api_register(compositor, WESTON_WINDOWED_OUTPUT_API_NAME,
&api, sizeof(api)); &api, sizeof(api));

@ -1299,6 +1299,8 @@ rdp_backend_create(struct weston_compositor *compositor,
b->rdp_key = config->rdp_key ? strdup(config->rdp_key) : NULL; b->rdp_key = config->rdp_key ? strdup(config->rdp_key) : NULL;
b->no_clients_resize = config->no_clients_resize; b->no_clients_resize = config->no_clients_resize;
compositor->backend = &b->base;
/* activate TLS only if certificate/key are available */ /* activate TLS only if certificate/key are available */
if (config->server_cert && config->server_key) { if (config->server_cert && config->server_key) {
weston_log("TLS support activated\n"); weston_log("TLS support activated\n");
@ -1345,8 +1347,6 @@ rdp_backend_create(struct weston_compositor *compositor,
goto err_output; goto err_output;
} }
compositor->backend = &b->base;
ret = weston_plugin_api_register(compositor, WESTON_RDP_OUTPUT_API_NAME, ret = weston_plugin_api_register(compositor, WESTON_RDP_OUTPUT_API_NAME,
&api, sizeof(api)); &api, sizeof(api));

@ -2487,6 +2487,8 @@ wayland_backend_create(struct weston_compositor *compositor,
return NULL; return NULL;
b->compositor = compositor; b->compositor = compositor;
compositor->backend = &b->base;
if (weston_compositor_set_presentation_clock_software(compositor) < 0) if (weston_compositor_set_presentation_clock_software(compositor) < 0)
goto err_compositor; goto err_compositor;
@ -2559,7 +2561,6 @@ wayland_backend_create(struct weston_compositor *compositor,
"support failed.\n"); "support failed.\n");
} }
compositor->backend = &b->base;
return b; return b;
err_display: err_display:
wl_display_disconnect(b->parent.wl_display); wl_display_disconnect(b->parent.wl_display);

@ -1669,6 +1669,8 @@ x11_backend_create(struct weston_compositor *compositor,
b->fullscreen = config->fullscreen; b->fullscreen = config->fullscreen;
b->no_input = config->no_input; b->no_input = config->no_input;
compositor->backend = &b->base;
if (weston_compositor_set_presentation_clock_software(compositor) < 0) if (weston_compositor_set_presentation_clock_software(compositor) < 0)
goto err_free; goto err_free;
@ -1728,8 +1730,6 @@ x11_backend_create(struct weston_compositor *compositor,
"support failed.\n"); "support failed.\n");
} }
compositor->backend = &b->base;
ret = weston_plugin_api_register(compositor, WESTON_WINDOWED_OUTPUT_API_NAME, ret = weston_plugin_api_register(compositor, WESTON_WINDOWED_OUTPUT_API_NAME,
&api, sizeof(api)); &api, sizeof(api));

Loading…
Cancel
Save