Mercurial > hg > svgui
comparison layer/SpectrogramLayer.cpp @ 1029:fdfd84b022df spectrogram-minor-refactor
Fix calculation of repaint area when we haven't scrolled but cache is not complete
author | Chris Cannam |
---|---|
date | Wed, 27 Jan 2016 11:10:48 +0000 |
parents | 78ece8cdfaee |
children | 0be17aafa935 |
comparison
equal
deleted
inserted
replaced
1028:78ece8cdfaee | 1029:fdfd84b022df |
---|---|
1851 cerr << "SpectrogramLayer: dx == " << dx << ": scrolled too far for cache to be useful" << endl; | 1851 cerr << "SpectrogramLayer: dx == " << dx << ": scrolled too far for cache to be useful" << endl; |
1852 #endif | 1852 #endif |
1853 | 1853 |
1854 cache.validArea = QRect(); | 1854 cache.validArea = QRect(); |
1855 recreateWholeImageCache = true; | 1855 recreateWholeImageCache = true; |
1856 | |
1857 } else { | |
1858 | |
1859 // dx == 0, we haven't scrolled but the cache is | |
1860 // only partly valid | |
1861 | |
1862 #ifdef DEBUG_SPECTROGRAM_REPAINT | |
1863 cerr << "SpectrogramLayer: haven't scrolled, but cache is not complete" << endl; | |
1864 #endif | |
1865 if (cache.validArea.x() == 0) { | |
1866 x0 = cache.validArea.width(); | |
1867 } else { | |
1868 x1 = cache.validArea.x(); | |
1869 } | |
1856 } | 1870 } |
1857 } | 1871 } |
1858 } else { | 1872 } else { |
1859 #ifdef DEBUG_SPECTROGRAM_REPAINT | 1873 #ifdef DEBUG_SPECTROGRAM_REPAINT |
1860 cerr << "SpectrogramLayer: image cache useless" << endl; | 1874 cerr << "SpectrogramLayer: image cache useless" << endl; |
1907 bool rightToLeft = (x0 == 0 && x1 < v->getPaintWidth()); | 1921 bool rightToLeft = (x0 == 0 && x1 < v->getPaintWidth()); |
1908 | 1922 |
1909 #ifdef DEBUG_SPECTROGRAM_REPAINT | 1923 #ifdef DEBUG_SPECTROGRAM_REPAINT |
1910 cerr << "SpectrogramLayer: x0 " << x0 << ", x1 " << x1 | 1924 cerr << "SpectrogramLayer: x0 " << x0 << ", x1 " << x1 |
1911 << ", repaintWidth " << repaintWidth << ", h " << h | 1925 << ", repaintWidth " << repaintWidth << ", h " << h |
1912 << ", rightToLeft " << rightToLeft << endl; | 1926 << ", rightToLeft " << rightToLeft |
1927 << ", recreateWholeImageCache " << recreateWholeImageCache << endl; | |
1913 #endif | 1928 #endif |
1914 | 1929 |
1915 sv_samplerate_t sr = m_model->getSampleRate(); | 1930 sv_samplerate_t sr = m_model->getSampleRate(); |
1916 | 1931 |
1917 // Set minFreq and maxFreq to the frequency extents of the possibly | 1932 // Set minFreq and maxFreq to the frequency extents of the possibly |
2092 | 2107 |
2093 int failedToRepaint = bufwid - attainedBufwid; | 2108 int failedToRepaint = bufwid - attainedBufwid; |
2094 if (failedToRepaint > 0) { | 2109 if (failedToRepaint > 0) { |
2095 #ifdef DEBUG_SPECTROGRAM_REPAINT | 2110 #ifdef DEBUG_SPECTROGRAM_REPAINT |
2096 cerr << "SpectrogramLayer::paint(): Failed to repaint " << failedToRepaint << " of " << bufwid | 2111 cerr << "SpectrogramLayer::paint(): Failed to repaint " << failedToRepaint << " of " << bufwid |
2097 << " columns in time" << endl; | 2112 << " columns in time (so managed to repaint " << bufwid - failedToRepaint << ")" << endl; |
2098 #endif | 2113 #endif |
2099 } else if (failedToRepaint < 0) { | 2114 } else if (failedToRepaint < 0) { |
2100 cerr << "WARNING: failedToRepaint < 0 (= " << failedToRepaint << ")" | 2115 cerr << "WARNING: failedToRepaint < 0 (= " << failedToRepaint << ")" |
2101 << endl; | 2116 << endl; |
2102 failedToRepaint = 0; | 2117 failedToRepaint = 0; |
2203 | 2218 |
2204 #ifdef DEBUG_SPECTROGRAM_REPAINT | 2219 #ifdef DEBUG_SPECTROGRAM_REPAINT |
2205 cerr << "SpectrogramLayer: Cache valid area becomes " << cache.validArea.x() | 2220 cerr << "SpectrogramLayer: Cache valid area becomes " << cache.validArea.x() |
2206 << ", " << cache.validArea.y() << ", " | 2221 << ", " << cache.validArea.y() << ", " |
2207 << cache.validArea.width() << "x" | 2222 << cache.validArea.width() << "x" |
2208 << cache.validArea.height() << endl; | 2223 << cache.validArea.height() << " (size = " |
2224 << cache.image.width() << "x" << cache.image.height() << ")" | |
2225 << endl; | |
2209 #endif | 2226 #endif |
2210 | 2227 |
2211 QRect pr = rect & cache.validArea; | 2228 QRect pr = rect & cache.validArea; |
2212 | 2229 |
2213 #ifdef DEBUG_SPECTROGRAM_REPAINT | 2230 #ifdef DEBUG_SPECTROGRAM_REPAINT |