summaryrefslogtreecommitdiffstatsci
path: root/src/skia-egl.cpp
diff options
context:
space:
mode:
authorBryce Harrington <b.harrington@samsung.com>2013-12-18 15:39:37 -0800
committerBryce Harrington <b.harrington@samsung.com>2013-12-18 15:39:37 -0800
commit599030c8fe3b60e9b23d6dab5e62122c8331ef6f (patch)
tree855f90b650aa636ccc0473d808276638f8ce25f3 /src/skia-egl.cpp
parentefdd7f7835e281cea9d6955696593361b5067c21 (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-egl.cpp')
-rw-r--r--src/skia-egl.cpp34
1 files changed, 8 insertions, 26 deletions
diff --git a/src/skia-egl.cpp b/src/skia-egl.cpp
index 15caed5..1b3fe16 100644
--- a/src/skia-egl.cpp
+++ b/src/skia-egl.cpp
@@ -11,19 +11,11 @@
#include "egl.h"
-static void
-cleanup (void *data)
-{
- egl_state_t *state = (egl_state_t*)data;
- destroyEGLContextAndWindow (state);
- free (state);
-}
+static egl_state_t *state;
SkBaseDevice *
create_skia_device_egl (int width, int height)
{
- egl_state_t *state;
-
GrBackendRenderTargetDesc desc;
GrContext* ctx;
GrRenderTarget* target;
@@ -36,7 +28,7 @@ create_skia_device_egl (int width, int height)
}
if (!createEGLContextAndWindow(state, width, height)) {
- cleanup(state);
+ cleanup_state_egl(state);
return NULL;
}
@@ -54,21 +46,11 @@ create_skia_device_egl (int width, int height)
target = ctx->wrapBackendRenderTarget(desc);
device = new SkGpuDevice(ctx, target);
-
- /* TODO: Set cleanup routine to get called
-
- 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_egl(void)
+{
+ cleanup_state_egl(state);
+}