# HG changeset patch # User Chris Cannam # Date 1467887068 -3600 # Node ID ac10a087e04569399a20650f4ca993af74f456af # Parent c8c747783110538ecd7e76c4a96703fbadf31a89 Time-constrained rendering diff -r c8c747783110 -r ac10a087e045 layer/SpectrogramLayer.cpp --- a/layer/SpectrogramLayer.cpp Tue Jul 05 17:48:26 2016 +0100 +++ b/layer/SpectrogramLayer.cpp Thu Jul 07 11:24:28 2016 +0100 @@ -1536,11 +1536,53 @@ { Colour3DPlotRenderer *renderer = getRenderer(v); - //!!! not time-constrained for now - Colour3DPlotRenderer::RenderResult result = renderer->render(v, paint, rect); - - //!!! do - (void)result; + if (m_synchronous) { + (void)renderer->render(v, paint, rect); + return; + } + + Colour3DPlotRenderer::RenderResult result = + renderer->renderTimeConstrained(v, paint, rect); + + //!!! + mag range + + QRect rendered = result.rendered; + if (rendered == rect) 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()) { + v->updatePaintRect(areaLeft); + v->updatePaintRect(areaRight); + } else { + v->updatePaintRect(areaRight); + v->updatePaintRect(areaLeft); + } + } else { + v->updatePaintRect(areaLeft); + } + } else { + v->updatePaintRect(areaRight); + } } Colour3DPlotRenderer *