From 7d1a04e499564212a2a9aace12b05f424a357d3f Mon Sep 17 00:00:00 2001 From: Brian Date: Wed, 7 Nov 2007 08:05:09 -0700 Subject: Add winsys->surface_release() to complement winsys->surface_alloc(). pipe_surface now has a pointer to the winsys which create/owns the surface. This allows clean surface deallocation w/out a rendering context. --- src/mesa/pipe/xlib/xm_winsys.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'src/mesa/pipe/xlib/xm_winsys.c') diff --git a/src/mesa/pipe/xlib/xm_winsys.c b/src/mesa/pipe/xlib/xm_winsys.c index f7e55ed8f7..b73fcab68d 100644 --- a/src/mesa/pipe/xlib/xm_winsys.c +++ b/src/mesa/pipe/xlib/xm_winsys.c @@ -284,6 +284,7 @@ xm_surface_alloc(struct pipe_winsys *ws, GLuint pipeFormat) xms->surface.format = pipeFormat; xms->surface.refcount = 1; + xms->surface.winsys = ws; #if 0 /* * This is really just a softpipe surface, not an XImage/Pixmap surface. @@ -295,13 +296,24 @@ xm_surface_alloc(struct pipe_winsys *ws, GLuint pipeFormat) +static void +xm_surface_release(struct pipe_winsys *ws, struct pipe_surface **s) +{ + struct pipe_surface *surf = *s; + if (surf->region) + winsys->region_release(winsys, &surf->region); + free(surf); + *s = NULL; +} + + /** * Return pointer to a pipe_winsys object. * For Xlib, this is a singleton object. * Nothing special for the Xlib driver so no subclassing or anything. */ -static struct pipe_winsys * +struct pipe_winsys * xmesa_get_pipe_winsys(void) { static struct pipe_winsys *ws = NULL; @@ -325,6 +337,7 @@ xmesa_get_pipe_winsys(void) ws->region_release = xm_region_release; ws->surface_alloc = xm_surface_alloc; + ws->surface_release = xm_surface_release; ws->flush_frontbuffer = xm_flush_frontbuffer; ws->wait_idle = xm_wait_idle; -- cgit v1.2.3