Re: Getting a Cairo context



Hi;

On 24 March 2015 at 12:17, Sergei Naumov <vomus rambler ru> wrote:

I am developing a program that has to draw some data using Cairo. The
question I have is about getting a cairo context from outside of the signal
"draw" that the examples describe. I have a multithreaded application where
one thread sets up the GTK drawing area, axes, tickmarks, etc. and another
thread has to draw in this area. I attach a function  to a "draw" signal on
this GTK widget (drawing area) in one thread, but what do I do in another?

The idiomatic way is to create a surface either using
gdk_window_create_similar_surface(), or
gdk_window_create_similar_image_surface(), which will take care of
giving you the most appropriate surface for the platform you're using.

You can usually do that from the main thread context, after realizing
the widget in order to obtain its GdkWindow; you keep the surface
inside your widget instance data, and draw on it from the thread you
create for rendering. At the end of the thread, you queue a redraw on
the widget, and then you use the surface as the source for rendering
on the cairo_t* that the ::draw signal gives to you.

Ciao,
 Emmanuele.

-- 
https://www.bassi.io
[ ] ebassi [ gmail com]


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]