[cairo] cairo stroke problem with potential patch

Keith Wells wellsk at us.ibm.com
Tue Jun 20 04:47:28 PDT 2006






I originally sent this to Carl and he kindly suggested I re-post it to this
mailing list, so...

I have been working on some bugs in the Mozilla SVG arena.  The initial
stroke-cap is missing from the very first dash-array element drawn in the
following svg example.   I noticed there was a cairo bug already in the
system, https://bugs.freedesktop.org/show_bug.cgi?id=4409,  that addressed
this issue,  or close to it, but apparently still exists on, at least,  the
Windows XP version of recent builds of firefox.  I don't think this has
been resolved in the most recent version of cairo-path-stroke.c.

This is the svg example I have been playing with that shows this problem:
<?xml version="1.0" ?>
 <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 600 600">
<rect  x="20" y="20" width="100" height="100" fill="blue" stroke="red"
stroke-width="20" stroke-dasharray="0.001,20" stroke-linecap="round"/>
</svg>

If you render this in firefox, you will notice that the very first leading
cap is cutoff.

I am using a recent mozilla/gfx/cairo/cairo/src/cairo-path-stroke.c file
from the Mozilla core to make changes for testing so my cvs diff is off
from the cairo base code (otherwise I would include the entire patch).
This change is minor but makes a difference in the rendering of the first
array element in the case above.
Here is a fix for it:

@@ -720,21 +738,20 @@ _cairo_stroker_line_to_dashed (void *clo
            if (stroker->has_current_face) {
                status = _cairo_stroker_join (stroker,
&stroker->current_face, &sub_start);
                if (status)
                  return status;
            } else {
                if (!stroker->has_first_face) {
                  stroker->first_face = sub_start;
                  stroker->has_first_face = 1;
-               } else {
+               }
                  status = _cairo_stroker_add_leading_cap (stroker,
&sub_start);
                  if (status)
                      return status;
-               }
            }
          }
          if (remain) {
            /*
             * Cap if not at end of segment
             */
            status = _cairo_stroker_add_trailing_cap (stroker, &sub_end);
            if (status)

The problem  with the above svg example is that the first element in this
dash-array NEVER invokes _cairo_stroker_add_leading_cap.  I think
_cairo_stroker_add_leading_cap needs to be called in both cases of  if
(!stroker->has_first_face).

Thanks,
Keith
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.freedesktop.org/archives/cairo/attachments/20060620/722f87fc/attachment.html


More information about the cairo mailing list