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 <yshuiv7@gmail.com>
This commit is contained in:
Yuxuan Shui 2019-03-10 19:59:44 +00:00
parent 9296706f7b
commit e40f16c60e
No known key found for this signature in database
GPG Key ID: 37C999F617EA1A47
2 changed files with 8 additions and 0 deletions

View File

@ -736,6 +736,7 @@ bool gl_image_op(backend_t *base, enum image_operations op, void *image_data,
break; break;
case IMAGE_OP_APPLY_ALPHA_ALL: tex->opacity *= *(double *)arg; break; case IMAGE_OP_APPLY_ALPHA_ALL: tex->opacity *= *(double *)arg; break;
case IMAGE_OP_APPLY_ALPHA: case IMAGE_OP_APPLY_ALPHA:
// TODO
log_warn("IMAGE_OP_APPLY_ALPHA not implemented yet"); log_warn("IMAGE_OP_APPLY_ALPHA not implemented yet");
break; break;
case IMAGE_OP_RESIZE_TILE: case IMAGE_OP_RESIZE_TILE:

View File

@ -37,6 +37,7 @@ struct _glx_image_data {
gl_texture_t texture; gl_texture_t texture;
GLXPixmap glpixmap; GLXPixmap glpixmap;
xcb_pixmap_t pixmap; xcb_pixmap_t pixmap;
bool owned;
}; };
struct _glx_data { struct _glx_data {
@ -178,6 +179,11 @@ void glx_release_image(backend_t *base, void *image_data) {
wd->glpixmap = 0; wd->glpixmap = 0;
} }
if (wd->owned) {
xcb_free_pixmap(base->c, wd->pixmap);
wd->pixmap = XCB_NONE;
}
glDeleteTextures(1, &wd->texture.texture); glDeleteTextures(1, &wd->texture.texture);
free(wd->texture.refcount); 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.has_alpha = fmt.alpha_size != 0;
wd->texture.refcount = ccalloc(1, int); wd->texture.refcount = ccalloc(1, int);
*wd->texture.refcount = 1; *wd->texture.refcount = 1;
wd->owned = owned;
glBindTexture(wd->texture.target, wd->texture.texture); glBindTexture(wd->texture.target, wd->texture.texture);
glXBindTexImageEXT(gd->display, wd->glpixmap, GLX_FRONT_LEFT_EXT, NULL); glXBindTexImageEXT(gd->display, wd->glpixmap, GLX_FRONT_LEFT_EXT, NULL);
glBindTexture(wd->texture.target, 0); glBindTexture(wd->texture.target, 0);