mirror of
https://gitlab.freedesktop.org/wlroots/wlroots.git
synced 2025-11-02 09:01:38 -05:00
Refactor wlr_egl_init to accept config_attribs
This commit is contained in:
parent
bc5bdb7793
commit
b99d1f4fcc
6 changed files with 36 additions and 106 deletions
21
render/egl.c
21
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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue