[cairo] about cairo_stroke's performance
mkbosmans at gmail.com
Mon Sep 27 13:42:49 PDT 2010
2010/9/27 oken <okenjian at 163.com>:
> Hi, all,
> I am using cairo 1.8.10 under wine, and i find that in some situations,
> cairo_stroke works very slow.
> drawing 1000 lines on an image surface takes only 915ms, but on a Win32
> surface it takes 10,493ms!
> the testing code is as follow:
This is also what I see in my app (mostly scrolling text), the
framerate using an image surface is much higher.
> I run my test under both wine and win7, and i get the similar result:drawing
> on an image surface is much faster than WIN32 surface does.
> Most of the time is consumed by cairo_stroke.
> I know i can move cairo_stroke out of the for loop and call it only once, it
> improve the performance a lot.
The win32 surface is really basic, since it uses the windows GDI
subsystem. Pixman has a lot of fast paths using e.g. SSE2 assembly,
which makes the image surface quite fast.
> I also find that drawing rectangles on a win32 surface is fast if the
> parameters are integer, however using double decrease the performance a
> lot(about 10 times slower!).
By double do you mean, non-integer doubles? That is expected, because
the rectangles are not pixel-aligned.
> I have a few questions:
> 1. does it make sense that drawing a single line(not horizontal or vertical)
> or a rectangle(with double parameters) on a WIN32 surface takes about 10ms?
I guess so.
> 2. is it possible to improve it ? how?
Render all your lines to an image surface and when you're done, blit
the pixels to the win32 surface.
> 3. what can i do the improve the performance of cairo if i am using it under
More information about the cairo