[cairo] Cairo Drawing Speed

Maarten Bosmans mkbosmans at gmail.com
Tue Nov 24 00:12:40 PST 2009


Your code looks like the right way to construct these lines.

What backend are you using? It could very well be that using an
imagesurface to draw the lines and then blit the result to the screen
is faster.

And of course it is always faster if the lines are aligned on the
pixel grid, but in your case that's probably not possible because of
diagonal line segments.

Maarten


2009/11/24 Duong Hoang Linh <linh.duong at quantuminventions.com>:
> 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, vLines[k].ptLineArray[0].y);
>         for(int i=1;i<vLines[k].numLinePoints;i++)
>             cairo_line_to (cr, vLines[k].ptLineArray[i].x, vLines[k].ptLineArray[i].y);
>     }
>
>     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.
>
> Thanks.


More information about the cairo mailing list