From afdf4dc890d512b4d56796451af5a76a18376c0e Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Thu, 14 Jan 2021 12:45:07 +0100 Subject: render/gles2: make EGL context current in bind_buffer Instead of requiring callers to manually make the EGL context current before binding a buffer and unsetting it after unbinding a buffer, do it inside wlr_renderer_bind_buffer. This hides renderer-specific implementation details inside the wlr_renderer interface. Non-GLES2 renderers may not use EGL. This removes all EGL dependencies from the backends. References: https://github.com/swaywm/wlroots/issues/2618 References: https://github.com/swaywm/wlroots/pull/2615#issuecomment-756687006 --- render/gles2/renderer.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'render/gles2') diff --git a/render/gles2/renderer.c b/render/gles2/renderer.c index 8e7c37a8..59d46a91 100644 --- a/render/gles2/renderer.c +++ b/render/gles2/renderer.c @@ -139,10 +139,11 @@ error_buffer: static bool gles2_bind_buffer(struct wlr_renderer *wlr_renderer, struct wlr_buffer *wlr_buffer) { - struct wlr_gles2_renderer *renderer = - gles2_get_renderer_in_context(wlr_renderer); + struct wlr_gles2_renderer *renderer = gles2_get_renderer(wlr_renderer); if (renderer->current_buffer != NULL) { + assert(wlr_egl_is_current(renderer->egl)); + push_gles2_debug(renderer); glFlush(); glBindFramebuffer(GL_FRAMEBUFFER, 0); @@ -153,9 +154,12 @@ static bool gles2_bind_buffer(struct wlr_renderer *wlr_renderer, } if (wlr_buffer == NULL) { + wlr_egl_unset_current(renderer->egl); return true; } + wlr_egl_make_current(renderer->egl); + struct wlr_gles2_buffer *buffer = get_buffer(renderer, wlr_buffer); if (buffer == NULL) { buffer = create_buffer(renderer, wlr_buffer); -- cgit v1.2.3