[cairo] Cairo + GTK animation - high Xorg load
Stefan Salewski
mail at ssalewski.de
Fri Oct 28 15:48:23 UTC 2016
On Thu, 2016-10-27 at 14:40 -0400, David J. Herzfeld wrote:
> I've updated the example again, to use exactly this model
> <http://pastebin.com/apaFiGyd>. Here, the Xorg load is decreased
> somewhat (at the expense of increased load for the actual
> application),
> but Xorg load is still ~15% and scales with the size of the window.
Interesting. Currently I have only one remark: You create an image
surface for your drawing, which then is copied to the X display. But
that image may be not good compatible with the X display. Generally it
is recommended to use cairo_surface_create_similar() to get a mostly
compatibe surface. I think that is what I tried for my graphics editor.
That is not really straight forward, one has to extract the surface
used by XOrg first to be able to create the new surface. I can not
remember how I did it, I have not used cairo in the last two years.
Maybe even better:
https://www.cairographics.org/manual/cairo-cairo-t.html#cairo-push-group
With this you can draw to an intermediate surface with no X involved,
and copy the result back with the pop operation.
Unfortunately most existings cairo examples are outdated. There is one
example called threaded animation, I once considered using that to
create a Nim example, but I was told that that example contains bad
code, so I have never investigated that any further.
More information about the cairo
mailing list