[librsvg] Factor out a function to add a node and its ancestors to the RsvgDrawingCtx's stack
- From: Federico Mena Quintero <federico src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg] Factor out a function to add a node and its ancestors to the RsvgDrawingCtx's stack
- Date: Fri, 17 Mar 2017 02:00:57 +0000 (UTC)
commit 4e8de80c75930ddaf124804106efdc740b2b6615
Author: Federico Mena Quintero <federico gnome org>
Date: Thu Mar 16 19:21:42 2017 -0600
Factor out a function to add a node and its ancestors to the RsvgDrawingCtx's stack
This bit of code was duplicated in three places; move it to a single
function.
rsvg-base.c | 28 +++++++++++++++-------------
rsvg-cairo-render.c | 9 +--------
rsvg-private.h | 4 +++-
3 files changed, 19 insertions(+), 22 deletions(-)
---
diff --git a/rsvg-base.c b/rsvg-base.c
index ee655f1..cf3606d 100644
--- a/rsvg-base.c
+++ b/rsvg-base.c
@@ -1578,12 +1578,7 @@ rsvg_handle_get_dimensions_sub (RsvgHandle * handle, RsvgDimensionData * dimensi
}
g_assert (sself != NULL);
- sself = rsvg_node_ref (sself);
-
- while (sself != NULL) {
- draw->drawsub_stack = g_slist_prepend (draw->drawsub_stack, sself);
- sself = rsvg_node_get_parent (sself);
- }
+ rsvg_drawing_ctx_add_node_and_ancestors_to_stack (draw, sself);
rsvg_drawing_ctx_draw_node_from_stack (draw, handle->priv->treebase, 0);
bbox = RSVG_CAIRO_RENDER (draw->render)->bbox;
@@ -1671,13 +1666,7 @@ rsvg_handle_get_position_sub (RsvgHandle * handle, RsvgPositionData * position_d
goto bail;
g_assert (node != NULL);
-
- node = rsvg_node_ref (node);
-
- while (node != NULL) {
- draw->drawsub_stack = g_slist_prepend (draw->drawsub_stack, node);
- node = rsvg_node_get_parent (node);
- }
+ rsvg_drawing_ctx_add_node_and_ancestors_to_stack (draw, node);
rsvg_drawing_ctx_draw_node_from_stack (draw, handle->priv->treebase, 0);
bbox = RSVG_CAIRO_RENDER (draw->render)->bbox;
@@ -2314,6 +2303,19 @@ rsvg_drawing_ctx_release_node (RsvgDrawingCtx * ctx, RsvgNode *node)
}
void
+rsvg_drawing_ctx_add_node_and_ancestors_to_stack (RsvgDrawingCtx *draw_ctx, RsvgNode *node)
+{
+ if (node) {
+ node = rsvg_node_ref (node);
+
+ while (node != NULL) {
+ draw_ctx->drawsub_stack = g_slist_prepend (draw_ctx->drawsub_stack, node);
+ node = rsvg_node_get_parent (node);
+ }
+ }
+}
+
+void
rsvg_drawing_ctx_draw_node_from_stack (RsvgDrawingCtx *ctx, RsvgNode *node, int dominate)
{
RsvgState *state;
diff --git a/rsvg-cairo-render.c b/rsvg-cairo-render.c
index 262a213..48c3507 100644
--- a/rsvg-cairo-render.c
+++ b/rsvg-cairo-render.c
@@ -232,14 +232,7 @@ rsvg_handle_render_cairo_sub (RsvgHandle * handle, cairo_t * cr, const char *id)
if (!draw)
return FALSE;
- if (drawsub) {
- drawsub = rsvg_node_ref (drawsub);
-
- while (drawsub != NULL) {
- draw->drawsub_stack = g_slist_prepend (draw->drawsub_stack, drawsub);
- drawsub = rsvg_node_get_parent (drawsub);
- }
- }
+ rsvg_drawing_ctx_add_node_and_ancestors_to_stack (draw, drawsub);
cairo_save (cr);
diff --git a/rsvg-private.h b/rsvg-private.h
index b735d72..6bb5c6c 100644
--- a/rsvg-private.h
+++ b/rsvg-private.h
@@ -453,7 +453,9 @@ G_GNUC_INTERNAL
void rsvg_drawing_ctx_release_node (RsvgDrawingCtx * ctx, RsvgNode *node);
G_GNUC_INTERNAL
-void rsvg_drawing_ctx_draw_node_from_stack (RsvgDrawingCtx *ctx, RsvgNode *node, int dominate);
+void rsvg_drawing_ctx_add_node_and_ancestors_to_stack (RsvgDrawingCtx *draw_ctx, RsvgNode *node);
+G_GNUC_INTERNAL
+void rsvg_drawing_ctx_draw_node_from_stack (RsvgDrawingCtx *ctx, RsvgNode *node, int dominate);
G_GNUC_INTERNAL
void rsvg_render_path_builder (RsvgDrawingCtx * ctx, RsvgPathBuilder *builder);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]