[librsvg/rustification] Push/pop the state stack in rsvg_node_draw(), not everywhere it is called
- From: Federico Mena Quintero <federico src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg/rustification] Push/pop the state stack in rsvg_node_draw(), not everywhere it is called
- Date: Fri, 2 Dec 2016 16:59:58 +0000 (UTC)
commit ac48e507ec23d7ab00f63a4d424790adba46cb40
Author: Federico Mena Quintero <federico gnome org>
Date: Fri Dec 2 10:40:09 2016 -0600
Push/pop the state stack in rsvg_node_draw(), not everywhere it is called
Every place that called rsvg_node_draw() would do
rsvg_state_push()/pop() around it. Now we do that in a single place,
inside rsvg_node_draw() itself.
rsvg-base.c | 6 ------
rsvg-cairo-draw.c | 2 --
rsvg-cairo-render.c | 3 +--
rsvg-marker.c | 2 --
rsvg-structure.c | 16 ++++++++--------
5 files changed, 9 insertions(+), 20 deletions(-)
---
diff --git a/rsvg-base.c b/rsvg-base.c
index 625b9b8..b1500e5 100644
--- a/rsvg-base.c
+++ b/rsvg-base.c
@@ -1579,12 +1579,9 @@ rsvg_handle_get_dimensions_sub (RsvgHandle * handle, RsvgDimensionData * dimensi
sself = rsvg_node_get_parent (sself);
}
- rsvg_state_push (draw);
-
rsvg_node_draw (handle->priv->treebase, draw, 0);
bbox = RSVG_CAIRO_RENDER (draw->render)->bbox;
- rsvg_state_pop (draw);
rsvg_drawing_ctx_free (draw);
cairo_destroy (cr);
cairo_surface_destroy (target);
@@ -1674,12 +1671,9 @@ rsvg_handle_get_position_sub (RsvgHandle * handle, RsvgPositionData * position_d
node = rsvg_node_get_parent (node);
}
- rsvg_state_push (draw);
-
rsvg_node_draw (handle->priv->treebase, draw, 0);
bbox = RSVG_CAIRO_RENDER (draw->render)->bbox;
- rsvg_state_pop (draw);
rsvg_drawing_ctx_free (draw);
position_data->x = bbox.rect.x;
diff --git a/rsvg-cairo-draw.c b/rsvg-cairo-draw.c
index 142a7a7..f837e37 100644
--- a/rsvg-cairo-draw.c
+++ b/rsvg-cairo-draw.c
@@ -924,9 +924,7 @@ rsvg_cairo_get_surface_of_node (RsvgDrawingCtx *ctx,
render = rsvg_cairo_render_new (cr, width, height);
ctx->render = (RsvgRender *) render;
- rsvg_state_push (ctx);
rsvg_node_draw (drawable, ctx, 0);
- rsvg_state_pop (ctx);
cairo_destroy (cr);
diff --git a/rsvg-cairo-render.c b/rsvg-cairo-render.c
index f196e70..dd35e1d 100644
--- a/rsvg-cairo-render.c
+++ b/rsvg-cairo-render.c
@@ -220,13 +220,12 @@ rsvg_handle_render_cairo_sub (RsvgHandle * handle, cairo_t * cr, const char *id)
drawsub = rsvg_node_get_parent (drawsub);
}
- rsvg_state_push (draw);
cairo_save (cr);
rsvg_node_draw (handle->priv->treebase, draw, 0);
cairo_restore (cr);
- rsvg_state_pop (draw);
+
rsvg_drawing_ctx_free (draw);
return TRUE;
diff --git a/rsvg-marker.c b/rsvg-marker.c
index cc89e84..180db73 100644
--- a/rsvg-marker.c
+++ b/rsvg-marker.c
@@ -110,9 +110,7 @@ draw_child (RsvgNode *node, gpointer data)
ctx = data;
- rsvg_state_push (ctx);
rsvg_node_draw (node, ctx, 0);
- rsvg_state_pop (ctx);
return TRUE;
}
diff --git a/rsvg-structure.c b/rsvg-structure.c
index ac85d2e..b0dbb3c 100644
--- a/rsvg-structure.c
+++ b/rsvg-structure.c
@@ -40,19 +40,25 @@ rsvg_node_draw (RsvgNode * self, RsvgDrawingCtx * ctx, int dominate)
RsvgState *state;
GSList *stacksave;
+ rsvg_state_push (ctx);
+
state = rsvg_node_get_state (self);
stacksave = ctx->drawsub_stack;
if (stacksave) {
if (stacksave->data != self)
- return;
+ goto out;
+
ctx->drawsub_stack = stacksave->next;
}
if (!state->visible)
- return;
+ goto out;
self->draw (self, ctx, dominate);
ctx->drawsub_stack = stacksave;
+
+out:
+ rsvg_state_pop (ctx);
}
static gboolean
@@ -62,9 +68,7 @@ draw_child (RsvgNode *node, gpointer data)
ctx = data;
- rsvg_state_push (ctx);
rsvg_node_draw (node, ctx, 0);
- rsvg_state_pop (ctx);
return TRUE;
}
@@ -194,9 +198,7 @@ rsvg_node_use_draw (RsvgNode * self, RsvgDrawingCtx * ctx, int dominate)
cairo_matrix_multiply (&state->affine, &affine, &state->affine);
rsvg_push_discrete_layer (ctx);
- rsvg_state_push (ctx);
rsvg_node_draw (child, ctx, 1);
- rsvg_state_pop (ctx);
rsvg_pop_discrete_layer (ctx);
} else {
RsvgNodeSymbol *symbol = (RsvgNodeSymbol *) child;
@@ -467,9 +469,7 @@ draw_child_if_cond_true_and_stop (RsvgNode *node, gpointer data)
ctx = data;
if (rsvg_node_get_state (node)->cond_true) {
- rsvg_state_push (ctx);
rsvg_node_draw (node, ctx, 0);
- rsvg_state_pop (ctx);
return FALSE;
} else {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]