[cairo-commit] src/cairo-svg-surface.c

Emmanuel Pacaud emmanuel at kemper.freedesktop.org
Sat Dec 8 13:31:10 PST 2007


 src/cairo-svg-surface.c |   15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

New commits:
commit 1f1f96d6459014a236611edf811a60225a652044
Author: Emmanuel Pacaud <emmanuel.pacaud at free.fr>
Date:   Sat Dec 8 22:32:16 2007 +0100

    [SVG] Fix a minor issue when emitting a radial gradient with r1 == r2.
    
    Minor because I don't know how the output is supposed to look in this case.

diff --git a/src/cairo-svg-surface.c b/src/cairo-svg-surface.c
index a3d2b7e..4e9e7e0 100644
--- a/src/cairo-svg-surface.c
+++ b/src/cairo-svg-surface.c
@@ -1538,6 +1538,8 @@ _cairo_svg_surface_emit_radial_pattern (cairo_svg_surface_t    *surface,
     assert (status == CAIRO_STATUS_SUCCESS);
 
     if (pattern->r1 == pattern->r2) {
+	unsigned int n_stops = pattern->base.n_stops;
+
 	_cairo_output_stream_printf (document->xml_node_defs,
 				     "<radialGradient id=\"radial%d\" "
 				     "gradientUnits=\"userSpaceOnUse\" "
@@ -1549,8 +1551,7 @@ _cairo_svg_surface_emit_radial_pattern (cairo_svg_surface_t    *surface,
 	_cairo_svg_surface_emit_transform (document->xml_node_defs, "gradientTransform", &p2u);
 	_cairo_output_stream_printf (document->xml_node_defs, ">\n");
 
-	if (extend == CAIRO_EXTEND_NONE ||
-	    pattern->base.n_stops < 1)
+	if (extend == CAIRO_EXTEND_NONE || n_stops < 1)
 	    _cairo_output_stream_printf (document->xml_node_defs,
 					 "<stop offset=\"0\" style=\""
 					 "stop-color: rgb(0%%,0%%,0%%); "
@@ -1564,15 +1565,15 @@ _cairo_svg_surface_emit_radial_pattern (cairo_svg_surface_t    *surface,
 					 pattern->base.stops[0].color.green * 100.0,
 					 pattern->base.stops[0].color.blue  * 100.0,
 					 pattern->base.stops[0].color.alpha);
-	    if (pattern->base.n_stops > 1)
+	    if (n_stops > 1)
 		_cairo_output_stream_printf (document->xml_node_defs,
 					     "<stop offset=\"0\" style=\""
 					     "stop-color: rgb(%f%%,%f%%,%f%%); "
 					     "stop-opacity: %f;\"/>\n",
-					     pattern->base.stops[1].color.red   * 100.0,
-					     pattern->base.stops[1].color.green * 100.0,
-					     pattern->base.stops[1].color.blue  * 100.0,
-					     pattern->base.stops[1].color.alpha);
+					     pattern->base.stops[n_stops - 1].color.red   * 100.0,
+					     pattern->base.stops[n_stops - 1].color.green * 100.0,
+					     pattern->base.stops[n_stops - 1].color.blue  * 100.0,
+					     pattern->base.stops[n_stops - 1].color.alpha);
 	}
 
     } else {


More information about the cairo-commit mailing list