Re: What should be used?

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

 



Hi;

On 29 July 2015 at 14:55, Stefan Salewski <mail@xxxxxxxxxxxx> wrote:
> On Wed, 2015-07-29 at 13:05 +0100, Emmanuele Bassi wrote:
>> If you have legacy code that requires disabling double buffering, you
>> should probably invest some time into porting it to a proper solution
>> integrated with the GTK drawing model;
>
> It would be great if someone could port this example to GTK3:
>
> http://www.cairographics.org/threaded_animation_with_cairo/

Those examples, especially the one that uses Unix signals to interrupt
the program flow, ought to be burned with fire. Not only they are
questionable in GTK 2.x, but they are also unportable jumbles of code
that work by sheer accident.

If you want to draw with Cairo on a separate thread Because Of
Reasons™, then you need to create a Cairo surface using the GdkWindow
API — see gdk_window_create_similar_image_surface() — then draw on it
from within your thread; at the end of the thread, queue a redraw on
the widget. At the same time, inside a GtkWidget::draw handler, use
the Cairo surface you drew on inside the thread, set it as you source,
and draw the surface on the Cairo context that GTK gives you. This
way, the drawing code will happen in a separate thread, and you'll
draw only when GTK tells you to draw.

All considerations on accessing GTK and GDK API from the thread that
called gtk_init/gtk_main (or g_application_run(), if you're writing
modern code) still apply.

Ciao,
 Emmanuele.

-- 
https://www.bassi.io
[@] ebassi [@gmail.com]
_______________________________________________
gtk-list mailing list
gtk-list@xxxxxxxxx
https://mail.gnome.org/mailman/listinfo/gtk-list




[Index of Archives]     [Touch Screen Library]     [GIMP Users]     [Gnome]     [KDE]     [Yosemite News]     [Steve's Art]

  Powered by Linux