[gtk+/wip/otte/rendernode: 21/100] gsk: Add GskRenderNodeClass.finalize()
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/wip/otte/rendernode: 21/100] gsk: Add GskRenderNodeClass.finalize()
- Date: Sun, 18 Dec 2016 06:30:27 +0000 (UTC)
commit 48b17584a06431e0c03fabd5d708ae7fc6ad90cc
Author: Benjamin Otte <otte redhat com>
Date: Sun Dec 11 04:18:25 2016 +0100
gsk: Add GskRenderNodeClass.finalize()
gsk/gskrendernode.c | 4 ++--
gsk/gskrendernodeimpl.c | 27 ++++++++++++++++++++++++---
gsk/gskrendernodeprivate.h | 1 +
3 files changed, 27 insertions(+), 5 deletions(-)
---
diff --git a/gsk/gskrendernode.c b/gsk/gskrendernode.c
index 6ac7836..310482c 100644
--- a/gsk/gskrendernode.c
+++ b/gsk/gskrendernode.c
@@ -74,8 +74,8 @@ gsk_render_node_finalize (GskRenderNode *self)
{
self->is_mutable = TRUE;
- g_clear_pointer (&self->surface, cairo_surface_destroy);
- g_clear_pointer (&self->texture, gsk_texture_unref);
+ self->node_class->finalize (self);
+
g_clear_pointer (&self->name, g_free);
while (self->first_child)
diff --git a/gsk/gskrendernodeimpl.c b/gsk/gskrendernodeimpl.c
index 920afaf..0623c50 100644
--- a/gsk/gskrendernodeimpl.c
+++ b/gsk/gskrendernodeimpl.c
@@ -24,9 +24,16 @@
/*** GSK_TEXTURE_NODE ***/
+static void
+gsk_texture_node_finalize (GskRenderNode *node)
+{
+ gsk_texture_unref (node->texture);
+}
+
static const GskRenderNodeClass GSK_TEXTURE_NODE_CLASS = {
GSK_TEXTURE_NODE,
- "GskTextureNode"
+ "GskTextureNode",
+ gsk_texture_node_finalize
};
GskTexture *
@@ -68,9 +75,17 @@ gsk_texture_node_new (GskTexture *texture,
/*** GSK_CAIRO_NODE ***/
+static void
+gsk_cairo_node_finalize (GskRenderNode *node)
+{
+ if (node->surface)
+ cairo_surface_destroy (node->surface);
+}
+
static const GskRenderNodeClass GSK_CAIRO_NODE_CLASS = {
GSK_CAIRO_NODE,
- "GskCairoNode"
+ "GskCairoNode",
+ gsk_cairo_node_finalize
};
/*< private >
@@ -203,9 +218,15 @@ gsk_cairo_node_get_draw_context (GskRenderNode *node,
/**** GSK_CONTAINER_NODE ***/
+static void
+gsk_container_node_finalize (GskRenderNode *node)
+{
+}
+
static const GskRenderNodeClass GSK_CONTAINER_NODE_CLASS = {
GSK_CONTAINER_NODE,
- "GskContainerNode"
+ "GskContainerNode",
+ gsk_container_node_finalize
};
/**
diff --git a/gsk/gskrendernodeprivate.h b/gsk/gskrendernodeprivate.h
index 3908f94..2c969d1 100644
--- a/gsk/gskrendernodeprivate.h
+++ b/gsk/gskrendernodeprivate.h
@@ -67,6 +67,7 @@ struct _GskRenderNodeClass
{
GskRenderNodeType node_type;
const char *type_name;
+ void (* finalize) (GskRenderNode *node);
};
GskRenderNode *gsk_render_node_new (const GskRenderNodeClass *node_class);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]