[cairo-commit] 2 commits - src/cairo-svg-surface.c
Carl Worth
cworth at kemper.freedesktop.org
Mon Mar 5 16:04:35 PST 2007
src/cairo-svg-surface.c | 37 ++++++++++++++++++++++++-------------
1 files changed, 24 insertions(+), 13 deletions(-)
New commits:
diff-tree e1a598211b1944bad6b32148da052208d9b58093 (from 47f2bf4e28b80102f10505916be2bf4c01ce9354)
Author: Emmanuel Pacaud <emmanuel.pacaud at lapp.in2p3.fr>
Date: Mon Mar 5 16:03:40 2007 -0800
Use the offset attribute to improve cairo-svg handling of EXTEND_REPEAT and EXTEND_REFLECT
With this change, the cairo-svg output is perfectly fine with
CAIRO_EXTEND_REPEAT, but is still very slightly wrong with
CAIRO_EXTEND_REFLECT, (though *much* better than it was before
this fix).
diff --git a/src/cairo-svg-surface.c b/src/cairo-svg-surface.c
index 6f1f66d..7cb7d4d 100644
--- a/src/cairo-svg-surface.c
+++ b/src/cairo-svg-surface.c
@@ -1190,11 +1190,29 @@ emit_surface_pattern (cairo_svg_surface_
static void
emit_pattern_stops (cairo_output_stream_t *output,
cairo_gradient_pattern_t const *pattern,
- double start_offset)
+ double start_offset,
+ cairo_extend_t extend)
{
double offset;
- unsigned int i;
+ unsigned int i, stop_index;
+ if (start_offset > 0.0
+ && (extend == CAIRO_EXTEND_REPEAT
+ || extend == CAIRO_EXTEND_REFLECT))
+ for (i = 0; i < pattern->n_stops; i++) {
+ offset = start_offset *
+ _cairo_fixed_to_double (pattern->stops[i].x);
+ stop_index = (extend == CAIRO_EXTEND_REPEAT) ? i : pattern->n_stops - i - 1;
+ _cairo_output_stream_printf (output,
+ "<stop offset=\"%f\" style=\""
+ "stop-color: rgb(%f%%,%f%%,%f%%); "
+ "stop-opacity: %f;\"/>\n",
+ offset,
+ pattern->stops[stop_index].color.red / 655.35,
+ pattern->stops[stop_index].color.green / 655.35,
+ pattern->stops[stop_index].color.blue / 655.35,
+ pattern->stops[stop_index].color.alpha / 65535.0);
+ }
for (i = 0; i < pattern->n_stops; i++) {
offset = start_offset + (1 - start_offset ) *
_cairo_fixed_to_double (pattern->stops[i].x);
@@ -1222,9 +1240,7 @@ emit_pattern_extend (cairo_output_stream
_cairo_output_stream_printf (output, "spreadMethod=\"reflect\" ");
break;
case CAIRO_EXTEND_NONE:
- break;
case CAIRO_EXTEND_PAD:
- /* FIXME not implemented */
break;
}
}
@@ -1256,7 +1272,7 @@ emit_linear_pattern (cairo_svg_surface_t
cairo_matrix_invert (&p2u);
emit_transform (document->xml_node_defs, "gradientTransform", ">\n", &p2u);
- emit_pattern_stops (document->xml_node_defs ,&pattern->base, 0.0);
+ emit_pattern_stops (document->xml_node_defs ,&pattern->base, 0.0, CAIRO_EXTEND_NONE);
_cairo_output_stream_printf (document->xml_node_defs,
"</linearGradient>\n");
@@ -1322,7 +1338,7 @@ emit_radial_pattern (cairo_svg_surface_t
"stop-opacity: 0;\"/>\n",
r0 / r1);
}
- emit_pattern_stops (document->xml_node_defs, &pattern->base, r0 / r1);
+ emit_pattern_stops (document->xml_node_defs, &pattern->base, r0 / r1, pattern->base.base.extend);
if (pattern->base.base.extend == CAIRO_EXTEND_NONE)
_cairo_output_stream_printf (document->xml_node_defs,
"<stop offset=\"1.0\" style=\""
diff-tree 47f2bf4e28b80102f10505916be2bf4c01ce9354 (from a724f816e17bfe3d9abefb1f6dcfe30480a0d143)
Author: Emmanuel Pacaud <emmanuel.pacaud at lapp.in2p3.fr>
Date: Mon Mar 5 15:57:28 2007 -0800
Remove broken special-casing of radial gradient fx,fy under CAIRO_EXTEND_NONE
Carl can't explain why he added this special-case, and removing it
eliminates one failure case from the radial-gradient test matrix.
diff --git a/src/cairo-svg-surface.c b/src/cairo-svg-surface.c
index c57ca98..6f1f66d 100644
--- a/src/cairo-svg-surface.c
+++ b/src/cairo-svg-surface.c
@@ -1290,13 +1290,8 @@ emit_radial_pattern (cairo_svg_surface_t
/* SVG doesn't have a start radius, so computing now SVG focal coordinates
* and emulating start radius by translating color stops.
* FIXME: Handle radius1 <= radius0 */
- if (pattern->base.base.extend == CAIRO_EXTEND_NONE) {
- fx = x0;
- fy = y0;
- } else {
- fx = (r1 * x0 - r0 * x1) / (r1 - r0);
- fy = (r1 * y0 - r0 * y1) / (r1 - r0);
- }
+ fx = (r1 * x0 - r0 * x1) / (r1 - r0);
+ fy = (r1 * y0 - r0 * y1) / (r1 - r0);
_cairo_output_stream_printf (document->xml_node_defs,
"<radialGradient id=\"radial%d\" "
More information about the cairo-commit
mailing list