|
|
Log in / Subscribe / Register

GTK 4.0

GTK 4.0

Posted Dec 17, 2020 11:56 UTC (Thu) by alexl (guest, #19068)
In reply to: GTK 4.0 by mchehab
Parent article: GTK 4.0

Why do you need to convert a pixbuf to a cairo surface to draw it? Just call gdk_cairo_set_source_pixbuf() to draw it onto the cairo_t.

Of course, with Gtk 4 you ideally don't want to use cairo to draw at all as it is really the old "fallback" software rendering codepath.

The modern way to draw is to implement snapshot and create render nodes which will avoid any cairo work and just do OpenGL rendering.

However snapshot is kind of lowlevel. Its used if you want to do some custom specialized rendering. If you just want to render an image in your UI, just put the pixbuf in a in a GtkPicture subwindow. One of the nice advantages of Gtk4 is that everything, even sub-parts of widgets are just widgets. You very rarely have to have a custom drawing function that draws multiple things.


to post comments

GTK 4.0

Posted Dec 17, 2020 12:05 UTC (Thu) by alexl (guest, #19068) [Link]

eh, subwidget, not subwindow


Copyright © 2026, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds