diff options
author | emersion <contact@emersion.fr> | 2017-12-17 23:51:04 +0100 |
---|---|---|
committer | emersion <contact@emersion.fr> | 2017-12-17 23:51:04 +0100 |
commit | b99d1f4fcca0f8d7b1d2042f51fdefcc73304e6f (patch) | |
tree | fab66d90e45cff436d123eab2f4475ed4f5bb7bc /render | |
parent | bc5bdb7793d7737a42489ddb07b2fbb7f74a47f5 (diff) |
Refactor wlr_egl_init to accept config_attribs
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; } |