diff options
author | Simon Ser <contact@emersion.fr> | 2024-02-22 19:26:06 +0100 |
---|---|---|
committer | Simon Ser <contact@emersion.fr> | 2024-02-23 18:52:48 +0100 |
commit | d5556ec78f65c286ae281a17d7b6b2ddc38c4c00 (patch) | |
tree | 94c083203c65b621f9ee8a5b58cd8f95d1ee04f5 /render/gles2/texture.c | |
parent | 2521fba37c396909eec6da88070ec9111aa2c507 (diff) |
render/egl: add save_context parameter to wlr_egl_make_current()
Saving the old context and immediately making our own context
current is a common pattern. Let's make it easier to do.
No functional change, just refactoring.
Diffstat (limited to 'render/gles2/texture.c')
-rw-r--r-- | render/gles2/texture.c | 23 |
1 files changed, 8 insertions, 15 deletions
diff --git a/render/gles2/texture.c b/render/gles2/texture.c index d66e9c16..f9ad4cc5 100644 --- a/render/gles2/texture.c +++ b/render/gles2/texture.c @@ -68,8 +68,7 @@ static bool gles2_texture_update_from_buffer(struct wlr_texture *wlr_texture, } struct wlr_egl_context prev_ctx; - wlr_egl_save_context(&prev_ctx); - wlr_egl_make_current(texture->renderer->egl); + wlr_egl_make_current(texture->renderer->egl, &prev_ctx); push_gles2_debug(texture->renderer); @@ -112,8 +111,7 @@ void gles2_texture_destroy(struct wlr_gles2_texture *texture) { wlr_buffer_unlock(texture->buffer->buffer); } else { struct wlr_egl_context prev_ctx; - wlr_egl_save_context(&prev_ctx); - wlr_egl_make_current(texture->renderer->egl); + wlr_egl_make_current(texture->renderer->egl, &prev_ctx); push_gles2_debug(texture->renderer); @@ -196,9 +194,7 @@ static bool gles2_texture_read_pixels(struct wlr_texture *wlr_texture, push_gles2_debug(texture->renderer); struct wlr_egl_context prev_ctx; - wlr_egl_save_context(&prev_ctx); - - if (!wlr_egl_make_current(texture->renderer->egl)) { + if (!wlr_egl_make_current(texture->renderer->egl, &prev_ctx)) { return false; } @@ -240,13 +236,12 @@ static uint32_t gles2_texture_preferred_read_format(struct wlr_texture *wlr_text struct wlr_gles2_texture *texture = gles2_get_texture(wlr_texture); push_gles2_debug(texture->renderer); - struct wlr_egl_context prev_ctx; - wlr_egl_save_context(&prev_ctx); uint32_t fmt = DRM_FORMAT_INVALID; - if (!wlr_egl_make_current(texture->renderer->egl)) { - goto out; + struct wlr_egl_context prev_ctx; + if (!wlr_egl_make_current(texture->renderer->egl, &prev_ctx)) { + return fmt; } if (!gles2_texture_bind(texture)) { @@ -339,8 +334,7 @@ static struct wlr_texture *gles2_texture_from_pixels( } struct wlr_egl_context prev_ctx; - wlr_egl_save_context(&prev_ctx); - wlr_egl_make_current(renderer->egl); + wlr_egl_make_current(renderer->egl, &prev_ctx); push_gles2_debug(renderer); @@ -387,8 +381,7 @@ static struct wlr_texture *gles2_texture_from_dmabuf( texture->has_alpha = pixel_format_has_alpha(attribs->format); struct wlr_egl_context prev_ctx; - wlr_egl_save_context(&prev_ctx); - wlr_egl_make_current(renderer->egl); + wlr_egl_make_current(renderer->egl, &prev_ctx); push_gles2_debug(texture->renderer); bool invalid; |