<pre><code>Hi, I want to use cairo in multi-threads context, anybody know if cairo is thread-safe? especially the </code>cairo_t object.<br><code>I found some mutex related code, so i guess cairo lib might be threadsafe.<br>Who can tell me the truth?<br></code><br><code><code>void threadDrawFunc(void *cr)<br>{<br> // do we need lock cr here?<br> // lock();<br><br> // sample drawing code<br> cairo_select_font_face (cr, font, CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_BOLD);<br> cairo_set_font_size (cr, 32.0);<br> cairo_set_source_rgb (cr, 0.0, 0.0, 1.0);<br> cairo_move_to (cr, 10.0, 50.0);<br><br> cairo_show_text (cr, text);<br><br> // unlock();<br>}<br><br>void mainThread()<br>{<br></code> cairo_surface_t *surface =
cairo_image_surface_create (CAIRO_FORMAT_ARGB32, 240, 80);
cairo_t *cr =
cairo_create (surface);<br><br> create_thread(threadDrawFunc, cr);<br><br> // wait threads to exit<br> join_thread(...);<br><br> cairo_destroy (cr);<br><br> cairo_surface_write_to_png (surface, "c:/temp/hello-cairo.png");<br> cairo_surface_destroy (surface);<br>}<br></code></pre>