mirror of
https://gitlab.freedesktop.org/wlroots/wlroots.git
synced 2025-10-31 22:25:21 -04:00
backends: implement custom EGL and renderer initialization
Compositors now have more control over how the backend creates its renderer. Currently all backends create an EGL/GLES2 renderer, so the necessary attributes for creating the context are passed to a user-provided callback function. It is responsible for initializing provided wlr_egl and to return a renderer. On fail, return 0. Fixes #987
This commit is contained in:
parent
a0eb37e2ea
commit
24cf70ae96
22 changed files with 106 additions and 69 deletions
|
|
@ -139,7 +139,7 @@ static void handle_display_destroy(struct wl_listener *listener, void *data) {
|
|||
}
|
||||
|
||||
struct wlr_backend *wlr_wl_backend_create(struct wl_display *display,
|
||||
const char *remote) {
|
||||
const char *remote, wlr_renderer_create_func_t create_renderer_func) {
|
||||
wlr_log(L_INFO, "Creating wayland backend");
|
||||
|
||||
struct wlr_wl_backend *backend = calloc(1, sizeof(struct wlr_wl_backend));
|
||||
|
|
@ -174,14 +174,14 @@ struct wlr_backend *wlr_wl_backend_create(struct wl_display *display,
|
|||
EGL_ALPHA_SIZE, 1,
|
||||
EGL_NONE,
|
||||
};
|
||||
if (!wlr_egl_init(&backend->egl, EGL_PLATFORM_WAYLAND_EXT,
|
||||
backend->remote_display, config_attribs, WL_SHM_FORMAT_ARGB8888)) {
|
||||
wlr_log(L_ERROR, "Could not initialize EGL");
|
||||
goto error_egl;
|
||||
}
|
||||
wlr_egl_bind_display(&backend->egl, backend->local_display);
|
||||
|
||||
backend->renderer = wlr_gles2_renderer_create(&backend->egl);
|
||||
if (!create_renderer_func) {
|
||||
create_renderer_func = wlr_renderer_autocreate;
|
||||
}
|
||||
|
||||
backend->renderer = create_renderer_func(&backend->egl, EGL_PLATFORM_WAYLAND_EXT,
|
||||
backend->remote_display, config_attribs, WL_SHM_FORMAT_ARGB8888);
|
||||
|
||||
if (backend->renderer == NULL) {
|
||||
wlr_log(L_ERROR, "Could not create renderer");
|
||||
goto error_renderer;
|
||||
|
|
@ -193,8 +193,6 @@ struct wlr_backend *wlr_wl_backend_create(struct wl_display *display,
|
|||
return &backend->backend;
|
||||
|
||||
error_renderer:
|
||||
wlr_egl_finish(&backend->egl);
|
||||
error_egl:
|
||||
wl_registry_destroy(backend->registry);
|
||||
error_registry:
|
||||
wl_display_disconnect(backend->remote_display);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue