# HG changeset patch # User Chris Cannam # Date 1453819466 0 # Node ID dade9bfc7695b1354d173c72e7106cd58e4b6489 # Parent 53110ace211f497d73bbfc9dce23161dbe440bd5 Fix return value from paintDrawBuffer in rightToLeft case; propagate timing change to PeakFrequencies version as well diff -r 53110ace211f -r dade9bfc7695 layer/SpectrogramLayer.cpp --- a/layer/SpectrogramLayer.cpp Tue Jan 26 13:19:53 2016 +0000 +++ b/layer/SpectrogramLayer.cpp Tue Jan 26 14:44:26 2016 +0000 @@ -2292,6 +2292,10 @@ float *values = (float *)alloca((maxbin - minbin + 1) * sizeof(float)); #endif + int minColumns = 4; + double maxTime = 0.15; // seconds; only for non-synchronous drawing + auto startTime = chrono::steady_clock::now(); + int start = 0; int finish = w; int step = 1; @@ -2302,8 +2306,12 @@ step = -1; } + int columnCount = 0; + for (int x = start; x != finish; x += step) { + ++columnCount; + if (binforx[x] < 0) continue; int sx0 = binforx[x]; @@ -2382,9 +2390,23 @@ } } } + + if (!m_synchronous) { + if (columnCount >= minColumns) { + auto t = chrono::steady_clock::now(); + double diff = chrono::duration(t - startTime).count(); + if (diff > maxTime) { +#ifdef DEBUG_SPECTROGRAM_REPAINT + cerr << "SpectrogramLayer::paintDrawBufferPeakFrequencies: Max time " << maxTime << " sec exceeded after " + << x << " columns with time " << diff << endl; +#endif + return columnCount; + } + } + } } - return w; + return columnCount; } int @@ -2400,13 +2422,6 @@ { Profiler profiler("SpectrogramLayer::paintDrawBuffer"); - //!!! todo: propagate to paintDrawBufferPeakFrequencies - - int minColumns = 4; - double maxTime = 0.1; // seconds; only for non-synchronous drawing - - auto startTime = chrono::steady_clock::now(); - int minbin = int(binfory[0] + 0.0001); int maxbin = int(binfory[h-1]); @@ -2457,6 +2472,10 @@ const float *values = autoarray; DenseThreeDimensionalModel::Column c; + int minColumns = 4; + double maxTime = 0.1; // seconds; only for non-synchronous drawing + auto startTime = chrono::steady_clock::now(); + int start = 0; int finish = w; int step = 1; @@ -2466,8 +2485,12 @@ finish = -1; step = -1; } + + int columnCount = 0; for (int x = start; x != finish; x += step) { + + ++columnCount; if (binforx[x] < 0) continue; @@ -2638,7 +2661,7 @@ } if (!m_synchronous) { - if (x >= minColumns) { + if (columnCount >= minColumns) { auto t = chrono::steady_clock::now(); double diff = chrono::duration(t - startTime).count(); if (diff > maxTime) { @@ -2646,13 +2669,13 @@ cerr << "SpectrogramLayer::paintDrawBuffer: Max time " << maxTime << " sec exceeded after " << x << " columns with time " << diff << endl; #endif - return x; + return columnCount; } } } } - return w; + return columnCount; } void