# HG changeset patch # User Chris Cannam # Date 1468244223 -3600 # Node ID 6288f1b5f49b0abde97eabe530341081f7d8a7b9 # Parent ba62684a4512ea3ee544e5d2f9e91ab827ea2f71 Far more pragmatic update strategy diff -r ba62684a4512 -r 6288f1b5f49b layer/Colour3DPlotRenderer.cpp --- 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 diff -r ba62684a4512 -r 6288f1b5f49b layer/Colour3DPlotRenderer.h --- 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; diff -r ba62684a4512 -r 6288f1b5f49b layer/SpectrogramLayer.cpp --- 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;