aboutsummaryrefslogtreecommitdiff
path: root/render/gles2/texture.c
diff options
context:
space:
mode:
authorSimon Ser <contact@emersion.fr>2020-05-19 11:54:59 +0200
committerDrew DeVault <sir@cmpwn.com>2020-05-19 14:56:20 +0200
commit1edc42157bbb01b25ec27750f883fd84ee5908d6 (patch)
tree068205ea52bf4c76a86e96f19862f794852937d0 /render/gles2/texture.c
parent781ed1ff02e38dffdfebca0fa80baa1791849c3b (diff)
render/egl: introduce wlr_egl_unset_current
This function can be called after wlr_egl_make_current to cleanup the EGL context. This avoids having lingering EGL contexts that make things work by chance. Closes: https://github.com/swaywm/wlroots/issues/2197
Diffstat (limited to 'render/gles2/texture.c')
-rw-r--r--render/gles2/texture.c34
1 files changed, 17 insertions, 17 deletions
diff --git a/render/gles2/texture.c b/render/gles2/texture.c
index 32efb03f..64a0d9f1 100644
--- a/render/gles2/texture.c
+++ b/render/gles2/texture.c
@@ -29,9 +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);
- if (!wlr_egl_is_current(texture->egl)) {
- wlr_egl_make_current(texture->egl, EGL_NO_SURFACE, NULL);
- }
+ wlr_egl_make_current(texture->egl, EGL_NO_SURFACE, NULL);
return texture;
}
@@ -49,6 +47,7 @@ static bool gles2_texture_write_pixels(struct wlr_texture *wlr_texture,
if (texture->target != GL_TEXTURE_2D) {
wlr_log(WLR_ERROR, "Cannot write pixels to immutable texture");
+ wlr_egl_unset_current(texture->egl);
return false;
}
@@ -75,6 +74,8 @@ static bool gles2_texture_write_pixels(struct wlr_texture *wlr_texture,
glBindTexture(GL_TEXTURE_2D, 0);
POP_GLES2_DEBUG;
+
+ wlr_egl_unset_current(texture->egl);
return true;
}
@@ -111,11 +112,8 @@ static void gles2_texture_destroy(struct wlr_texture *wlr_texture) {
return;
}
- struct wlr_gles2_texture *texture = gles2_get_texture(wlr_texture);
-
- if (!wlr_egl_is_current(texture->egl)) {
- wlr_egl_make_current(texture->egl, EGL_NO_SURFACE, NULL);
- }
+ struct wlr_gles2_texture *texture =
+ get_gles2_texture_in_context(wlr_texture);
PUSH_GLES2_DEBUG;
@@ -124,6 +122,8 @@ static void gles2_texture_destroy(struct wlr_texture *wlr_texture) {
POP_GLES2_DEBUG;
+ wlr_egl_unset_current(texture->egl);
+
free(texture);
}
@@ -137,9 +137,7 @@ static const struct wlr_texture_impl texture_impl = {
struct wlr_texture *wlr_gles2_texture_from_pixels(struct wlr_egl *egl,
enum wl_shm_format wl_fmt, uint32_t stride, uint32_t width,
uint32_t height, const void *data) {
- if (!wlr_egl_is_current(egl)) {
- wlr_egl_make_current(egl, EGL_NO_SURFACE, NULL);
- }
+ wlr_egl_make_current(egl, EGL_NO_SURFACE, NULL);
const struct wlr_gles2_pixel_format *fmt = get_gles2_format_from_wl(wl_fmt);
if (fmt == NULL) {
@@ -172,14 +170,14 @@ struct wlr_texture *wlr_gles2_texture_from_pixels(struct wlr_egl *egl,
glBindTexture(GL_TEXTURE_2D, 0);
POP_GLES2_DEBUG;
+
+ wlr_egl_unset_current(egl);
return &texture->wlr_texture;
}
struct wlr_texture *wlr_gles2_texture_from_wl_drm(struct wlr_egl *egl,
struct wl_resource *resource) {
- if (!wlr_egl_is_current(egl)) {
- wlr_egl_make_current(egl, EGL_NO_SURFACE, NULL);
- }
+ wlr_egl_make_current(egl, EGL_NO_SURFACE, NULL);
if (!gles2_procs.glEGLImageTargetTexture2DOES) {
return NULL;
@@ -235,14 +233,14 @@ struct wlr_texture *wlr_gles2_texture_from_wl_drm(struct wlr_egl *egl,
glBindTexture(GL_TEXTURE_EXTERNAL_OES, 0);
POP_GLES2_DEBUG;
+
+ wlr_egl_unset_current(egl);
return &texture->wlr_texture;
}
struct wlr_texture *wlr_gles2_texture_from_dmabuf(struct wlr_egl *egl,
struct wlr_dmabuf_attributes *attribs) {
- if (!wlr_egl_is_current(egl)) {
- wlr_egl_make_current(egl, EGL_NO_SURFACE, NULL);
- }
+ wlr_egl_make_current(egl, EGL_NO_SURFACE, NULL);
if (!gles2_procs.glEGLImageTargetTexture2DOES) {
return NULL;
@@ -297,6 +295,8 @@ struct wlr_texture *wlr_gles2_texture_from_dmabuf(struct wlr_egl *egl,
glBindTexture(GL_TEXTURE_EXTERNAL_OES, 0);
POP_GLES2_DEBUG;
+
+ wlr_egl_unset_current(egl);
return &texture->wlr_texture;
}