Mercurial > hg > svgui
comparison layer/ScrollableImageCache.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 | bc9b4a163926 |
| children | 7ebfb61b1701 |
comparison
equal
deleted
inserted
replaced
| 1039:bfce7940c017 | 1040:25b035362c44 |
|---|---|
| 15 #include "ScrollableImageCache.h" | 15 #include "ScrollableImageCache.h" |
| 16 | 16 |
| 17 #include <iostream> | 17 #include <iostream> |
| 18 using namespace std; | 18 using namespace std; |
| 19 | 19 |
| 20 #define DEBUG_SCROLLABLE_IMAGE_CACHE 1 | 20 //#define DEBUG_SCROLLABLE_IMAGE_CACHE 1 |
| 21 | 21 |
| 22 void | 22 void |
| 23 ScrollableImageCache::scrollTo(sv_frame_t newStartFrame) | 23 ScrollableImageCache::scrollTo(sv_frame_t newStartFrame) |
| 24 { | 24 { |
| 25 if (!m_v) throw std::logic_error("ScrollableImageCache: not associated with a LayerGeometryProvider"); | 25 if (!m_v) throw std::logic_error("ScrollableImageCache: not associated with a LayerGeometryProvider"); |
| 138 << m_image.height() << endl; | 138 << m_image.height() << endl; |
| 139 throw std::logic_error("Image height must match cache height in ScrollableImageCache::drawImage"); | 139 throw std::logic_error("Image height must match cache height in ScrollableImageCache::drawImage"); |
| 140 } | 140 } |
| 141 if (left < 0 || width < 0 || left + width > m_image.width()) { | 141 if (left < 0 || width < 0 || left + width > m_image.width()) { |
| 142 cerr << "ScrollableImageCache::drawImage: ERROR: Target area (left = " | 142 cerr << "ScrollableImageCache::drawImage: ERROR: Target area (left = " |
| 143 << left << ", width = " << width << ") out of bounds for cache of " | 143 << left << ", width = " << width << ", so right = " << left + width |
| 144 << "width " << m_image.width() << endl; | 144 << ") out of bounds for cache of width " << m_image.width() << endl; |
| 145 throw std::logic_error("Target area out of bounds in ScrollableImageCache::drawImage"); | 145 throw std::logic_error("Target area out of bounds in ScrollableImageCache::drawImage"); |
| 146 } | 146 } |
| 147 if (imageLeft < 0 || imageWidth < 0 || | 147 if (imageLeft < 0 || imageWidth < 0 || |
| 148 imageLeft + imageWidth > image.width()) { | 148 imageLeft + imageWidth > image.width()) { |
| 149 cerr << "ScrollableImageCache::drawImage: ERROR: Source area (left = " | 149 cerr << "ScrollableImageCache::drawImage: ERROR: Source area (left = " |
| 150 << imageLeft << ", width = " << imageWidth | 150 << imageLeft << ", width = " << imageWidth << ", so right = " |
| 151 << ") out of bounds for image of " | 151 << imageLeft + imageWidth << ") out of bounds for image of " |
| 152 << "width " << image.width() << endl; | 152 << "width " << image.width() << endl; |
| 153 throw std::logic_error("Source area out of bounds in ScrollableImageCache::drawImage"); | 153 throw std::logic_error("Source area out of bounds in ScrollableImageCache::drawImage"); |
| 154 } | 154 } |
| 155 | 155 |
| 156 QPainter painter(&m_image); | 156 QPainter painter(&m_image); |
