Remove infinite looping when stroking with a line width at or close to 0.0. Thanks to Rob Buis <buis@kde.org> and Noah Levitt <nlevitt@columbia.edu> for providing in-the-wild examples of SVG files with stroke-width:0 that demonstrated the problem, (cowboy.svg and albania.svg).

Do nothing if the pen is a degenerate, single point. This happens when the line width is a very small, non-zero value.
Do nothing when asked to stroke a path with a line_width of 0.0. Previously, this would lead to an infinite loop.
Force negative line width to 0.0.
Updated TODO list.
This commit is contained in:
Carl Worth 2003-11-17 07:04:15 +00:00
parent 399803d067
commit f27af5d98d
7 changed files with 53 additions and 6 deletions

View file

@ -1,3 +1,24 @@
2003-11-17 Carl Worth <cworth@isi.edu>
* Remove infinite looping when stroking with a line width at or
close to 0.0. Thanks to Rob Buis <buis@kde.org> and Noah Levitt
<nlevitt@columbia.edu> for providing in-the-wild examples of SVG
files with stroke-width:0 that demonstrated the problem,
(cowboy.svg and albania.svg).
* src/cairo_pen.c (_cairo_pen_stroke_spline): Do nothing if the
pen is a degenerate, single point. This happens when the line
width is a very small, non-zero value.
* src/cairo_gstate.c (_cairo_gstate_stroke): Do nothing when asked
to stroke a path with a line_width of 0.0. Previously, this would
lead to an infinite loop.
* src/cairo.c (cairo_set_line_width): Force negative line width
to 0.0.
* TODO: Updated TODO list.
2003-11-10 Carl Worth <cworth@east.isi.edu>
* configure.in: Fix typo (thanks to John Ellson

20
TODO
View file

@ -1,22 +1,30 @@
* Fix the intersection problem, (see reference to Hobby's paper
mentioned in cairo_traps.c)
* Change stroke code to go through one giant polygon. This will fix
problems with stroking self-intersecting paths.
* Implement support for programmatic patterns
* Implement cairo_stroke_path, (very easy to do after the above change
is done).
* Fix the intersection problem, (see reference to Hobby's paper
mentioned in cairo_traps.c).
* Implement support for programmatic patterns.
* Implement cairo_text_extents, cairo_glyph_extents, cairo_text_path,
cairo_glyph_path, and cairo_stroke_path, cairo_arc_to.
* Add a few new, needed functions?
* Investigate what needs to be done so that old X servers aren't
swamped with image transport. This may involve adding one or more of
the following functions:
cairo_flush
cairo_erase
cairo_mark_dirty
* Verification, profiling, optimization.
* Re-implement the trapezoid rasterization algorithm according to the
new "specification".
* Verification, profiling, optimization.
A comparison with PostScript
============================

View file

@ -1157,6 +1157,9 @@ _cairo_gstate_stroke (cairo_gstate_t *gstate)
cairo_traps_t traps;
cairo_matrix_t user_to_source, device_to_source;
if (gstate->line_width <= 0.0)
return CAIRO_STATUS_SUCCESS;
status = _cairo_gstate_ensure_source (gstate);
if (status)
return status;

View file

@ -322,6 +322,11 @@ _cairo_pen_stroke_spline (cairo_pen_t *pen,
cairo_status_t status;
cairo_polygon_t polygon;
/* If the line width is so small that the pen is reduced to a
single point, then we have nothing to do. */
if (pen->num_vertices <= 1)
return CAIRO_STATUS_SUCCESS;
_cairo_polygon_init (&polygon);
status = _cairo_spline_decompose (spline, tolerance);

View file

@ -265,6 +265,8 @@ cairo_set_line_width (cairo_t *cr, double width)
if (cr->status)
return;
_cairo_restrict_value (&width, 0.0, width);
cr->status = _cairo_gstate_set_line_width (cr->gstate, width);
}

View file

@ -1157,6 +1157,9 @@ _cairo_gstate_stroke (cairo_gstate_t *gstate)
cairo_traps_t traps;
cairo_matrix_t user_to_source, device_to_source;
if (gstate->line_width <= 0.0)
return CAIRO_STATUS_SUCCESS;
status = _cairo_gstate_ensure_source (gstate);
if (status)
return status;

View file

@ -322,6 +322,11 @@ _cairo_pen_stroke_spline (cairo_pen_t *pen,
cairo_status_t status;
cairo_polygon_t polygon;
/* If the line width is so small that the pen is reduced to a
single point, then we have nothing to do. */
if (pen->num_vertices <= 1)
return CAIRO_STATUS_SUCCESS;
_cairo_polygon_init (&polygon);
status = _cairo_spline_decompose (spline, tolerance);