diff options
author | Simon Ser <contact@emersion.fr> | 2021-01-14 12:45:07 +0100 |
---|---|---|
committer | Simon Ser <contact@emersion.fr> | 2021-01-16 09:06:17 +0100 |
commit | afdf4dc890d512b4d56796451af5a76a18376c0e (patch) | |
tree | f84b567ad6f70f98eca9834a9123f9ea61555ffd /render/gles2 | |
parent | 08a4c62aac9d9771197018a155a9d80d6f93d764 (diff) |
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
Diffstat (limited to 'render/gles2')
-rw-r--r-- | render/gles2/renderer.c | 8 |
1 files changed, 6 insertions, 2 deletions
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); |