diff options
author | Keith Packard <[email protected]> | 2013-11-21 21:30:07 -0800 |
---|---|---|
committer | Kenneth Graunke <[email protected]> | 2013-12-20 16:17:59 -0800 |
commit | 95b04850d0c578392288939723d8d56e4b600c93 (patch) | |
tree | c207ab904cd3a15f4495c0f75886acdcec0f8fbe /src/glx/dri3_glx.c | |
parent | 568a27588d13146d0fd7cb4e775e1ac0187e5e29 (diff) |
dri3: Free resources when drawable is destroyed.
Always nice to clean up after ourselves.
Signed-off-by: Keith Packard <[email protected]>
Reviewed-by: Kenneth Graunke <[email protected]>
Diffstat (limited to 'src/glx/dri3_glx.c')
-rw-r--r-- | src/glx/dri3_glx.c | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/src/glx/dri3_glx.c b/src/glx/dri3_glx.c index 1834c6d4a8e..4c0dc29fdf8 100644 --- a/src/glx/dri3_glx.c +++ b/src/glx/dri3_glx.c @@ -266,13 +266,25 @@ dri3_create_context(struct glx_screen *base, } static void +dri3_free_render_buffer(struct dri3_drawable *pdraw, struct dri3_buffer *buffer); + +static void dri3_destroy_drawable(__GLXDRIdrawable *base) { struct dri3_screen *psc = (struct dri3_screen *) base->psc; struct dri3_drawable *pdraw = (struct dri3_drawable *) base; + xcb_connection_t *c = XGetXCBConnection(pdraw->base.psc->dpy); + int i; (*psc->core->destroyDrawable) (pdraw->driDrawable); + for (i = 0; i < DRI3_NUM_BUFFERS; i++) { + if (pdraw->buffers[i]) + dri3_free_render_buffer(pdraw, pdraw->buffers[i]); + } + + if (pdraw->special_event) + xcb_unregister_for_special_event(c, pdraw->special_event); free(pdraw); } @@ -736,6 +748,7 @@ dri3_alloc_render_buffer(struct glx_screen *glx_screen, Drawable draw, fence_fd); buffer->pixmap = pixmap; + buffer->own_pixmap = true; buffer->sync_fence = sync_fence; buffer->shm_fence = shm_fence; buffer->width = width; @@ -769,7 +782,8 @@ dri3_free_render_buffer(struct dri3_drawable *pdraw, struct dri3_buffer *buffer) struct dri3_screen *psc = (struct dri3_screen *) pdraw->base.psc; xcb_connection_t *c = XGetXCBConnection(pdraw->base.psc->dpy); - xcb_free_pixmap(c, buffer->pixmap); + if (buffer->own_pixmap) + xcb_free_pixmap(c, buffer->pixmap); xcb_sync_destroy_fence(c, buffer->sync_fence); xshmfence_unmap_shm(buffer->shm_fence); (*psc->image->destroyImage)(buffer->image); @@ -987,6 +1001,7 @@ dri3_get_pixmap_buffer(__DRIdrawable *driDrawable, goto no_image; buffer->pixmap = pixmap; + buffer->own_pixmap = false; buffer->width = bp_reply->width; buffer->height = bp_reply->height; buffer->buffer_type = buffer_type; |