<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content="text/html; charset=gb2312" http-equiv=Content-Type>
<META name=GENERATOR content="MSHTML 8.00.7600.16625"></HEAD>
<BODY>
<P>Hi, all,<BR>I am using cairo 1.8.10 under wine, and i find that in some
situations, cairo_stroke works very slow.<BR>drawing 1000 lines on an image
surface takes only 915ms, but on a Win32 surface it takes 10,493ms!<BR>the
testing code is as follow:<BR><BR>void drawLines(cairo_surface_t *surface, int
nCount)<BR>{ <BR> cairo_t *cr = cairo_create
(surface);<BR> cairo_set_source_rgb(cr, 1, 0,
0);<BR> /*cairo_set_antialias(cr, CAIRO_ANTIALIAS_NONE);*/</P>
<P> srand(time(NULL));<BR> CTimer
timer;<BR> timer.Restart();<BR> for (int i = 0; i < nCount;
i++)<BR> {<BR> double x1 = rand() % 500;<BR> double
y1 = rand() % 500;<BR> double x2 = rand() % 1500 +
100;<BR> double y2 = rand() % 1000 +
100;<BR> cairo_move_to(cr, x1, y1);<BR> cairo_line_to(cr,
x2, y2);<BR> <FONT
color=#ff0000>cairo_stroke(cr);</FONT><BR> } <BR> <BR> timer.Stop();<BR> printf("drawlines,
%d times:%d(ms)\n", nCount,
timer.ElapsedMsec());<BR> cairo_surface_write_to_png(surface,
"drawLines.png");<BR> cairo_destroy (cr); <BR>}</P>
<P>TEST(DrawLine, ImageBackend)<BR>{<BR> <FONT
color=#ff0000>cairo_surface_t *surface = cairo_image_surface_create
(CAIRO_FORMAT_ARGB32, 1000, 1000);<BR></FONT> drawLines(surface,
1000);<BR> cairo_surface_destroy (surface);<BR>}</P>
<P>TEST(DrawLine, HDCBackend)<BR>{<BR> HDC hdc =
GetDC(NULL);<BR> <FONT color=#ff0000>cairo_surface_t *surface =
cairo_win32_surface_create(hdc);</FONT><BR> drawLines(surface,
1000);<BR> cairo_surface_destroy (surface);<BR> ReleaseDC(NULL,
hdc);<BR>}<BR><BR>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.<BR>Most of the time is consumed by cairo_stroke.<BR>I know i can move
cairo_stroke out of the for loop and call it only once, it improve the
performance a lot.<BR><BR>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!).<BR>I have a few questions:<BR>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?<BR>2. is
it possible to improve it ? how?<BR>3. what can i do the improve the performance
of cairo if i am using it under wine?<BR><BR>thanks!</P></BODY></HTML>