[cairo] [PATCH 1/2] gl: Add a first bit of general documentation on cairo-gl usage.

Benjamin Otte otte at redhat.com
Tue Feb 1 07:58:04 PST 2011


On Mon, 2011-01-31 at 23:57 -0800, Eric Anholt wrote:
> + * Cairo-gl does not unbind its context after its rendering, and
> + * OpenGL requires that a context being bound to a thread not
> + * currently be bound to a different thread .  Therefore, an
> + * application using cairo-gl surfaces from multiple threads must
> + * manually unbind the cairo_device_t's context from the leaving
> + * thread before calling cairo from the entering thread.
>  
I don't think that change is gonna work if you want to allow anything
multithreaded in cairo-gl. Neither Wayland-GTK nor GStreamer will be
able to work with cairo-gl this way.

The reason is that cairo-gl does not just acquire the context upon
drawing with stroke/fill/mask/show_glyphs, but also when it's used as a
source or even with cairo_surface_write_to_png(). Which de-facto means
that in your app, if you grab a surface from GTK, you must call
glXMakeCurrent(NULL) if you intend your lib to work in a multithreaded
application.

But it's interesting that we actually do have performance differences
these days with avoiding glXMakeCurrent(NULL), because when I added it,
I benchmarked it and there was virtually no difference at all. So I
guess that's new code that Mesa grew in recent times?

Benjamin



More information about the cairo mailing list