|
View:
New views
4 Messages
—
Rating Filter:
Alert me
|
|
|
Threading: painting from the same source_surfaceHi,
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. _______________________________________________ cairo mailing list cairo@... http://lists.cairographics.org/mailman/listinfo/cairo |
|
|
Re: Threading: painting from the same source_surfaceExcerpts from Arjen Nienhuis's message of Fri Nov 06 13:18:52 +0000 2009:
> 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. What is the connection of this bug to the shared source? What you have described should work fine with cairo. What requires serialisation is writing to the same objects (cairo_t and cairo_surface_t). If you could provide a long snippet of code, or ideally a minimal test case, we could help you further diagnose the issue. -ickle -- Chris Wilson, Intel Open Source Technology Centre _______________________________________________ cairo mailing list cairo@... http://lists.cairographics.org/mailman/listinfo/cairo |
|
|
Re: Threading: painting from the same source_surfaceOn Fri, Nov 6, 2009 at 2:33 PM, Chris Wilson <chris@...> wrote:
> Excerpts from Arjen Nienhuis's message of Fri Nov 06 13:18:52 +0000 2009: >> 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. > > What is the connection of this bug to the shared source? What you have > described should work fine with cairo. What requires serialisation is > writing to the same objects (cairo_t and cairo_surface_t). > > If you could provide a long snippet of code, or ideally a minimal test > case, we could help you further diagnose the issue. > -ickle > -- > Chris Wilson, Intel Open Source Technology Centre > test case shows the same problem. As a minimal test case needs thraeding, I can only do this in python. If you need anything in C, can you please point me to a simple C program with threads? The example png here is one of 9 broken pngs in the result of 200. I run Ubuntu 8.10 with cairo 1.8.8. Met vriendelijke groet, Arjen Nienhuis [test.py] import cairo src = cairo.ImageSurface.create_from_png('liefde062.png') def f1(): for i in range(100): print 'f1 ', i im = cairo.ImageSurface(cairo.FORMAT_ARGB32, 500, 500) ctx = cairo.Context(im) ctx.translate(-300, 0) ctx.scale(0.8, 0.3) ctx.set_source_surface(src) ctx.paint() im.write_to_png(open('f1_%03d.png' % i, 'wb')) def f2(): for i in range(100): print 'f2 ', i im = cairo.ImageSurface(cairo.FORMAT_ARGB32, 500, 500) ctx = cairo.Context(im) ctx.translate(300, 100) ctx.scale(0.1, 0.3) ctx.set_source_surface(src) ctx.paint() im.write_to_png(open('f2_%03d.png' % i, 'wb')) from threading import Thread t1 = Thread(target=f1) t2 = Thread(target=f2) t1.start() t2.start() t1.join() t2.join() _______________________________________________ cairo mailing list cairo@... http://lists.cairographics.org/mailman/listinfo/cairo |
|
|
Re: Threading: painting from the same source_surfaceOn Fri, Nov 6, 2009 at 6:12 PM, Arjen Nienhuis <a.g.nienhuis@...> wrote:
> On Fri, Nov 6, 2009 at 2:33 PM, Chris Wilson <chris@...> wrote: >> Excerpts from Arjen Nienhuis's message of Fri Nov 06 13:18:52 +0000 2009: >>> 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. >> >> What is the connection of this bug to the shared source? What you have >> described should work fine with cairo. What requires serialisation is >> writing to the same objects (cairo_t and cairo_surface_t). >> >> If you could provide a long snippet of code, or ideally a minimal test >> case, we could help you further diagnose the issue. >> -ickle >> -- >> Chris Wilson, Intel Open Source Technology Centre >> > > I'm afraid that the bug is in that short snippet of code. The attached > test case shows the same problem. > > As a minimal test case needs thraeding, I can only do this in python. > If you need anything in C, can you please point me to a simple C > program with threads? > > The example png here is one of 9 broken pngs in the result of 200. > > I run Ubuntu 8.10 with cairo 1.8.8. > > Met vriendelijke groet, > Arjen Nienhuis > Does it help if I write a test for this like test/pthread-show-text.c that can be included with cairo? BTW: The problem doesn't show up with ubuntu 8.04 because it uses pycairo version 1.4.12 (instead of 1.8.6 for Ubuntu 8.10) because that version of pycairo is not multithreaded. Met vriendelijke groet, Arjen Nienhuis _______________________________________________ cairo mailing list cairo@... http://lists.cairographics.org/mailman/listinfo/cairo |
| Free embeddable forum powered by Nabble | Forum Help |