diff options
author | Drew DeVault <sir@cmpwn.com> | 2017-12-17 20:48:01 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-12-17 20:48:01 -0500 |
commit | f3769a4b1f552b7dc826418e78b88bffe277c2c4 (patch) | |
tree | fe07e6a1333f8f96a9075deb26e3ea96519e618b /render | |
parent | 10c72f4bf6202bfce89e5a40b03475dd28cd68df (diff) | |
parent | b99d1f4fcca0f8d7b1d2042f51fdefcc73304e6f (diff) |
Merge pull request #496 from emersion/headless-backend
Headless backend
Diffstat (limited to 'render')
-rw-r--r-- | render/egl.c | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/render/egl.c b/render/egl.c index e895df8d..fe20973c 100644 --- a/render/egl.c +++ b/render/egl.c @@ -1,3 +1,4 @@ +#include <assert.h> #include <EGL/egl.h> #include <EGL/eglext.h> #include <GLES2/gl2.h> @@ -47,7 +48,8 @@ const char *egl_error(void) { } } -static bool egl_get_config(EGLDisplay disp, EGLConfig *out, EGLint visual_id) { +static bool egl_get_config(EGLDisplay disp, EGLint *attribs, EGLConfig *out, + EGLint visual_id) { EGLint count = 0, matched = 0, ret; ret = eglGetConfigs(disp, NULL, 0, &count); @@ -58,7 +60,7 @@ static bool egl_get_config(EGLDisplay disp, EGLConfig *out, EGLint visual_id) { EGLConfig configs[count]; - ret = eglChooseConfig(disp, NULL, configs, count, &matched); + ret = eglChooseConfig(disp, attribs, configs, count, &matched); if (ret == EGL_FALSE) { wlr_log(L_ERROR, "eglChooseConfig failed"); return false; @@ -71,7 +73,7 @@ static bool egl_get_config(EGLDisplay disp, EGLConfig *out, EGLint visual_id) { continue; } - if (visual == visual_id) { + if (!visual_id || visual == visual_id) { *out = configs[i]; return true; } @@ -81,8 +83,8 @@ static bool egl_get_config(EGLDisplay disp, EGLConfig *out, EGLint visual_id) { return false; } -bool wlr_egl_init(struct wlr_egl *egl, EGLenum platform, EGLint visual_id, - void *remote_display) { +bool wlr_egl_init(struct wlr_egl *egl, EGLenum platform, void *remote_display, + EGLint *config_attribs, EGLint visual_id) { if (!load_glapi()) { return false; } @@ -92,7 +94,12 @@ bool wlr_egl_init(struct wlr_egl *egl, EGLenum platform, EGLint visual_id, goto error; } - egl->display = eglGetPlatformDisplayEXT(platform, remote_display, NULL); + if (platform == EGL_PLATFORM_SURFACELESS_MESA) { + assert(remote_display == NULL); + egl->display = eglGetDisplay(EGL_DEFAULT_DISPLAY); + } else { + egl->display = eglGetPlatformDisplayEXT(platform, remote_display, NULL); + } if (egl->display == EGL_NO_DISPLAY) { wlr_log(L_ERROR, "Failed to create EGL display: %s", egl_error()); goto error; @@ -104,7 +111,7 @@ bool wlr_egl_init(struct wlr_egl *egl, EGLenum platform, EGLint visual_id, goto error; } - if (!egl_get_config(egl->display, &egl->config, visual_id)) { + if (!egl_get_config(egl->display, config_attribs, &egl->config, visual_id)) { wlr_log(L_ERROR, "Failed to get EGL config"); goto error; } |