[cairo] Cairo Drawing Speed

Duong Hoang Linh linh.duong at quantuminventions.com
Mon Nov 23 23:53:32 PST 2009

Hi Emmanuel,

This is my code for drawing line:

    cairo_set_source_rgb (cr, 0, 0, 0);
    cairo_set_line_width (cr, 7);
    cairo_set_line_cap  (cr, CAIRO_LINE_CAP_ROUND);
    cairo_set_line_join (cr, CAIRO_LINE_JOIN_ROUND);

    for(int k=0;k<vLines.size();k++)
        cairo_move_to (cr, vLines[k].ptLineArray[0].x, 
        for(int i=1;i<vLines[k].numLinePoints;i++)
            cairo_line_to (cr, vLines[k].ptLineArray[i].x, 

    cairo_stroke_preserve (cr);

    cairo_set_source_rgb (cr, 1, 1, 1);
    cairo_set_line_width (cr, 4);

    cairo_stroke (cr);

I run this code on wince 5.0 device, processor ARM920T, 40MB RAM.

In more detail, i measure the time execution of cairo_stroke and it 
takes from 100-120ms. And in total, i need to do cairo_stroke 6 times, 
which add up to 700+ms.


Emmanuel Pacaud wrote:
> Hi,
> Le mardi 24 novembre 2009 à 02:50 +0100, Duong Hoang Linh a écrit :
>> I have implemented a simple application to draw a set of 90 lines and 
>> measure the execution time of drawing using Cairo.
>> In more detail, i want to draw a set of 90 linses, which constitute 388 
>> points (average 4.3 points/line). I divide 90 lines into 3 groups and 
>> draw each group in different colors/widths. It is noted that i draw each 
>> line with border. The execution time is summarized as follows:
>> LINE_CAP_ROUND, LINE_JOIN_ROUND: it takes 802ms
>> LINE_CAP_BUTT, LINE_JOIN_MITTER: it takes 700ms
>> At the moment, i want to evaluate the performance of Cairo in terms of 
>> speed for drawing and I need to achieve the time execution between 300ms 
>> and 500ms (<300 is certainly wonderful). Is there any possible way for 
>> speeding up my drawing with Cairo?
> 700/800 ms for drawing 90 lines seems slow.
> But wihout showing us your code, nor telling the platform you use for
> your tests, it's not easy to give you an advice.
> 	Emmanuel.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.cairographics.org/archives/cairo/attachments/20091124/c2c4ff7c/attachment.htm 

More information about the cairo mailing list