From 24cf70ae9691d605e4a1f7e9d8dc59ec72401bd0 Mon Sep 17 00:00:00 2001 From: Ilia Bozhinov Date: Fri, 25 May 2018 13:14:35 +0300 Subject: 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 --- backend/headless/backend.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) (limited to 'backend/headless') diff --git a/backend/headless/backend.c b/backend/headless/backend.c index 1d29e12a..7015099e 100644 --- a/backend/headless/backend.c +++ b/backend/headless/backend.c @@ -78,7 +78,8 @@ static void handle_display_destroy(struct wl_listener *listener, void *data) { backend_destroy(&backend->backend); } -struct wlr_backend *wlr_headless_backend_create(struct wl_display *display) { +struct wlr_backend *wlr_headless_backend_create(struct wl_display *display, + wlr_renderer_create_func_t create_renderer_func) { wlr_log(L_INFO, "Creating headless backend"); struct wlr_headless_backend *backend = @@ -101,16 +102,18 @@ struct wlr_backend *wlr_headless_backend_create(struct wl_display *display) { EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, EGL_NONE, }; - bool ok = wlr_egl_init(&backend->egl, EGL_PLATFORM_SURFACELESS_MESA, NULL, - (EGLint *)config_attribs, 0); - if (!ok) { - free(backend); - return NULL; + + if (!create_renderer_func) { + create_renderer_func = wlr_renderer_autocreate; } - backend->renderer = wlr_gles2_renderer_create(&backend->egl); - if (backend->renderer == NULL) { + backend->renderer = create_renderer_func(&backend->egl, EGL_PLATFORM_SURFACELESS_MESA, + NULL, (EGLint*)config_attribs, 0); + + if (!backend->renderer) { wlr_log(L_ERROR, "Failed to create renderer"); + free(backend); + return NULL; } backend->display_destroy.notify = handle_display_destroy; -- cgit v1.2.3