[cairo] perf: long dashed lines
bertram.felgenhauer at googlemail.com
Sun Feb 3 11:30:03 PST 2008
Vladimir Vukicevic wrote:
> Here's a followup patch that attempts to implement the bigger optimization
> -- entirely avoid creating faces for out-of-bounds segments. This is still
> a work in progress, but figured I would toss it out for feedback. Seems to
> work quite well, though I'm not sure if my quick fix of expanding the
> bounding box by the line width is enough to catch all edge issues. (Also,
> I just realized that I'm not sure if that's the right line width -- do I
> need to transform it?)
The bounding box is in device space, while the line width is in user
space, so yes, you'll have to transform it.
But then the code will still have trouble with miter joins and large
miter limits, which allow joins to reach arbitrarily far from their
corresponding line segments. For bevel and round joins, line_width/2
____\|____ . . .
Similarily, square line caps can reach up to sqrt(2)/2*line_width
from a line end point. For round and butt caps, line_width/2 is
Given the maximum distance d from a line in user space, which according
to the above argument is
d = max(box_cap ? sqrt(2)/2 : 0.5, miter_join ? miter_limit : 0),
and the ctm,
/ xx xy x0 \
\ yx yy y0 /
the maximum horizontal offset is
dx = d * sqrt(xx^2 + xy^2)
and the maximum vertical offset is
dy = d * sqrt(xy^2 + yy^2).
You can use these values to adjust the bounding box.
More information about the cairo