mirror of
https://gitlab.freedesktop.org/cairo/cairo.git
synced 2026-02-04 23:30:30 +01:00
test: Add explicit device management to xlib-surface-source
Mostly pedagogical example.
This commit is contained in:
parent
ca02b51ef6
commit
005b0c4eb2
1 changed files with 5 additions and 0 deletions
|
|
@ -34,6 +34,7 @@
|
|||
static cairo_user_data_key_t closure_key;
|
||||
|
||||
struct closure {
|
||||
cairo_device_t *device;
|
||||
Display *dpy;
|
||||
Pixmap pix;
|
||||
};
|
||||
|
|
@ -43,6 +44,9 @@ cleanup (void *data)
|
|||
{
|
||||
struct closure *arg = data;
|
||||
|
||||
cairo_device_finish (arg->device);
|
||||
cairo_device_destroy (arg->device);
|
||||
|
||||
XFreePixmap (arg->dpy, arg->pix);
|
||||
XCloseDisplay (arg->dpy);
|
||||
|
||||
|
|
@ -74,6 +78,7 @@ create_source_surface (int size)
|
|||
DefaultScreenOfDisplay (data->dpy),
|
||||
xrender_format,
|
||||
size, size);
|
||||
data->device = cairo_device_reference (cairo_surface_get_device (surface));
|
||||
cairo_surface_set_user_data (surface, &closure_key, data, cleanup);
|
||||
|
||||
return surface;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue