# HG changeset patch # User Chris Cannam # Date 1210238596 0 # Node ID 44670ce11a0cedcc3b30c9a5d443cd1d77c434f7 # Parent 64e84e5efb76ff6625de27a744ef0f46750c96b4 * Some debug output and tweaks diff -r 64e84e5efb76 -r 44670ce11a0c layer/SpectrogramLayer.cpp --- a/layer/SpectrogramLayer.cpp Wed Feb 27 11:59:42 2008 +0000 +++ b/layer/SpectrogramLayer.cpp Thu May 08 09:23:16 2008 +0000 @@ -1716,7 +1716,7 @@ // Plan: // // - the QImage cache is managed by the GUI thread (which creates, -// sizes and destroys it). +// sizes and destroys it) // // - but the cache is drawn on by another thread (paint thread) // @@ -1758,7 +1758,9 @@ // paints. The GUI thread should then never modify the cache // image without holding its specific mutex.) - Profiler profiler("SpectrogramLayer::paint", false); + Profiler profiler("SpectrogramLayer::paint", true); + + std::cerr << "SpectrogramLayer::paint entering" << std::endl; QMutexLocker locker(&m_pixmapCacheMutex); @@ -1767,6 +1769,8 @@ float ratio = float(v->getZoomLevel()) / float(getWindowIncrement()); int imageWidth = lrintf(v->width() * ratio); + std::cerr << "SpectrogramLayer::paint: view width = " << v->width() << ", ratio = " << ratio << ", imageWidth = " << imageWidth << std::endl; + PixmapCache *cache = m_pixmapCaches[v]; if (!cache) { cache = new PixmapCache; @@ -1778,8 +1782,8 @@ cache->mutex.unlock(); #ifdef DEBUG_SPECTROGRAM_REPAINT std::cerr << "SpectrogramLayer::paint: Created new cache, size " - << v->width() << "x" << v->height() << " (" - << v->width() * v->height() * 4 << " bytes)" << std::endl; + << imageWidth << "x" << v->height() << " (" + << imageWidth * v->height() * 4 << " bytes)" << std::endl; #endif return; //!!! prod paint thread } @@ -1915,8 +1919,12 @@ if (!m_exiting) { //!!! wait on condition - if (workToDo) ; // usleep(100); - else sleep(1); + if (workToDo) { + // usleep(100); + std::cerr << "SpectrogramLayer::PaintThread::run: still work to do, continuing" << std::endl; + } else { + sleep(10); + } } } } @@ -1926,7 +1934,7 @@ bool SpectrogramLayer::paintCache(View *v) const { - Profiler profiler("SpectrogramLayer::paintCache", false); + Profiler profiler("SpectrogramLayer::paintCache", true); m_pixmapCacheMutex.lock(); @@ -1944,6 +1952,11 @@ QMutexLocker locker(&cache.mutex); m_pixmapCacheMutex.unlock(); +#ifdef DEBUG_SPECTROGRAM_REPAINT + std::cerr << "SpectrogramLayer::paintCache(): Have cache to paint onto" + << std::endl; +#endif + QImage &image = *cache.pixmap; //!!! rename to cache.image const DenseTimeValueModel *model = m_model; @@ -2144,6 +2157,7 @@ } bool runOutOfData = false; + int runOutOfDataAt = x1; std::cerr << "painting from " << x0 << " to " << x1 << std::endl; @@ -2169,6 +2183,7 @@ std::cerr << "Met unavailable column at col " << col << std::endl; #endif runOutOfData = true; + runOutOfDataAt = x0 + x; break; } @@ -2357,11 +2372,21 @@ #endif } */ + + if (runOutOfData) { + std::cerr << "ran out of data, setting x1 to " << runOutOfDataAt + << std::endl; + x1 = runOutOfDataAt; + } + if (cache.validArea.width() > 0) { int vx0 = 0, vx1 = 0; vx0 = cache.validArea.x(); vx1 = cache.validArea.x() + cache.validArea.width(); + + std::cerr << "set cache valid region from " + << cache.validArea.x() << " -> " << cache.validArea.x() + cache.validArea.width(); cache.validArea = QRect (std::min(vx0, x0), cache.validArea.y(), @@ -2369,9 +2394,17 @@ x1 - std::min(vx0, x0)), cache.validArea.height()); + std::cerr << " to " + << cache.validArea.x() << " -> " << cache.validArea.x() + cache.validArea.width() + << std::endl; + } else { cache.validArea = QRect(x0, 0, x1 - x0, h); + + std::cerr << "set cache valid region from empty to " + << cache.validArea.x() << " -> " << cache.validArea.x() + cache.validArea.width() + << std::endl; } /* @@ -2620,8 +2653,6 @@ if (x0 < vx0) { if (x0 + paintBlockWidth < vx0) { x0 = vx0 - paintBlockWidth; -// } else { -// x0 = 0; } x1 = vx0; } else if (x0 >= vx1) { @@ -2664,6 +2695,8 @@ // } } } + + std::cerr << "SpectrogramLayer::selectPaintStrip: returning " << x0 << " -> " << x1 << std::endl; } void