[cairo] Threading: painting from the same source_surface

Arjen Nienhuis a.g.nienhuis at gmail.com
Fri Nov 6 05:18:52 PST 2009


Hi,

I have a big png file that I try to copy to two different
ImageSurfaces using two different threads.

One of the two resulting images is corrupted.

Is this a bug in cairo or in my code (wrong assumptions about threading)?

Here is my pseudo-python-code:

Thread 1:
========
src = cairo.ImageSurface.create_from_png(path)
...
ctx = cairo.ImageSurface(...)
ctx.translate(...)
ctx.scale(...)
ctx.set_source_surface(src)
ctx.paint()

Thread 2:
========
ctx = cairo.ImageSurface(...)
ctx.translate(...)
ctx.scale(...)
ctx.set_source_surface(src)
ctx.paint()

The result from thread 1 is T1_bad.jpg but should be T1_ok.jpg. (What
happened to the text?)
Thread 2 is fine and results in T2.jpg.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: T1_bad.jpg
Type: image/jpeg
Size: 10121 bytes
Desc: not available
Url : http://lists.cairographics.org/archives/cairo/attachments/20091106/fbf56bce/attachment-0003.jpg 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: T1_ok.jpg
Type: image/jpeg
Size: 9822 bytes
Desc: not available
Url : http://lists.cairographics.org/archives/cairo/attachments/20091106/fbf56bce/attachment-0004.jpg 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: T2.jpg
Type: image/jpeg
Size: 6021 bytes
Desc: not available
Url : http://lists.cairographics.org/archives/cairo/attachments/20091106/fbf56bce/attachment-0005.jpg 


More information about the cairo mailing list