[cairo] Performance of the image surface back-end

Vladimir Vukicevic vladimir at pobox.com
Sat Aug 16 17:27:45 PDT 2008

On Aug 16, 2008, at 1:15 AM, Nicholas Allen wrote:

> Hash: SHA1
> Vladimir Vukicevic wrote:
>> On Aug 15, 2008, at 6:20 AM, Nicholas Allen wrote:
>>> Cairo (image surface back-end version 1.6.4 on Windows):
>>> ~     DrawHorizLine                 44352 ms             1000000  
>>> solid
>>> horiz lines from 0.5, 50.5 to 500.5, 50.5
>> This is not actually a pixel-aligned horizontal line, unless you are
>> using the non-default SQUARE endcaps.  The horizontal line would be
>> from 0.0, 50.5 to 501.0, 50.5.  With this line, you are getting
>> essentially the slowest possible path for path rasterization;  
>> however,
>> even with that, it seems quite slow.  As others mentioned, seeing the
>> source for your benchmark would be useful!  (If, however, you are
>> explicitly setting SQUARE endcaps, then something is likely going
>> quite wrong.)
> Thanks for pointing out that error. At the moment I am just trying to
> get something to profile and not that draws correctly. If this 0.5
> offset can slow a line down by factors of a hundred or so then I would
> say this indicates some serious problems with the line capping code.

The problem in your case is that the line caps are -not- drawn.  A  
stroke which results in a fully pixel-aligned outline is just a fast  
solid fill.  One that's not pixel aligned (such as one that's offset  
by 0.5 pixel that causes the stroke outline to fall on a non-pixel  
boundary) ends up going through the slower rendering path because of  
the antialiasing that has to happen at that half pixel.  This is, as  
you say, not ideal, and some optimization is certainly possible (and  
some is in progress), and it is certainly slower than code that only  
has to deal with pixel-aligned strokes without any antialiasing.

    - Vlad

More information about the cairo mailing list