[cairo] about cairo_stroke's performance
okenjian at 163.com
Mon Sep 27 06:56:30 PDT 2010
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:
void drawLines(cairo_surface_t *surface, int nCount)
cairo_t *cr = cairo_create (surface);
cairo_set_source_rgb(cr, 1, 0, 0);
for (int i = 0; i < nCount; i++)
double x1 = rand() % 500;
double y1 = rand() % 500;
double x2 = rand() % 1500 + 100;
double y2 = rand() % 1000 + 100;
cairo_move_to(cr, x1, y1);
cairo_line_to(cr, x2, y2);
printf("drawlines, %d times:%d(ms)\n", nCount, timer.ElapsedMsec());
cairo_surface_t *surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, 1000, 1000);
HDC hdc = GetDC(NULL);
cairo_surface_t *surface = cairo_win32_surface_create(hdc);
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.
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!).
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?
2. is it possible to improve it ? how?
3. what can i do the improve the performance of cairo if i am using it under wine?
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the cairo