From e40f16c60ecb526636bf3c020713e82bb93983d3 Mon Sep 17 00:00:00 2001 From: Yuxuan Shui Date: Sun, 10 Mar 2019 19:59:44 +0000 Subject: [PATCH] new glx: fix leak of X pixmaps release_image should release the X pixmap when it's owned by the backend. Signed-off-by: Yuxuan Shui --- src/backend/gl/gl_common.c | 1 + src/backend/gl/glx.c | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/src/backend/gl/gl_common.c b/src/backend/gl/gl_common.c index ded67be..137f049 100644 --- a/src/backend/gl/gl_common.c +++ b/src/backend/gl/gl_common.c @@ -736,6 +736,7 @@ bool gl_image_op(backend_t *base, enum image_operations op, void *image_data, break; case IMAGE_OP_APPLY_ALPHA_ALL: tex->opacity *= *(double *)arg; break; case IMAGE_OP_APPLY_ALPHA: + // TODO log_warn("IMAGE_OP_APPLY_ALPHA not implemented yet"); break; case IMAGE_OP_RESIZE_TILE: diff --git a/src/backend/gl/glx.c b/src/backend/gl/glx.c index 945c06a..600aa50 100644 --- a/src/backend/gl/glx.c +++ b/src/backend/gl/glx.c @@ -37,6 +37,7 @@ struct _glx_image_data { gl_texture_t texture; GLXPixmap glpixmap; xcb_pixmap_t pixmap; + bool owned; }; struct _glx_data { @@ -178,6 +179,11 @@ void glx_release_image(backend_t *base, void *image_data) { wd->glpixmap = 0; } + if (wd->owned) { + xcb_free_pixmap(base->c, wd->pixmap); + wd->pixmap = XCB_NONE; + } + glDeleteTextures(1, &wd->texture.texture); free(wd->texture.refcount); @@ -404,6 +410,7 @@ glx_bind_pixmap(backend_t *base, xcb_pixmap_t pixmap, struct xvisual_info fmt, b wd->texture.has_alpha = fmt.alpha_size != 0; wd->texture.refcount = ccalloc(1, int); *wd->texture.refcount = 1; + wd->owned = owned; glBindTexture(wd->texture.target, wd->texture.texture); glXBindTexImageEXT(gd->display, wd->glpixmap, GLX_FRONT_LEFT_EXT, NULL); glBindTexture(wd->texture.target, 0);