Change egl_get_config to always use visual id

This commit is contained in:
Scott Anderson 2017-09-26 14:57:23 +13:00
parent 7ad2a57feb
commit 517ba0bc16
4 changed files with 12 additions and 19 deletions

View File

@ -182,7 +182,8 @@ bool wlr_drm_renderer_init(struct wlr_drm_renderer *renderer, int fd) {
return false; return false;
} }
if (!wlr_egl_init(&renderer->egl, EGL_PLATFORM_GBM_MESA, renderer->gbm)) { if (!wlr_egl_init(&renderer->egl, EGL_PLATFORM_GBM_MESA,
GBM_FORMAT_ARGB8888, renderer->gbm)) {
gbm_device_destroy(renderer->gbm); gbm_device_destroy(renderer->gbm);
return false; return false;
} }

View File

@ -42,6 +42,7 @@ static bool wlr_wl_backend_start(struct wlr_backend *_backend) {
} }
backend->started = true; backend->started = true;
for (size_t i = 0; i < backend->requested_outputs; ++i) { for (size_t i = 0; i < backend->requested_outputs; ++i) {
wlr_wl_output_create(&backend->backend); wlr_wl_output_create(&backend->backend);
} }
@ -145,7 +146,7 @@ struct wlr_backend *wlr_wl_backend_create(struct wl_display *display) {
return false; return false;
} }
wlr_egl_init(&backend->egl, EGL_PLATFORM_WAYLAND_EXT, backend->remote_display); wlr_egl_init(&backend->egl, EGL_PLATFORM_WAYLAND_EXT, WL_SHM_FORMAT_ARGB8888, backend->remote_display);
wlr_egl_bind_display(&backend->egl, backend->local_display); wlr_egl_bind_display(&backend->egl, backend->local_display);
return &backend->backend; return &backend->backend;

View File

@ -30,7 +30,7 @@ struct wlr_egl {
* Initializes an egl context for the given platform and remote display. * Initializes an egl context for the given platform and remote display.
* Will attempt to load all possibly required api functions. * Will attempt to load all possibly required api functions.
*/ */
bool wlr_egl_init(struct wlr_egl *egl, EGLenum platform, void *display); bool wlr_egl_init(struct wlr_egl *egl, EGLenum platform, EGLint visual_id, void *display);
/** /**
* Frees all related egl resources, makes the context not-current and * Frees all related egl resources, makes the context not-current and

View File

@ -1,7 +1,6 @@
#include <EGL/egl.h> #include <EGL/egl.h>
#include <EGL/eglext.h> #include <EGL/eglext.h>
#include <GLES2/gl2.h> #include <GLES2/gl2.h>
#include <gbm.h> // GBM_FORMAT_XRGB8888
#include <stdlib.h> #include <stdlib.h>
#include <wlr/util/log.h> #include <wlr/util/log.h>
#include <wlr/egl.h> #include <wlr/egl.h>
@ -68,7 +67,7 @@ static bool egl_exts(struct wlr_egl *egl) {
return true; return true;
} }
static bool egl_get_config(EGLDisplay disp, EGLConfig *out, EGLenum platform) { static bool egl_get_config(EGLDisplay disp, EGLConfig *out, EGLint visual_id) {
EGLint count = 0, matched = 0, ret; EGLint count = 0, matched = 0, ret;
ret = eglGetConfigs(disp, NULL, 0, &count); ret = eglGetConfigs(disp, NULL, 0, &count);
@ -86,21 +85,13 @@ static bool egl_get_config(EGLDisplay disp, EGLConfig *out, EGLenum platform) {
} }
for (int i = 0; i < matched; ++i) { for (int i = 0; i < matched; ++i) {
EGLint gbm_format; EGLint visual;
if (!eglGetConfigAttrib(disp, configs[i],
if (platform == EGL_PLATFORM_WAYLAND_EXT) { EGL_NATIVE_VISUAL_ID, &visual)) {
*out = configs[i];
return true;
}
if (!eglGetConfigAttrib(disp,
configs[i],
EGL_NATIVE_VISUAL_ID,
&gbm_format)) {
continue; continue;
} }
if (gbm_format == GBM_FORMAT_ARGB8888) { if (visual == visual_id) {
*out = configs[i]; *out = configs[i];
return true; return true;
} }
@ -110,7 +101,7 @@ static bool egl_get_config(EGLDisplay disp, EGLConfig *out, EGLenum platform) {
return false; return false;
} }
bool wlr_egl_init(struct wlr_egl *egl, EGLenum platform, bool wlr_egl_init(struct wlr_egl *egl, EGLenum platform, EGLint visual_id,
void *remote_display) { void *remote_display) {
if (!egl_exts(egl)) { if (!egl_exts(egl)) {
return false; return false;
@ -133,7 +124,7 @@ bool wlr_egl_init(struct wlr_egl *egl, EGLenum platform,
goto error; goto error;
} }
if (!egl_get_config(egl->display, &egl->config, platform)) { if (!egl_get_config(egl->display, &egl->config, visual_id)) {
wlr_log(L_ERROR, "Failed to get EGL config"); wlr_log(L_ERROR, "Failed to get EGL config");
goto error; goto error;
} }