Re: Cairo + GTK animation - high Xorg load
Stefan Salewski <[email protected]>
| Newsgroups | gmane.comp.lib.cairo |
|---|---|
| Message-ID | <[email protected]> |
On Wed, 2016-10-26 at 15:51 -0400, David J. Herzfeld wrote: > I must be doing something wrong... Nice example. I think that drawing 1000 lines with 60 Hz in fullscreen mode is indeed a high load for Cairo. I have created a schematics editor with GTK3 and cairo (http://ssalewsk i.de/PetEd.html.en) and my observation was very similar. I have restricted the redraw with bounding boxes to only the areas which have changed, but still drawing is not fully smooth. OK, that tool is still coded in Ruby, moving to a fast compiled language like Nim, Rust or similar would increase speed, but not too much. What you can do is of course: Shift the already drawn curve to the left and draw only the new part. Cairo offers fast routines for copying areas, so for that case cpu load should be really low. For the trivial case of a plain sine wave, you can even draw the size extended curve to a backup area and then just copy the desired area to your window, so no drawing is necessary at all. That is what I did for my schematics editor for the background grid. (Of course complete redraw is easier, and when copying areas there is a minimal risk that you can get artefacts at the borders of old and new area.) Of course you don't have to code in plain C in these days, my Nim bindings are available, https://github.com/ngtk3 http://forum.nim-lang.org/t/2198#15801 and I think for Rust, Go and some other nice and fast languages there should exists bindings too. Other backends: As far as I know there is no hope for much speedup when using the not well supported opengl backend -- at least that was what I found some years ago when doing some google research. With GTK 3.16 we get better OpenGL support by GTK GlArea I think. So maybe situation has improved since then, my feeling is that GlArea is more for real 3D objects and not for fast line drawings, but I have not done investigations in this direction yet. -- cairo mailing list [email protected] https://lists.cairographics.org/mailman/listinfo/cairo