Mercurial > hg > svgui
comparison layer/SpectrogramLayer.cpp @ 131:eaae73b6bd28
* Suspend/resume fft data server write activity while reading from a server
to repaint the spectrogram display. Makes a significant improvement to
the otherwise dreadful responsiveness of spectrogram display.
author | Chris Cannam |
---|---|
date | Thu, 03 Aug 2006 12:42:15 +0000 |
parents | 10eec0da9efe |
children | 5d3a483856ff |
comparison
equal
deleted
inserted
replaced
130:10eec0da9efe | 131:eaae73b6bd28 |
---|---|
542 void | 542 void |
543 SpectrogramLayer::invalidatePixmapCaches(size_t startFrame, size_t endFrame) | 543 SpectrogramLayer::invalidatePixmapCaches(size_t startFrame, size_t endFrame) |
544 { | 544 { |
545 for (ViewPixmapCache::iterator i = m_pixmapCaches.begin(); | 545 for (ViewPixmapCache::iterator i = m_pixmapCaches.begin(); |
546 i != m_pixmapCaches.end(); ++i) { | 546 i != m_pixmapCaches.end(); ++i) { |
547 | |
547 //!!! when are views removed from the map? on setLayerDormant? | 548 //!!! when are views removed from the map? on setLayerDormant? |
548 const View *v = i->first; | 549 const View *v = i->first; |
549 | 550 |
550 if (startFrame < v->getEndFrame() && int(endFrame) >= v->getStartFrame()) { | 551 if (startFrame < v->getEndFrame() && int(endFrame) >= v->getStartFrame()) { |
551 i->second.validArea = QRect(); | 552 i->second.validArea = QRect(); |
876 } | 877 } |
877 | 878 |
878 void | 879 void |
879 SpectrogramLayer::setLayerDormant(const View *v, bool dormant) | 880 SpectrogramLayer::setLayerDormant(const View *v, bool dormant) |
880 { | 881 { |
881 if (dormant == m_dormancy[v]) return; | |
882 | |
883 if (dormant) { | 882 if (dormant) { |
884 | 883 |
885 m_dormancy[v] = true; | 884 if (isLayerDormant(v)) { |
885 return; | |
886 } | |
887 | |
888 Layer::setLayerDormant(v, true); | |
886 | 889 |
887 invalidatePixmapCaches(); | 890 invalidatePixmapCaches(); |
888 m_pixmapCaches.erase(v); | 891 m_pixmapCaches.erase(v); |
889 | 892 |
890 if (m_fftModels.find(v) != m_fftModels.end()) { | 893 if (m_fftModels.find(v) != m_fftModels.end()) { |
892 m_fftModels.erase(v); | 895 m_fftModels.erase(v); |
893 } | 896 } |
894 | 897 |
895 } else { | 898 } else { |
896 | 899 |
897 m_dormancy[v] = false; | 900 Layer::setLayerDormant(v, false); |
898 } | 901 } |
899 } | 902 } |
900 | 903 |
901 void | 904 void |
902 SpectrogramLayer::cacheInvalid() | 905 SpectrogramLayer::cacheInvalid() |
1645 v->setLightBackground(true); | 1648 v->setLightBackground(true); |
1646 } else { | 1649 } else { |
1647 v->setLightBackground(false); | 1650 v->setLightBackground(false); |
1648 } | 1651 } |
1649 | 1652 |
1650 // Profiler profiler("SpectrogramLayer::paint", true); | 1653 Profiler profiler("SpectrogramLayer::paint", true); |
1651 #ifdef DEBUG_SPECTROGRAM_REPAINT | 1654 #ifdef DEBUG_SPECTROGRAM_REPAINT |
1652 std::cerr << "SpectrogramLayer::paint(): m_model is " << m_model << ", zoom level is " << v->getZoomLevel() << ", m_updateTimer " << m_updateTimer << std::endl; | 1655 std::cerr << "SpectrogramLayer::paint(): m_model is " << m_model << ", zoom level is " << v->getZoomLevel() << ", m_updateTimer " << m_updateTimer << std::endl; |
1653 | 1656 |
1654 std::cerr << "rect is " << rect.x() << "," << rect.y() << " " << rect.width() << "x" << rect.height() << std::endl; | 1657 std::cerr << "rect is " << rect.x() << "," << rect.y() << " " << rect.width() << "x" << rect.height() << std::endl; |
1655 #endif | 1658 #endif |
1668 | 1671 |
1669 // Need to do this even if !isLayerDormant, as that could mean v | 1672 // Need to do this even if !isLayerDormant, as that could mean v |
1670 // is not in the dormancy map at all -- we need it to be present | 1673 // is not in the dormancy map at all -- we need it to be present |
1671 // and accountable for when determining whether we need the cache | 1674 // and accountable for when determining whether we need the cache |
1672 // in the cache-fill thread above. | 1675 // in the cache-fill thread above. |
1673 m_dormancy[v] = false; | 1676 //!!! no longer use cache-fill thread |
1677 const_cast<SpectrogramLayer *>(this)->Layer::setLayerDormant(v, false); | |
1674 | 1678 |
1675 size_t fftSize = getFFTSize(v); | 1679 size_t fftSize = getFFTSize(v); |
1676 FFTModel *fft = getFFTModel(v); | 1680 FFTModel *fft = getFFTModel(v); |
1677 if (!fft) { | 1681 if (!fft) { |
1678 std::cerr << "ERROR: SpectrogramLayer::paint(): No FFT model, returning" << std::endl; | 1682 std::cerr << "ERROR: SpectrogramLayer::paint(): No FFT model, returning" << std::endl; |
1935 } | 1939 } |
1936 | 1940 |
1937 MagnitudeRange overallMag = m_viewMags[v]; | 1941 MagnitudeRange overallMag = m_viewMags[v]; |
1938 bool overallMagChanged = false; | 1942 bool overallMagChanged = false; |
1939 | 1943 |
1944 fft->suspend(); | |
1945 | |
1940 for (int x = 0; x < w; ++x) { | 1946 for (int x = 0; x < w; ++x) { |
1941 | 1947 |
1942 for (int y = 0; y < h; ++y) { | 1948 for (int y = 0; y < h; ++y) { |
1943 ymag[y] = 0.0; | 1949 ymag[y] = 0.0; |
1944 ydiv[y] = 0.0; | 1950 ydiv[y] = 0.0; |
2114 illuminateLocalFeatures(v, paint); | 2120 illuminateLocalFeatures(v, paint); |
2115 | 2121 |
2116 #ifdef DEBUG_SPECTROGRAM_REPAINT | 2122 #ifdef DEBUG_SPECTROGRAM_REPAINT |
2117 std::cerr << "SpectrogramLayer::paint() returning" << std::endl; | 2123 std::cerr << "SpectrogramLayer::paint() returning" << std::endl; |
2118 #endif | 2124 #endif |
2125 | |
2126 fft->resume(); | |
2119 } | 2127 } |
2120 | 2128 |
2121 void | 2129 void |
2122 SpectrogramLayer::illuminateLocalFeatures(View *v, QPainter &paint) const | 2130 SpectrogramLayer::illuminateLocalFeatures(View *v, QPainter &paint) const |
2123 { | 2131 { |