diff options
| author | Bryce Harrington <b.harrington@samsung.com> | 2013-12-18 15:39:37 -0800 |
|---|---|---|
| committer | Bryce Harrington <b.harrington@samsung.com> | 2013-12-18 15:39:37 -0800 |
| commit | 599030c8fe3b60e9b23d6dab5e62122c8331ef6f (patch) | |
| tree | 855f90b650aa636ccc0473d808276638f8ce25f3 /src/skia-glx.cpp | |
| parent | efdd7f7835e281cea9d6955696593361b5067c21 (diff) | |
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.
Diffstat (limited to 'src/skia-glx.cpp')
| -rw-r--r-- | src/skia-glx.cpp | 35 |
1 files changed, 10 insertions, 25 deletions
diff --git a/src/skia-glx.cpp b/src/skia-glx.cpp index 33ac276..fc273c0 100644 --- a/src/skia-glx.cpp +++ b/src/skia-glx.cpp @@ -8,19 +8,11 @@ #include "glx.h" -static void -cleanup (void *data) -{ - glx_state_t *state = (glx_state_t*)data; - destroyGLXContextAndWindow(state); - free(state); -} +static glx_state_t *state; SkBaseDevice * create_skia_device_glx (int width, int height) { - glx_state_t *state; - GrBackendRenderTargetDesc desc; GrContext* ctx; GrRenderTarget* target; @@ -28,12 +20,13 @@ create_skia_device_glx (int width, int height) state = (glx_state_t*) malloc (sizeof (glx_state_t)); if (!state) { - warnx ("Out of memory\n"); + warnx("Out of memory\n"); return NULL; } if (!createGLXContextAndWindow(state, width, height)) { - warnx ("Could not create GLX context and window\n"); + warnx("Could not create GLX context and window\n"); + cleanup_state_glx(state); return NULL; } @@ -49,19 +42,11 @@ create_skia_device_glx (int width, int height) target = ctx->wrapBackendRenderTarget(desc); device = new SkGpuDevice(ctx, target); - /* - if (cairo_device_set_user_data (cairo_device, - (cairo_user_data_key_t *) cleanup, - state, - cleanup)) - { - warnx ("Failed to setup cleanup callback closure\n"); - cleanup (state); - return NULL; - } - - cairo_device_destroy (cairo_device); - */ - return device; } + +void +destroy_skia_glx(void) +{ + cleanup_state_glx(state); +} |