[cairo] How to know if a surface is mapped
psychon at znc.in
Wed Mar 20 03:35:52 PDT 2013
On 20.03.2013 10:57, Carlos López González wrote:
> 2013/3/20 Uli Schlachter <psychon at znc.in>
>> On 20.03.2013 08:33, Carlos López González wrote:
>>> The problem comes when the render system needs to map/unmap the Cairo
>>> surface and the widget is requested to be drawn. In that case, according
>>> the documentation the surface behavior is unknown and so the render result
>>> is incorrect. But the widget thinks that the update of the drawing area
>>> done and it is marked as 'clean' (no refreshed again).
>>> So the question is: is there any way to know if a surface is currently
>> What does "mapped" mean here? How do you map/unmap a cairo surface?
> Yes, mapped means that the surface is right after a
> cairo_surface_map_to_image() call.
So let me see if I understand this correctly?
Thread 1 paints to the surface (and possibly does a map_to_image()). At the same
time, thread 2 uses the surface as a source for another drawing operation.
How can this work without map_to_image()? The two threads will always race with
each other. Thread 2 could access the surface between any two drawing operations
of thread 1 and thus random results result.
You need some synchronisation between the two threads to make sure that the
widget isn't drawn while the rendering thread paints its surface.
P.S.: No, there is no way to see if a surface is currently mapped to an image.
More information about the cairo