[librsvg/rustification] rsvg-cairo-draw: Factor out function to set up a cairo_t for stroking
- From: Federico Mena Quintero <federico src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg/rustification] rsvg-cairo-draw: Factor out function to set up a cairo_t for stroking
- Date: Wed, 9 Nov 2016 01:17:56 +0000 (UTC)
commit 8e84816357b2b3423bd1ee5c61c2ed34074e6994
Author: Federico Mena Quintero <federico gnome org>
Date: Tue Nov 8 18:40:48 2016 -0600
rsvg-cairo-draw: Factor out function to set up a cairo_t for stroking
rsvg-cairo-draw.c | 26 ++++++++++++++------------
1 files changed, 14 insertions(+), 12 deletions(-)
---
diff --git a/rsvg-cairo-draw.c b/rsvg-cairo-draw.c
index 79dd260..89044ac 100644
--- a/rsvg-cairo-draw.c
+++ b/rsvg-cairo-draw.c
@@ -381,6 +381,17 @@ rsvg_cairo_create_pango_context (RsvgDrawingCtx * ctx)
return context;
}
+static void
+setup_cr_for_stroke (cairo_t *cr, RsvgDrawingCtx *ctx, RsvgState *state)
+{
+ cairo_set_line_width (cr, _rsvg_css_normalize_length (&state->stroke_width, ctx, LENGTH_DIR_BOTH));
+ cairo_set_miter_limit (cr, state->miter_limit);
+ cairo_set_line_cap (cr, (cairo_line_cap_t) state->cap);
+ cairo_set_line_join (cr, (cairo_line_join_t) state->join);
+ cairo_set_dash (cr, state->dash.dash, state->dash.n_dash,
+ _rsvg_css_normalize_length (&state->dash.offset, ctx, LENGTH_DIR_BOTH));
+}
+
void
rsvg_cairo_render_pango_layout (RsvgDrawingCtx * ctx, PangoLayout * layout, double x, double y)
{
@@ -442,12 +453,8 @@ rsvg_cairo_render_pango_layout (RsvgDrawingCtx * ctx, PangoLayout * layout, doub
cairo_rotate (render->cr, -rotation);
pango_cairo_layout_path (render->cr, layout);
- cairo_set_line_width (render->cr, _rsvg_css_normalize_length (&state->stroke_width, ctx,
LENGTH_DIR_BOTH));
- cairo_set_miter_limit (render->cr, state->miter_limit);
- cairo_set_line_cap (render->cr, (cairo_line_cap_t) state->cap);
- cairo_set_line_join (render->cr, (cairo_line_join_t) state->join);
- cairo_set_dash (render->cr, state->dash.dash, state->dash.n_dash,
- _rsvg_css_normalize_length (&state->dash.offset, ctx, LENGTH_DIR_BOTH));
+ setup_cr_for_stroke (render->cr, ctx, state);
+
cairo_stroke (render->cr);
cairo_restore (render->cr);
}
@@ -470,12 +477,7 @@ rsvg_cairo_render_path_builder (RsvgDrawingCtx * ctx, RsvgPathBuilder *builder)
_set_rsvg_affine (render, &state->affine);
- cairo_set_line_width (cr, _rsvg_css_normalize_length (&state->stroke_width, ctx, LENGTH_DIR_BOTH));
- cairo_set_miter_limit (cr, state->miter_limit);
- cairo_set_line_cap (cr, (cairo_line_cap_t) state->cap);
- cairo_set_line_join (cr, (cairo_line_join_t) state->join);
- cairo_set_dash (cr, state->dash.dash, state->dash.n_dash,
- _rsvg_css_normalize_length (&state->dash.offset, ctx, LENGTH_DIR_BOTH));
+ setup_cr_for_stroke (cr, ctx, state);
rsvg_path_builder_add_to_cairo_context (builder, cr);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]