Bug 5561 - cairo_set_dash does not work properly when the first dash length is 0
Summary: cairo_set_dash does not work properly when the first dash length is 0
Status: RESOLVED FIXED
Alias: None
Product: cairo
Classification: Unclassified
Component: general (show other bugs)
Version: 1.1.1
Hardware: x86 (IA32) Linux (All)
: high normal
Assignee: Carl Worth
QA Contact: cairo-bugs mailing list
URL:
Whiteboard:
Keywords:
: 5838 6158 (view as bug list)
Depends on:
Blocks:
 
Reported: 2006-01-10 16:26 UTC by Jeff Muizelaar
Modified: 2006-04-19 00:02 UTC (History)
2 users (show)

See Also:
i915 platform:
i915 features:


Attachments
a test cases that exercises the failure (1.99 KB, text/x-csrc)
2006-01-10 16:28 UTC, Jeff Muizelaar
Details
a quick work around (557 bytes, patch)
2006-02-16 08:25 UTC, Jeff Muizelaar
Details | Splinter Review
compute the dashed line slope once and use that slope to compute line faces (3.39 KB, patch)
2006-03-25 16:34 UTC, Jeff Muizelaar
Details | Splinter Review
cleaner patch (3.88 KB, patch)
2006-04-03 15:26 UTC, Jeff Muizelaar
Details | Splinter Review

Description Jeff Muizelaar 2006-01-10 16:26:46 UTC
calling somthing like cairo_set_dash(cr, (double[]){0, 4}, 2, 0.0) causes
_cairo_stroker_line_to_dashed to call _cairo_stroker_add_leading_cap without
initializing sub_start. This can be seen by running valgrind and getting a
failure further down this call chain.
Comment 1 Jeff Muizelaar 2006-01-10 16:28:12 UTC
Created attachment 4309 [details]
a test cases that exercises the failure
Comment 2 Jeff Muizelaar 2006-02-16 08:25:22 UTC
Created attachment 4614 [details] [review]
a quick work around
Comment 3 Jeff Muizelaar 2006-02-17 09:05:50 UTC
The attached patch is wrong. It doesn't work properly when there are line caps.
If there are line caps they should still be drawn even if the dash length is 0
Comment 4 Jeff Muizelaar 2006-02-17 09:10:05 UTC
*** Bug 5838 has been marked as a duplicate of this bug. ***
Comment 5 Jeff Muizelaar 2006-03-25 16:34:02 UTC
Created attachment 5050 [details] [review]
compute the dashed line slope once and use that slope to compute line faces

quick hack of a patch that appears to fix this bug.
Comment 6 Jeff Muizelaar 2006-04-03 15:26:10 UTC
Created attachment 5175 [details] [review]
cleaner patch

a cleaner patch, this time against git HEAD.
Comment 7 Jeff Muizelaar 2006-04-13 10:03:00 UTC
*** Bug 6158 has been marked as a duplicate of this bug. ***
Comment 8 Carl Worth 2006-04-19 17:02:12 UTC
Thanks to Jeff this bug is now fixed in any checkout of cairo 1.1.1 after
2006-04-09 (and the fixes will be released in the upcoming 1.2.0 release). Here
are the relevant commits:

commit 2078557c5c9e10cf8ae16fb3fa8a225f908ab528
Author: Jeff Muizelaar <jeff@infidigm.net>
Date:   Sun Apr 9 23:11:27 2006 -0400

    Fix skipping zero length dash segments in dash_start.

    The extra check makes sure zero length segments are not skipped when computing
    the dash start state. This is needed so that we get proper line capping if, for
    example, the first dash segment has zero length and we have a dash offset of
    zero.

commit 5eaf71e77bd975f5865cc059b4aa4d57c096688e
Author: Jeff Muizelaar <jeff@infidigm.net>
Date:   Sun Apr 9 23:11:11 2006 -0400

    Move the test for zero length sub edges below the computation of faces.

    Face computation still works if a line has zero length, all that is needed is a
    slope and a point. This patch fixes bug #5561 because the faces are initialized
    even if the segment has zero length as expected by
    _cairo_stroker_line_to_dashed.

commit 20fca01a2cc539df017e442be0cc6ad35353571f
Author: Jeff Muizelaar <jeff@infidigm.net>
Date:   Sun Apr 9 23:10:59 2006 -0400

    Move calculation of slope outside of _cairo_stroker_add_sub_edge.

    This makes the slope calculation more accurate for dashed lines by computing it
    once for the entire line instead for each individual dash segment. It also
    adjusts stroker_line_to() to match the new convention for
    stroker_add_sub_edge().

commit 8a2ea660fb59beb4eacaf73978368c8db7a6b584
Author: Jeff Muizelaar <jeff@infidigm.net>
Date:   Sun Apr 9 23:10:46 2006 -0400

    Check for zero length dashed lines.

    This makes line_to_dashed more like line_to by returning immediately on
    degenerate paths. This is needed so that we can do the slope calculation for
    the entire line.

commit 584109d5e6160c1e74da0e79b6e024701a354293
Author: Jeff Muizelaar <jeff@infidigm.net>
Date:   Sun Apr 9 23:11:47 2006 -0400

    Add test case for dashed lines.

    The new test case tests a variety of circumstances involved with zero length
dashing.



Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.