Re: Slow canvas performance
- From: Jody Goldberg <jody gnome org>
- To: Rob Clack <rnc sanger ac uk>
- Cc: gtk-app-devel-list gnome org
- Subject: Re: Slow canvas performance
- Date: Thu, 29 Apr 2004 11:19:40 -0400
On Thu, Apr 29, 2004 at 04:02:24PM +0100, Rob Clack wrote:
I'm writing an app which has to draw 10's of thousands of squares - it's
human genome data, so I'm not exaggerating. I'm using gtk2 and gnome
canvas running on a Compaq deskpro with 512Mb memory and Red Hat 9, but
finding performance is really poor.
Drawing a thousand or two squares is fine, but as the numbers rise, the
time taken increases to levels my users are going to find unacceptable.
I thought that if what I was drawing was outside the viewable area (ie
the canvas is bigger than the scrolled window) then it wouldn't even try
to draw the squares, but that doesn't seem to be the case. eg if the
window can show, say, 1000 squares and I run 3 tests, drawing 1000, 2000
and 3000 squares respectively, I'd expect them to take the same time to
run, since the extra squares should simply be cropped before the display
was rendered on the screen. This is not the case. The time taken
increases linearly. I thought that was the whole point of double-buffering.
Have I misunderstood how this is supposed to work or is there some
setting I've got wrong that disables that aspect? Or is there a better
way for me to set about this?
To create the item I just use
for (i = 0, x = 0.0; i < 100; i++, x += x_incr)
{
for (j = 0, y = 0.0; j < number; j++, y += y_incr)
{
gnome_canvas_item_new(group,
type,
"x1" , x ,
"y1" , y ,
"x2" , x + 5,0,
"y2" , y + 5.0,
"outline_color", "red" ,
"fill_color" , "white" ,
"width_units" , 1.0,
NULL);
}
}
x and y are doubles, so no casting is necessary.
I'm surprised that redraw time is effected by invisible objects, but
ignoring that question I'll still make a few suggestions
1) You may want to use the foocanvas rather than the gnomecanvas.
foo is a simplification of the gnomecanvas that removes option of
antialiasing and ties more closely to the gtk redraw framework.
It is used in nautilus and gnumeric.
2) With 10s of thousands of things you may want to consider a custom
canvas item. The overhead of a canvas item for each square may
get unacceptable for large data sets. eg in gnumeric we have one
canvas item for the entire grid, not one per cell.
Good Luck
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]