Mercurial > hg > svgui
comparison layer/SpectrogramLayer.cpp @ 1028:78ece8cdfaee spectrogram-minor-refactor
Start repainting from the middle -- but this is quite unreliable
author | Chris Cannam |
---|---|
date | Tue, 26 Jan 2016 17:21:46 +0000 |
parents | dade9bfc7695 |
children | fdfd84b022df |
comparison
equal
deleted
inserted
replaced
1027:dade9bfc7695 | 1028:78ece8cdfaee |
---|---|
1829 | 1829 |
1830 cache.validArea = | 1830 cache.validArea = |
1831 QRect(px, cache.validArea.y(), | 1831 QRect(px, cache.validArea.y(), |
1832 pw, cache.validArea.height()); | 1832 pw, cache.validArea.height()); |
1833 | 1833 |
1834 if (cache.validArea.width() == 0) { | |
1835 recreateWholeImageCache = true; | |
1836 } | |
1837 | |
1834 #ifdef DEBUG_SPECTROGRAM_REPAINT | 1838 #ifdef DEBUG_SPECTROGRAM_REPAINT |
1835 cerr << "SpectrogramLayer: valid area now " | 1839 cerr << "SpectrogramLayer: valid area now " |
1836 << px << "," << cache.validArea.y() | 1840 << px << "," << cache.validArea.y() |
1837 << " " << pw << "x" << cache.validArea.height() | 1841 << " " << pw << "x" << cache.validArea.height() |
1838 << endl; | 1842 << endl; |
1870 cache.validArea = QRect(); | 1874 cache.validArea = QRect(); |
1871 } | 1875 } |
1872 } | 1876 } |
1873 | 1877 |
1874 if (recreateWholeImageCache) { | 1878 if (recreateWholeImageCache) { |
1875 x0 = 0; | 1879 if (!m_synchronous) { |
1880 // When rendering the whole thing, start from somewhere near | |
1881 // the middle so that the region of interest appears first | |
1882 x0 = int(v->getPaintWidth() * 0.4); | |
1883 } else { | |
1884 x0 = 0; | |
1885 } | |
1876 x1 = v->getPaintWidth(); | 1886 x1 = v->getPaintWidth(); |
1877 } | 1887 } |
1878 | 1888 |
1879 // We always paint the full height when refreshing the cache. | 1889 // We always paint the full height when refreshing the cache. |
1880 // Smaller heights can be used when painting direct from cache | 1890 // Smaller heights can be used when painting direct from cache |
2162 cachePainter.end(); | 2172 cachePainter.end(); |
2163 } | 2173 } |
2164 | 2174 |
2165 // update cache valid area based on painted area | 2175 // update cache valid area based on painted area |
2166 | 2176 |
2167 int left = min(cache.validArea.x(), x0); | 2177 int left = x0; |
2168 | 2178 int wid = x1 - x0; |
2169 if (cache.validArea.width() == 0) { | 2179 |
2170 left = 0; // cache was not valid at all | |
2171 } | |
2172 | |
2173 int wid = max(cache.validArea.x() + cache.validArea.width() - left, | |
2174 x1 - left); | |
2175 | |
2176 if (failedToRepaint > 0) { | 2180 if (failedToRepaint > 0) { |
2177 #ifdef DEBUG_SPECTROGRAM_REPAINT | 2181 #ifdef DEBUG_SPECTROGRAM_REPAINT |
2178 cerr << "SpectrogramLayer: Reduced painted extent from " | 2182 cerr << "SpectrogramLayer: Reduced painted extent from " |
2179 << left << "," << wid; | 2183 << left << "," << wid; |
2180 #endif | 2184 #endif |
2188 #ifdef DEBUG_SPECTROGRAM_REPAINT | 2192 #ifdef DEBUG_SPECTROGRAM_REPAINT |
2189 cerr << " to " << left << "," << wid << endl; | 2193 cerr << " to " << left << "," << wid << endl; |
2190 #endif | 2194 #endif |
2191 } | 2195 } |
2192 | 2196 |
2197 if (cache.validArea.width() > 0) { | |
2198 left = min(left, cache.validArea.x()); | |
2199 wid = cache.validArea.width() + wid; | |
2200 } | |
2201 | |
2193 cache.validArea = QRect(left, 0, wid, h); | 2202 cache.validArea = QRect(left, 0, wid, h); |
2194 | 2203 |
2195 #ifdef DEBUG_SPECTROGRAM_REPAINT | 2204 #ifdef DEBUG_SPECTROGRAM_REPAINT |
2196 cerr << "SpectrogramLayer: Cache valid area becomes " << cache.validArea.x() | 2205 cerr << "SpectrogramLayer: Cache valid area becomes " << cache.validArea.x() |
2197 << ", " << cache.validArea.y() << ", " | 2206 << ", " << cache.validArea.y() << ", " |