rsvg-cairo-draw: Factor out function to set up a cairo_t for stroking

parent ad0ebab5
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment