# HG changeset patch # User Chris Cannam # Date 1541172233 0 # Node ID 2c01be83657045dc369d1cbd196bc423ddf78003 # Parent ca9a36a5ab7655544ab8da1a1a726b664a43a33b Short-circuit drawing a little bit for contiguous ranges diff -r ca9a36a5ab76 -r 2c01be836570 layer/WaveformLayer.cpp --- a/layer/WaveformLayer.cpp Fri Nov 02 15:23:42 2018 +0000 +++ b/layer/WaveformLayer.cpp Fri Nov 02 15:23:53 2018 +0000 @@ -801,6 +801,7 @@ vector individualSamplePoints; bool firstPoint = true; + double prevRangeBottom = 0, prevRangeTop = 0; for (int x = x0; x <= x1; ++x) { @@ -986,20 +987,30 @@ individualSamplePoints.push_back(QPointF(px, rangeBottom)); } } + + bool contiguous = true; + if (rangeTop > prevRangeBottom + 0.5 || + rangeBottom < prevRangeTop - 0.5) { + contiguous = false; + } - if (firstPoint) { - waveformPath = QPainterPath(QPointF(px, rangeMiddle)); - firstPoint = false; + if (firstPoint || (contiguous && !trivialRange)) { + waveformPath.moveTo(QPointF(px, rangeTop)); + waveformPath.lineTo(QPointF(px, rangeBottom)); + waveformPath.moveTo(QPointF(px, rangeMiddle)); } else { waveformPath.lineTo(QPointF(px, rangeMiddle)); + if (!trivialRange) { + waveformPath.lineTo(QPointF(px, rangeTop)); + waveformPath.lineTo(QPointF(px, rangeBottom)); + waveformPath.lineTo(QPointF(px, rangeMiddle)); + } } - if (!trivialRange) { - waveformPath.lineTo(QPointF(px, rangeTop)); - waveformPath.lineTo(QPointF(px, rangeBottom)); - waveformPath.lineTo(QPointF(px, rangeMiddle)); - } - + firstPoint = false; + prevRangeTop = rangeTop; + prevRangeBottom = rangeBottom; + if (drawMean) { meanPath.moveTo(QPointF(px, meanBottom)); meanPath.lineTo(QPointF(px, meanTop));