[cairo] does cairo_paint method always slow?

Chris Wilson chris at chris-wilson.co.uk
Sat Jun 2 02:47:51 PDT 2012


On Sat, 2 Jun 2012 17:38:54 +0800, Jihe Wei <jihe.wei at gmail.com> wrote:
> Hi,
> Now have two surface, one for display,another for draw.So when draw
> finish, need to paint to display,
> we do it this way,
> cairo_surface_t * surface_display,surface_draw;
> ...
> cairo_t *cr = cairo_create (surface_display);
> cairo_set_source_surface (cr, surface_draw, 0, 0);
> cairo_paint (cr);
> 
> But finally found most time was killed by cairo_paint(cr), not draw operations.
> Why?Is there any better ways to do this stuff ?

Most likely reasons are due to blend mode and overdraw. That is you are
using an alpha channel and an OVER operator causing it to use a
composite operation rather than a blit, and that you are copying the
whole surface when you could just copy the dirty regions. The answer to
why is this so slow, is generally to look at the profile and wonder how
you ended up there. But that takes the fun out of guessing.

Pageflipping is not directly supported by cairo, but that doesn't
prevent you from doing so yourself.
-Chris

-- 
Chris Wilson, Intel Open Source Technology Centre


More information about the cairo mailing list