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 --- render/wlr_renderer.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'render/wlr_renderer.c') diff --git a/render/wlr_renderer.c b/render/wlr_renderer.c index 8d1bd9ce..39006b58 100644 --- a/render/wlr_renderer.c +++ b/render/wlr_renderer.c @@ -4,6 +4,7 @@ #include #include #include +#include #include #include "util/signal.h" @@ -179,3 +180,19 @@ void wlr_renderer_init_wl_shm(struct wlr_renderer *r, } } } + +struct wlr_renderer *wlr_renderer_autocreate(struct wlr_egl *egl, + EGLenum platform, void *remote_display, EGLint *config_attribs, EGLint visual_id) { + + if (!wlr_egl_init(egl, platform, remote_display, config_attribs, visual_id)) { + wlr_log(L_ERROR, "Could not initialize EGL"); + return NULL; + } + + struct wlr_renderer *renderer = wlr_gles2_renderer_create(egl); + if (!renderer) { + wlr_egl_finish(egl); + } + + return renderer; +} -- cgit v1.2.3