Mercurial > hg > svgui
changeset 1096:6288f1b5f49b spectrogram-minor-refactor
Far more pragmatic update strategy
author | Chris Cannam |
---|---|
date | Mon, 11 Jul 2016 14:37:03 +0100 |
parents | ba62684a4512 |
children | 92ac1fce7102 |
files | layer/Colour3DPlotRenderer.cpp layer/Colour3DPlotRenderer.h layer/SpectrogramLayer.cpp |
diffstat | 3 files changed, 35 insertions(+), 50 deletions(-) [+] |
line wrap: on
line diff
--- a/layer/Colour3DPlotRenderer.cpp Mon Jul 11 10:38:23 2016 +0100 +++ b/layer/Colour3DPlotRenderer.cpp Mon Jul 11 14:37:03 2016 +0100 @@ -42,6 +42,22 @@ return render(v, paint, rect, true); } +QRect +Colour3DPlotRenderer::getLargestUncachedRect() +{ + int h = m_cache.getSize().height(); + + QRect areaLeft(0, 0, m_cache.getValidLeft(), h); + QRect areaRight(m_cache.getValidRight(), 0, + m_cache.getSize().width() - m_cache.getValidRight(), h); + + if (areaRight.width() > areaLeft.width()) { + return areaRight; + } else { + return areaLeft; + } +} + Colour3DPlotRenderer::RenderResult Colour3DPlotRenderer::render(LayerGeometryProvider *v, QPainter &paint, QRect rect, bool timeConstrained) @@ -184,8 +200,6 @@ //!!! todo: transparent style from Colour3DPlot - //!!! todo: bin boundary alignment when in BinResolution - //!!! todo: view magnitudes / normalise visible area //!!! todo: alter documentation for view mag stuff (cached paints
--- a/layer/Colour3DPlotRenderer.h Mon Jul 11 10:38:23 2016 +0100 +++ b/layer/Colour3DPlotRenderer.h Mon Jul 11 14:37:03 2016 +0100 @@ -147,6 +147,20 @@ */ RenderResult renderTimeConstrained(LayerGeometryProvider *v, QPainter &paint, QRect rect); + + /** + * Return the area of the largest rectangle within the entire area + * of the cache that is unavailable in the cache. This is only + * valid in relation to a preceding render() call which is + * presumed to have set the area, start frame, and zoom level for + * the cache. It could be used to establish a suitable region for + * a subsequent paint request (because if an area is not in the + * cache, it cannot have been rendered since the cache was + * cleared). + * + * Returns an empty QRect if the cache is entirely valid. + */ + QRect getLargestUncachedRect(); private: Sources m_sources;
--- a/layer/SpectrogramLayer.cpp Mon Jul 11 10:38:23 2016 +0100 +++ b/layer/SpectrogramLayer.cpp Mon Jul 11 14:37:03 2016 +0100 @@ -1556,54 +1556,11 @@ //!!! + mag range - QRect rendered = result.rendered; - if (rendered == rect) { - cerr << "exiting paint depth " << depth << endl; - --depth; - return; - } - - int rLeft = rendered.x(); - int rRight = rendered.x() + rendered.width(); - - if (rLeft < rect.x()) { - rLeft = rect.x(); - } - if (rRight > rect.x() + rect.width()) { - rRight = rect.x() + rect.width(); - } - - QRect areaLeft(rect.x(), rect.y(), - rLeft - rect.x(), rect.height()); - - QRect areaRight(rRight, rect.y(), - rect.x() + rect.width() - rRight, rect.height()); - - bool updateLeft = (areaLeft.width() > 0); - bool updateRight = (areaRight.width() > 0); - - if (updateLeft) { - if (updateRight) { - if (areaLeft.width() > areaRight.width()) { - cerr << "update left then right, widths " - << areaLeft.width() << " and " - << areaRight.width() << endl; - v->updatePaintRect(areaLeft); - v->updatePaintRect(areaRight); - } else { - cerr << "update right then left, widths " - << areaLeft.width() << " and " - << areaRight.width() << endl; - v->updatePaintRect(areaRight); - v->updatePaintRect(areaLeft); - } - } else { - cerr << "update left, width " << areaLeft.width() << endl; - v->updatePaintRect(areaLeft); - } - } else { - cerr << "update right, width " << areaRight.width() << endl; - v->updatePaintRect(areaRight); + QRect uncached = renderer->getLargestUncachedRect(); + if (uncached.width() > 0) { + cerr << "updating rect at " << uncached.x() << " width " + << uncached.width() << endl; + v->updatePaintRect(uncached); } cerr << "exiting paint depth " << depth << endl;