changeset 1411:6dc3a36d9794

Sample a column only if it is set (avoids flash of mis-ranged material when scrolling with view normalisation on)
author Chris Cannam
date Wed, 19 Dec 2018 10:40:09 +0000
parents 24234307c9b2
children 79032214f79d
files layer/ScrollableMagRangeCache.cpp
diffstat 1 files changed, 20 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/layer/ScrollableMagRangeCache.cpp	Thu Nov 29 11:57:30 2018 +0000
+++ b/layer/ScrollableMagRangeCache.cpp	Wed Dec 19 10:40:09 2018 +0000
@@ -15,6 +15,7 @@
 #include "ScrollableMagRangeCache.h"
 
 #include "base/HitCount.h"
+#include "base/Debug.h"
 
 #include <iostream>
 using namespace std;
@@ -31,8 +32,8 @@
               v->getXForFrame(newStartFrame));
 
 #ifdef DEBUG_SCROLLABLE_MAG_RANGE_CACHE
-    cerr << "ScrollableMagRangeCache::scrollTo: start frame " << m_startFrame
-         << " -> " << newStartFrame << ", dx = " << dx << endl;
+    SVDEBUG << "ScrollableMagRangeCache::scrollTo: start frame " << m_startFrame
+            << " -> " << newStartFrame << ", dx = " << dx << endl;
 #endif
 
     if (m_startFrame == newStartFrame) {
@@ -86,11 +87,11 @@
     }
 
 #ifdef DEBUG_SCROLLABLE_MAG_RANGE_CACHE
-    cerr << "maxes (" << m_ranges.size() << ") now: ";
+    SVDEBUG << "maxes (" << m_ranges.size() << ") now: ";
     for (int i = 0; in_range_for(m_ranges, i); ++i) {
-        cerr << m_ranges[i].getMax() << " ";
+        SVDEBUG << m_ranges[i].getMax() << " ";
     }
-    cerr << endl;
+    SVDEBUG << endl;
 #endif
 }
 
@@ -99,11 +100,20 @@
 {
     MagnitudeRange r;
 #ifdef DEBUG_SCROLLABLE_MAG_RANGE_CACHE
-    cerr << "ScrollableMagRangeCache::getRange(" << x << ", " << count << ")" << endl;
+    SVDEBUG << "ScrollableMagRangeCache::getRange(" << x << ", " << count << ")" << endl;
 #endif
     for (int i = 0; i < count; ++i) {
-        r.sample(m_ranges.at(x + i));
+        const auto &cr = m_ranges.at(x + i);
+        if (cr.isSet()) {
+            r.sample(cr);
+        }
+#ifdef DEBUG_SCROLLABLE_MAG_RANGE_CACHE
+        SVDEBUG << cr.getMin() << "->" << cr.getMax() << " ";
+#endif
     }
+#ifdef DEBUG_SCROLLABLE_MAG_RANGE_CACHE
+    SVDEBUG << endl;
+#endif
     return r;
 }
 
@@ -111,9 +121,9 @@
 ScrollableMagRangeCache::sampleColumn(int column, const MagnitudeRange &r)
 {
     if (!in_range_for(m_ranges, column)) {
-        cerr << "ERROR: ScrollableMagRangeCache::sampleColumn: column " << column
-             << " is out of range for cache of width " << m_ranges.size()
-             << " (with start frame " << m_startFrame << ")" << endl;
+        SVCERR << "ERROR: ScrollableMagRangeCache::sampleColumn: column " << column
+               << " is out of range for cache of width " << m_ranges.size()
+               << " (with start frame " << m_startFrame << ")" << endl;
         throw logic_error("column out of range");
     } else {
         m_ranges[column].sample(r);