Skip to content

Commit

Permalink
render/egl: remove config_attribs and egl->config
Browse files Browse the repository at this point in the history
Just another part of swaywm#2624 and swaywm#1352 that I felt needed to be done.

Breaking change:

Both "EGLint *config_attribs" and "egl->config" no longer exist.
  • Loading branch information
berylline committed Jan 22, 2021
1 parent 7bc8dbb commit 1e92c27
Show file tree
Hide file tree
Showing 12 changed files with 18 additions and 49 deletions.
3 changes: 1 addition & 2 deletions examples/idle-inhibit.c
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,7 @@ int main(int argc, char **argv) {
return EXIT_FAILURE;
}

EGLint attribs[] = { EGL_NONE };
egl = wlr_egl_create(EGL_PLATFORM_WAYLAND_EXT, display, attribs);
egl = wlr_egl_create(EGL_PLATFORM_WAYLAND_EXT, display);

struct wl_surface *surface = wl_compositor_create_surface(compositor);
struct xdg_surface *xdg_surface =
Expand Down
3 changes: 1 addition & 2 deletions examples/input-inhibitor.c
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,7 @@ int main(int argc, char **argv) {
input_inhibit_manager);
assert(input_inhibitor);

EGLint attribs[] = { EGL_NONE };
egl = wlr_egl_create(EGL_PLATFORM_WAYLAND_EXT, display, attribs);
egl = wlr_egl_create(EGL_PLATFORM_WAYLAND_EXT, display);

struct wl_surface *surface = wl_compositor_create_surface(compositor);
assert(surface);
Expand Down
3 changes: 1 addition & 2 deletions examples/keyboard-shortcuts-inhibit.c
Original file line number Diff line number Diff line change
Expand Up @@ -224,8 +224,7 @@ int main(int argc, char **argv) {
return EXIT_FAILURE;
}

EGLint attribs[] = { EGL_NONE };
egl = wlr_egl_create(EGL_PLATFORM_WAYLAND_EXT, display, attribs);
egl = wlr_egl_create(EGL_PLATFORM_WAYLAND_EXT, display);

struct wl_surface *surface = wl_compositor_create_surface(compositor);
struct xdg_surface *xdg_surface =
Expand Down
3 changes: 1 addition & 2 deletions examples/layer-shell.c
Original file line number Diff line number Diff line change
Expand Up @@ -631,8 +631,7 @@ int main(int argc, char **argv) {
cursor_surface = wl_compositor_create_surface(compositor);
assert(cursor_surface);

EGLint attribs[] = { EGL_ALPHA_SIZE, 8, EGL_NONE };
egl = wlr_egl_create(EGL_PLATFORM_WAYLAND_EXT, display, attribs);
egl = wlr_egl_create(EGL_PLATFORM_WAYLAND_EXT, display);

wl_surface = wl_compositor_create_surface(compositor);
assert(wl_surface);
Expand Down
3 changes: 1 addition & 2 deletions examples/pointer-constraints.c
Original file line number Diff line number Diff line change
Expand Up @@ -211,8 +211,7 @@ int main(int argc, char **argv) {
wl_region_add(joint_region, 256, 256, 256, 256);
regions[REGION_TYPE_JOINT] = joint_region;

EGLint attribs[] = { EGL_NONE };
egl = wlr_egl_create(EGL_PLATFORM_WAYLAND_EXT, display, attribs);
egl = wlr_egl_create(EGL_PLATFORM_WAYLAND_EXT, display);

struct wl_surface *surface = wl_compositor_create_surface(compositor);
struct xdg_surface *xdg_surface =
Expand Down
3 changes: 1 addition & 2 deletions examples/relative-pointer-unstable-v1.c
Original file line number Diff line number Diff line change
Expand Up @@ -442,8 +442,7 @@ int main(int argc, char **argv) {
struct egl_info *e = calloc(1, sizeof(struct egl_info));
e->width = e->height = 512;

EGLint attribs[] = { EGL_NONE };
e->egl = wlr_egl_create(EGL_PLATFORM_WAYLAND_EXT, display, attribs);
e->egl = wlr_egl_create(EGL_PLATFORM_WAYLAND_EXT, display);

/* Create the surface and xdg_toplevels, and set listeners */

Expand Down
3 changes: 1 addition & 2 deletions examples/text-input.c
Original file line number Diff line number Diff line change
Expand Up @@ -363,8 +363,7 @@ int main(int argc, char **argv) {

zwp_text_input_v3_add_listener(text_input, &text_input_listener, NULL);

EGLint attribs[] = { EGL_NONE };
egl = wlr_egl_create(EGL_PLATFORM_WAYLAND_EXT, display, attribs);
egl = wlr_egl_create(EGL_PLATFORM_WAYLAND_EXT, display);

struct wl_surface *surface = wl_compositor_create_surface(compositor);
struct xdg_surface *xdg_surface =
Expand Down
3 changes: 1 addition & 2 deletions examples/toplevel-decoration.c
Original file line number Diff line number Diff line change
Expand Up @@ -218,8 +218,7 @@ int main(int argc, char **argv) {
return EXIT_FAILURE;
}

EGLint attribs[] = { EGL_NONE };
egl = wlr_egl_create(EGL_PLATFORM_WAYLAND_EXT, display, attribs);
egl = wlr_egl_create(EGL_PLATFORM_WAYLAND_EXT, display);

struct wl_surface *surface = wl_compositor_create_surface(compositor);
struct xdg_surface *xdg_surface =
Expand Down
6 changes: 1 addition & 5 deletions include/wlr/render/egl.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ struct wlr_egl_context {

struct wlr_egl {
EGLDisplay display;
EGLConfig config; // may be EGL_NO_CONFIG
EGLContext context;
EGLDeviceEXT device; // may be EGL_NO_DEVICE_EXT
struct gbm_device *gbm_device;
Expand Down Expand Up @@ -81,11 +80,8 @@ struct wlr_egl {
/**
* Initializes an EGL context for the given platform and remote display.
* Will attempt to load all possibly required api functions.
*
* If config_attribs is NULL, the EGL config is not created.
*/
struct wlr_egl *wlr_egl_create(EGLenum platform, void *remote_display,
const EGLint *config_attribs);
struct wlr_egl *wlr_egl_create(EGLenum platform, void *remote_display);

/**
* Frees all related EGL resources, makes the context not-current and
Expand Down
31 changes: 8 additions & 23 deletions render/egl.c
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,7 @@ static void init_dmabuf_formats(struct wlr_egl *egl) {
free(formats);
}

struct wlr_egl *wlr_egl_create(EGLenum platform, void *remote_display,
const EGLint *config_attribs) {
struct wlr_egl *wlr_egl_create(EGLenum platform, void *remote_display) {
struct wlr_egl *egl = calloc(1, sizeof(struct wlr_egl));
if (egl == NULL) {
wlr_log_errno(WLR_ERROR, "Allocation failed");
Expand Down Expand Up @@ -276,25 +275,11 @@ struct wlr_egl *wlr_egl_create(EGLenum platform, void *remote_display,
check_egl_ext(device_exts_str, "EGL_EXT_device_drm");
}

if (config_attribs != NULL) {
EGLint matched = 0;
if (!eglChooseConfig(egl->display, config_attribs, &egl->config, 1,
&matched)) {
wlr_log(WLR_ERROR, "eglChooseConfig failed");
goto error;
}
if (matched == 0) {
wlr_log(WLR_ERROR, "Failed to match an EGL config");
goto error;
}
} else {
if (!check_egl_ext(display_exts_str, "EGL_KHR_no_config_context") &&
!check_egl_ext(display_exts_str, "EGL_MESA_configless_context")) {
wlr_log(WLR_ERROR, "EGL_KHR_no_config_context or "
"EGL_MESA_configless_context not supported");
goto error;
}
egl->config = EGL_NO_CONFIG_KHR;
if (!check_egl_ext(display_exts_str, "EGL_KHR_no_config_context") &&
!check_egl_ext(display_exts_str, "EGL_MESA_configless_context")) {
wlr_log(WLR_ERROR, "EGL_KHR_no_config_context or "
"EGL_MESA_configless_context not supported");
goto error;
}

wlr_log(WLR_INFO, "Using EGL %d.%d", (int)major, (int)minor);
Expand Down Expand Up @@ -329,7 +314,7 @@ struct wlr_egl *wlr_egl_create(EGLenum platform, void *remote_display,
attribs[atti++] = EGL_NONE;
assert(atti <= sizeof(attribs)/sizeof(attribs[0]));

egl->context = eglCreateContext(egl->display, egl->config,
egl->context = eglCreateContext(egl->display, EGL_NO_CONFIG_KHR,
EGL_NO_CONTEXT, attribs);
if (egl->context == EGL_NO_CONTEXT) {
wlr_log(WLR_ERROR, "Failed to create EGL context");
Expand Down Expand Up @@ -409,7 +394,7 @@ bool wlr_egl_destroy_image(struct wlr_egl *egl, EGLImage image) {
EGLSurface wlr_egl_create_surface(struct wlr_egl *egl, void *window) {
assert(egl->procs.eglCreatePlatformWindowSurfaceEXT);
EGLSurface surf = egl->procs.eglCreatePlatformWindowSurfaceEXT(
egl->display, egl->config, window, NULL);
egl->display, EGL_NO_CONFIG_KHR, window, NULL);
if (surf == EGL_NO_SURFACE) {
wlr_log(WLR_ERROR, "Failed to create EGL surface");
return EGL_NO_SURFACE;
Expand Down
3 changes: 0 additions & 3 deletions render/gles2/renderer.c
Original file line number Diff line number Diff line change
Expand Up @@ -466,9 +466,6 @@ static enum wl_shm_format gles2_preferred_read_format(
glGetRenderbufferParameteriv(GL_RENDERBUFFER,
GL_RENDERBUFFER_ALPHA_SIZE, &alpha_size);
glBindRenderbuffer(GL_RENDERBUFFER, 0);
} else if (renderer->egl->config != EGL_NO_CONFIG_KHR) {
eglGetConfigAttrib(renderer->egl->display, renderer->egl->config,
EGL_ALPHA_SIZE, &alpha_size);
}

const struct wlr_gles2_pixel_format *fmt =
Expand Down
3 changes: 1 addition & 2 deletions render/wlr_renderer.c
Original file line number Diff line number Diff line change
Expand Up @@ -257,8 +257,7 @@ struct wlr_renderer *wlr_renderer_autocreate_with_drm_fd(int drm_fd) {
return NULL;
}

struct wlr_egl *egl = wlr_egl_create(EGL_PLATFORM_GBM_KHR, gbm_device,
NULL);
struct wlr_egl *egl = wlr_egl_create(EGL_PLATFORM_GBM_KHR, gbm_device);
if (egl == NULL) {
wlr_log(WLR_ERROR, "Could not initialize EGL");
gbm_device_destroy(gbm_device);
Expand Down

0 comments on commit 1e92c27

Please sign in to comment.