diff options
author | Ilia Bozhinov <ammen99@gmail.com> | 2018-05-25 13:14:35 +0300 |
---|---|---|
committer | Ilia Bozhinov <ammen99@gmail.com> | 2018-05-25 14:56:52 +0300 |
commit | 24cf70ae9691d605e4a1f7e9d8dc59ec72401bd0 (patch) | |
tree | 93d550e437722bdeabca5605ada5c0b4d41128cf /backend/headless | |
parent | a0eb37e2ea4ad96b4f6e98fddbc5c31d0bd0f293 (diff) |
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
Diffstat (limited to 'backend/headless')
-rw-r--r-- | backend/headless/backend.c | 19 |
1 files changed, 11 insertions, 8 deletions
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; |