<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Hi all,<br>
<br>
I change to use image surface and amazingly drawing time is now only
220ms. Awesome.<br>
<br>
Thanks for your helps. I think this thread can be closed now.<br>
<br>
<br>
Duong Hoang Linh wrote:
<blockquote cite="mid:4B0B9E88.9030206@quantuminventions.com"
type="cite">
<pre wrap="">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:
</pre>
<blockquote type="cite">
<pre wrap="">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 <a class="moz-txt-link-rfc2396E" href="mailto:linh.duong@quantuminventions.com"><linh.duong@quantuminventions.com></a>:
</pre>
<blockquote type="cite">
<pre wrap="">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.
</pre>
</blockquote>
</blockquote>
<pre wrap=""><!---->
</pre>
</blockquote>
<br>
</body>
</html>