[cairo] Performance stroking lines
Carl Worth
cworth at cworth.org
Thu Nov 15 15:29:00 PST 2007
On Thu, 15 Nov 2007 21:18:18 +0000, Peter Clifton wrote:
> Yes, indeed.. although I've realised one possible workaround. Damon
> Chaplin tells me performance will be near GDK levels if I disable
> anti-aliasing (shame, as this was why I wanted Cairo)...
It may not be *that* much faster even with antialiasing disabled. (And
I'm with you---disabling antialiasing isn't generally worth it.)
> > So, the fall-back answer is to find some way to do less work (avoid
> > unecessary work, cache the results of previous work, etc).
You said your test is "dragging a component around" and your profile
shows a lot of time doing rasterization, (that is, work from
cairo_fill or cairo_stroke).
So an approach that should help a lot is to have the rasterization
done already by having the component pre-drawn to another surface,
(Dan said "image surface" but a better approach is a "similar"
surface---see cairo_surface_create_similar).
With that, when dragging a component around you should only be calling
cairo_paint, so all the rasterization time should disappear from the
profile.
> I'm taking this to mean 1: "Invalidate, then draw in the expose handler"
> as opposed to 2: "draw when we feel like", or 3: "draw in a backbuffer
> when we feel like it, then invalidate / blit the screen"
>
> (The old code does 2, I was in the process of changing it to 3 as a way
> to avoid horrendous performance hits when using a composited desktop,
> then I started looking at 1, and cairo).
Your (1) is definitely a good approach, but it's actually independent
of whether you have your components cached in off-screen surfaces that
you are painting, or if you're re-drawing them from scratch each time.
-Carl
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://lists.cairographics.org/archives/cairo/attachments/20071115/8f2cb501/attachment-0001.pgp
More information about the cairo
mailing list