Qt 4.8
Classes | Functions
qblendfunctions_p.h File Reference
#include <qmath.h>
#include "qdrawhelper_p.h"

Go to the source code of this file.

Classes

struct  QTransformImageVertex
 

Functions

template<typename SRC , typename T >
void qt_scale_image_16bit (uchar *destPixels, int dbpl, const uchar *srcPixels, int sbpl, int sh, const QRectF &targetRect, const QRectF &srcRect, const QRect &clip, T blender)
 
template<typename T >
void qt_scale_image_32bit (uchar *destPixels, int dbpl, const uchar *srcPixels, int sbpl, int sh, const QRectF &targetRect, const QRectF &srcRect, const QRect &clip, T blender)
 
template<class SrcT , class DestT , class Blender >
void qt_transform_image (DestT *destPixels, int dbpl, const SrcT *srcPixels, int sbpl, const QRectF &targetRect, const QRectF &sourceRect, const QRect &clip, const QTransform &targetRectTransform, Blender blender)
 
template<class SrcT , class DestT , class Blender >
void qt_transform_image_rasterize (DestT *destPixels, int dbpl, const SrcT *srcPixels, int sbpl, const QTransformImageVertex &topLeft, const QTransformImageVertex &bottomLeft, const QTransformImageVertex &topRight, const QTransformImageVertex &bottomRight, const QRect &sourceRect, const QRect &clip, qreal topY, qreal bottomY, int dudx, int dvdx, int dudy, int dvdy, int u0, int v0, Blender blender)
 

Function Documentation

◆ qt_scale_image_16bit()

template<typename SRC , typename T >
void qt_scale_image_16bit ( uchar destPixels,
int  dbpl,
const uchar srcPixels,
int  sbpl,
int  sh,
const QRectF targetRect,
const QRectF srcRect,
const QRect clip,
blender 
)

Definition at line 62 of file qblendfunctions_p.h.

68 {
69  qreal sx = targetRect.width() / (qreal) srcRect.width();
70  qreal sy = targetRect.height() / (qreal) srcRect.height();
71 
72  int ix = 0x00010000 / sx;
73  int iy = 0x00010000 / sy;
74 
75 // qDebug() << "scale:" << endl
76 // << " - target" << targetRect << endl
77 // << " - source" << srcRect << endl
78 // << " - clip" << clip << endl
79 // << " - sx=" << sx << " sy=" << sy << " ix=" << ix << " iy=" << iy;
80 
81  int cx1 = clip.x();
82  int cx2 = clip.x() + clip.width();
83  int cy1 = clip.top();
84  int cy2 = clip.y() + clip.height();
85 
86  int tx1 = qRound(targetRect.left());
87  int tx2 = qRound(targetRect.right());
88  int ty1 = qRound(targetRect.top());
89  int ty2 = qRound(targetRect.bottom());
90 
91  if (tx2 < tx1)
92  qSwap(tx2, tx1);
93 
94  if (ty2 < ty1)
95  qSwap(ty2, ty1);
96 
97  if (tx1 < cx1)
98  tx1 = cx1;
99 
100  if (tx2 >= cx2)
101  tx2 = cx2;
102 
103  if (tx1 >= tx2)
104  return;
105 
106  if (ty1 < cy1)
107  ty1 = cy1;
108 
109  if (ty2 >= cy2)
110  ty2 = cy2;
111 
112  if (ty1 >= ty2)
113  return;
114 
115  int h = ty2 - ty1;
116  int w = tx2 - tx1;
117 
118 
119  quint32 basex;
120  quint32 srcy;
121 
122  if (sx < 0) {
123  int dstx = qFloor((tx1 + qreal(0.5) - targetRect.right()) * ix) + 1;
124  basex = quint32(srcRect.right() * 65536) + dstx;
125  } else {
126  int dstx = qCeil((tx1 + qreal(0.5) - targetRect.left()) * ix) - 1;
127  basex = quint32(srcRect.left() * 65536) + dstx;
128  }
129  if (sy < 0) {
130  int dsty = qFloor((ty1 + qreal(0.5) - targetRect.bottom()) * iy) + 1;
131  srcy = quint32(srcRect.bottom() * 65536) + dsty;
132  } else {
133  int dsty = qCeil((ty1 + qreal(0.5) - targetRect.top()) * iy) - 1;
134  srcy = quint32(srcRect.top() * 65536) + dsty;
135  }
136 
137  quint16 *dst = ((quint16 *) (destPixels + ty1 * dbpl)) + tx1;
138 
139  // this bounds check here is required as floating point rounding above might in some cases lead to
140  // w/h values that are one pixel too large, falling outside of the valid image area.
141  int yend = (srcy + iy * (h - 1)) >> 16;
142  if (yend < 0 || yend >= sh)
143  --h;
144  int xend = (basex + ix * (w - 1)) >> 16;
145  if (xend < 0 || xend >= (int)(sbpl/sizeof(quint32)))
146  --w;
147 
148  while (h--) {
149  const SRC *src = (const SRC *) (srcPixels + (srcy >> 16) * sbpl);
150  int srcx = basex;
151  int x = 0;
152  for (; x<w-7; x+=8) {
153  blender.write(&dst[x], src[srcx >> 16]); srcx += ix;
154  blender.write(&dst[x+1], src[srcx >> 16]); srcx += ix;
155  blender.write(&dst[x+2], src[srcx >> 16]); srcx += ix;
156  blender.write(&dst[x+3], src[srcx >> 16]); srcx += ix;
157  blender.write(&dst[x+4], src[srcx >> 16]); srcx += ix;
158  blender.write(&dst[x+5], src[srcx >> 16]); srcx += ix;
159  blender.write(&dst[x+6], src[srcx >> 16]); srcx += ix;
160  blender.write(&dst[x+7], src[srcx >> 16]); srcx += ix;
161  }
162  for (; x<w; ++x) {
163  blender.write(&dst[x], src[srcx >> 16]);
164  srcx += ix;
165  }
166  blender.flush(&dst[x]);
167  dst = (quint16 *)(((uchar *) dst) + dbpl);
168  srcy += iy;
169  }
170 }
qreal right() const
Returns the x-coordinate of the rectangle&#39;s right edge.
Definition: qrect.h:527
double qreal
Definition: qglobal.h:1193
int qCeil(qreal v)
Definition: qmath.h:63
int qFloor(qreal v)
Definition: qmath.h:73
qreal left() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:525
int width() const
Returns the width of the rectangle.
Definition: qrect.h:303
int height() const
Returns the height of the rectangle.
Definition: qrect.h:306
unsigned char uchar
Definition: qglobal.h:994
qreal height() const
Returns the height of the rectangle.
Definition: qrect.h:710
unsigned short quint16
Definition: qglobal.h:936
qreal width() const
Returns the width of the rectangle.
Definition: qrect.h:707
void qSwap(T &value1, T &value2)
Definition: qglobal.h:2181
int top() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:243
int y() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:255
int x() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:252
unsigned int quint32
Definition: qglobal.h:938
qreal top() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:526
qreal bottom() const
Returns the y-coordinate of the rectangle&#39;s bottom edge.
Definition: qrect.h:528
Q_DECL_CONSTEXPR int qRound(qreal d)
Definition: qglobal.h:1203

◆ qt_scale_image_32bit()

template<typename T >
void qt_scale_image_32bit ( uchar destPixels,
int  dbpl,
const uchar srcPixels,
int  sbpl,
int  sh,
const QRectF targetRect,
const QRectF srcRect,
const QRect clip,
blender 
)

Definition at line 172 of file qblendfunctions_p.h.

Referenced by qt_scale_image_argb32_on_argb32(), and qt_scale_image_rgb32_on_rgb32().

178 {
179  qreal sx = targetRect.width() / (qreal) srcRect.width();
180  qreal sy = targetRect.height() / (qreal) srcRect.height();
181 
182  int ix = 0x00010000 / sx;
183  int iy = 0x00010000 / sy;
184 
185 // qDebug() << "scale:" << endl
186 // << " - target" << targetRect << endl
187 // << " - source" << srcRect << endl
188 // << " - clip" << clip << endl
189 // << " - sx=" << sx << " sy=" << sy << " ix=" << ix << " iy=" << iy;
190 
191  int cx1 = clip.x();
192  int cx2 = clip.x() + clip.width();
193  int cy1 = clip.top();
194  int cy2 = clip.y() + clip.height();
195 
196  int tx1 = qRound(targetRect.left());
197  int tx2 = qRound(targetRect.right());
198  int ty1 = qRound(targetRect.top());
199  int ty2 = qRound(targetRect.bottom());
200 
201  if (tx2 < tx1)
202  qSwap(tx2, tx1);
203 
204  if (ty2 < ty1)
205  qSwap(ty2, ty1);
206 
207  if (tx1 < cx1)
208  tx1 = cx1;
209 
210  if (tx2 >= cx2)
211  tx2 = cx2;
212 
213  if (tx1 >= tx2)
214  return;
215 
216  if (ty1 < cy1)
217  ty1 = cy1;
218 
219  if (ty2 >= cy2)
220  ty2 = cy2;
221 
222  if (ty1 >= ty2)
223  return;
224 
225  int h = ty2 - ty1;
226  int w = tx2 - tx1;
227 
228  quint32 basex;
229  quint32 srcy;
230 
231  if (sx < 0) {
232  int dstx = qFloor((tx1 + qreal(0.5) - targetRect.right()) * ix) + 1;
233  basex = quint32(srcRect.right() * 65536) + dstx;
234  } else {
235  int dstx = qCeil((tx1 + qreal(0.5) - targetRect.left()) * ix) - 1;
236  basex = quint32(srcRect.left() * 65536) + dstx;
237  }
238  if (sy < 0) {
239  int dsty = qFloor((ty1 + qreal(0.5) - targetRect.bottom()) * iy) + 1;
240  srcy = quint32(srcRect.bottom() * 65536) + dsty;
241  } else {
242  int dsty = qCeil((ty1 + qreal(0.5) - targetRect.top()) * iy) - 1;
243  srcy = quint32(srcRect.top() * 65536) + dsty;
244  }
245 
246  quint32 *dst = ((quint32 *) (destPixels + ty1 * dbpl)) + tx1;
247 
248  // this bounds check here is required as floating point rounding above might in some cases lead to
249  // w/h values that are one pixel too large, falling outside of the valid image area.
250  int yend = (srcy + iy * (h - 1)) >> 16;
251  if (yend < 0 || yend >= sh)
252  --h;
253  int xend = (basex + ix * (w - 1)) >> 16;
254  if (xend < 0 || xend >= (int)(sbpl/sizeof(quint32)))
255  --w;
256 
257  while (h--) {
258  const uint *src = (const quint32 *) (srcPixels + (srcy >> 16) * sbpl);
259  int srcx = basex;
260  int x = 0;
261  for (; x<w; ++x) {
262  blender.write(&dst[x], src[srcx >> 16]);
263  srcx += ix;
264  }
265  blender.flush(&dst[x]);
266  dst = (quint32 *)(((uchar *) dst) + dbpl);
267  srcy += iy;
268  }
269 }
qreal right() const
Returns the x-coordinate of the rectangle&#39;s right edge.
Definition: qrect.h:527
double qreal
Definition: qglobal.h:1193
int qCeil(qreal v)
Definition: qmath.h:63
int qFloor(qreal v)
Definition: qmath.h:73
qreal left() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:525
int width() const
Returns the width of the rectangle.
Definition: qrect.h:303
int height() const
Returns the height of the rectangle.
Definition: qrect.h:306
unsigned char uchar
Definition: qglobal.h:994
qreal height() const
Returns the height of the rectangle.
Definition: qrect.h:710
unsigned int uint
Definition: qglobal.h:996
qreal width() const
Returns the width of the rectangle.
Definition: qrect.h:707
void qSwap(T &value1, T &value2)
Definition: qglobal.h:2181
int top() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:243
int y() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:255
int x() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:252
unsigned int quint32
Definition: qglobal.h:938
qreal top() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:526
qreal bottom() const
Returns the y-coordinate of the rectangle&#39;s bottom edge.
Definition: qrect.h:528
Q_DECL_CONSTEXPR int qRound(qreal d)
Definition: qglobal.h:1203

◆ qt_transform_image()

template<class SrcT , class DestT , class Blender >
void qt_transform_image ( DestT *  destPixels,
int  dbpl,
const SrcT *  srcPixels,
int  sbpl,
const QRectF targetRect,
const QRectF sourceRect,
const QRect clip,
const QTransform targetRectTransform,
Blender  blender 
)

Definition at line 406 of file qblendfunctions_p.h.

Referenced by qt_transform_image_argb24_on_rgb16(), qt_transform_image_argb32_on_argb32(), qt_transform_image_argb32_on_rgb16(), qt_transform_image_rgb16_on_rgb16(), and qt_transform_image_rgb32_on_rgb32().

413 {
414  enum Corner
415  {
416  TopLeft,
417  TopRight,
418  BottomRight,
419  BottomLeft
420  };
421 
422  // map source rectangle to destination.
424  v[TopLeft].u = v[BottomLeft].u = sourceRect.left();
425  v[TopLeft].v = v[TopRight].v = sourceRect.top();
426  v[TopRight].u = v[BottomRight].u = sourceRect.right();
427  v[BottomLeft].v = v[BottomRight].v = sourceRect.bottom();
428  targetRectTransform.map(targetRect.left(), targetRect.top(), &v[TopLeft].x, &v[TopLeft].y);
429  targetRectTransform.map(targetRect.right(), targetRect.top(), &v[TopRight].x, &v[TopRight].y);
430  targetRectTransform.map(targetRect.left(), targetRect.bottom(), &v[BottomLeft].x, &v[BottomLeft].y);
431  targetRectTransform.map(targetRect.right(), targetRect.bottom(), &v[BottomRight].x, &v[BottomRight].y);
432 
433  // find topmost vertex.
434  int topmost = 0;
435  for (int i = 1; i < 4; ++i) {
436  if (v[i].y < v[topmost].y)
437  topmost = i;
438  }
439  // rearrange array such that topmost vertex is at index 0.
440  switch (topmost) {
441  case 1:
442  {
443  QTransformImageVertex t = v[0];
444  for (int i = 0; i < 3; ++i)
445  v[i] = v[i+1];
446  v[3] = t;
447  }
448  break;
449  case 2:
450  qSwap(v[0], v[2]);
451  qSwap(v[1], v[3]);
452  break;
453  case 3:
454  {
455  QTransformImageVertex t = v[3];
456  for (int i = 3; i > 0; --i)
457  v[i] = v[i-1];
458  v[0] = t;
459  }
460  break;
461  }
462 
463  // if necessary, swap vertex 1 and 3 such that 1 is to the left of 3.
464  qreal dx1 = v[1].x - v[0].x;
465  qreal dy1 = v[1].y - v[0].y;
466  qreal dx2 = v[3].x - v[0].x;
467  qreal dy2 = v[3].y - v[0].y;
468  if (dx1 * dy2 - dx2 * dy1 > 0)
469  qSwap(v[1], v[3]);
470 
471  QTransformImageVertex u = {v[1].x - v[0].x, v[1].y - v[0].y, v[1].u - v[0].u, v[1].v - v[0].v};
472  QTransformImageVertex w = {v[2].x - v[0].x, v[2].y - v[0].y, v[2].u - v[0].u, v[2].v - v[0].v};
473 
474  qreal det = u.x * w.y - u.y * w.x;
475  if (det == 0)
476  return;
477 
478  qreal invDet = 1.0 / det;
479  qreal m11, m12, m21, m22, mdx, mdy;
480 
481  m11 = (u.u * w.y - u.y * w.u) * invDet;
482  m12 = (u.x * w.u - u.u * w.x) * invDet;
483  m21 = (u.v * w.y - u.y * w.v) * invDet;
484  m22 = (u.x * w.v - u.v * w.x) * invDet;
485  mdx = v[0].u - m11 * v[0].x - m12 * v[0].y;
486  mdy = v[0].v - m21 * v[0].x - m22 * v[0].y;
487 
488  int dudx = int(m11 * 0x10000);
489  int dvdx = int(m21 * 0x10000);
490  int dudy = int(m12 * 0x10000);
491  int dvdy = int(m22 * 0x10000);
492  int u0 = qCeil((qreal(0.5) * m11 + qreal(0.5) * m12 + mdx) * 0x10000) - 1;
493  int v0 = qCeil((qreal(0.5) * m21 + qreal(0.5) * m22 + mdy) * 0x10000) - 1;
494 
495  int x1 = qFloor(sourceRect.left());
496  int y1 = qFloor(sourceRect.top());
497  int x2 = qCeil(sourceRect.right());
498  int y2 = qCeil(sourceRect.bottom());
499  QRect sourceRectI(x1, y1, x2 - x1, y2 - y1);
500 
501  // rasterize trapezoids.
502  if (v[1].y < v[3].y) {
503  qt_transform_image_rasterize(destPixels, dbpl, srcPixels, sbpl, v[0], v[1], v[0], v[3], sourceRectI, clip, v[0].y, v[1].y, dudx, dvdx, dudy, dvdy, u0, v0, blender);
504  qt_transform_image_rasterize(destPixels, dbpl, srcPixels, sbpl, v[1], v[2], v[0], v[3], sourceRectI, clip, v[1].y, v[3].y, dudx, dvdx, dudy, dvdy, u0, v0, blender);
505  qt_transform_image_rasterize(destPixels, dbpl, srcPixels, sbpl, v[1], v[2], v[3], v[2], sourceRectI, clip, v[3].y, v[2].y, dudx, dvdx, dudy, dvdy, u0, v0, blender);
506  } else {
507  qt_transform_image_rasterize(destPixels, dbpl, srcPixels, sbpl, v[0], v[1], v[0], v[3], sourceRectI, clip, v[0].y, v[3].y, dudx, dvdx, dudy, dvdy, u0, v0, blender);
508  qt_transform_image_rasterize(destPixels, dbpl, srcPixels, sbpl, v[0], v[1], v[3], v[2], sourceRectI, clip, v[3].y, v[1].y, dudx, dvdx, dudy, dvdy, u0, v0, blender);
509  qt_transform_image_rasterize(destPixels, dbpl, srcPixels, sbpl, v[1], v[2], v[3], v[2], sourceRectI, clip, v[1].y, v[2].y, dudx, dvdx, dudy, dvdy, u0, v0, blender);
510  }
511 }
void qt_transform_image_rasterize(DestT *destPixels, int dbpl, const SrcT *srcPixels, int sbpl, const QTransformImageVertex &topLeft, const QTransformImageVertex &bottomLeft, const QTransformImageVertex &topRight, const QTransformImageVertex &bottomRight, const QRect &sourceRect, const QRect &clip, qreal topY, qreal bottomY, int dudx, int dvdx, int dudy, int dvdy, int u0, int v0, Blender blender)
qreal right() const
Returns the x-coordinate of the rectangle&#39;s right edge.
Definition: qrect.h:527
double qreal
Definition: qglobal.h:1193
int qCeil(qreal v)
Definition: qmath.h:63
int qFloor(qreal v)
Definition: qmath.h:73
qreal left() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:525
quint16 u
QPoint map(const QPoint &p) const
Creates and returns a QPoint object that is a copy of the given point, mapped into the coordinate sys...
void qSwap(T &value1, T &value2)
Definition: qglobal.h:2181
Corner
Definition: qnamespace.h:1456
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
qreal top() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:526
qreal bottom() const
Returns the y-coordinate of the rectangle&#39;s bottom edge.
Definition: qrect.h:528

◆ qt_transform_image_rasterize()

template<class SrcT , class DestT , class Blender >
void qt_transform_image_rasterize ( DestT *  destPixels,
int  dbpl,
const SrcT *  srcPixels,
int  sbpl,
const QTransformImageVertex topLeft,
const QTransformImageVertex bottomLeft,
const QTransformImageVertex topRight,
const QTransformImageVertex bottomRight,
const QRect sourceRect,
const QRect clip,
qreal  topY,
qreal  bottomY,
int  dudx,
int  dvdx,
int  dudy,
int  dvdy,
int  u0,
int  v0,
Blender  blender 
)

Definition at line 277 of file qblendfunctions_p.h.

Referenced by qt_transform_image().

286 {
287  int fromY = qMax(qRound(topY), clip.top());
288  int toY = qMin(qRound(bottomY), clip.top() + clip.height());
289  if (fromY >= toY)
290  return;
291 
292  qreal leftSlope = (bottomLeft.x - topLeft.x) / (bottomLeft.y - topLeft.y);
293  qreal rightSlope = (bottomRight.x - topRight.x) / (bottomRight.y - topRight.y);
294  int dx_l = int(leftSlope * 0x10000);
295  int dx_r = int(rightSlope * 0x10000);
296  int x_l = int((topLeft.x + (qreal(0.5) + fromY - topLeft.y) * leftSlope + qreal(0.5)) * 0x10000);
297  int x_r = int((topRight.x + (qreal(0.5) + fromY - topRight.y) * rightSlope + qreal(0.5)) * 0x10000);
298 
299  int fromX, toX, x1, x2, u, v, i, ii;
300  DestT *line;
301  for (int y = fromY; y < toY; ++y) {
302  line = reinterpret_cast<DestT *>(reinterpret_cast<uchar *>(destPixels) + y * dbpl);
303 
304  fromX = qMax(x_l >> 16, clip.left());
305  toX = qMin(x_r >> 16, clip.left() + clip.width());
306  if (fromX < toX) {
307  // Because of rounding, we can get source coordinates outside the source image.
308  // Clamp these coordinates to the source rect to avoid segmentation fault and
309  // garbage on the screen.
310 
311  // Find the first pixel on the current scan line where the source coordinates are within the source rect.
312  x1 = fromX;
313  u = x1 * dudx + y * dudy + u0;
314  v = x1 * dvdx + y * dvdy + v0;
315  for (; x1 < toX; ++x1) {
316  int uu = u >> 16;
317  int vv = v >> 16;
318  if (uu >= sourceRect.left() && uu < sourceRect.left() + sourceRect.width()
319  && vv >= sourceRect.top() && vv < sourceRect.top() + sourceRect.height()) {
320  break;
321  }
322  u += dudx;
323  v += dvdx;
324  }
325 
326  // Find the last pixel on the current scan line where the source coordinates are within the source rect.
327  x2 = toX;
328  u = (x2 - 1) * dudx + y * dudy + u0;
329  v = (x2 - 1) * dvdx + y * dvdy + v0;
330  for (; x2 > x1; --x2) {
331  int uu = u >> 16;
332  int vv = v >> 16;
333  if (uu >= sourceRect.left() && uu < sourceRect.left() + sourceRect.width()
334  && vv >= sourceRect.top() && vv < sourceRect.top() + sourceRect.height()) {
335  break;
336  }
337  u -= dudx;
338  v -= dvdx;
339  }
340 
341  // Set up values at the beginning of the scan line.
342  u = fromX * dudx + y * dudy + u0;
343  v = fromX * dvdx + y * dvdy + v0;
344  line += fromX;
345 
346  // Beginning of the scan line, with per-pixel checks.
347  i = x1 - fromX;
348  while (i) {
349  int uu = qBound(sourceRect.left(), u >> 16, sourceRect.left() + sourceRect.width() - 1);
350  int vv = qBound(sourceRect.top(), v >> 16, sourceRect.top() + sourceRect.height() - 1);
351  blender.write(line, reinterpret_cast<const SrcT *>(reinterpret_cast<const uchar *>(srcPixels) + vv * sbpl)[uu]);
352  u += dudx;
353  v += dvdx;
354  ++line;
355  --i;
356  }
357 
358  // Middle of the scan line, without checks.
359  // Manual loop unrolling.
360  i = x2 - x1;
361  ii = i >> 3;
362  while (ii) {
363  blender.write(&line[0], reinterpret_cast<const SrcT *>(reinterpret_cast<const uchar *>(srcPixels) + (v >> 16) * sbpl)[u >> 16]); u += dudx; v += dvdx;
364  blender.write(&line[1], reinterpret_cast<const SrcT *>(reinterpret_cast<const uchar *>(srcPixels) + (v >> 16) * sbpl)[u >> 16]); u += dudx; v += dvdx;
365  blender.write(&line[2], reinterpret_cast<const SrcT *>(reinterpret_cast<const uchar *>(srcPixels) + (v >> 16) * sbpl)[u >> 16]); u += dudx; v += dvdx;
366  blender.write(&line[3], reinterpret_cast<const SrcT *>(reinterpret_cast<const uchar *>(srcPixels) + (v >> 16) * sbpl)[u >> 16]); u += dudx; v += dvdx;
367  blender.write(&line[4], reinterpret_cast<const SrcT *>(reinterpret_cast<const uchar *>(srcPixels) + (v >> 16) * sbpl)[u >> 16]); u += dudx; v += dvdx;
368  blender.write(&line[5], reinterpret_cast<const SrcT *>(reinterpret_cast<const uchar *>(srcPixels) + (v >> 16) * sbpl)[u >> 16]); u += dudx; v += dvdx;
369  blender.write(&line[6], reinterpret_cast<const SrcT *>(reinterpret_cast<const uchar *>(srcPixels) + (v >> 16) * sbpl)[u >> 16]); u += dudx; v += dvdx;
370  blender.write(&line[7], reinterpret_cast<const SrcT *>(reinterpret_cast<const uchar *>(srcPixels) + (v >> 16) * sbpl)[u >> 16]); u += dudx; v += dvdx;
371 
372  line += 8;
373 
374  --ii;
375  }
376  switch (i & 7) {
377  case 7: blender.write(line, reinterpret_cast<const SrcT *>(reinterpret_cast<const uchar *>(srcPixels) + (v >> 16) * sbpl)[u >> 16]); u += dudx; v += dvdx; ++line;
378  case 6: blender.write(line, reinterpret_cast<const SrcT *>(reinterpret_cast<const uchar *>(srcPixels) + (v >> 16) * sbpl)[u >> 16]); u += dudx; v += dvdx; ++line;
379  case 5: blender.write(line, reinterpret_cast<const SrcT *>(reinterpret_cast<const uchar *>(srcPixels) + (v >> 16) * sbpl)[u >> 16]); u += dudx; v += dvdx; ++line;
380  case 4: blender.write(line, reinterpret_cast<const SrcT *>(reinterpret_cast<const uchar *>(srcPixels) + (v >> 16) * sbpl)[u >> 16]); u += dudx; v += dvdx; ++line;
381  case 3: blender.write(line, reinterpret_cast<const SrcT *>(reinterpret_cast<const uchar *>(srcPixels) + (v >> 16) * sbpl)[u >> 16]); u += dudx; v += dvdx; ++line;
382  case 2: blender.write(line, reinterpret_cast<const SrcT *>(reinterpret_cast<const uchar *>(srcPixels) + (v >> 16) * sbpl)[u >> 16]); u += dudx; v += dvdx; ++line;
383  case 1: blender.write(line, reinterpret_cast<const SrcT *>(reinterpret_cast<const uchar *>(srcPixels) + (v >> 16) * sbpl)[u >> 16]); u += dudx; v += dvdx; ++line;
384  }
385 
386  // End of the scan line, with per-pixel checks.
387  i = toX - x2;
388  while (i) {
389  int uu = qBound(sourceRect.left(), u >> 16, sourceRect.left() + sourceRect.width() - 1);
390  int vv = qBound(sourceRect.top(), v >> 16, sourceRect.top() + sourceRect.height() - 1);
391  blender.write(line, reinterpret_cast<const SrcT *>(reinterpret_cast<const uchar *>(srcPixels) + vv * sbpl)[uu]);
392  u += dudx;
393  v += dvdx;
394  ++line;
395  --i;
396  }
397 
398  blender.flush(line);
399  }
400  x_l += dx_l;
401  x_r += dx_r;
402  }
403 }
double qreal
Definition: qglobal.h:1193
Q_DECL_CONSTEXPR const T & qMin(const T &a, const T &b)
Definition: qglobal.h:1215
int left() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:240
int width() const
Returns the width of the rectangle.
Definition: qrect.h:303
quint16 u
int height() const
Returns the height of the rectangle.
Definition: qrect.h:306
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
Definition: qglobal.h:1217
unsigned char uchar
Definition: qglobal.h:994
int top() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:243
Q_DECL_CONSTEXPR const T & qBound(const T &min, const T &val, const T &max)
Definition: qglobal.h:1219
Q_DECL_CONSTEXPR int qRound(qreal d)
Definition: qglobal.h:1203