canvas painting
Michael Noble <[email protected]> Wed, 15 Dec 2004 07:39:00 -0500
| Newsgroups | gmane.comp.scigraphica.gtkextra |
|---|---|
| Message-ID | <[email protected]> |
> On Wed, Dec 15, 2004 at 01:16:08AM -0800, Al Hooton wrote
>
> I'm not asking for a new feature here, just tossing out a question/idea
> to discuss: Would it make sense to add some kind of mechanism to
> canvas/plots so that axes only have to be redrawn when necessary? As
> you point out, it is certainly possible for the app to cache the values
> in an array and avoid recalculating them, but this still leaves the
> canvas & plot the job of repainting axes each time, something that takes
> a lot of processor cycles too.
Al, I think you're on the right track, although the issue is more
widespread than just axis redrawing, and so probably warrants a
more general solution.
For example, try plotting a million points, then laying down two circles,
then moving the circles to new locations on the canvas. Each move must
be performed individually, and each erase/redraw operation induces a
complete canvas repaint. It shouldn't be hard to imagine how slow/choppy
it can be, then, to make even the finest adjustments to circle/region
positions when they are laid over million-point plots (which are not
completely rare in my domain).
I've ameliorated this to some extent (in my local copy of GtkExtra)
with a number of performance improvements (which I hope to someday
to find the time to post here), but the real issue seems to be that
points (data) should be drawn upon one backing pixmap and decorations
(axes, circles, etc) upon another.
It's been a long time since I looked at the code, and I've never quite
found the time to do this myself, but in principle this should be feasible
and entail only a little extra code to:
- fabricate the extra backing pixmap at canvas creation time
- ensure the proper one is used when the respective graphics are drawn
(might be able to get away with changing only the plot/data objects)
- blit the decorative pixmap first, then the data pixmap, when
painting the canvas
Otherwise the rest of the code might remain largely unchanged, as objects
simply shouldn't care upon which pixmap they're drawn.
Hopefully Useful,
Mike Noble
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://productguide.itmanagersjournal.com/