From 3f7e0cf5f073ef7ef88128e8661b959cc9140490 Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Sat, 9 Jan 2021 12:13:35 +0100 Subject: [PATCH] render/egl: remove surface and buffer age args from make_current These aren't used anymore. --- backend/drm/renderer.c | 2 +- backend/headless/output.c | 2 +- backend/wayland/output.c | 4 ++-- backend/x11/output.c | 2 +- include/wlr/render/egl.h | 7 ++----- render/egl.c | 31 ++++--------------------------- render/gles2/renderer.c | 8 ++++---- render/gles2/texture.c | 8 ++++---- 8 files changed, 19 insertions(+), 45 deletions(-) diff --git a/backend/drm/renderer.c b/backend/drm/renderer.c index 2997687f..f2d7677c 100644 --- a/backend/drm/renderer.c +++ b/backend/drm/renderer.c @@ -116,7 +116,7 @@ bool drm_surface_make_current(struct wlr_drm_surface *surf, } struct wlr_egl *egl = wlr_gles2_renderer_get_egl(surf->renderer->wlr_rend); - if (!wlr_egl_make_current(egl, EGL_NO_SURFACE, NULL)) { + if (!wlr_egl_make_current(egl)) { return false; } if (!wlr_renderer_bind_buffer(surf->renderer->wlr_rend, surf->back_buffer)) { diff --git a/backend/headless/output.c b/backend/headless/output.c index ee1fd317..0ffdee79 100644 --- a/backend/headless/output.c +++ b/backend/headless/output.c @@ -52,7 +52,7 @@ static bool output_attach_render(struct wlr_output *wlr_output, return false; } - if (!wlr_egl_make_current(egl, EGL_NO_SURFACE, NULL)) { + if (!wlr_egl_make_current(egl)) { return false; } if (!wlr_renderer_bind_buffer(output->backend->renderer, diff --git a/backend/wayland/output.c b/backend/wayland/output.c index bf2d97ca..3abf2b5e 100644 --- a/backend/wayland/output.c +++ b/backend/wayland/output.c @@ -125,7 +125,7 @@ static bool output_attach_render(struct wlr_output *wlr_output, return false; } - if (!wlr_egl_make_current(egl, EGL_NO_SURFACE, NULL)) { + if (!wlr_egl_make_current(egl)) { return false; } if (!wlr_renderer_bind_buffer(output->backend->renderer, @@ -433,7 +433,7 @@ static bool output_set_cursor(struct wlr_output *wlr_output, return false; } - if (!wlr_egl_make_current(egl, EGL_NO_SURFACE, NULL)) { + if (!wlr_egl_make_current(egl)) { return false; } if (!wlr_renderer_bind_buffer(output->backend->renderer, wlr_buffer)) { diff --git a/backend/x11/output.c b/backend/x11/output.c index 4d764414..11dda67d 100644 --- a/backend/x11/output.c +++ b/backend/x11/output.c @@ -106,7 +106,7 @@ static bool output_attach_render(struct wlr_output *wlr_output, return false; } - if (!wlr_egl_make_current(egl, EGL_NO_SURFACE, NULL)) { + if (!wlr_egl_make_current(egl)) { return false; } if (!wlr_renderer_bind_buffer(x11->renderer, output->back_buffer)) { diff --git a/include/wlr/render/egl.h b/include/wlr/render/egl.h index b967be8e..845cc388 100644 --- a/include/wlr/render/egl.h +++ b/include/wlr/render/egl.h @@ -45,7 +45,6 @@ struct wlr_egl { struct { // Display extensions bool bind_wayland_display_wl; - bool buffer_age_ext; bool image_base_khr; bool image_dma_buf_export_mesa; bool image_dmabuf_import_ext; @@ -141,14 +140,12 @@ bool wlr_egl_export_image_to_dmabuf(struct wlr_egl *egl, EGLImageKHR image, bool wlr_egl_destroy_image(struct wlr_egl *egl, EGLImageKHR image); /** - * Make the EGL context current. The provided surface will be made current - * unless EGL_NO_SURFACE. + * Make the EGL context current. * * Callers are expected to clear the current context when they are done by * calling wlr_egl_unset_current. */ -bool wlr_egl_make_current(struct wlr_egl *egl, EGLSurface surface, - int *buffer_age); +bool wlr_egl_make_current(struct wlr_egl *egl); bool wlr_egl_unset_current(struct wlr_egl *egl); diff --git a/render/egl.c b/render/egl.c index 8cf20ece..1c986e47 100644 --- a/render/egl.c +++ b/render/egl.c @@ -220,9 +220,6 @@ struct wlr_egl *wlr_egl_create(EGLenum platform, void *remote_display, load_egl_proc(&egl->procs.eglDestroyImageKHR, "eglDestroyImageKHR"); } - egl->exts.buffer_age_ext = - check_egl_ext(display_exts_str, "EGL_EXT_buffer_age"); - egl->exts.image_dmabuf_import_ext = check_egl_ext(display_exts_str, "EGL_EXT_image_dma_buf_import"); if (check_egl_ext(display_exts_str, @@ -414,32 +411,12 @@ EGLSurface wlr_egl_create_surface(struct wlr_egl *egl, void *window) { return surf; } -static int egl_get_buffer_age(struct wlr_egl *egl, EGLSurface surface) { - if (!egl->exts.buffer_age_ext) { - return -1; - } - - EGLint buffer_age; - EGLBoolean ok = eglQuerySurface(egl->display, surface, - EGL_BUFFER_AGE_EXT, &buffer_age); - if (!ok) { - wlr_log(WLR_ERROR, "Failed to get EGL surface buffer age"); - return -1; - } - - return buffer_age; -} - -bool wlr_egl_make_current(struct wlr_egl *egl, EGLSurface surface, - int *buffer_age) { - if (!eglMakeCurrent(egl->display, surface, surface, egl->context)) { +bool wlr_egl_make_current(struct wlr_egl *egl) { + if (!eglMakeCurrent(egl->display, EGL_NO_SURFACE, EGL_NO_SURFACE, + egl->context)) { wlr_log(WLR_ERROR, "eglMakeCurrent failed"); return false; } - - if (buffer_age != NULL) { - *buffer_age = egl_get_buffer_age(egl, surface); - } return true; } @@ -751,7 +728,7 @@ bool wlr_egl_destroy_surface(struct wlr_egl *egl, EGLSurface surface) { // Reset the current EGL surface in case it's the one we're destroying, // otherwise the next wlr_egl_make_current call will result in a // use-after-free. - wlr_egl_make_current(egl, EGL_NO_SURFACE, NULL); + wlr_egl_make_current(egl); } return eglDestroySurface(egl->display, surface); } diff --git a/render/gles2/renderer.c b/render/gles2/renderer.c index 5474e1b6..428fcd95 100644 --- a/render/gles2/renderer.c +++ b/render/gles2/renderer.c @@ -41,7 +41,7 @@ static void destroy_buffer(struct wlr_gles2_buffer *buffer) { wl_list_remove(&buffer->link); wl_list_remove(&buffer->buffer_destroy.link); - wlr_egl_make_current(buffer->renderer->egl, EGL_NO_SURFACE, NULL); + wlr_egl_make_current(buffer->renderer->egl); push_gles2_debug(buffer->renderer); @@ -575,7 +575,7 @@ static bool gles2_blit_dmabuf(struct wlr_renderer *wlr_renderer, gles2_src_tex->inverted_y = !gles2_src_tex->inverted_y; } - if (!wlr_egl_make_current(renderer->egl, EGL_NO_SURFACE, NULL)) { + if (!wlr_egl_make_current(renderer->egl)) { goto texture_destroy_out; } @@ -673,7 +673,7 @@ struct wlr_egl *wlr_gles2_renderer_get_egl(struct wlr_renderer *wlr_renderer) { static void gles2_destroy(struct wlr_renderer *wlr_renderer) { struct wlr_gles2_renderer *renderer = gles2_get_renderer(wlr_renderer); - wlr_egl_make_current(renderer->egl, EGL_NO_SURFACE, NULL); + wlr_egl_make_current(renderer->egl); struct wlr_gles2_buffer *buffer, *buffer_tmp; wl_list_for_each_safe(buffer, buffer_tmp, &renderer->buffers, link) { @@ -861,7 +861,7 @@ extern const GLchar tex_fragment_src_rgbx[]; extern const GLchar tex_fragment_src_external[]; struct wlr_renderer *wlr_gles2_renderer_create(struct wlr_egl *egl) { - if (!wlr_egl_make_current(egl, EGL_NO_SURFACE, NULL)) { + if (!wlr_egl_make_current(egl)) { return NULL; } diff --git a/render/gles2/texture.c b/render/gles2/texture.c index ea3a1161..9f886391 100644 --- a/render/gles2/texture.c +++ b/render/gles2/texture.c @@ -29,7 +29,7 @@ struct wlr_gles2_texture *gles2_get_texture( static struct wlr_gles2_texture *get_gles2_texture_in_context( struct wlr_texture *wlr_texture) { struct wlr_gles2_texture *texture = gles2_get_texture(wlr_texture); - wlr_egl_make_current(texture->renderer->egl, EGL_NO_SURFACE, NULL); + wlr_egl_make_current(texture->renderer->egl); return texture; } @@ -138,7 +138,7 @@ struct wlr_texture *gles2_texture_from_pixels(struct wlr_renderer *wlr_renderer, uint32_t height, const void *data) { struct wlr_gles2_renderer *renderer = gles2_get_renderer(wlr_renderer); - wlr_egl_make_current(renderer->egl, EGL_NO_SURFACE, NULL); + wlr_egl_make_current(renderer->egl); const struct wlr_gles2_pixel_format *fmt = get_gles2_format_from_wl(wl_fmt); if (fmt == NULL) { @@ -180,7 +180,7 @@ struct wlr_texture *gles2_texture_from_wl_drm(struct wlr_renderer *wlr_renderer, struct wl_resource *resource) { struct wlr_gles2_renderer *renderer = gles2_get_renderer(wlr_renderer); - wlr_egl_make_current(renderer->egl, EGL_NO_SURFACE, NULL); + wlr_egl_make_current(renderer->egl); if (!renderer->procs.glEGLImageTargetTexture2DOES) { return NULL; @@ -245,7 +245,7 @@ struct wlr_texture *gles2_texture_from_dmabuf(struct wlr_renderer *wlr_renderer, struct wlr_dmabuf_attributes *attribs) { struct wlr_gles2_renderer *renderer = gles2_get_renderer(wlr_renderer); - wlr_egl_make_current(renderer->egl, EGL_NO_SURFACE, NULL); + wlr_egl_make_current(renderer->egl); if (!renderer->procs.glEGLImageTargetTexture2DOES) { return NULL;