From 599030c8fe3b60e9b23d6dab5e62122c8331ef6f Mon Sep 17 00:00:00 2001 From: Bryce Harrington Date: Wed, 18 Dec 2013 15:39:37 -0800 Subject: Make destructors called explicitly rather than through callbacks While Cairo has callback support for the destructor, there's not an analogous way to do this with Skia, so instead of trying to be clever let's just build explicit destruction in. --- src/cairo-image.cpp | 37 ++++++++++--------------------------- 1 file changed, 10 insertions(+), 27 deletions(-) (limited to 'src/cairo-image.cpp') diff --git a/src/cairo-image.cpp b/src/cairo-image.cpp index 98fe05f..7c47ac8 100644 --- a/src/cairo-image.cpp +++ b/src/cairo-image.cpp @@ -3,30 +3,16 @@ #include #include -struct graphics_state { - Display *dpy; - Window window; -}; +#include "image.h" -static void -cleanup (void *data) -{ - struct graphics_state *state = (graphics_state*)data; - - /* - XDestroyWindow (state->dpy, state->window); - XCloseDisplay (state->dpy); - */ - free (state); -} +static image_state_t *state; cairo_surface_t * create_cairo_surface_image (int width, int height) { - struct graphics_state *state; cairo_surface_t *cairo_surface; - state = (graphics_state*) malloc (sizeof (struct graphics_state)); + state = (image_state_t*) malloc (sizeof (image_state_t)); if (!state) { warnx ("Out of memory\n"); return NULL; @@ -44,15 +30,12 @@ create_cairo_surface_image (int width, int height) width, height); - if (cairo_surface_set_user_data (cairo_surface, - (cairo_user_data_key_t *) cleanup, - state, - cleanup)) - { - warnx ("Failed to setup cleanup callback closure\n"); - cleanup (state); - return NULL; - } - return cairo_surface; } + +void +destroy_cairo_image(void) +{ + cleanup_state_image(state); +} + -- cgit v1.3.1-4-g156e