efficient use of canvas lines
- From: Paul Davis <pbd op net>
- To: gtk-list gnome org
- Subject: efficient use of canvas lines
- Date: Sun, 15 Jul 2001 11:25:25 -0400
i'm attempting to port a very powerful wave-drawing widget from its
current implementation as a native GTK widget to something that will
function properly on a (Gtk|Gnome)Canvas.
one area of concern is that the widget already does a bunch of line
draws to render the waveform, and uses various data reduction
algorithms to correctly draw the waveform when the pixels/sample ratio
is not 1 (i.e. more or less all the time).
the rendering is done by drawing a line at the x-coordinate between
two y-coordinates representing (typically) the max+min values for the
samples mapped to that x-coordinate.
the most obvious thing to do is to convert the calls to
gdk_draw_line() into a gtk_canvas_item_set () call to redefine each of
the line segments used to render the wave. but this implies one
GtkCanvasItem per line segment, and there is one line segment per
visible pixel.
Even with a regular sized window, this implies hundreds of
GtkCanvasItems to represent the waveform. I am also not even sure how
to manage the fact that the actual number may be much larger, since
the widget/canvas item may extend off screen - one of the whole points
of the canvas is to be able to forget about this kind of thing. the
problem is the waveform display might be of an enormous wavefile (its
not atypical to be dealing with files in the GB range), and its
clearly absurd to create millions of GtkCanvasItems to represent this.
so, i'd like some advice about what to do here. i really need to use
the functionality offered by the canvas. one option is to embed a
drawing area into the canvas, and draw on that, but this causes
massive flicker. any other thoughts?
--p
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]