diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2010-05-06 17:02:39 +0100 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2010-05-06 17:07:02 +0100 |
commit | 2658d7ef5f8f7e06929f4b1cae64e5312db24ec4 (patch) | |
tree | 04836da5b5b1f43a26235b5a2d57367f3b48b39f | |
parent | f5167dc2e1a13d8c4e5d66d7178a24b9b5e7ac7a (diff) |
test/gl-surface-source: Attach GLXContext to device user data.
As we actually use the GLXContext to create the device, we only want to
free those resources upon the final unreference of the device (and not
the initial surface).
-rw-r--r-- | test/gl-surface-source.c | 26 |
1 files changed, 11 insertions, 15 deletions
diff --git a/test/gl-surface-source.c b/test/gl-surface-source.c index 60f85914..09d4d9c4 100644 --- a/test/gl-surface-source.c +++ b/test/gl-surface-source.c @@ -32,8 +32,6 @@ struct closure { Display *dpy; GLXContext ctx; - - cairo_device_t *device; }; static void @@ -41,9 +39,6 @@ cleanup (void *data) { struct closure *arg = data; - cairo_device_finish (arg->device); - cairo_device_destroy (arg->device); - glXDestroyContext (arg->dpy, arg->ctx); XCloseDisplay (arg->dpy); @@ -65,6 +60,7 @@ create_source_surface (int size) XVisualInfo *visinfo; GLXContext ctx; struct closure *arg; + cairo_device_t *device; cairo_surface_t *surface; Display *dpy; @@ -89,21 +85,21 @@ create_source_surface (int size) arg = xmalloc (sizeof (struct closure)); arg->dpy = dpy; arg->ctx = ctx; - arg->device = cairo_glx_device_create (dpy, ctx); - surface = cairo_gl_surface_create (arg->device, - CAIRO_CONTENT_COLOR_ALPHA, - size, size); - - if (cairo_surface_set_user_data (surface, - (cairo_user_data_key_t *) create_source_surface, - arg, - cleanup)) + device = cairo_glx_device_create (dpy, ctx); + if (cairo_device_set_user_data (device, + (cairo_user_data_key_t *) cleanup, + arg, + cleanup)) { - cairo_surface_destroy (surface); cleanup (arg); return NULL; } + surface = cairo_gl_surface_create (device, + CAIRO_CONTENT_COLOR_ALPHA, + size, size); + cairo_device_destroy (device); + return surface; } |