+
+ max *= half_height;
+ min *= half_height;
+
+ next_pymax = (int) rint ((item->y1 + origin - max) * item->canvas->pixels_per_unit);
+ next_pymin = (int) rint ((item->y1 + origin - min) * item->canvas->pixels_per_unit);
+
+ /*
+ * And now the loop
+ */
+ for(x = begin; x < end; ++x) {
+ int clip_max = next_clip_max;
+ int clip_min = next_clip_min;
+ int fill_max, fill_min;
+
+ pymax = next_pymax;
+ pymin = next_pymin;
+
+ /* compute next */
+ if(x == end - 1) {
+ /*next is now the last column, which is outside the rendering rect, and possibly outside the region*/
+ next_pymax = last_pymax;
+ next_pymin = last_pymin;
+ }
+ else {
+ ++cache_index;
+
+ if (cache_index < waveview->cache->data_size) {
+ max = waveview->cache->data[cache_index].max;
+ min = waveview->cache->data[cache_index].min;
+ } else {
+ max = min = 0;
+ }
+
+ next_clip_max = 0;
+ next_clip_min = 0;
+
+ if (max >= 1.0) {
+ max = 1.0;
+ next_clip_max = 1;
+ }
+
+ if (min <= -1.0) {
+ min = -1.0;
+ next_clip_min = 1;
+ }
+
+ max *= half_height;
+ min *= half_height;
+
+ next_pymax = (int) rint ((item->y1 + origin - max) * item->canvas->pixels_per_unit);
+ next_pymin = (int) rint ((item->y1 + origin - min) * item->canvas->pixels_per_unit);
+ }
+
+ /* render */
+ if (pymax == pymin) {
+ PAINT_DOTA(buf, waveview->wave_r, waveview->wave_g, waveview->wave_b, waveview->wave_a, x, pymin);
+ } else {
+ if((prev_pymax < pymax && next_pymax < pymax) ||
+ (prev_pymax == pymax && next_pymax == pymax)) {
+ fill_max = pymax + 1;
+ PAINT_DOTA(buf, waveview->wave_r, waveview->wave_g, waveview->wave_b, waveview->wave_a, x, pymax);
+ }
+ else {
+ fill_max = MAX(prev_pymax, next_pymax);
+ if(pymax == fill_max) {
+ PAINT_DOTA(buf, waveview->wave_r, waveview->wave_g, waveview->wave_b, waveview->wave_a, x, pymax);
+ ++fill_max;
+ }
+ else {
+ PAINT_VERTA(buf, waveview->wave_r, waveview->wave_g, waveview->wave_b, waveview->wave_a, x, pymax, fill_max);
+ }
+ }
+
+ if((prev_pymin > pymin && next_pymin > pymin) ||
+ (prev_pymin == pymin && next_pymin == pymin)) {
+ fill_min = pymin - 1;
+ PAINT_DOTA(buf, waveview->wave_r, waveview->wave_g, waveview->wave_b, waveview->wave_a, x, pymin-1);
+ }
+ else {
+ fill_min = MIN(prev_pymin, next_pymin);
+ if(pymin == fill_min) {
+ PAINT_DOTA(buf, waveview->wave_r, waveview->wave_g, waveview->wave_b, waveview->wave_a, x, pymin);
+ }
+ else {
+ PAINT_VERTA(buf, waveview->wave_r, waveview->wave_g, waveview->wave_b, waveview->wave_a, x, fill_min, pymin);
+ }
+ }
+
+ if(fill_max < fill_min) {
+ PAINT_VERTA(buf, waveview->fill_r, waveview->fill_g, waveview->fill_b, waveview->fill_a, x, fill_max, fill_min);
+ }
+ else if(fill_max == fill_min) {
+ PAINT_DOTA(buf, waveview->fill_r, waveview->fill_g, waveview->fill_b, waveview->fill_a, x, fill_max);
+ }
+ }