[cairo] Cairo + GTK animation - high Xorg load

Uli Schlachter psychon at znc.in
Fri Oct 28 16:08:10 UTC 2016


On 27.10.2016 20:40, 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. I
> don't understand this - I've already done all of the necessary drawing
> work in the thread. I could understand if the thread load increased with
> the size of the surface (which it does not appear to), but why should
> Xorg's? Essentially I want to say - here is this pixel buffer - just
> display it as is. Perhaps this is too simplistic an understanding of how
> Cairo is interacting with the display system.

Well, the pixel data in the buffer is serialised and sent to the X
server over a unix socket 60 times per seconds. Let's assume the widget
has size 2000x1000, then you are pushing 2000*1000*4*60 bytes of data to
the server. That's about 457 MiB per second. Over a unix socket. With
multiple copies involved until the pixel data reaches its target. Media
players know why they don't use this path. ;-)

Also, I don't see the point of the thread, so I started from the
previous example.

Attached is an example which actually implements the behaviour proposed
by Stefan: Scrolling the old content to the left and only drawing the
newest point. For this to work it needs two surfaces, since it has to
copy things back and forth between them.

Also, as proposed by Stefan I use cairo_surface_create_similar for
creating the surfaces to draw to, so that cairo doesn't have to push
"all of that data" to the X server all the time.

CPU usage seems to be a bit lower, but I guess still higher than you wish.

Cheers,
Uli
-- 
ā€œIā€™m Olaf and I like warm hugs.ā€
-------------- next part --------------
A non-text attachment was scrubbed...
Name: in17XGjs.c
Type: text/x-csrc
Size: 4202 bytes
Desc: not available
URL: <https://lists.cairographics.org/archives/cairo/attachments/20161028/0be54b46/attachment.c>


More information about the cairo mailing list