[cairo] How to create and redraw canvas?

Радомир Хаџић radomirhadzic46 at gmail.com
Wed Mar 6 19:04:07 UTC 2019


Hello. I'm trying to save the current surface and then redraw only it
when drawable area is refreshed, instead of drawing everything again.
This surface will be continuously updated when something changes and
then that surface will be shown, and of course if nothing is to be
updated only the current surface will be shown. The purpose of this is
to improve performance, because it is easier to update the surface and
then just draw it than to draw everything that has been drawn till now
(probably saved in a vector) each time drawable needs to be refreshed.

Saving the current surface is easy: Cairo::Surface surface =
cr->get_target();. As you can see, I'm using cairomm but I'm OK with
just ordinary cairo (for C) explanation as well. What actually I can't
figure out is how can I display this saved surface, and that's what
I'd like you to explain.

I tried using Cairo::Context::set_source() since it looked like it
might work but it didn't. I couldn't find anything else in the
documentation that looked like a candidate for what I need.


More information about the cairo mailing list