summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFederico Mena Quintero <federico@gnome.org>2015-02-20 13:34:40 -0600
committerFederico Mena Quintero <federico@gnome.org>2015-02-20 13:34:52 -0600
commitac5564493f13ff905c9d29d4fc6088da06e61a9e (patch)
tree737656af9e3d25859475adb0642c9cb2ca22ff52
parent0b11fe8358a7e7477bc2c4ae6d3b49e0bfb4ca47 (diff)
downloadlibrsvg-ac5564493f13ff905c9d29d4fc6088da06e61a9e.tar.gz
RsvgNodeLine: Use RsvgPathBuilder instead of building/parsing a path string
Again; no need to go through the production process for Luwak coffee just to paint a line. Signed-off-by: Federico Mena Quintero <federico@gnome.org>
-rw-r--r--rsvg-shapes.c31
1 files changed, 12 insertions, 19 deletions
diff --git a/rsvg-shapes.c b/rsvg-shapes.c
index 42754362..2ee43883 100644
--- a/rsvg-shapes.c
+++ b/rsvg-shapes.c
@@ -281,34 +281,27 @@ _rsvg_node_line_set_atts (RsvgNode * self, RsvgHandle * ctx, RsvgPropertyBag * a
static void
_rsvg_node_line_draw (RsvgNode * overself, RsvgDrawingCtx * ctx, int dominate)
{
- GString *d;
cairo_path_t *path;
- char buf[G_ASCII_DTOSTR_BUF_SIZE];
+ RsvgPathBuilder builder;
RsvgNodeLine *self = (RsvgNodeLine *) overself;
+ double x1, y1, x2, y2;
- /* emulate a line using a path */
- /* ("M %f %f L %f %f", x1, y1, x2, y2) */
- d = g_string_new ("M ");
+ rsvg_path_builder_init (&builder, 4);
- g_string_append (d, g_ascii_dtostr (buf, sizeof (buf),
- _rsvg_css_normalize_length (&self->x1, ctx, 'h')));
- g_string_append_c (d, ' ');
- g_string_append (d, g_ascii_dtostr (buf, sizeof (buf),
- _rsvg_css_normalize_length (&self->y1, ctx, 'v')));
- g_string_append (d, " L ");
- g_string_append (d, g_ascii_dtostr (buf, sizeof (buf),
- _rsvg_css_normalize_length (&self->x2, ctx, 'h')));
- g_string_append_c (d, ' ');
- g_string_append (d, g_ascii_dtostr (buf, sizeof (buf),
- _rsvg_css_normalize_length (&self->y2, ctx, 'v')));
+ x1 = _rsvg_css_normalize_length (&self->x1, ctx, 'h');
+ y1 = _rsvg_css_normalize_length (&self->y1, ctx, 'v');
+ x2 = _rsvg_css_normalize_length (&self->x2, ctx, 'h');
+ y2 = _rsvg_css_normalize_length (&self->y2, ctx, 'v');
+
+ rsvg_path_builder_move_to (&builder, x1, y1);
+ rsvg_path_builder_line_to (&builder, x2, y2);
+
+ path = rsvg_path_builder_finish (&builder);
rsvg_state_reinherit_top (ctx, overself->state, dominate);
- path = rsvg_parse_path (d->str);
rsvg_render_path (ctx, path);
rsvg_cairo_path_destroy (path);
-
- g_string_free (d, TRUE);
}
RsvgNode *