comparison layer/SpectrogramLayer.cpp @ 1040:25b035362c44 spectrogram-minor-refactor

Truncate edges when about to paint beyond limits of cache
author Chris Cannam
date Wed, 03 Feb 2016 16:51:37 +0000
parents bfce7940c017
children fccee028a522
comparison
equal deleted inserted replaced
1039:bfce7940c017 1040:25b035362c44
2061 #ifdef DEBUG_SPECTROGRAM_REPAINT 2061 #ifdef DEBUG_SPECTROGRAM_REPAINT
2062 cerr << "SpectrogramLayer: Drawing image region of width " << scaledRightCrop - scaledLeftCrop << " to " 2062 cerr << "SpectrogramLayer: Drawing image region of width " << scaledRightCrop - scaledLeftCrop << " to "
2063 << scaledLeftCrop << " from " << scaledLeftCrop - scaledLeft << endl; 2063 << scaledLeftCrop << " from " << scaledLeftCrop - scaledLeft << endl;
2064 #endif 2064 #endif
2065 2065
2066 //!!! Update this for failedToRepaint logic 2066 int targetLeft = scaledLeftCrop;
2067 if (targetLeft < 0) {
2068 targetLeft = 0;
2069 }
2070
2071 int targetWidth = scaledRightCrop - targetLeft;
2072 if (targetLeft + targetWidth > cache.getSize().width()) {
2073 targetWidth = cache.getSize().width() - targetLeft;
2074 }
2067 2075
2068 cache.drawImage 2076 int sourceLeft = targetLeft - scaledLeft;
2069 (scaledLeftCrop, 2077 if (sourceLeft < 0) {
2070 scaledRightCrop - scaledLeftCrop, 2078 sourceLeft = 0;
2071 scaled, 2079 }
2072 scaledLeftCrop - scaledLeft, 2080
2073 scaledRightCrop - scaledLeftCrop); 2081 int sourceWidth = targetWidth;
2082
2083 if (targetWidth > 0) {
2084 cache.drawImage
2085 (targetLeft,
2086 targetWidth,
2087 scaled,
2088 sourceLeft,
2089 sourceWidth);
2090 }
2074 2091
2075 } else { 2092 } else {
2076 2093
2077 cache.drawImage(paintedLeft, paintedWidth, 2094 cache.drawImage(paintedLeft, paintedWidth,
2078 m_drawBuffer, 2095 m_drawBuffer,