Re: Re: Rendering performance on custom text view on Gdk::Drawable



On , "ivar ." <ivarbug gmail com> wrote:
> But still, it would be interesting to get my own rendering sorted aswell.

General tip on DrawingArea widgets (although my experience is mostly with Cairo):
-Have lots of data, and draw it all at one, not with multiple draw calls
-Keep the cairo operations out of loops if at all possible
-If there's a "zoom level" in your widget, draw detail accordingly: don't draw every point of data if its not essential! Just draw enough to give the user the detail they need, no more.

Eg:
expose()
{
float* destX = &XArray[0];
float* destY = &YArray[0];

for()
{
cr->set_source_rgba(0.2, 0.0, 0.1, 0.7); // move this out of the loop!
cr->rel_line_to( *destX++, *destY++ );
}
}

Setting the source for every line will *severly* slow down your code there, and moving it above the loop (or after the loop before the stroke() or fill() call) will have exactly the same effect!

You probably guessed that stuff, but just for the list record :) -Harry

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]