[cairo] Cairo, GtkDrawingArea, and buffer

Andrea Canciani ranma42 at gmail.com
Sun Feb 27 00:19:39 PST 2011


On Sun, Feb 27, 2011 at 6:50 AM, Xi Yang <jiandingzhe at 163.com> wrote:
> Hi, everyone!
> I want to have a customized widget, and I decided to use GtkDrawingArea and Cairo together.
>
>
> However, each time the GtkDrawingArea is resized or uncovered, it needs to be redrawed. I don't want to perform the Cairo drawing at each exposure_event, as my drawing procedure is pretty complicated.
>
>
> I need a buffer which the cairo_t would build on. At each exposure_event, I just need to copy the buffer to the GtkDrawingArea. So how can I achieve that? Which classes should I use?

You can keep a cairo_surface_t and blit it upon exposure.
To achieve best performance you should use a surface
"similar" to your true render target. See:
http://www.cairographics.org/manual/cairo-cairo-surface-t.html#cairo-surface-create-similar

Andrea


More information about the cairo mailing list