diff options
author | Benjamin Otte <otte@redhat.com> | 2015-10-07 12:31:07 +0200 |
---|---|---|
committer | Benjamin Otte <otte@redhat.com> | 2015-10-22 12:56:13 +0200 |
commit | 7fc0fb6023931cca829fda2e265e047c73fa9134 (patch) | |
tree | da34c258f1d2b4c4c8a1952849ce71f058e37378 | |
parent | 3ae509be6a1b14b93a0839dc241d54a7ca3a1b25 (diff) | |
download | librsvg-7fc0fb6023931cca829fda2e265e047c73fa9134.tar.gz |
use: Resolve link lazily
And that really concludes conversion of everything to
rsvg_acquire_node().
For real this time!
-rw-r--r-- | rsvg-structure.c | 26 | ||||
-rw-r--r-- | rsvg-structure.h | 2 |
2 files changed, 21 insertions, 7 deletions
diff --git a/rsvg-structure.c b/rsvg-structure.c index 1370dbc9..b86cded5 100644 --- a/rsvg-structure.c +++ b/rsvg-structure.c @@ -208,13 +208,15 @@ rsvg_node_use_draw (RsvgNode * self, RsvgDrawingCtx * ctx, int dominate) rsvg_state_reinherit_top (ctx, self->state, dominate); - child = use->link; - - /* If it can find nothing to draw... draw nothing */ + if (use->link == NULL) + return; + child = rsvg_acquire_node (ctx, use->link); if (!child) return; - else if (rsvg_node_is_ancestor (child, self)) /* or, if we're <use>'ing ourself */ + else if (rsvg_node_is_ancestor (child, self)) { /* or, if we're <use>'ing ourself */ + rsvg_release_node (ctx, child); return; + } state = rsvg_current_state (ctx); if (RSVG_NODE_TYPE (child) != RSVG_NODE_TYPE_SYMBOL) { @@ -263,6 +265,7 @@ rsvg_node_use_draw (RsvgNode * self, RsvgDrawingCtx * ctx, int dominate) _rsvg_pop_view_box (ctx); } + rsvg_release_node (ctx, child); } static void @@ -409,6 +412,14 @@ rsvg_new_svg (void) } static void +rsvg_node_use_free (RsvgNode * node) +{ + RsvgNodeUse *use = (RsvgNodeUse *) node; + g_free (use->link); + _rsvg_node_free (node); +} + +static void rsvg_node_use_set_atts (RsvgNode * self, RsvgHandle * ctx, RsvgPropertyBag * atts) { const char *value = NULL, *klazz = NULL, *id = NULL; @@ -430,8 +441,10 @@ rsvg_node_use_set_atts (RsvgNode * self, RsvgHandle * ctx, RsvgPropertyBag * att id = value; rsvg_defs_register_name (ctx->priv->defs, value, &use->super); } - if ((value = rsvg_property_bag_lookup (atts, "xlink:href"))) - rsvg_defs_add_resolver (ctx->priv->defs, &use->link, value); + if ((value = rsvg_property_bag_lookup (atts, "xlink:href"))) { + g_free (use->link); + use->link = g_strdup (value); + } rsvg_parse_style_attrs (ctx, self->state, "use", klazz, id, atts); } @@ -444,6 +457,7 @@ rsvg_new_use (void) use = g_new (RsvgNodeUse, 1); _rsvg_node_init (&use->super, RSVG_NODE_TYPE_USE); use->super.draw = rsvg_node_use_draw; + use->super.free = rsvg_node_use_free; use->super.set_atts = rsvg_node_use_set_atts; use->x = _rsvg_css_parse_length ("0"); use->y = _rsvg_css_parse_length ("0"); diff --git a/rsvg-structure.h b/rsvg-structure.h index 1324ad60..601a2736 100644 --- a/rsvg-structure.h +++ b/rsvg-structure.h @@ -67,7 +67,7 @@ struct _RsvgNodeSymbol { struct _RsvgNodeUse { RsvgNode super; - RsvgNode *link; + char *link; RsvgLength x, y, w, h; }; |