# HG changeset patch # User Chris Cannam # Date 1478616953 0 # Node ID ab169938832aa3ce9d738ba56981f8c11a8ff673 # Parent 081c7ebf1fea0a2cb6e7b97be86230cf81555264 Use peak cache at one zoom level lower (since it exists at that level already -- this is a >= vs > question) + make naming more uniform diff -r 081c7ebf1fea -r ab169938832a layer/Colour3DPlotLayer.cpp --- a/layer/Colour3DPlotLayer.cpp Fri Nov 04 16:44:59 2016 +0000 +++ b/layer/Colour3DPlotLayer.cpp Tue Nov 08 14:55:53 2016 +0000 @@ -1028,7 +1028,7 @@ sources.verticalBinLayer = this; sources.fft = 0; sources.source = m_model; - sources.peaks = getPeakCache(); + sources.peakCache = getPeakCache(); ColourScale::Parameters cparams; cparams.colourMap = m_colourMap; diff -r 081c7ebf1fea -r ab169938832a layer/Colour3DPlotRenderer.cpp --- a/layer/Colour3DPlotRenderer.cpp Fri Nov 04 16:44:59 2016 +0000 +++ b/layer/Colour3DPlotRenderer.cpp Tue Nov 08 14:55:53 2016 +0000 @@ -287,7 +287,7 @@ ColumnOp::Column Colour3DPlotRenderer::getColumn(int sx, int minbin, int nbins, - bool usePeaksCache) const + bool usePeakCache) const { // order: // get column -> scale -> normalise -> record extents -> @@ -309,7 +309,7 @@ } else { ColumnOp::Column fullColumn = - (usePeaksCache ? m_sources.peaks : m_sources.source)-> + (usePeakCache ? m_sources.peakCache : m_sources.source)-> getColumn(sx); column = vector(fullColumn.data() + minbin, @@ -506,7 +506,7 @@ vector binforx(repaintWidth); vector binfory(h); - bool usePeaksCache = false; + bool usePeakCache = false; int binsPerPeak = 1; int zoomLevel = v->getZoomLevel(); int binResolution = model->getResolution(); @@ -517,25 +517,21 @@ binforx[x] = int(s0 + 0.0001); } - if (m_sources.peaks) { // peaks cache exists - - binsPerPeak = m_sources.peaks->getColumnsPerPeak(); - usePeaksCache = (binResolution * binsPerPeak) < zoomLevel; - + if (m_sources.peakCache) { + binsPerPeak = m_sources.peakCache->getColumnsPerPeak(); + usePeakCache = (zoomLevel >= binResolution * binsPerPeak); if (m_params.colourScale.getScale() == ColourScaleType::Phase) { - usePeaksCache = false; + usePeakCache = false; } } -#ifdef DEBUG_COLOUR_PLOT_REPAINT - cerr << "[PIX] zoomLevel = " << zoomLevel - << ", binResolution " << binResolution - << ", binsPerPeak " << binsPerPeak - << ", peak cache " << m_sources.peaks - << ", usePeaksCache = " << usePeaksCache - << endl; -#endif + SVDEBUG << "[PIX] zoomLevel = " << zoomLevel + << ", binResolution " << binResolution + << ", binsPerPeak " << binsPerPeak + << ", peak cache " << m_sources.peakCache + << ", usePeakCache = " << usePeakCache + << endl; for (int y = 0; y < h; ++y) { binfory[y] = m_sources.verticalBinLayer->getBinForY(v, h - y - 1); @@ -557,7 +553,7 @@ h, binforx, binfory, - usePeaksCache, + usePeakCache, rightToLeft, timeConstrained); } @@ -652,10 +648,8 @@ binforx[x] = int(leftBoundaryFrame / binResolution) + x; } -#ifdef DEBUG_COLOUR_PLOT_REPAINT - cerr << "[BIN] binResolution " << binResolution - << endl; -#endif + SVDEBUG << "[BIN] binResolution " << binResolution + << endl; for (int y = 0; y < h; ++y) { binfory[y] = m_sources.verticalBinLayer->getBinForY(v, h - y - 1); @@ -731,13 +725,13 @@ Colour3DPlotRenderer::renderDrawBuffer(int w, int h, const vector &binforx, const vector &binfory, - bool usePeaksCache, + bool usePeakCache, bool rightToLeft, bool timeConstrained) { // Callers must have checked that the appropriate subset of // Sources data members are set for the supplied flags (e.g. that - // peaks model exists if usePeaksCache) + // peakCache model exists if usePeakCache) RenderTimer timer(timeConstrained ? RenderTimer::FastRender : @@ -745,9 +739,9 @@ int divisor = 1; const DenseThreeDimensionalModel *sourceModel = m_sources.source; - if (usePeaksCache) { - divisor = m_sources.peaks->getColumnsPerPeak(); - sourceModel = m_sources.peaks; + if (usePeakCache) { + divisor = m_sources.peakCache->getColumnsPerPeak(); + sourceModel = m_sources.peakCache; } int sh = sourceModel->getHeight(); @@ -823,7 +817,7 @@ // this does the first three: ColumnOp::Column column = getColumn(sx, minbin, nbins, - usePeaksCache); + usePeakCache); magRange.sample(column); diff -r 081c7ebf1fea -r ab169938832a layer/Colour3DPlotRenderer.h --- a/layer/Colour3DPlotRenderer.h Fri Nov 04 16:44:59 2016 +0000 +++ b/layer/Colour3DPlotRenderer.h Tue Nov 08 14:55:53 2016 +0000 @@ -48,12 +48,12 @@ { public: struct Sources { - Sources() : verticalBinLayer(0), source(0), peaks(0), fft(0) { } + Sources() : verticalBinLayer(0), source(0), peakCache(0), fft(0) { } // These must all outlive this class const VerticalBinLayer *verticalBinLayer; // always const DenseThreeDimensionalModel *source; // always - const Dense3DModelPeakCache *peaks; // optionally + const Dense3DModelPeakCache *peakCache; // optionally const FFTModel *fft; // optionally }; @@ -280,7 +280,7 @@ int renderDrawBuffer(int w, int h, const std::vector &binforx, const std::vector &binfory, - bool usePeaksCache, + bool usePeakCache, bool rightToLeft, bool timeConstrained); @@ -303,7 +303,7 @@ RenderType decideRenderType(const LayerGeometryProvider *) const; ColumnOp::Column getColumn(int sx, int minbin, int nbins, - bool usePeaksCache) const; + bool usePeakCache) const; }; #endif diff -r 081c7ebf1fea -r ab169938832a layer/SpectrogramLayer.cpp --- a/layer/SpectrogramLayer.cpp Fri Nov 04 16:44:59 2016 +0000 +++ b/layer/SpectrogramLayer.cpp Tue Nov 08 14:55:53 2016 +0000 @@ -1421,7 +1421,7 @@ sources.verticalBinLayer = this; sources.fft = getFFTModel(); sources.source = sources.fft; - sources.peaks = getPeakCache(); + sources.peakCache = getPeakCache(); ColourScale::Parameters cparams; cparams.colourMap = m_colourMap;