17 #include "base/HitCount.h" 26 sv_frame_t newStartFrame)
28 static HitCount count(
"ScrollableImageCache: scrolling");
33 #ifdef DEBUG_SCROLLABLE_IMAGE_CACHE 34 cerr <<
"ScrollableImageCache::scrollTo: start frame " << m_startFrame
35 <<
" -> " << newStartFrame <<
", dx = " << dx << endl;
38 if (m_startFrame == newStartFrame) {
44 m_startFrame = newStartFrame;
51 int w = m_image.width();
59 if (dx <= -w || dx >= w) {
71 if (dxp < 0) dxp = -dxp;
73 int copylen = (w - dxp) *
int(
sizeof(QRgb));
74 for (
int y = 0; y < m_image.height(); ++y) {
75 QRgb *line = (QRgb *)m_image.scanLine(y);
77 memmove(line, line + dxp, copylen);
79 memmove(line + dxp, line, copylen);
86 int pw = m_validWidth;
115 bool &isLeftOfValidArea)
const 117 #ifdef DEBUG_SCROLLABLE_IMAGE_CACHE 118 cerr <<
"ScrollableImageCache::adjustToTouchValidArea: left " << left
119 <<
", width " << width << endl;
120 cerr <<
"ScrollableImageCache: my left " << m_validLeft
121 <<
", width " << m_validWidth <<
" so right " << (m_validLeft + m_validWidth) << endl;
123 if (left < m_validLeft) {
124 isLeftOfValidArea =
true;
125 if (left + width <= m_validLeft + m_validWidth) {
126 width = m_validLeft - left;
128 #ifdef DEBUG_SCROLLABLE_IMAGE_CACHE 129 cerr <<
"ScrollableImageCache: we're left of valid area, adjusted width to " << width << endl;
132 isLeftOfValidArea =
false;
133 width = left + width - (m_validLeft + m_validWidth);
134 left = m_validLeft + m_validWidth;
135 if (width < 0) width = 0;
136 #ifdef DEBUG_SCROLLABLE_IMAGE_CACHE 137 cerr <<
"ScrollableImageCache: we're right of valid area, adjusted left to " << left <<
", width to " << width << endl;
149 if (image.height() != m_image.height()) {
150 cerr <<
"ScrollableImageCache::drawImage: ERROR: Supplied image height " 151 << image.height() <<
" does not match cache height " 152 << m_image.height() << endl;
153 throw std::logic_error(
"Image height must match cache height in ScrollableImageCache::drawImage");
155 if (left < 0 || width < 0 || left + width > m_image.width()) {
156 cerr <<
"ScrollableImageCache::drawImage: ERROR: Target area (left = " 157 << left <<
", width = " << width <<
", so right = " << left + width
158 <<
") out of bounds for cache of width " << m_image.width() << endl;
159 throw std::logic_error(
"Target area out of bounds in ScrollableImageCache::drawImage");
161 if (imageLeft < 0 || imageWidth < 0 ||
162 imageLeft + imageWidth > image.width()) {
163 cerr <<
"ScrollableImageCache::drawImage: ERROR: Source area (left = " 164 << imageLeft <<
", width = " << imageWidth <<
", so right = " 165 << imageLeft + imageWidth <<
") out of bounds for image of " 166 <<
"width " << image.width() << endl;
167 throw std::logic_error(
"Source area out of bounds in ScrollableImageCache::drawImage");
170 QPainter painter(&m_image);
171 painter.drawImage(QRect(left, 0, width, m_image.height()),
173 QRect(imageLeft, 0, imageWidth, image.height()));
178 m_validWidth = width;
182 if (left < m_validLeft) {
183 if (left + width > m_validLeft + m_validWidth) {
187 m_validWidth = width;
188 }
else if (left + width < m_validLeft) {
193 m_validWidth = width;
198 m_validWidth = (m_validLeft + m_validWidth) - left;
202 if (left > m_validLeft + m_validWidth) {
207 m_validWidth = width;
208 }
else if (left + width > m_validLeft + m_validWidth) {
212 m_validWidth = (left + width) - m_validLeft;
Interface for classes that provide geometry information (such as size, start frame, and a large number of other properties) about the disposition of a layer.
virtual int getXForFrame(sv_frame_t frame) const =0
Return the pixel x-coordinate corresponding to a given sample frame (which may be negative)...