[cairo] Background image

Olivier Jolet olivier.jolet at skynet.be
Tue Feb 20 00:18:44 PST 2007



> -----Message d'origine-----
> De : Daniel Amelang [mailto:daniel.amelang at gmail.com]
> Envoyé : lundi 19 février 2007 22:26
> À : Olivier Jolet
> Cc : cairo at cairographics.org
> Objet : Re: RE : [cairo] Background image
> 
> On 2/19/07, Olivier Jolet <olivier.jolet at skynet.be> wrote:
> > > No, I don't have problem with this method. But the display is very
> > slow
> > > (zoom in & out with the scroll mouse button)
> >
> > ...
> >
> > Ok, I will not use glitz backend... I still use native (Xlib)
surfaces.
> > The problem is that I need to draw many (between 10k 500k) lines,
> > polygones and arcs (fill or not), and I don't get a nice speedup. (I
> > tried to reduce the number of calls to cairo_stroke). I noticed that
the
> > worst performance came from the build of arcs.
> > I'm going to try another method that consist in drawing the arcs I
need
> > with specifics sizes in another surface and copy them with a color
mask
> > instead of building them at each call.
> 
> The code you provided is basically a really small graphics interpreter
> w/out any input data. So it's hard to give you really meaningful
> feedback on it. Ideally, you would provide code + data so that one
> could actually execute the program and run a profilier on it. That
> said, I don't see anything unusually wrong (from a performance point
> of view) from the code you provided.
> 
> Now, you have a bunch of calls to getINT16 and getFCT inbetween calls
> to cairo functions. We can't see what is going on in those functions
> (no code provided), so there's always the possibility that those calls
> are slowing things down. Again, running a profiler would answer than
> question pretty well.
> 
> Also, you mentioned that you expect to draw (in real time) possibliy
> 500k lines/arcs/rects. That's a lot of drawing. And the user probably
> isn't going to actually be able to see 500k primitives at one time,
> especially when there's some zooming going on. So, you could probably
> benifit from some clipping, if you aren't doing it already. Even your
> own application-level clipping would probably help in reducing the
> number of cairo calls.
> 
> One more thing: if your scene is static, you could first draw the
> whole thing at various scales and them zoom between the cached
> renderings at run time. Sorta like a roll-your-own mipmapping thing.
> 
> Dan


It's a little complicated to provide the code + data because it is based
on a greater real time application. Moreover, 500k is the extreme. I
exaggerated a little, in general they are around 5k-10k primitives.
(Clipping is done) 
Anyway, I reduced the number of cairo calls by copying primitives that
appears many times in a buffer and just copying them using a mask with
the needed color.
Also, I have another problem of performance, if I use the
'cairo_set_line_width' primitive, it is very much slower. I don't
understand why there is a such difference?

Oli



More information about the cairo mailing list