changeset 1451:f72fb7fac92a single-point

When invalidating cache in a time-constrained context, don't start rendering in the same cycle as well - leave it for a further update. Slightly experimental effort to make the UI feel more responsive.
author Chris Cannam
date Wed, 01 May 2019 15:15:26 +0100
parents 6cf3cb6641e1
children 8b7f797bca86
files layer/Colour3DPlotRenderer.cpp
diffstat 1 files changed, 19 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/layer/Colour3DPlotRenderer.cpp	Wed May 01 14:41:28 2019 +0100
+++ b/layer/Colour3DPlotRenderer.cpp	Wed May 01 15:15:26 2019 +0100
@@ -129,6 +129,10 @@
     if (x1 > v->getPaintWidth()) x1 = v->getPaintWidth();
 
     sv_frame_t startFrame = v->getStartFrame();
+
+    bool justInvalidated =
+        (m_cache.getSize() != v->getPaintSize() ||
+         m_cache.getZoomLevel() != v->getZoomLevel());
     
     m_cache.resize(v->getPaintSize());
     m_cache.setZoomLevel(v->getZoomLevel());
@@ -153,7 +157,7 @@
 #endif
 
     static HitCount count("Colour3DPlotRenderer: image cache");
-    
+
     if (m_cache.isValid()) { // some part of the cache is valid
 
         if (v->getXForFrame(m_cache.getStartFrame()) ==
@@ -292,7 +296,11 @@
 
     } else { // must be DrawBufferPixelResolution, handled DirectTranslucent earlier
 
-        renderToCachePixelResolution(v, x0, x1 - x0, rightToLeft, timeConstrained);
+        if (timeConstrained && justInvalidated) {
+            SVDEBUG << "render: just invalidated cache in time-constrained context, that's all we're doing for now - wait for next update to start filling" << endl;
+        } else {
+            renderToCachePixelResolution(v, x0, x1 - x0, rightToLeft, timeConstrained);
+        }
     }
 
     QRect pr = rect & m_cache.getValidArea();
@@ -301,11 +309,12 @@
 
     if (!timeConstrained && (pr != rect)) {
         SVCERR << "WARNING: failed to render entire requested rect "
-               << "even when not time-constrained: requested "
+               << "even when not time-constrained: wanted "
                << rect.x() << "," << rect.y() << " "
-               << rect.width() << "x" << rect.height() << ", have "
+               << rect.width() << "x" << rect.height() << ", got "
                << pr.x() << "," << pr.y() << " "
                << pr.width() << "x" << pr.height()
+               << ", after request of width " << (x1 - x0)
                << endl;
     }
 
@@ -993,6 +1002,7 @@
 
 #ifdef DEBUG_COLOUR_PLOT_REPAINT
     SVDEBUG << "modelWidth " << modelWidth << ", divisor " << divisor << endl;
+    SVDEBUG << "start = " << start << ", finish = " << finish << ", step = " << step << endl;
 #endif
     
     for (int x = start; x != finish; x += step) {
@@ -1084,7 +1094,7 @@
         double fractionComplete = double(xPixelCount) / double(w);
         if (timer.outOfTime(fractionComplete)) {
 #ifdef DEBUG_COLOUR_PLOT_REPAINT
-            SVDEBUG << "out of time" << endl;
+            SVDEBUG << "out of time with xPixelCount = " << xPixelCount << endl;
 #endif
             updateTimings(timer, xPixelCount);
             return xPixelCount;
@@ -1092,6 +1102,10 @@
     }
 
     updateTimings(timer, xPixelCount);
+
+#ifdef DEBUG_COLOUR_PLOT_REPAINT
+    SVDEBUG << "completed with xPixelCount = " << xPixelCount << endl;
+#endif
     return xPixelCount;
 }