comparison layer/Colour3DPlotRenderer.cpp @ 1500:ac5a82e57d23

More debug bits
author Chris Cannam
date Wed, 11 Sep 2019 11:21:00 +0100
parents e4c9d38d304d
children 62aad7969f8b
comparison
equal deleted inserted replaced
1499:e4c9d38d304d 1500:ac5a82e57d23
151 SVDEBUG << "render " << m_sources.source 151 SVDEBUG << "render " << m_sources.source
152 << ": cache start " << m_cache.getStartFrame() 152 << ": cache start " << m_cache.getStartFrame()
153 << " valid left " << m_cache.getValidLeft() 153 << " valid left " << m_cache.getValidLeft()
154 << " valid right " << m_cache.getValidRight() 154 << " valid right " << m_cache.getValidRight()
155 << endl; 155 << endl;
156 SVDEBUG << " view start " << startFrame 156 SVDEBUG << "render " << m_sources.source
157 << ": view start " << startFrame
157 << " x0 " << x0 158 << " x0 " << x0
158 << " x1 " << x1 159 << " x1 " << x1
159 << endl; 160 << endl;
160 #endif 161 #endif
161 162
167 v->getXForFrame(startFrame) && 168 v->getXForFrame(startFrame) &&
168 m_cache.getValidLeft() <= x0 && 169 m_cache.getValidLeft() <= x0 &&
169 m_cache.getValidRight() >= x1) { 170 m_cache.getValidRight() >= x1) {
170 171
171 #ifdef DEBUG_COLOUR_PLOT_REPAINT 172 #ifdef DEBUG_COLOUR_PLOT_REPAINT
172 SVDEBUG << "cache hit" << endl; 173 SVDEBUG << "render " << m_sources.source
174 << ": cache hit" << endl;
173 #endif 175 #endif
174 count.hit(); 176 count.hit();
175 177
176 // cache is valid for the complete requested area 178 // cache is valid for the complete requested area
177 paint.drawImage(rect, m_cache.getImage(), rect); 179 paint.drawImage(rect, m_cache.getImage(), rect);
180 182
181 return { rect, range }; 183 return { rect, range };
182 184
183 } else { 185 } else {
184 #ifdef DEBUG_COLOUR_PLOT_REPAINT 186 #ifdef DEBUG_COLOUR_PLOT_REPAINT
185 SVDEBUG << "cache partial hit" << endl; 187 SVDEBUG << "render " << m_sources.source
188 << ": cache partial hit" << endl;
186 #endif 189 #endif
187 count.partial(); 190 count.partial();
188 191
189 // cache doesn't begin at the right frame or doesn't 192 // cache doesn't begin at the right frame or doesn't
190 // contain the complete view, but might be scrollable or 193 // contain the complete view, but might be scrollable or
298 renderToCacheBinResolution(v, x0, x1 - x0); 301 renderToCacheBinResolution(v, x0, x1 - x0);
299 302
300 } else { // must be DrawBufferPixelResolution, handled DirectTranslucent earlier 303 } else { // must be DrawBufferPixelResolution, handled DirectTranslucent earlier
301 304
302 if (timeConstrained && justInvalidated) { 305 if (timeConstrained && justInvalidated) {
303 SVDEBUG << "render " << m_sources.source << ": just invalidated cache in time-constrained context, that's all we're doing for now - wait for next update to start filling" << endl; 306 SVDEBUG << "render " << m_sources.source
307 << ": invalidated cache in time-constrained context, that's all we're doing for now - wait for next update to start filling" << endl;
304 } else { 308 } else {
305 renderToCachePixelResolution(v, x0, x1 - x0, rightToLeft, timeConstrained); 309 renderToCachePixelResolution(v, x0, x1 - x0, rightToLeft, timeConstrained);
306 } 310 }
307 } 311 }
308 312
640 (m_sources.peakCaches[ix]); 644 (m_sources.peakCaches[ix]);
641 if (!peakCache) continue; 645 if (!peakCache) continue;
642 int bpp = peakCache->getColumnsPerPeak(); 646 int bpp = peakCache->getColumnsPerPeak();
643 ZoomLevel equivZoom(ZoomLevel::FramesPerPixel, binResolution * bpp); 647 ZoomLevel equivZoom(ZoomLevel::FramesPerPixel, binResolution * bpp);
644 #ifdef DEBUG_COLOUR_PLOT_REPAINT 648 #ifdef DEBUG_COLOUR_PLOT_REPAINT
645 SVDEBUG << "getPreferredPeakCache: zoomLevel = " << zoomLevel 649 SVDEBUG << "render " << m_sources.source
650 << ": getPreferredPeakCache: zoomLevel = " << zoomLevel
646 << ", cache " << ix << " has bpp = " << bpp 651 << ", cache " << ix << " has bpp = " << bpp
647 << " for equivZoom = " << equivZoom << endl; 652 << " for equivZoom = " << equivZoom << endl;
648 #endif 653 #endif
649 if (zoomLevel >= equivZoom) { 654 if (zoomLevel >= equivZoom) {
650 // this peak cache would work, though it might not be best 655 // this peak cache would work, though it might not be best
674 bool timeConstrained) 679 bool timeConstrained)
675 { 680 {
676 Profiler profiler("Colour3DPlotRenderer::renderToCachePixelResolution"); 681 Profiler profiler("Colour3DPlotRenderer::renderToCachePixelResolution");
677 #ifdef DEBUG_COLOUR_PLOT_REPAINT 682 #ifdef DEBUG_COLOUR_PLOT_REPAINT
678 SVDEBUG << "render " << m_sources.source 683 SVDEBUG << "render " << m_sources.source
679 << ": renderToCachePixelResolution" << endl; 684 << ": [PIXEL] renderToCachePixelResolution" << endl;
680 #endif 685 #endif
681 686
682 // Draw to the draw buffer, and then copy from there. The draw 687 // Draw to the draw buffer, and then copy from there. The draw
683 // buffer is at the same resolution as the target in the cache, so 688 // buffer is at the same resolution as the target in the cache, so
684 // no extra scaling needed. 689 // no extra scaling needed.
814 int x0, int repaintWidth) 819 int x0, int repaintWidth)
815 { 820 {
816 Profiler profiler("Colour3DPlotRenderer::renderToCacheBinResolution"); 821 Profiler profiler("Colour3DPlotRenderer::renderToCacheBinResolution");
817 #ifdef DEBUG_COLOUR_PLOT_REPAINT 822 #ifdef DEBUG_COLOUR_PLOT_REPAINT
818 SVDEBUG << "render " << m_sources.source 823 SVDEBUG << "render " << m_sources.source
819 << ": renderToCacheBinResolution" << endl; 824 << ": [BIN] renderToCacheBinResolution" << endl;
820 #endif 825 #endif
821 826
822 // Draw to the draw buffer, and then scale-copy from there. Draw 827 // Draw to the draw buffer, and then scale-copy from there. Draw
823 // buffer is at bin resolution, i.e. buffer x == source column 828 // buffer is at bin resolution, i.e. buffer x == source column
824 // number. We use toolkit smooth scaling for interpolation. 829 // number. We use toolkit smooth scaling for interpolation.
889 for (int x = 0; x < drawBufferWidth; ++x) { 894 for (int x = 0; x < drawBufferWidth; ++x) {
890 binforx[x] = int(leftBoundaryFrame / binResolution) + x; 895 binforx[x] = int(leftBoundaryFrame / binResolution) + x;
891 } 896 }
892 897
893 #ifdef DEBUG_COLOUR_PLOT_REPAINT 898 #ifdef DEBUG_COLOUR_PLOT_REPAINT
894 SVDEBUG << "[BIN] binResolution " << binResolution << endl; 899 SVDEBUG << "render " << m_sources.source
900 << ": binResolution " << binResolution << endl;
895 #endif 901 #endif
896 902
897 for (int y = 0; y < h; ++y) { 903 for (int y = 0; y < h; ++y) {
898 binfory[y] = m_sources.verticalBinLayer->getBinForY(v, h - y - 1); 904 binfory[y] = m_sources.verticalBinLayer->getBinForY(v, h - y - 1);
899 } 905 }
910 916
911 int scaledLeft = v->getXForFrame(leftBoundaryFrame); 917 int scaledLeft = v->getXForFrame(leftBoundaryFrame);
912 int scaledRight = v->getXForFrame(rightBoundaryFrame); 918 int scaledRight = v->getXForFrame(rightBoundaryFrame);
913 919
914 #ifdef DEBUG_COLOUR_PLOT_REPAINT 920 #ifdef DEBUG_COLOUR_PLOT_REPAINT
915 SVDEBUG << "scaling draw buffer from width " << m_drawBuffer.width() 921 SVDEBUG << "render " << m_sources.source
922 << ": scaling draw buffer from width " << m_drawBuffer.width()
916 << " to " << (scaledRight - scaledLeft) 923 << " to " << (scaledRight - scaledLeft)
917 << " (nb drawBufferWidth = " 924 << " (nb drawBufferWidth = "
918 << drawBufferWidth << ", attainedWidth = " 925 << drawBufferWidth << ", attainedWidth = "
919 << attainedWidth << ")" << endl; 926 << attainedWidth << ")" << endl;
920 #endif 927 #endif
939 if (sourceLeft < 0) { 946 if (sourceLeft < 0) {
940 sourceLeft = 0; 947 sourceLeft = 0;
941 } 948 }
942 949
943 #ifdef DEBUG_COLOUR_PLOT_REPAINT 950 #ifdef DEBUG_COLOUR_PLOT_REPAINT
944 SVDEBUG << "leftBoundaryFrame = " << leftBoundaryFrame 951 SVDEBUG << "render " << m_sources.source
952 << ": leftBoundaryFrame = " << leftBoundaryFrame
945 << ", leftCropFrame = " << leftCropFrame 953 << ", leftCropFrame = " << leftCropFrame
946 << ", scaledLeft = " << scaledLeft 954 << ", scaledLeft = " << scaledLeft
947 << ", scaledLeftCrop = " << scaledLeftCrop 955 << ", scaledLeftCrop = " << scaledLeftCrop
948 << endl; 956 << endl;
949 SVDEBUG << "rightBoundaryFrame = " << rightBoundaryFrame 957 SVDEBUG << "render " << m_sources.source
958 << ": rightBoundaryFrame = " << rightBoundaryFrame
950 << ", rightCropFrame = " << rightCropFrame 959 << ", rightCropFrame = " << rightCropFrame
951 << ", scaledRight = " << scaledRight 960 << ", scaledRight = " << scaledRight
952 << ", scaledRightCrop = " << scaledRightCrop 961 << ", scaledRightCrop = " << scaledRightCrop
953 << endl; 962 << endl;
954 #endif 963 #endif
955 964
956 #ifdef DEBUG_COLOUR_PLOT_REPAINT 965 #ifdef DEBUG_COLOUR_PLOT_REPAINT
957 SVDEBUG << "x0 = " << x0 966 SVDEBUG << "render " << m_sources.source
967 << ": x0 = " << x0
958 << ", repaintWidth = " << repaintWidth 968 << ", repaintWidth = " << repaintWidth
959 << ", targetLeft = " << targetLeft 969 << ", targetLeft = " << targetLeft
960 << ", targetWidth = " << targetWidth << endl; 970 << ", targetWidth = " << targetWidth << endl;
961 #endif 971 #endif
962 972
1015 } 1025 }
1016 1026
1017 if (!sourceModel) return 0; 1027 if (!sourceModel) return 0;
1018 1028
1019 #ifdef DEBUG_COLOUR_PLOT_REPAINT 1029 #ifdef DEBUG_COLOUR_PLOT_REPAINT
1020 SVDEBUG << "renderDrawBuffer: w = " << w << ", h = " << h 1030 SVDEBUG << "render " << m_sources.source
1031 << ": renderDrawBuffer: w = " << w << ", h = " << h
1021 << ", peakCacheIndex = " << peakCacheIndex << " (divisor = " 1032 << ", peakCacheIndex = " << peakCacheIndex << " (divisor = "
1022 << divisor << "), rightToLeft = " << rightToLeft 1033 << divisor << "), rightToLeft = " << rightToLeft
1023 << ", timeConstrained = " << timeConstrained << endl; 1034 << ", timeConstrained = " << timeConstrained << endl;
1024 SVDEBUG << "renderDrawBuffer: normalization = " << int(m_params.normalization) 1035 SVDEBUG << "render " << m_sources.source
1036 << ": renderDrawBuffer: normalization = " << int(m_params.normalization)
1025 << ", binDisplay = " << int(m_params.binDisplay) 1037 << ", binDisplay = " << int(m_params.binDisplay)
1026 << ", binScale = " << int(m_params.binScale) 1038 << ", binScale = " << int(m_params.binScale)
1027 << ", alwaysOpaque = " << m_params.alwaysOpaque 1039 << ", alwaysOpaque = " << m_params.alwaysOpaque
1028 << ", interpolate = " << m_params.interpolate << endl; 1040 << ", interpolate = " << m_params.interpolate << endl;
1029 #endif 1041 #endif
1036 1048
1037 int nbins = int(binfory[h-1] + 0.0001) - minbin + 1; 1049 int nbins = int(binfory[h-1] + 0.0001) - minbin + 1;
1038 if (minbin + nbins > sh) nbins = sh - minbin; 1050 if (minbin + nbins > sh) nbins = sh - minbin;
1039 1051
1040 #ifdef DEBUG_COLOUR_PLOT_REPAINT 1052 #ifdef DEBUG_COLOUR_PLOT_REPAINT
1041 SVDEBUG << "minbin = " << minbin << ", nbins = " << nbins << ", last binfory = " 1053 SVDEBUG << "render " << m_sources.source
1042 << binfory[h-1] << " (rounds to " << int(binfory[h-1]) << ") (model height " << sh << ")" << endl; 1054 << ": minbin = " << minbin << ", nbins = " << nbins
1055 << ", last binfory = " << binfory[h-1]
1056 << " (rounds to " << int(binfory[h-1])
1057 << ") (model height " << sh << ")" << endl;
1043 #endif 1058 #endif
1044 1059
1045 int psx = -1; 1060 int psx = -1;
1046 1061
1047 int start = 0; 1062 int start = 0;
1059 vector<float> preparedColumn; 1074 vector<float> preparedColumn;
1060 1075
1061 int modelWidth = sourceModel->getWidth(); 1076 int modelWidth = sourceModel->getWidth();
1062 1077
1063 #ifdef DEBUG_COLOUR_PLOT_REPAINT 1078 #ifdef DEBUG_COLOUR_PLOT_REPAINT
1064 SVDEBUG << "modelWidth " << modelWidth << ", divisor " << divisor << endl; 1079 SVDEBUG << "render " << m_sources.source
1065 SVDEBUG << "start = " << start << ", finish = " << finish << ", step = " << step << endl; 1080 << ": modelWidth " << modelWidth << ", divisor " << divisor << endl;
1081 SVDEBUG << "render " << m_sources.source
1082 << ": start = " << start << ", finish = " << finish << ", step = " << step << endl;
1066 #endif 1083 #endif
1067 1084
1068 for (int x = start; x != finish; x += step) { 1085 for (int x = start; x != finish; x += step) {
1069 1086
1070 // x is the on-canvas pixel coord; sx (later) will be the 1087 // x is the on-canvas pixel coord; sx (later) will be the
1152 } 1169 }
1153 1170
1154 double fractionComplete = double(xPixelCount) / double(w); 1171 double fractionComplete = double(xPixelCount) / double(w);
1155 if (timer.outOfTime(fractionComplete)) { 1172 if (timer.outOfTime(fractionComplete)) {
1156 #ifdef DEBUG_COLOUR_PLOT_REPAINT 1173 #ifdef DEBUG_COLOUR_PLOT_REPAINT
1157 SVDEBUG << "out of time with xPixelCount = " << xPixelCount << endl; 1174 SVDEBUG << "render " << m_sources.source
1175 << ": out of time with xPixelCount = " << xPixelCount << endl;
1158 #endif 1176 #endif
1159 updateTimings(timer, xPixelCount); 1177 updateTimings(timer, xPixelCount);
1160 return xPixelCount; 1178 return xPixelCount;
1161 } 1179 }
1162 } 1180 }
1163 1181
1164 updateTimings(timer, xPixelCount); 1182 updateTimings(timer, xPixelCount);
1165 1183
1166 #ifdef DEBUG_COLOUR_PLOT_REPAINT 1184 #ifdef DEBUG_COLOUR_PLOT_REPAINT
1167 SVDEBUG << "completed with xPixelCount = " << xPixelCount << endl; 1185 SVDEBUG << "render " << m_sources.source
1186 << ": completed with xPixelCount = " << xPixelCount << endl;
1168 #endif 1187 #endif
1169 return xPixelCount; 1188 return xPixelCount;
1170 } 1189 }
1171 1190
1172 int 1191 int
1175 const vector<int> &binforx, 1194 const vector<int> &binforx,
1176 const vector<double> &binfory, 1195 const vector<double> &binfory,
1177 bool rightToLeft, 1196 bool rightToLeft,
1178 bool timeConstrained) 1197 bool timeConstrained)
1179 { 1198 {
1199 #ifdef DEBUG_COLOUR_PLOT_REPAINT
1200 SVDEBUG << "render " << m_sources.source
1201 << ": [PEAK] renderDrawBufferPeakFrequencies" << endl;
1202 #endif
1203
1180 // Callers must have checked that the appropriate subset of 1204 // Callers must have checked that the appropriate subset of
1181 // Sources data members are set for the supplied flags (e.g. that 1205 // Sources data members are set for the supplied flags (e.g. that
1182 // fft model exists) 1206 // fft model exists)
1183 1207
1184 RenderTimer timer(timeConstrained ? 1208 RenderTimer timer(timeConstrained ?
1215 1239
1216 vector<float> preparedColumn; 1240 vector<float> preparedColumn;
1217 1241
1218 int modelWidth = fft->getWidth(); 1242 int modelWidth = fft->getWidth();
1219 #ifdef DEBUG_COLOUR_PLOT_REPAINT 1243 #ifdef DEBUG_COLOUR_PLOT_REPAINT
1220 SVDEBUG << "modelWidth " << modelWidth << endl; 1244 SVDEBUG << "render " << m_sources.source
1245 << ": modelWidth " << modelWidth << endl;
1221 #endif 1246 #endif
1222 1247
1223 double minFreq = 1248 double minFreq =
1224 (double(minbin) * fft->getSampleRate()) / fft->getFFTSize(); 1249 (double(minbin) * fft->getSampleRate()) / fft->getFFTSize();
1225 double maxFreq = 1250 double maxFreq =
1226 (double(minbin + nbins - 1) * fft->getSampleRate()) / fft->getFFTSize(); 1251 (double(minbin + nbins - 1) * fft->getSampleRate()) / fft->getFFTSize();
1227 1252
1228 bool logarithmic = (m_params.binScale == BinScale::Log); 1253 bool logarithmic = (m_params.binScale == BinScale::Log);
1229 1254
1230 #ifdef DEBUG_COLOUR_PLOT_REPAINT 1255 #ifdef DEBUG_COLOUR_PLOT_REPAINT
1231 SVDEBUG << "start = " << start << ", finish = " << finish 1256 SVDEBUG << "render " << m_sources.source
1257 << ": start = " << start << ", finish = " << finish
1232 << ", step = " << step << endl; 1258 << ", step = " << step << endl;
1233 #endif 1259 #endif
1234 1260
1235 for (int x = start; x != finish; x += step) { 1261 for (int x = start; x != finish; x += step) {
1236 1262
1312 1338
1313 m_magRanges.push_back(magRange); 1339 m_magRanges.push_back(magRange);
1314 1340
1315 } else { 1341 } else {
1316 #ifdef DEBUG_COLOUR_PLOT_REPAINT 1342 #ifdef DEBUG_COLOUR_PLOT_REPAINT
1317 SVDEBUG << "pixel peak column for range " << sx0 << " to " << sx1 1343 SVDEBUG << "render " << m_sources.source
1344 << ": pixel peak column for range " << sx0 << " to " << sx1
1318 << " is empty" << endl; 1345 << " is empty" << endl;
1319 #endif 1346 #endif
1320 } 1347 }
1321 1348
1322 double fractionComplete = double(xPixelCount) / double(w); 1349 double fractionComplete = double(xPixelCount) / double(w);
1323 if (timer.outOfTime(fractionComplete)) { 1350 if (timer.outOfTime(fractionComplete)) {
1324 #ifdef DEBUG_COLOUR_PLOT_REPAINT 1351 #ifdef DEBUG_COLOUR_PLOT_REPAINT
1325 SVDEBUG << "out of time" << endl; 1352 SVDEBUG << "render " << m_sources.source
1353 << ": out of time" << endl;
1326 #endif 1354 #endif
1327 updateTimings(timer, xPixelCount); 1355 updateTimings(timer, xPixelCount);
1328 return xPixelCount; 1356 return xPixelCount;
1329 } 1357 }
1330 } 1358 }
1345 if (valid) { 1373 if (valid) {
1346 m_secondsPerXPixel = secondsPerXPixel; 1374 m_secondsPerXPixel = secondsPerXPixel;
1347 m_secondsPerXPixelValid = true; 1375 m_secondsPerXPixelValid = true;
1348 1376
1349 #ifdef DEBUG_COLOUR_PLOT_REPAINT 1377 #ifdef DEBUG_COLOUR_PLOT_REPAINT
1350 SVDEBUG << "across " << xPixelCount << " x-pixels, seconds per x-pixel = " 1378 SVDEBUG << "render " << m_sources.source
1379 << ": across " << xPixelCount
1380 << " x-pixels, seconds per x-pixel = "
1351 << m_secondsPerXPixel << " (total = " 1381 << m_secondsPerXPixel << " (total = "
1352 << (xPixelCount * m_secondsPerXPixel) << ")" << endl; 1382 << (xPixelCount * m_secondsPerXPixel) << ")" << endl;
1353 #endif 1383 #endif
1354 } 1384 }
1355 } 1385 }