[cairo] cairo_set_dash performance
Vladimir Vukicevic
vladimir at pobox.com
Thu Feb 5 16:04:01 PST 2009
On 2/5/09 11:33 AM, cu wrote:
> Good day all!
>
> When using cairo_set_dash (i.e. drawing lines with various dash
> patterns) I am experiencing a performance hit of about 20% application
> wide. That translates to more than that for just the line drawing -
> drawing is about 80% of execution time and lines comprise about 1/3 of
> objects that need to be drawn.
>
> Is that an expected result? Am I doing/not doing anything specific that
> I should? Is there a way to still get dashed lines without a performance
> hit of this magnitude?
Dashes compared to normal lines are pretty expensive, especially if the
lines were always pixel aligned (and resulted in pixel aligned regions
being filled). There are some things you can do, though:
1) If you're drawing something like a dashed rectangle, where there's a
large surface area but only a small portion of it is actually rendered
to, you can often get better performance by drawing each side
separately. (I don't know if this is still the case with the scanline
rasterizer.)
2) Try to ensure that your dash patterns all result in pixel aligned
dashes; effectively this means that your lines must start/end on integer
pixels (and fully fill those pixels), and that the dash pattern should
be composed of integers only. All gets thrown out the door if you have
scaling/rotation/etc. going on, though.
- Vlad
More information about the cairo
mailing list