[cairo] Cairo Drawing Speed

Duong Hoang Linh linh.duong at quantuminventions.com
Tue Nov 24 01:49:45 PST 2009


Hi all,

I change to use image surface and amazingly drawing time is now only 
220ms. Awesome.

Thanks for your helps. I think this thread can be closed now.


Duong Hoang Linh wrote:
> Hi Maarten,
>
> I think i used win32 surface. Below is the code for initializing my 
> cairo structure before drawing:
>
>     //Cairo structures
>     cairo_surface_t *surface;
>     cairo_t *cr;
>
>     int ww, wh;
>     RECT rc;
>     GetWindowRect(&rc);
>     ww = (rc.right - rc.left);
>     wh = (rc.bottom - rc.top);
>
>     HDC memdc;
>     HBITMAP hbuffer;
>
>     memdc = CreateCompatibleDC(paintDC.m_hDC);
>     hbuffer = CreateCompatibleBitmap(paintDC.m_hDC, ww, wh);
>     SelectObject(memdc, hbuffer);
>
>     surface = cairo_win32_surface_create (memdc);  // to the memory DC
>     cr = cairo_create (surface);
>
> It may be a good idea to use image surface. I will try out and compare.
>
> Thanks!
>
> Maarten Bosmans wrote:
>   
>> 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.
>>>     
>>>       
>
>   

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


More information about the cairo mailing list