I am computing live image data at 60 fps. I want to blit this into a Gtk.Window preferably in a zero-copy fashion. The buffer data is created by an optimised C module which hooks into Python. I can use GdkPixbuf.new()
to create the buffer and then use a Gtk.Image to display this image. The render path is quick: benchmarked at ~3ms or thereabouts.
However, this seems to invoke a slow X11 path, resulting in my application barely achieving 18 fps when rendering a window at 1920x1080. Little time seems to be spent in direct Gtk API, with the majority of the time spent during the Gtk iteration. The Python application is busy with 100% CPU and in addition the X11 server is using another 45%.
Since I have a decent amount of flexibility over how the data reaches the buffer, I would like to do this in a zero-copy fashion. In other words, get a pointer to a buffer to write calculated data directly to. If that is not possible, I would like to create the buffer in a format that X11 is most happy with and for which little or no data conversion is necessary. Unfortunately, GtkPixbuf seems to only support RGB or RGBA buffers and has no way (that I can see) to infer a fast buffer format.
I am writing this software for a Raspberry Pi (3B+), so performance is essential. I am using Python and PyGObject 3.2.