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:
Ilia Bozhinov 2018-05-25 13:14:35 +03:00
parent a0eb37e2ea
commit 24cf70ae96
22 changed files with 106 additions and 69 deletions

View file

@ -4,6 +4,7 @@
#include <wlr/render/interface.h>
#include <wlr/render/wlr_renderer.h>
#include <wlr/types/wlr_matrix.h>
#include <wlr/render/gles2.h>
#include <wlr/util/log.h>
#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;
}