[cairo] Cairo and layered application
daniel.amelang at gmail.com
Fri Mar 2 22:58:48 PST 2007
On 3/2/07, Gauthier Quesnel <quesnel at lil.univ-littoral.fr> wrote:
> Le Wed, 28 Feb 2007 17:00:47 -0800,
> "Daniel Amelang" <daniel.amelang at gmail.com> a écrit :
> > Having said all that, for drawing as simple as yours, I wouldn't
> > expect the need for any optimization. Would you care to share your
> > code with us? If you give us something that we can run, it makes it
> > easier to analyze where the performance problems are.
> Yep, my sources are GPL (require pygtk 2.10 and numpy):
Thank you for making it so easy to help you :) This also really help
us get a feel for how cairo performs "in the wild".
First of all, when I ran your app, I didn't notice anything
particularly slow about it. Window resizing, hiding/showing layers and
changing opacity all completed in well under a second. What operation
were you doing that felt slow?
Regardless, I went ahead and profiled the app anyway just to get an
idea of what's going on (using `valgrind --tool=callgrind`) by forcing
a bunch of redraws and resizing. So, about 30% of the time is spend in
cairo_fill downwards. 19% of that is spent in
_cairo_bentley_ottmann_tessellate_polygon, which in your case is just
chomping away on those rectangles.
So, I think I remember Carl mentioning some idea he had for speeding
up rectangle rendering. Carl, do you see that helping here? These
rectangles are all integer coordinates and sizes, BTW. This should
match our existing "rectangles" perf case pretty closely.
Besides that, it is interesting to note that cairo spends about 10% of
the overall time in malloc and free combined. Also, 6% of the overall
time is spend in cairo_rectangle calls and downwards.
In the meantime, Gauthier, you can avoid a lot of this overhead by
doing that surface cache idea that I mentioned earlier. Of course,
if/when your data changes, or if/when you resize the drawing area,
you'll have to redraw the surfaces.
Hope that helps!
More information about the cairo