4#ifndef QBLENDFUNCTIONS_P_H
5#define QBLENDFUNCTIONS_P_H
7#include <QtGui/private/qtguiglobal_p.h>
24template <
typename SRC,
typename T>
26 const uchar *srcPixels,
int sbpl,
int srch,
32 qreal sx = srcRect.width() / (
qreal) targetRect.width();
33 qreal sy = srcRect.height() / (
qreal) targetRect.height();
35 const int ix = 0x00010000 * sx;
36 const int iy = 0x00010000 * sy;
44 QRect tr = targetRect.normalized().toRect();
45 tr =
tr.intersected(clip);
48 const int tx1 =
tr.left();
49 const int ty1 =
tr.top();
57 int dstx =
qFloor((tx1 +
qreal(0.5) - targetRect.right()) * sx * 65536) + 1;
58 basex =
quint32(srcRect.right() * 65536) + dstx;
60 int dstx =
qCeil((tx1 +
qreal(0.5) - targetRect.left()) * sx * 65536) - 1;
61 basex =
quint32(srcRect.left() * 65536) + dstx;
64 int dsty =
qFloor((ty1 +
qreal(0.5) - targetRect.bottom()) * sy * 65536) + 1;
65 srcy =
quint32(srcRect.bottom() * 65536) + dsty;
67 int dsty =
qCeil((ty1 +
qreal(0.5) - targetRect.top()) * sy * 65536) - 1;
68 srcy =
quint32(srcRect.top() * 65536) + dsty;
75 const int ystart = srcy >> 16;
76 if (ystart >= srch && iy < 0) {
80 const int xstart = basex >> 16;
81 if (xstart >= (
int)(sbpl/
sizeof(SRC)) && ix < 0) {
85 int yend = (srcy + iy * (
h - 1)) >> 16;
86 if (yend < 0 || yend >= srch)
88 int xend = (basex + ix * (
w - 1)) >> 16;
89 if (xend < 0 || xend >= (
int)(sbpl/
sizeof(SRC)))
93 const SRC *
src = (
const SRC *) (srcPixels + (srcy >> 16) * sbpl);
97 blender.write(&
dst[
x],
src[srcx >> 16]); srcx += ix;
98 blender.write(&
dst[
x+1],
src[srcx >> 16]); srcx += ix;
99 blender.write(&
dst[
x+2],
src[srcx >> 16]); srcx += ix;
100 blender.write(&
dst[
x+3],
src[srcx >> 16]); srcx += ix;
101 blender.write(&
dst[
x+4],
src[srcx >> 16]); srcx += ix;
102 blender.write(&
dst[
x+5],
src[srcx >> 16]); srcx += ix;
103 blender.write(&
dst[
x+6],
src[srcx >> 16]); srcx += ix;
104 blender.write(&
dst[
x+7],
src[srcx >> 16]); srcx += ix;
107 blender.write(&
dst[
x],
src[srcx >> 16]);
110 blender.flush(&
dst[
x]);
117 const uchar *srcPixels,
int sbpl,
int srch,
123 qreal sx = srcRect.width() / (
qreal) targetRect.width();
124 qreal sy = srcRect.height() / (
qreal) targetRect.height();
126 const int ix = 0x00010000 * sx;
127 const int iy = 0x00010000 * sy;
135 QRect tr = targetRect.normalized().toRect();
136 tr =
tr.intersected(clip);
139 const int tx1 =
tr.left();
140 const int ty1 =
tr.top();
148 int dstx =
qFloor((tx1 +
qreal(0.5) - targetRect.right()) * sx * 65536) + 1;
149 basex =
quint32(srcRect.right() * 65536) + dstx;
151 int dstx =
qCeil((tx1 +
qreal(0.5) - targetRect.left()) * sx * 65536) - 1;
152 basex =
quint32(srcRect.left() * 65536) + dstx;
155 int dsty =
qFloor((ty1 +
qreal(0.5) - targetRect.bottom()) * sy * 65536) + 1;
156 srcy =
quint32(srcRect.bottom() * 65536) + dsty;
158 int dsty =
qCeil((ty1 +
qreal(0.5) - targetRect.top()) * sy * 65536) - 1;
159 srcy =
quint32(srcRect.top() * 65536) + dsty;
166 const int ystart = srcy >> 16;
167 if (ystart >= srch && iy < 0) {
171 const int xstart = basex >> 16;
172 if (xstart >= (
int)(sbpl/
sizeof(
quint32)) && ix < 0) {
176 int yend = (srcy + iy * (
h - 1)) >> 16;
177 if (yend < 0 || yend >= srch)
179 int xend = (basex + ix * (
w - 1)) >> 16;
180 if (xend < 0 || xend >= (
int)(sbpl/
sizeof(
quint32)))
184 const uint *
src = (
const quint32 *) (srcPixels + (srcy >> 16) * sbpl);
188 blender.write(&
dst[
x],
src[srcx >> 16]);
191 blender.flush(&
dst[
x]);
202template <
class SrcT,
class DestT,
class Blender>
204 const SrcT *srcPixels,
int sbpl,
207 const QRect &sourceRect,
210 int dudx,
int dvdx,
int dudy,
int dvdy,
int u0,
int v0,
218 qreal leftSlope = (bottomLeft.
x - topLeft.
x) / (bottomLeft.
y - topLeft.
y);
219 qreal rightSlope = (bottomRight.
x - topRight.
x) / (bottomRight.
y - topRight.
y);
235 line =
reinterpret_cast<DestT *
>(
reinterpret_cast<uchar *
>(destPixels) +
y * dbpl);
237 fromX =
qMax(x_l >> 16, clipLeft);
238 toX =
qMin(x_r >> 16, clipLeft + clipWidth);
246 u =
x1 * dudx +
y * dudy + u0;
247 v =
x1 * dvdx +
y * dvdy +
v0;
248 for (;
x1 < toX; ++
x1) {
251 if (uu >= sourceRectLeft && uu < sourceRectLeft + sourceRectWidth
252 && vv >= sourceRectTop && vv < sourceRectTop + sourceRectHeight) {
261 u = (
x2 - 1) * dudx +
y * dudy + u0;
262 v = (
x2 - 1) * dvdx +
y * dvdy +
v0;
266 if (uu >= sourceRectLeft && uu < sourceRectLeft + sourceRectWidth
267 && vv >= sourceRectTop && vv < sourceRectTop + sourceRectHeight) {
275 u = fromX * dudx +
y * dudy + u0;
276 v = fromX * dvdx +
y * dvdy +
v0;
282 qint64 uu =
qBound(sourceRectLeft, u >> 16, sourceRectLeft + sourceRectWidth - 1);
283 qint64 vv =
qBound(sourceRectTop,
v >> 16, sourceRectTop + sourceRectHeight - 1);
284 blender.write(
line,
reinterpret_cast<const SrcT *
>(
reinterpret_cast<const uchar *
>(srcPixels) + vv * sbpl)[uu]);
296 blender.write(&
line[0],
reinterpret_cast<const SrcT *
>(
reinterpret_cast<const uchar *
>(srcPixels) + (
v >> 16) * sbpl)[u >> 16]); u += dudx;
v += dvdx;
297 blender.write(&
line[1],
reinterpret_cast<const SrcT *
>(
reinterpret_cast<const uchar *
>(srcPixels) + (
v >> 16) * sbpl)[u >> 16]); u += dudx;
v += dvdx;
298 blender.write(&
line[2],
reinterpret_cast<const SrcT *
>(
reinterpret_cast<const uchar *
>(srcPixels) + (
v >> 16) * sbpl)[u >> 16]); u += dudx;
v += dvdx;
299 blender.write(&
line[3],
reinterpret_cast<const SrcT *
>(
reinterpret_cast<const uchar *
>(srcPixels) + (
v >> 16) * sbpl)[u >> 16]); u += dudx;
v += dvdx;
300 blender.write(&
line[4],
reinterpret_cast<const SrcT *
>(
reinterpret_cast<const uchar *
>(srcPixels) + (
v >> 16) * sbpl)[u >> 16]); u += dudx;
v += dvdx;
301 blender.write(&
line[5],
reinterpret_cast<const SrcT *
>(
reinterpret_cast<const uchar *
>(srcPixels) + (
v >> 16) * sbpl)[u >> 16]); u += dudx;
v += dvdx;
302 blender.write(&
line[6],
reinterpret_cast<const SrcT *
>(
reinterpret_cast<const uchar *
>(srcPixels) + (
v >> 16) * sbpl)[u >> 16]); u += dudx;
v += dvdx;
303 blender.write(&
line[7],
reinterpret_cast<const SrcT *
>(
reinterpret_cast<const uchar *
>(srcPixels) + (
v >> 16) * sbpl)[u >> 16]); u += dudx;
v += dvdx;
310 case 7: blender.write(
line,
reinterpret_cast<const SrcT *
>(
reinterpret_cast<const uchar *
>(srcPixels) + (
v >> 16) * sbpl)[u >> 16]); u += dudx;
v += dvdx; ++
line;
Q_FALLTHROUGH();
311 case 6: blender.write(
line,
reinterpret_cast<const SrcT *
>(
reinterpret_cast<const uchar *
>(srcPixels) + (
v >> 16) * sbpl)[u >> 16]); u += dudx;
v += dvdx; ++
line;
Q_FALLTHROUGH();
312 case 5: blender.write(
line,
reinterpret_cast<const SrcT *
>(
reinterpret_cast<const uchar *
>(srcPixels) + (
v >> 16) * sbpl)[u >> 16]); u += dudx;
v += dvdx; ++
line;
Q_FALLTHROUGH();
313 case 4: blender.write(
line,
reinterpret_cast<const SrcT *
>(
reinterpret_cast<const uchar *
>(srcPixels) + (
v >> 16) * sbpl)[u >> 16]); u += dudx;
v += dvdx; ++
line;
Q_FALLTHROUGH();
314 case 3: blender.write(
line,
reinterpret_cast<const SrcT *
>(
reinterpret_cast<const uchar *
>(srcPixels) + (
v >> 16) * sbpl)[u >> 16]); u += dudx;
v += dvdx; ++
line;
Q_FALLTHROUGH();
315 case 2: blender.write(
line,
reinterpret_cast<const SrcT *
>(
reinterpret_cast<const uchar *
>(srcPixels) + (
v >> 16) * sbpl)[u >> 16]); u += dudx;
v += dvdx; ++
line;
Q_FALLTHROUGH();
316 case 1: blender.write(
line,
reinterpret_cast<const SrcT *
>(
reinterpret_cast<const uchar *
>(srcPixels) + (
v >> 16) * sbpl)[u >> 16]); u += dudx;
v += dvdx; ++
line;
322 qint64 uu =
qBound(sourceRectLeft, u >> 16, sourceRectLeft + sourceRectWidth - 1);
323 qint64 vv =
qBound(sourceRectTop,
v >> 16, sourceRectTop + sourceRectHeight - 1);
324 blender.write(
line,
reinterpret_cast<const SrcT *
>(
reinterpret_cast<const uchar *
>(srcPixels) + vv * sbpl)[uu]);
338template <
class SrcT,
class DestT,
class Blender>
340 const SrcT *srcPixels,
int sbpl,
359 v[TopRight].u =
v[BottomRight].u = sourceRect.
right();
361 targetRectTransform.map(targetRect.left(), targetRect.top(), &
v[
TopLeft].x, &
v[
TopLeft].y);
362 targetRectTransform.map(targetRect.right(), targetRect.top(), &
v[TopRight].x, &
v[TopRight].y);
364 targetRectTransform.map(targetRect.right(), targetRect.bottom(), &
v[BottomRight].x, &
v[BottomRight].y);
368 for (
int i = 1;
i < 4; ++
i) {
369 if (
v[
i].
y <
v[topmost].
y)
377 for (
int i = 0;
i < 3; ++
i)
389 for (
int i = 3;
i > 0; --
i)
401 if (dx1 * dy2 - dx2 * dy1 > 0)
411 qreal invDet = 1.0 / det;
412 qreal m11, m12, m21, m22, mdx, mdy;
414 m11 = (u.
u *
w.y - u.
y *
w.u) * invDet;
415 m12 = (u.
x *
w.u - u.
u *
w.x) * invDet;
416 m21 = (u.
v *
w.y - u.
y *
w.v) * invDet;
417 m22 = (u.
x *
w.v - u.
v *
w.x) * invDet;
418 mdx =
v[0].u - m11 *
v[0].x - m12 *
v[0].y;
419 mdy =
v[0].v - m21 *
v[0].x - m22 *
v[0].y;
421 int dudx = int(m11 * 0x10000);
422 int dvdx = int(m21 * 0x10000);
423 int dudy = int(m12 * 0x10000);
424 int dvdy = int(m22 * 0x10000);
425 int u0 =
qCeil((
qreal(0.5) * m11 +
qreal(0.5) * m12 + mdx) * 0x10000) - 1;
435 if (
v[1].
y <
v[3].
y) {
436 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);
437 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);
438 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);
440 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);
441 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);
442 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);
\inmodule QtCore\reentrant
constexpr qreal bottom() const noexcept
Returns the y-coordinate of the rectangle's bottom edge.
constexpr qreal left() const noexcept
Returns the x-coordinate of the rectangle's left edge.
constexpr qreal top() const noexcept
Returns the y-coordinate of the rectangle's top edge.
constexpr qreal right() const noexcept
Returns the x-coordinate of the rectangle's right edge.
\inmodule QtCore\reentrant
constexpr int height() const noexcept
Returns the height of the rectangle.
constexpr int top() const noexcept
Returns the y-coordinate of the rectangle's top edge.
constexpr int left() const noexcept
Returns the x-coordinate of the rectangle's left edge.
constexpr int width() const noexcept
Returns the width of the rectangle.
Combined button and popup list for selecting options.
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)
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)
QT_BEGIN_NAMESPACE void qt_scale_image_16bit(uchar *destPixels, int dbpl, const uchar *srcPixels, int sbpl, int srch, const QRectF &targetRect, const QRectF &srcRect, const QRect &clip, T blender)
void qt_scale_image_32bit(uchar *destPixels, int dbpl, const uchar *srcPixels, int sbpl, int srch, const QRectF &targetRect, const QRectF &srcRect, const QRect &clip, T blender)
int qRound(qfloat16 d) noexcept
constexpr const T & qMin(const T &a, const T &b)
constexpr const T & qBound(const T &min, const T &val, const T &max)
constexpr const T & qMax(const T &a, const T &b)
GLsizei const GLfloat * v
[13]
GLint GLint GLint GLint GLint x
[0]
GLfloat GLfloat GLfloat w
[0]
GLuint GLfloat GLfloat GLfloat GLfloat y1
GLuint GLfloat GLfloat GLfloat x1
GLfloat GLfloat GLfloat GLfloat h
GLfixed GLfixed GLfixed y2
QT_BEGIN_NAMESPACE constexpr void qSwap(T &value1, T &value2) noexcept(std::is_nothrow_swappable_v< T >)