Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qdrawhelper_p.h
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QDRAWHELPER_P_H
5#define QDRAWHELPER_P_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <QtGui/private/qtguiglobal_p.h>
19#include "QtCore/qmath.h"
20#include "QtGui/qcolor.h"
21#include "QtGui/qpainter.h"
22#include "QtGui/qimage.h"
23#include "QtGui/qrgba64.h"
24#ifndef QT_FT_BEGIN_HEADER
25#define QT_FT_BEGIN_HEADER
26#define QT_FT_END_HEADER
27#endif
28#include "private/qpixellayout_p.h"
29#include "private/qrasterdefs_p.h"
30#include <private/qsimd_p.h>
31
32#include <memory>
33#include <variant> // std::monostate
34
35QT_BEGIN_NAMESPACE
36
37#if defined(Q_CC_GNU)
38# define Q_DECL_RESTRICT __restrict__
39# if defined(Q_PROCESSOR_X86_32) && defined(Q_CC_GNU) && !defined(Q_CC_CLANG)
40# define Q_DECL_VECTORCALL __attribute__((sseregparm,regparm(3)))
41# else
42# define Q_DECL_VECTORCALL
43# endif
44#elif defined(Q_CC_MSVC)
45# define Q_DECL_RESTRICT __restrict
46# define Q_DECL_VECTORCALL __vectorcall
47#else
48# define Q_DECL_RESTRICT
49# define Q_DECL_VECTORCALL
50#endif
51
52static const uint AMASK = 0xff000000;
53static const uint RMASK = 0x00ff0000;
54static const uint GMASK = 0x0000ff00;
55static const uint BMASK = 0x000000ff;
56
57struct QSolidData;
58struct QTextureData;
59struct QGradientData;
63struct QSpanData;
64class QGradient;
65class QRasterBuffer;
66class QClipData;
68
69template<typename F> class QRgbaFloat;
70typedef QRgbaFloat<float> QRgbaFloat32;
71
73typedef void (*BitmapBlitFunc)(QRasterBuffer *rasterBuffer,
74 int x, int y, const QRgba64 &color,
75 const uchar *bitmap,
76 int mapWidth, int mapHeight, int mapStride);
77
78typedef void (*AlphamapBlitFunc)(QRasterBuffer *rasterBuffer,
79 int x, int y, const QRgba64 &color,
80 const uchar *bitmap,
81 int mapWidth, int mapHeight, int mapStride,
82 const QClipData *clip, bool useGammaCorrection);
83
84typedef void (*AlphaRGBBlitFunc)(QRasterBuffer *rasterBuffer,
85 int x, int y, const QRgba64 &color,
86 const uint *rgbmask,
87 int mapWidth, int mapHeight, int mapStride,
88 const QClipData *clip, bool useGammaCorrection);
89
90typedef void (*RectFillFunc)(QRasterBuffer *rasterBuffer,
91 int x, int y, int width, int height,
92 const QRgba64 &color);
93
94typedef void (*SrcOverBlendFunc)(uchar *destPixels, int dbpl,
95 const uchar *src, int spbl,
96 int w, int h,
97 int const_alpha);
98
99typedef void (*SrcOverScaleFunc)(uchar *destPixels, int dbpl,
100 const uchar *src, int spbl, int srch,
101 const QRectF &targetRect,
102 const QRectF &sourceRect,
103 const QRect &clipRect,
104 int const_alpha);
105
106typedef void (*SrcOverTransformFunc)(uchar *destPixels, int dbpl,
107 const uchar *src, int spbl,
108 const QRectF &targetRect,
109 const QRectF &sourceRect,
110 const QRect &clipRect,
111 const QTransform &targetRectTransform,
112 int const_alpha);
113
121
122extern SrcOverBlendFunc qBlendFunctions[QImage::NImageFormats][QImage::NImageFormats];
123extern SrcOverScaleFunc qScaleFunctions[QImage::NImageFormats][QImage::NImageFormats];
124extern SrcOverTransformFunc qTransformFunctions[QImage::NImageFormats][QImage::NImageFormats];
125
126extern DrawHelper qDrawHelper[QImage::NImageFormats];
127
128struct quint24 {
129 quint24() = default;
130 quint24(uint value)
131 {
132 data[0] = uchar(value >> 16);
133 data[1] = uchar(value >> 8);
134 data[2] = uchar(value);
135 }
136 operator uint() const
137 {
138 return data[2] | (data[1] << 8) | (data[0] << 16);
139 }
140
141 uchar data[3];
142};
143
144void qBlendGradient(int count, const QT_FT_Span *spans, void *userData);
145void qBlendTexture(int count, const QT_FT_Span *spans, void *userData);
146#if defined(Q_PROCESSOR_X86) || defined(QT_COMPILER_SUPPORTS_LSX)
147extern void (*qt_memfill64)(quint64 *dest, quint64 value, qsizetype count);
148extern void (*qt_memfill32)(quint32 *dest, quint32 value, qsizetype count);
149#else
150extern void qt_memfill64(quint64 *dest, quint64 value, qsizetype count);
151extern void qt_memfill32(quint32 *dest, quint32 value, qsizetype count);
152#endif
153extern void qt_memfill24(quint24 *dest, quint24 value, qsizetype count);
154extern void qt_memfill16(quint16 *dest, quint16 value, qsizetype count);
155
156typedef void (QT_FASTCALL *CompositionFunction)(uint *Q_DECL_RESTRICT dest, const uint *Q_DECL_RESTRICT src, int length, uint const_alpha);
157typedef void (QT_FASTCALL *CompositionFunction64)(QRgba64 *Q_DECL_RESTRICT dest, const QRgba64 *Q_DECL_RESTRICT src, int length, uint const_alpha);
158typedef void (QT_FASTCALL *CompositionFunctionFP)(QRgbaFloat32 *Q_DECL_RESTRICT dest, const QRgbaFloat32 *Q_DECL_RESTRICT src, int length, uint const_alpha);
159typedef void (QT_FASTCALL *CompositionFunctionSolid)(uint *dest, int length, uint color, uint const_alpha);
160typedef void (QT_FASTCALL *CompositionFunctionSolid64)(QRgba64 *dest, int length, QRgba64 color, uint const_alpha);
161typedef void (QT_FASTCALL *CompositionFunctionSolidFP)(QRgbaFloat32 *dest, int length, QRgbaFloat32 color, uint const_alpha);
162
170
180
181struct Operator;
182typedef uint* (QT_FASTCALL *DestFetchProc)(uint *buffer, QRasterBuffer *rasterBuffer, int x, int y, int length);
183typedef QRgba64* (QT_FASTCALL *DestFetchProc64)(QRgba64 *buffer, QRasterBuffer *rasterBuffer, int x, int y, int length);
184typedef QRgbaFloat32* (QT_FASTCALL *DestFetchProcFP)(QRgbaFloat32 *buffer, QRasterBuffer *rasterBuffer, int x, int y, int length);
185typedef void (QT_FASTCALL *DestStoreProc)(QRasterBuffer *rasterBuffer, int x, int y, const uint *buffer, int length);
186typedef void (QT_FASTCALL *DestStoreProc64)(QRasterBuffer *rasterBuffer, int x, int y, const QRgba64 *buffer, int length);
187typedef void (QT_FASTCALL *DestStoreProcFP)(QRasterBuffer *rasterBuffer, int x, int y, const QRgbaFloat32 *buffer, int length);
188typedef const uint* (QT_FASTCALL *SourceFetchProc)(uint *buffer, const Operator *o, const QSpanData *data, int y, int x, int length);
189typedef const QRgba64* (QT_FASTCALL *SourceFetchProc64)(QRgba64 *buffer, const Operator *o, const QSpanData *data, int y, int x, int length);
190typedef const QRgbaFloat32* (QT_FASTCALL *SourceFetchProcFP)(QRgbaFloat32 *buffer, const Operator *o, const QSpanData *data, int y, int x, int length);
191
219
221
223{
224 struct {
227 } origin;
228 struct {
229 qreal x;
230 qreal y;
231 } end;
232};
233
235{
236 struct {
240 } center;
241 struct {
242 qreal x;
243 qreal y;
244 qreal radius;
245 } focal;
246};
247
249{
250 struct {
253 } center;
255};
256
258{
260
261 union {
265 };
266
267#define GRADIENT_STOPTABLE_SIZE 1024
268#define GRADIENT_STOPTABLE_SIZE_SHIFT 10
269
270#if QT_CONFIG(raster_64bit) || QT_CONFIG(raster_fp)
271 const QRgba64 *colorTable64; //[GRADIENT_STOPTABLE_SIZE];
272#endif
273 const QRgb *colorTable32; //[GRADIENT_STOPTABLE_SIZE];
274
275 uint alphaColor : 1;
276};
277
279{
281 const uchar *scanLine(int y) const { return imageData + y*bytesPerLine; }
282
283 int width;
285 // clip rect
286 int x1;
287 int y1;
288 int x2;
289 int y2;
301};
302
304{
305 QSpanData() : tempImage(nullptr) {}
306 ~QSpanData() { delete tempImage; }
307
315 qreal m11, m12, m13, m21, m22, m23, m33, dx, dy; // inverse xform matrix
325 signed int txop : 8;
326 uint fast_matrix : 1;
330 union {
333 };
334 std::shared_ptr<const void> cachedGradient;
335
336
337 void init(QRasterBuffer *rb, const QRasterPaintEngine *pe);
338 void setup(const QBrush &brush, int alpha, QPainter::CompositionMode compositionMode, bool isCosmetic);
339 void setupMatrix(const QTransform &matrix, int bilinear);
340 void initTexture(const QImage *image, int alpha, QTextureData::Type = QTextureData::Plain, const QRect &sourceRect = QRect());
341 void adjustSpanMethods();
342};
343
344static inline uint qt_gradient_clamp(const QGradientData *data, int ipos)
345{
346 if (ipos < 0 || ipos >= GRADIENT_STOPTABLE_SIZE) {
347 if (data->spread == QGradient::RepeatSpread) {
348 ipos = ipos % GRADIENT_STOPTABLE_SIZE;
349 ipos = ipos < 0 ? GRADIENT_STOPTABLE_SIZE + ipos : ipos;
350 } else if (data->spread == QGradient::ReflectSpread) {
351 const int limit = GRADIENT_STOPTABLE_SIZE * 2;
352 ipos = ipos % limit;
353 ipos = ipos < 0 ? limit + ipos : ipos;
354 ipos = ipos >= GRADIENT_STOPTABLE_SIZE ? limit - 1 - ipos : ipos;
355 } else {
356 if (ipos < 0)
357 ipos = 0;
358 else if (ipos >= GRADIENT_STOPTABLE_SIZE)
360 }
361 }
362
363 Q_ASSERT(ipos >= 0);
364 Q_ASSERT(ipos < GRADIENT_STOPTABLE_SIZE);
365
366 return ipos;
367}
368
369static inline uint qt_gradient_pixel(const QGradientData *data, qreal pos)
370{
371 int ipos = int(pos * (GRADIENT_STOPTABLE_SIZE - 1) + qreal(0.5));
372 return data->colorTable32[qt_gradient_clamp(data, ipos)];
373}
374
375#if QT_CONFIG(raster_64bit)
376static inline const QRgba64& qt_gradient_pixel64(const QGradientData *data, qreal pos)
377{
378 int ipos = int(pos * (GRADIENT_STOPTABLE_SIZE - 1) + qreal(0.5));
379 return data->colorTable64[qt_gradient_clamp(data, ipos)];
380}
381#endif
382
383static inline qreal qRadialDeterminant(qreal a, qreal b, qreal c)
384{
385 return (b * b) - (4 * a * c);
386}
387
388template <class RadialFetchFunc, typename BlendType> static
389const BlendType * QT_FASTCALL qt_fetch_radial_gradient_template(BlendType *buffer, const Operator *op,
390 const QSpanData *data, int y, int x, int length)
391{
392 // avoid division by zero
393 if (qFuzzyIsNull(op->radial.a)) {
394 RadialFetchFunc::memfill(buffer, RadialFetchFunc::null(), length);
395 return buffer;
396 }
397
398 const BlendType *beginOfBuffer = buffer;
399 qreal rx = data->m21 * (y + qreal(0.5))
400 + data->dx + data->m11 * (x + qreal(0.5));
401 qreal ry = data->m22 * (y + qreal(0.5))
402 + data->dy + data->m12 * (x + qreal(0.5));
403 bool affine = !data->m13 && !data->m23;
404
405 BlendType *end = buffer + length;
406 qreal inv_a = 1 / qreal(2 * op->radial.a);
407
408 if (affine) {
409 rx -= data->gradient.radial.focal.x;
410 ry -= data->gradient.radial.focal.y;
411
412 const qreal delta_rx = data->m11;
413 const qreal delta_ry = data->m12;
414
415 qreal b = 2*(op->radial.dr*data->gradient.radial.focal.radius + rx * op->radial.dx + ry * op->radial.dy);
416 qreal delta_b = 2*(delta_rx * op->radial.dx + delta_ry * op->radial.dy);
417 const qreal b_delta_b = 2 * b * delta_b;
418 const qreal delta_b_delta_b = 2 * delta_b * delta_b;
419
420 const qreal bb = b * b;
421 const qreal delta_bb = delta_b * delta_b;
422
423 b *= inv_a;
424 delta_b *= inv_a;
425
426 const qreal rxrxryry = rx * rx + ry * ry;
427 const qreal delta_rxrxryry = delta_rx * delta_rx + delta_ry * delta_ry;
428 const qreal rx_plus_ry = 2*(rx * delta_rx + ry * delta_ry);
429 const qreal delta_rx_plus_ry = 2 * delta_rxrxryry;
430
431 inv_a *= inv_a;
432
433 qreal det = (bb - 4 * op->radial.a * (op->radial.sqrfr - rxrxryry)) * inv_a;
434 qreal delta_det = (b_delta_b + delta_bb + 4 * op->radial.a * (rx_plus_ry + delta_rxrxryry)) * inv_a;
435 const qreal delta_delta_det = (delta_b_delta_b + 4 * op->radial.a * delta_rx_plus_ry) * inv_a;
436
437 if (std::isfinite(float(det)) && std::isfinite(float(delta_det))
438 && std::isfinite(float(delta_delta_det)))
439 RadialFetchFunc::fetch(buffer, end, op, data, det, delta_det, delta_delta_det, b, delta_b);
440 else
441 RadialFetchFunc::memfill(buffer, RadialFetchFunc::null(), length);
442 } else {
443 qreal rw = data->m23 * (y + qreal(0.5))
444 + data->m33 + data->m13 * (x + qreal(0.5));
445
446 while (buffer < end) {
447 if (rw == 0) {
448 *buffer = RadialFetchFunc::null();
449 } else {
450 qreal invRw = 1 / rw;
451 qreal gx = rx * invRw - data->gradient.radial.focal.x;
452 qreal gy = ry * invRw - data->gradient.radial.focal.y;
453 qreal b = 2*(op->radial.dr*data->gradient.radial.focal.radius + gx*op->radial.dx + gy*op->radial.dy);
454 qreal det = qRadialDeterminant(op->radial.a, b, op->radial.sqrfr - (gx*gx + gy*gy));
455
456 BlendType result = RadialFetchFunc::null();
457 if (det >= 0) {
458 qreal detSqrt = qSqrt(det);
459
460 qreal s0 = (-b - detSqrt) * inv_a;
461 qreal s1 = (-b + detSqrt) * inv_a;
462
463 qreal s = qMax(s0, s1);
464
465 if (data->gradient.radial.focal.radius + op->radial.dr * s >= 0)
466 result = RadialFetchFunc::fetchSingle(data->gradient, s);
467 }
468
469 *buffer = result;
470 }
471
472 rx += data->m11;
473 ry += data->m12;
474 rw += data->m13;
475
476 ++buffer;
477 }
478 }
479
480 return beginOfBuffer;
481}
482
483template <class Simd>
485{
486public:
487 static uint null() { return 0; }
488 static uint fetchSingle(const QGradientData& gradient, qreal v)
489 {
490 return qt_gradient_pixel(&gradient, v);
491 }
492 static void memfill(uint *buffer, uint fill, int length)
493 {
494 qt_memfill32(buffer, fill, length);
495 }
496 static void fetch(uint *buffer, uint *end, const Operator *op, const QSpanData *data, qreal det,
497 qreal delta_det, qreal delta_delta_det, qreal b, qreal delta_b)
498 {
499 typename Simd::Vect_buffer_f det_vec;
500 typename Simd::Vect_buffer_f delta_det4_vec;
501 typename Simd::Vect_buffer_f b_vec;
502
503 for (int i = 0; i < 4; ++i) {
504 det_vec.f[i] = det;
505 delta_det4_vec.f[i] = 4 * delta_det;
506 b_vec.f[i] = b;
507
508 det += delta_det;
509 delta_det += delta_delta_det;
510 b += delta_b;
511 }
512
513 const typename Simd::Float32x4 v_delta_delta_det16 = Simd::v_dup(16 * delta_delta_det);
514 const typename Simd::Float32x4 v_delta_delta_det6 = Simd::v_dup(6 * delta_delta_det);
515 const typename Simd::Float32x4 v_delta_b4 = Simd::v_dup(4 * delta_b);
516
517 const typename Simd::Float32x4 v_r0 = Simd::v_dup(data->gradient.radial.focal.radius);
518 const typename Simd::Float32x4 v_dr = Simd::v_dup(op->radial.dr);
519
520#if defined(__ARM_NEON__)
521 // NEON doesn't have SIMD sqrt, but uses rsqrt instead that can't be taken of 0.
522 const typename Simd::Float32x4 v_min = Simd::v_dup(std::numeric_limits<float>::epsilon());
523#else
524 const typename Simd::Float32x4 v_min = Simd::v_dup(0.0f);
525#endif
526 const typename Simd::Float32x4 v_max = Simd::v_dup(float(GRADIENT_STOPTABLE_SIZE-1));
527 const typename Simd::Float32x4 v_half = Simd::v_dup(0.5f);
528
529 const typename Simd::Int32x4 v_repeat_mask = Simd::v_dup(~(uint(0xffffff) << GRADIENT_STOPTABLE_SIZE_SHIFT));
530 const typename Simd::Int32x4 v_reflect_mask = Simd::v_dup(~(uint(0xffffff) << (GRADIENT_STOPTABLE_SIZE_SHIFT+1)));
531
532 const typename Simd::Int32x4 v_reflect_limit = Simd::v_dup(2 * GRADIENT_STOPTABLE_SIZE - 1);
533
534 const int extended_mask = op->radial.extended ? 0x0 : ~0x0;
535
536#define FETCH_RADIAL_LOOP_PROLOGUE
537 while (buffer < end) {
538 typename Simd::Vect_buffer_i v_buffer_mask;
539 v_buffer_mask.v = Simd::v_greaterOrEqual(det_vec.v, v_min);
540 const typename Simd::Float32x4 v_index_local = Simd::v_sub(Simd::v_sqrt(Simd::v_max(v_min, det_vec.v)), b_vec.v);
541 const typename Simd::Float32x4 v_index = Simd::v_add(Simd::v_mul(v_index_local, v_max), v_half);
542 v_buffer_mask.v = Simd::v_and(v_buffer_mask.v, Simd::v_greaterOrEqual(Simd::v_add(v_r0, Simd::v_mul(v_dr, v_index_local)), v_min));
543 typename Simd::Vect_buffer_i index_vec;
544#define FETCH_RADIAL_LOOP_CLAMP_REPEAT
545 index_vec.v = Simd::v_and(v_repeat_mask, Simd::v_toInt(v_index));
546#define FETCH_RADIAL_LOOP_CLAMP_REFLECT
547 const typename Simd::Int32x4 v_index_i = Simd::v_and(v_reflect_mask, Simd::v_toInt(v_index));
548 const typename Simd::Int32x4 v_index_i_inv = Simd::v_sub(v_reflect_limit, v_index_i);
549 index_vec.v = Simd::v_min_16(v_index_i, v_index_i_inv);
550#define FETCH_RADIAL_LOOP_CLAMP_PAD
551 index_vec.v = Simd::v_toInt(Simd::v_min(v_max, Simd::v_max(v_min, v_index)));
552#define FETCH_RADIAL_LOOP_EPILOGUE
553 det_vec.v = Simd::v_add(Simd::v_add(det_vec.v, delta_det4_vec.v), v_delta_delta_det6);
554 delta_det4_vec.v = Simd::v_add(delta_det4_vec.v, v_delta_delta_det16);
555 b_vec.v = Simd::v_add(b_vec.v, v_delta_b4);
556 for (int i = 0; i < 4; ++i)
557 *buffer++ = (extended_mask | v_buffer_mask.i[i]) & data->gradient.colorTable32[index_vec.i[i]];
558 }
559
560#define FETCH_RADIAL_LOOP(FETCH_RADIAL_LOOP_CLAMP)
562 FETCH_RADIAL_LOOP_CLAMP
564
565 switch (data->gradient.spread) {
566 case QGradient::RepeatSpread:
568 break;
569 case QGradient::ReflectSpread:
571 break;
572 case QGradient::PadSpread:
574 break;
575 default:
576 Q_UNREACHABLE();
577 }
578 }
579};
580
581static inline uint INTERPOLATE_PIXEL_255(uint x, uint a, uint y, uint b) {
582 uint t = (x & 0xff00ff) * a + (y & 0xff00ff) * b;
583 t = (t + ((t >> 8) & 0xff00ff) + 0x800080) >> 8;
584 t &= 0xff00ff;
585
586 x = ((x >> 8) & 0xff00ff) * a + ((y >> 8) & 0xff00ff) * b;
587 x = (x + ((x >> 8) & 0xff00ff) + 0x800080);
588 x &= 0xff00ff00;
589 x |= t;
590 return x;
591}
592
593#if Q_PROCESSOR_WORDSIZE == 8 // 64-bit versions
594
595static inline uint INTERPOLATE_PIXEL_256(uint x, uint a, uint y, uint b) {
596 quint64 t = (((quint64(x)) | ((quint64(x)) << 24)) & 0x00ff00ff00ff00ff) * a;
597 t += (((quint64(y)) | ((quint64(y)) << 24)) & 0x00ff00ff00ff00ff) * b;
598 t >>= 8;
599 t &= 0x00ff00ff00ff00ff;
600 return (uint(t)) | (uint(t >> 24));
601}
602
603static inline uint BYTE_MUL(uint x, uint a) {
604 quint64 t = (((quint64(x)) | ((quint64(x)) << 24)) & 0x00ff00ff00ff00ff) * a;
605 t = (t + ((t >> 8) & 0xff00ff00ff00ff) + 0x80008000800080) >> 8;
606 t &= 0x00ff00ff00ff00ff;
607 return (uint(t)) | (uint(t >> 24));
608}
609
610#else // 32-bit versions
611
612static inline uint INTERPOLATE_PIXEL_256(uint x, uint a, uint y, uint b) {
613 uint t = (x & 0xff00ff) * a + (y & 0xff00ff) * b;
614 t >>= 8;
615 t &= 0xff00ff;
616
617 x = ((x >> 8) & 0xff00ff) * a + ((y >> 8) & 0xff00ff) * b;
618 x &= 0xff00ff00;
619 x |= t;
620 return x;
621}
622
623static inline uint BYTE_MUL(uint x, uint a) {
624 uint t = (x & 0xff00ff) * a;
625 t = (t + ((t >> 8) & 0xff00ff) + 0x800080) >> 8;
626 t &= 0xff00ff;
627
628 x = ((x >> 8) & 0xff00ff) * a;
629 x = (x + ((x >> 8) & 0xff00ff) + 0x800080);
630 x &= 0xff00ff00;
631 x |= t;
632 return x;
633}
634#endif
635
636static inline void blend_pixel(quint32 &dst, const quint32 src)
637{
638 if (src >= 0xff000000)
639 dst = src;
640 else if (src != 0)
641 dst = src + BYTE_MUL(dst, qAlpha(~src));
642}
643
644static inline void blend_pixel(quint32 &dst, const quint32 src, const int const_alpha)
645{
646 if (const_alpha == 255)
647 return blend_pixel(dst, src);
648 if (src != 0) {
649 const quint32 s = BYTE_MUL(src, const_alpha);
650 dst = s + BYTE_MUL(dst, qAlpha(~s));
651 }
652}
653
654#if defined(__SSE2__)
655static inline uint Q_DECL_VECTORCALL interpolate_4_pixels_sse2(__m128i vt, __m128i vb, uint distx, uint disty)
656{
657 // First interpolate top and bottom pixels in parallel.
658 vt = _mm_unpacklo_epi8(vt, _mm_setzero_si128());
659 vb = _mm_unpacklo_epi8(vb, _mm_setzero_si128());
660 vt = _mm_mullo_epi16(vt, _mm_set1_epi16(256 - disty));
661 vb = _mm_mullo_epi16(vb, _mm_set1_epi16(disty));
662 __m128i vlr = _mm_add_epi16(vt, vb);
663 vlr = _mm_srli_epi16(vlr, 8);
664 // vlr now contains the result of the first two interpolate calls vlr = unpacked((xright << 64) | xleft)
665
666 // Now the last interpolate between left and right..
667 const __m128i vidistx = _mm_shufflelo_epi16(_mm_cvtsi32_si128(256 - distx), _MM_SHUFFLE(0, 0, 0, 0));
668 const __m128i vdistx = _mm_shufflelo_epi16(_mm_cvtsi32_si128(distx), _MM_SHUFFLE(0, 0, 0, 0));
669 const __m128i vmulx = _mm_unpacklo_epi16(vidistx, vdistx);
670 vlr = _mm_unpacklo_epi16(vlr, _mm_srli_si128(vlr, 8));
671 // vlr now contains the colors of left and right interleaved { la, ra, lr, rr, lg, rg, lb, rb }
672 vlr = _mm_madd_epi16(vlr, vmulx); // Multiply and horizontal add.
673 vlr = _mm_srli_epi32(vlr, 8);
674 vlr = _mm_packs_epi32(vlr, vlr);
675 vlr = _mm_packus_epi16(vlr, vlr);
676 return _mm_cvtsi128_si32(vlr);
677}
678
679static inline uint interpolate_4_pixels(uint tl, uint tr, uint bl, uint br, uint distx, uint disty)
680{
681 __m128i vt = _mm_unpacklo_epi32(_mm_cvtsi32_si128(tl), _mm_cvtsi32_si128(tr));
682 __m128i vb = _mm_unpacklo_epi32(_mm_cvtsi32_si128(bl), _mm_cvtsi32_si128(br));
683 return interpolate_4_pixels_sse2(vt, vb, distx, disty);
684}
685
686static inline uint interpolate_4_pixels(const uint t[], const uint b[], uint distx, uint disty)
687{
688 __m128i vt = _mm_loadl_epi64((const __m128i*)t);
689 __m128i vb = _mm_loadl_epi64((const __m128i*)b);
690 return interpolate_4_pixels_sse2(vt, vb, distx, disty);
691}
692
693static constexpr inline bool hasFastInterpolate4() { return true; }
694
695#elif defined(__ARM_NEON__)
696static inline uint interpolate_4_pixels_neon(uint32x2_t vt32, uint32x2_t vb32, uint distx, uint disty)
697{
698 uint16x8_t vt16 = vmovl_u8(vreinterpret_u8_u32(vt32));
699 uint16x8_t vb16 = vmovl_u8(vreinterpret_u8_u32(vb32));
700 vt16 = vmulq_n_u16(vt16, 256 - disty);
701 vt16 = vmlaq_n_u16(vt16, vb16, disty);
702 vt16 = vshrq_n_u16(vt16, 8);
703 uint16x4_t vl16 = vget_low_u16(vt16);
704 uint16x4_t vr16 = vget_high_u16(vt16);
705 vl16 = vmul_n_u16(vl16, 256 - distx);
706 vl16 = vmla_n_u16(vl16, vr16, distx);
707 vl16 = vshr_n_u16(vl16, 8);
708 uint8x8_t vr = vmovn_u16(vcombine_u16(vl16, vl16));
709 return vget_lane_u32(vreinterpret_u32_u8(vr), 0);
710}
711
712static inline uint interpolate_4_pixels(uint tl, uint tr, uint bl, uint br, uint distx, uint disty)
713{
714 uint32x2_t vt32 = vmov_n_u32(tl);
715 uint32x2_t vb32 = vmov_n_u32(bl);
716 vt32 = vset_lane_u32(tr, vt32, 1);
717 vb32 = vset_lane_u32(br, vb32, 1);
718 return interpolate_4_pixels_neon(vt32, vb32, distx, disty);
719}
720
721static inline uint interpolate_4_pixels(const uint t[], const uint b[], uint distx, uint disty)
722{
723 uint32x2_t vt32 = vld1_u32(t);
724 uint32x2_t vb32 = vld1_u32(b);
725 return interpolate_4_pixels_neon(vt32, vb32, distx, disty);
726}
727
728static constexpr inline bool hasFastInterpolate4() { return true; }
729
730#else
731static inline uint interpolate_4_pixels(uint tl, uint tr, uint bl, uint br, uint distx, uint disty)
732{
733 uint idistx = 256 - distx;
734 uint idisty = 256 - disty;
735 uint xtop = INTERPOLATE_PIXEL_256(tl, idistx, tr, distx);
736 uint xbot = INTERPOLATE_PIXEL_256(bl, idistx, br, distx);
737 return INTERPOLATE_PIXEL_256(xtop, idisty, xbot, disty);
738}
739
740static inline uint interpolate_4_pixels(const uint t[], const uint b[], uint distx, uint disty)
741{
742 return interpolate_4_pixels(t[0], t[1], b[0], b[1], distx, disty);
743}
744
745static constexpr inline bool hasFastInterpolate4() { return false; }
746
747#endif
748
749static inline QRgba64 multiplyAlpha256(QRgba64 rgba64, uint alpha256)
750{
751 return QRgba64::fromRgba64((rgba64.red() * alpha256) >> 8,
752 (rgba64.green() * alpha256) >> 8,
753 (rgba64.blue() * alpha256) >> 8,
754 (rgba64.alpha() * alpha256) >> 8);
755}
756static inline QRgba64 interpolate256(QRgba64 x, uint alpha1, QRgba64 y, uint alpha2)
757{
758 return QRgba64::fromRgba64(multiplyAlpha256(x, alpha1) + multiplyAlpha256(y, alpha2));
759}
760
761#ifdef __SSE2__
762static inline QRgba64 interpolate_4_pixels_rgb64(const QRgba64 t[], const QRgba64 b[], uint distx, uint disty)
763{
764 __m128i vt = _mm_loadu_si128((const __m128i*)t);
765 if (disty) {
766 __m128i vb = _mm_loadu_si128((const __m128i*)b);
767 vt = _mm_mulhi_epu16(vt, _mm_set1_epi16(0x10000 - disty));
768 vb = _mm_mulhi_epu16(vb, _mm_set1_epi16(disty));
769 vt = _mm_add_epi16(vt, vb);
770 }
771 if (distx) {
772 const __m128i vdistx = _mm_shufflelo_epi16(_mm_cvtsi32_si128(distx), _MM_SHUFFLE(0, 0, 0, 0));
773 const __m128i vidistx = _mm_shufflelo_epi16(_mm_cvtsi32_si128(0x10000 - distx), _MM_SHUFFLE(0, 0, 0, 0));
774 vt = _mm_mulhi_epu16(vt, _mm_unpacklo_epi64(vidistx, vdistx));
775 vt = _mm_add_epi16(vt, _mm_srli_si128(vt, 8));
776 }
777#ifdef Q_PROCESSOR_X86_64
778 return QRgba64::fromRgba64(_mm_cvtsi128_si64(vt));
779#else
780 QRgba64 out;
781 _mm_storel_epi64((__m128i*)&out, vt);
782 return out;
783#endif // Q_PROCESSOR_X86_64
784}
785#elif defined(__ARM_NEON__)
786static inline QRgba64 interpolate_4_pixels_rgb64(const QRgba64 t[], const QRgba64 b[], uint distx, uint disty)
787{
788 uint64x1x2_t vt = vld2_u64(reinterpret_cast<const uint64_t *>(t));
789 if (disty) {
790 uint64x1x2_t vb = vld2_u64(reinterpret_cast<const uint64_t *>(b));
791 uint32x4_t vt0 = vmull_n_u16(vreinterpret_u16_u64(vt.val[0]), 0x10000 - disty);
792 uint32x4_t vt1 = vmull_n_u16(vreinterpret_u16_u64(vt.val[1]), 0x10000 - disty);
793 vt0 = vmlal_n_u16(vt0, vreinterpret_u16_u64(vb.val[0]), disty);
794 vt1 = vmlal_n_u16(vt1, vreinterpret_u16_u64(vb.val[1]), disty);
795 vt.val[0] = vreinterpret_u64_u16(vshrn_n_u32(vt0, 16));
796 vt.val[1] = vreinterpret_u64_u16(vshrn_n_u32(vt1, 16));
797 }
798 if (distx) {
799 uint32x4_t vt0 = vmull_n_u16(vreinterpret_u16_u64(vt.val[0]), 0x10000 - distx);
800 vt0 = vmlal_n_u16(vt0, vreinterpret_u16_u64(vt.val[1]), distx);
801 vt.val[0] = vreinterpret_u64_u16(vshrn_n_u32(vt0, 16));
802 }
803 QRgba64 out;
804 vst1_u64(reinterpret_cast<uint64_t *>(&out), vt.val[0]);
805 return out;
806}
807#else
808static inline QRgba64 interpolate_4_pixels_rgb64(const QRgba64 t[], const QRgba64 b[], uint distx, uint disty)
809{
810 const uint dx = distx>>8;
811 const uint dy = disty>>8;
812 const uint idx = 256 - dx;
813 const uint idy = 256 - dy;
814 QRgba64 xtop = interpolate256(t[0], idx, t[1], dx);
815 QRgba64 xbot = interpolate256(b[0], idx, b[1], dx);
816 return interpolate256(xtop, idy, xbot, dy);
817}
818#endif // __SSE2__
819
820#if QT_CONFIG(raster_fp)
821static inline QRgbaFloat32 multiplyAlpha_rgba32f(QRgbaFloat32 c, float a)
822{
823 return QRgbaFloat32 { c.r * a, c.g * a, c.b * a, c.a * a };
824}
825
826static inline QRgbaFloat32 interpolate_rgba32f(QRgbaFloat32 x, float alpha1, QRgbaFloat32 y, float alpha2)
827{
828 x = multiplyAlpha_rgba32f(x, alpha1);
829 y = multiplyAlpha_rgba32f(y, alpha2);
830 return QRgbaFloat32 { x.r + y.r, x.g + y.g, x.b + y.b, x.a + y.a };
831}
832#ifdef __SSE2__
833static inline __m128 Q_DECL_VECTORCALL interpolate_rgba32f(__m128 x, __m128 alpha1, __m128 y, __m128 alpha2)
834{
835 return _mm_add_ps(_mm_mul_ps(x, alpha1), _mm_mul_ps(y, alpha2));
836}
837#endif
838
839static inline QRgbaFloat32 interpolate_4_pixels_rgba32f(const QRgbaFloat32 t[], const QRgbaFloat32 b[], uint distx, uint disty)
840{
841 constexpr float f = 1.0f / 65536.0f;
842 const float dx = distx * f;
843 const float dy = disty * f;
844 const float idx = 1.0f - dx;
845 const float idy = 1.0f - dy;
846#ifdef __SSE2__
847 const __m128 vtl = _mm_load_ps((const float *)&t[0]);
848 const __m128 vtr = _mm_load_ps((const float *)&t[1]);
849 const __m128 vbl = _mm_load_ps((const float *)&b[0]);
850 const __m128 vbr = _mm_load_ps((const float *)&b[1]);
851
852 const __m128 vdx = _mm_set1_ps(dx);
853 const __m128 vidx = _mm_set1_ps(idx);
854 __m128 vt = interpolate_rgba32f(vtl, vidx, vtr, vdx);
855 __m128 vb = interpolate_rgba32f(vbl, vidx, vbr, vdx);
856 const __m128 vdy = _mm_set1_ps(dy);
857 const __m128 vidy = _mm_set1_ps(idy);
858 vt = interpolate_rgba32f(vt, vidy, vb, vdy);
859 QRgbaFloat32 res;
860 _mm_store_ps((float*)&res, vt);
861 return res;
862#else
863 QRgbaFloat32 xtop = interpolate_rgba32f(t[0], idx, t[1], dx);
864 QRgbaFloat32 xbot = interpolate_rgba32f(b[0], idx, b[1], dx);
865 xtop = interpolate_rgba32f(xtop, idy, xbot, dy);
866 return xtop;
867#endif
868}
869#endif // QT_CONFIG(raster_fp)
870
871static inline uint BYTE_MUL_RGB16(uint x, uint a) {
872 a += 1;
873 uint t = (((x & 0x07e0)*a) >> 8) & 0x07e0;
874 t |= (((x & 0xf81f)*(a>>2)) >> 6) & 0xf81f;
875 return t;
876}
877
878static inline uint BYTE_MUL_RGB16_32(uint x, uint a) {
879 uint t = (((x & 0xf81f07e0) >> 5)*a) & 0xf81f07e0;
880 t |= (((x & 0x07e0f81f)*a) >> 5) & 0x07e0f81f;
881 return t;
882}
883
884// qt_div_255 is a fast rounded division by 255 using an approximation that is accurate for all positive 16-bit integers
885static constexpr inline int qt_div_255(int x) { return (x + (x>>8) + 0x80) >> 8; }
886static constexpr inline uint qt_div_257_floor(uint x) { return (x - (x >> 8)) >> 8; }
887static constexpr inline uint qt_div_257(uint x) { return qt_div_257_floor(x + 128); }
888static constexpr inline uint qt_div_65535(uint x) { return (x + (x>>16) + 0x8000U) >> 16; }
889
890template <class T> inline void qt_memfill_template(T *dest, T color, qsizetype count)
891{
892 if (!count)
893 return;
894
895 qsizetype n = (count + 7) / 8;
896 switch (count & 0x07)
897 {
898 case 0: do { *dest++ = color; Q_FALLTHROUGH();
899 case 7: *dest++ = color; Q_FALLTHROUGH();
900 case 6: *dest++ = color; Q_FALLTHROUGH();
901 case 5: *dest++ = color; Q_FALLTHROUGH();
902 case 4: *dest++ = color; Q_FALLTHROUGH();
903 case 3: *dest++ = color; Q_FALLTHROUGH();
904 case 2: *dest++ = color; Q_FALLTHROUGH();
905 case 1: *dest++ = color;
906 } while (--n > 0);
907 }
908}
909
910template <class T> inline void qt_memfill(T *dest, T value, qsizetype count)
911{
912 qt_memfill_template(dest, value, count);
913}
914
915template<> inline void qt_memfill(quint64 *dest, quint64 color, qsizetype count)
916{
917 qt_memfill64(dest, color, count);
918}
919
920template<> inline void qt_memfill(quint32 *dest, quint32 color, qsizetype count)
921{
922 qt_memfill32(dest, color, count);
923}
924
925template<> inline void qt_memfill(quint24 *dest, quint24 color, qsizetype count)
926{
927 qt_memfill24(dest, color, count);
928}
929
930template<> inline void qt_memfill(quint16 *dest, quint16 color, qsizetype count)
931{
932 qt_memfill16(dest, color, count);
933}
934
935template<> inline void qt_memfill(quint8 *dest, quint8 color, qsizetype count)
936{
937 memset(dest, color, count);
938}
939
940template <class T> static
941inline void qt_rectfill(T *dest, T value,
942 int x, int y, int width, int height, qsizetype stride)
943{
944 char *d = reinterpret_cast<char*>(dest + x) + y * stride;
945 if (uint(stride) == (width * sizeof(T))) {
946 qt_memfill(reinterpret_cast<T*>(d), value, qsizetype(width) * height);
947 } else {
948 for (int j = 0; j < height; ++j) {
949 dest = reinterpret_cast<T*>(d);
950 qt_memfill(dest, value, width);
951 d += stride;
952 }
953 }
954}
955
956inline ushort qConvertRgb32To16(uint c)
957{
958 return (((c) >> 3) & 0x001f)
959 | (((c) >> 5) & 0x07e0)
960 | (((c) >> 8) & 0xf800);
961}
962
963inline QRgb qConvertRgb16To32(uint c)
964{
965 return 0xff000000
966 | ((((c) << 3) & 0xf8) | (((c) >> 2) & 0x7))
967 | ((((c) << 5) & 0xfc00) | (((c) >> 1) & 0x300))
968 | ((((c) << 8) & 0xf80000) | (((c) << 3) & 0x70000));
969}
970
971const uint qt_bayer_matrix[16][16] = {
972 { 0x1, 0xc0, 0x30, 0xf0, 0xc, 0xcc, 0x3c, 0xfc,
973 0x3, 0xc3, 0x33, 0xf3, 0xf, 0xcf, 0x3f, 0xff},
974 { 0x80, 0x40, 0xb0, 0x70, 0x8c, 0x4c, 0xbc, 0x7c,
975 0x83, 0x43, 0xb3, 0x73, 0x8f, 0x4f, 0xbf, 0x7f},
976 { 0x20, 0xe0, 0x10, 0xd0, 0x2c, 0xec, 0x1c, 0xdc,
977 0x23, 0xe3, 0x13, 0xd3, 0x2f, 0xef, 0x1f, 0xdf},
978 { 0xa0, 0x60, 0x90, 0x50, 0xac, 0x6c, 0x9c, 0x5c,
979 0xa3, 0x63, 0x93, 0x53, 0xaf, 0x6f, 0x9f, 0x5f},
980 { 0x8, 0xc8, 0x38, 0xf8, 0x4, 0xc4, 0x34, 0xf4,
981 0xb, 0xcb, 0x3b, 0xfb, 0x7, 0xc7, 0x37, 0xf7},
982 { 0x88, 0x48, 0xb8, 0x78, 0x84, 0x44, 0xb4, 0x74,
983 0x8b, 0x4b, 0xbb, 0x7b, 0x87, 0x47, 0xb7, 0x77},
984 { 0x28, 0xe8, 0x18, 0xd8, 0x24, 0xe4, 0x14, 0xd4,
985 0x2b, 0xeb, 0x1b, 0xdb, 0x27, 0xe7, 0x17, 0xd7},
986 { 0xa8, 0x68, 0x98, 0x58, 0xa4, 0x64, 0x94, 0x54,
987 0xab, 0x6b, 0x9b, 0x5b, 0xa7, 0x67, 0x97, 0x57},
988 { 0x2, 0xc2, 0x32, 0xf2, 0xe, 0xce, 0x3e, 0xfe,
989 0x1, 0xc1, 0x31, 0xf1, 0xd, 0xcd, 0x3d, 0xfd},
990 { 0x82, 0x42, 0xb2, 0x72, 0x8e, 0x4e, 0xbe, 0x7e,
991 0x81, 0x41, 0xb1, 0x71, 0x8d, 0x4d, 0xbd, 0x7d},
992 { 0x22, 0xe2, 0x12, 0xd2, 0x2e, 0xee, 0x1e, 0xde,
993 0x21, 0xe1, 0x11, 0xd1, 0x2d, 0xed, 0x1d, 0xdd},
994 { 0xa2, 0x62, 0x92, 0x52, 0xae, 0x6e, 0x9e, 0x5e,
995 0xa1, 0x61, 0x91, 0x51, 0xad, 0x6d, 0x9d, 0x5d},
996 { 0xa, 0xca, 0x3a, 0xfa, 0x6, 0xc6, 0x36, 0xf6,
997 0x9, 0xc9, 0x39, 0xf9, 0x5, 0xc5, 0x35, 0xf5},
998 { 0x8a, 0x4a, 0xba, 0x7a, 0x86, 0x46, 0xb6, 0x76,
999 0x89, 0x49, 0xb9, 0x79, 0x85, 0x45, 0xb5, 0x75},
1000 { 0x2a, 0xea, 0x1a, 0xda, 0x26, 0xe6, 0x16, 0xd6,
1001 0x29, 0xe9, 0x19, 0xd9, 0x25, 0xe5, 0x15, 0xd5},
1002 { 0xaa, 0x6a, 0x9a, 0x5a, 0xa6, 0x66, 0x96, 0x56,
1003 0xa9, 0x69, 0x99, 0x59, 0xa5, 0x65, 0x95, 0x55}
1004};
1005
1006#define ARGB_COMBINE_ALPHA(argb, alpha)
1007 ((((argb >> 24) * alpha) >> 8) << 24) | (argb & 0x00ffffff)
1008
1009
1010#if Q_PROCESSOR_WORDSIZE == 8 // 64-bit versions
1011#define AMIX(mask) (qMin(((quint64(s)&mask) + (quint64(d)&mask)), quint64(mask)))
1012#define MIX(mask) (qMin(((quint64(s)&mask) + (quint64(d)&mask)), quint64(mask)))
1013#else // 32 bits
1014// The mask for alpha can overflow over 32 bits
1015#define AMIX(mask) quint32(qMin(((quint64(s)&mask) + (quint64(d)&mask)), quint64(mask)))
1016#define MIX(mask) (qMin(((quint32(s)&mask) + (quint32(d)&mask)), quint32(mask)))
1017#endif
1018
1019inline uint comp_func_Plus_one_pixel_const_alpha(uint d, const uint s, const uint const_alpha, const uint one_minus_const_alpha)
1020{
1021 const uint result = uint(AMIX(AMASK) | MIX(RMASK) | MIX(GMASK) | MIX(BMASK));
1022 return INTERPOLATE_PIXEL_255(result, const_alpha, d, one_minus_const_alpha);
1023}
1024
1025inline uint comp_func_Plus_one_pixel(uint d, const uint s)
1026{
1027 const uint result = uint(AMIX(AMASK) | MIX(RMASK) | MIX(GMASK) | MIX(BMASK));
1028 return result;
1029}
1030
1031#undef MIX
1032#undef AMIX
1033
1034// must be multiple of 4 for easier SIMD implementations
1035static constexpr int BufferSize = 2048;
1036
1037// A buffer of intermediate results used by simple bilinear scaling.
1039{
1040 // The idea is first to do the interpolation between the row s1 and the row s2
1041 // into this intermediate buffer, then later interpolate between two pixel of this buffer.
1042 //
1043 // buffer_rb is a buffer of red-blue component of the pixel, in the form 0x00RR00BB
1044 // buffer_ag is the alpha-green component of the pixel, in the form 0x00AA00GG
1045 // +1 for the last pixel to interpolate with, and +1 for rounding errors.
1048};
1049
1050QT_END_NAMESPACE
1051
1052#endif // QDRAWHELPER_P_H
friend class QRasterPaintEngine
Definition qpainter.h:442
static uint fetchSingle(const QGradientData &gradient, qreal v)
static uint null()
SrcOverScaleFunc qScaleFunctions[QImage::NImageFormats][QImage::NImageFormats]
void qt_scale_image_argb32_on_rgb16(uchar *destPixels, int dbpl, const uchar *srcPixels, int sbpl, int srch, const QRectF &targetRect, const QRectF &sourceRect, const QRect &clip, int const_alpha)
static void qt_blend_argb32_on_argb32(uchar *destPixels, int dbpl, const uchar *srcPixels, int sbpl, int w, int h, int const_alpha)
void qInitBlendFunctions()
void qt_blend_argb32_on_rgb16_const_alpha(uchar *destPixels, int dbpl, const uchar *srcPixels, int sbpl, int w, int h, int const_alpha)
static void qt_blend_rgb32_on_rgb16(uchar *destPixels, int dbpl, const uchar *srcPixels, int sbpl, int w, int h, int const_alpha)
SrcOverTransformFunc qTransformFunctions[QImage::NImageFormats][QImage::NImageFormats]
void qt_transform_image_rgb32_on_rgb32(uchar *destPixels, int dbpl, const uchar *srcPixels, int sbpl, const QRectF &targetRect, const QRectF &sourceRect, const QRect &clip, const QTransform &targetRectTransform, int const_alpha)
void qt_scale_image_argb32_on_argb32(uchar *destPixels, int dbpl, const uchar *srcPixels, int sbpl, int srch, const QRectF &targetRect, const QRectF &sourceRect, const QRect &clip, int const_alpha)
void qt_transform_image_argb32_on_argb32(uchar *destPixels, int dbpl, const uchar *srcPixels, int sbpl, const QRectF &targetRect, const QRectF &sourceRect, const QRect &clip, const QTransform &targetRectTransform, int const_alpha)
void qt_transform_image_rgb16_on_rgb16(uchar *destPixels, int dbpl, const uchar *srcPixels, int sbpl, const QRectF &targetRect, const QRectF &sourceRect, const QRect &clip, const QTransform &targetRectTransform, int const_alpha)
void qt_transform_image_argb32_on_rgb16(uchar *destPixels, int dbpl, const uchar *srcPixels, int sbpl, const QRectF &targetRect, const QRectF &sourceRect, const QRect &clip, const QTransform &targetRectTransform, int const_alpha)
void qt_blend_rgb32_on_rgb32(uchar *destPixels, int dbpl, const uchar *srcPixels, int sbpl, int w, int h, int const_alpha)
void qt_scale_image_rgb16_on_rgb16(uchar *destPixels, int dbpl, const uchar *srcPixels, int sbpl, int srch, const QRectF &targetRect, const QRectF &sourceRect, const QRect &clip, int const_alpha)
void qt_scale_image_rgb32_on_rgb32(uchar *destPixels, int dbpl, const uchar *srcPixels, int sbpl, int srch, const QRectF &targetRect, const QRectF &sourceRect, const QRect &clip, int const_alpha)
SrcOverBlendFunc qBlendFunctions[QImage::NImageFormats][QImage::NImageFormats]
void qt_blend_rgb16_on_rgb16(uchar *dst, int dbpl, const uchar *src, int sbpl, int w, int h, int const_alpha)
static void qt_blend_argb32_on_rgb16(uchar *destPixels, int dbpl, const uchar *srcPixels, int sbpl, int w, int h, int const_alpha)
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)
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)
uint QT_FASTCALL fetch1Pixel< QPixelLayout::BPP1LSB >(const uchar *src, int index)
void qt_memfill24(quint24 *dest, quint24 value, qsizetype count)
static const uint BMASK
void(* RectFillFunc)(QRasterBuffer *rasterBuffer, int x, int y, int width, int height, const QRgba64 &color)
void qt_memfill(T *dest, T value, qsizetype count)
#define FETCH_RADIAL_LOOP_EPILOGUE
#define FETCH_RADIAL_LOOP_CLAMP_PAD
#define Q_DECL_RESTRICT
void(QT_FASTCALL * CompositionFunction)(uint *Q_DECL_RESTRICT dest, const uint *Q_DECL_RESTRICT src, int length, uint const_alpha)
#define FETCH_RADIAL_LOOP_CLAMP_REPEAT
void qt_memfill32(quint32 *dest, quint32 value, qsizetype count)
static void blend_pixel(quint32 &dst, const quint32 src, const int const_alpha)
static constexpr int BufferSize
static void qt_rectfill(T *dest, T value, int x, int y, int width, int height, qsizetype stride)
void(* SrcOverBlendFunc)(uchar *destPixels, int dbpl, const uchar *src, int spbl, int w, int h, int const_alpha)
void qt_memfill16(quint16 *dest, quint16 value, qsizetype count)
static qreal qRadialDeterminant(qreal a, qreal b, qreal c)
static void blend_pixel(quint32 &dst, const quint32 src)
static constexpr int qt_div_255(int x)
#define FETCH_RADIAL_LOOP_CLAMP_REFLECT
QT_FT_SpanFunc ProcessSpans
QRgbaFloat< float > QRgbaFloat32
void(* BitmapBlitFunc)(QRasterBuffer *rasterBuffer, int x, int y, const QRgba64 &color, const uchar *bitmap, int mapWidth, int mapHeight, int mapStride)
#define FETCH_RADIAL_LOOP(FETCH_RADIAL_LOOP_CLAMP)
DrawHelper qDrawHelper[QImage::NImageFormats]
static uint qt_gradient_pixel(const QGradientData *data, qreal pos)
static const uint RMASK
void(* AlphamapBlitFunc)(QRasterBuffer *rasterBuffer, int x, int y, const QRgba64 &color, const uchar *bitmap, int mapWidth, int mapHeight, int mapStride, const QClipData *clip, bool useGammaCorrection)
void qt_memfill(quint24 *dest, quint24 color, qsizetype count)
#define AMIX(mask)
#define MIX(mask)
static const uint GMASK
#define GRADIENT_STOPTABLE_SIZE_SHIFT
#define FETCH_RADIAL_LOOP_PROLOGUE
static uint qt_gradient_clamp(const QGradientData *data, int ipos)
void qt_memfill(quint64 *dest, quint64 color, qsizetype count)
void(* AlphaRGBBlitFunc)(QRasterBuffer *rasterBuffer, int x, int y, const QRgba64 &color, const uint *rgbmask, int mapWidth, int mapHeight, int mapStride, const QClipData *clip, bool useGammaCorrection)
#define GRADIENT_STOPTABLE_SIZE
void qBlendGradient(int count, const QT_FT_Span *spans, void *userData)
const uint qt_bayer_matrix[16][16]
void(* SrcOverScaleFunc)(uchar *destPixels, int dbpl, const uchar *src, int spbl, int srch, const QRectF &targetRect, const QRectF &sourceRect, const QRect &clipRect, int const_alpha)
void qt_memfill_template(T *dest, T color, qsizetype count)
void qBlendTexture(int count, const QT_FT_Span *spans, void *userData)
void qt_memfill64(quint64 *dest, quint64 value, qsizetype count)
void(* SrcOverTransformFunc)(uchar *destPixels, int dbpl, const uchar *src, int spbl, const QRectF &targetRect, const QRectF &sourceRect, const QRect &clipRect, const QTransform &targetRectTransform, int const_alpha)
#define Q_DECL_VECTORCALL
void write(quint32 *dst, quint32 src)
void write(quint32 *dst, quint32 src)
void write(quint16 *dst, quint32 src)
void write(quint16 *dst, quint32 src)
void write(quint16 *dst, quint16 src)
void write(quint16 *dst, quint16 src)
void write(quint32 *dst, quint32 src)
void write(quint32 *dst, quint32 src)
RectFillFunc fillRect
AlphaRGBBlitFunc alphaRGBBlit
ProcessSpans blendColor
AlphamapBlitFunc alphamapBlit
BitmapBlitFunc bitmapBlit
quint32 buffer_ag[BufferSize+2]
quint32 buffer_rb[BufferSize+2]
LinearGradientValues linear
CompositionFunction64 func64
DestStoreProcFP destStoreFP
CompositionFunctionSolidFP funcSolidFP
CompositionFunctionSolid funcSolid
DestStoreProc64 destStore64
SourceFetchProcFP srcFetchFP
DestStoreProc destStore
SourceFetchProc64 srcFetch64
QPainter::CompositionMode mode
CompositionFunction func
CompositionFunctionFP funcFP
DestFetchProcFP destFetchFP
DestFetchProc64 destFetch64
RadialGradientValues radial
SourceFetchProc srcFetch
CompositionFunctionSolid64 funcSolid64
std::monostate noGradient
DestFetchProc destFetch
QRadialGradientData radial
const QRgb * colorTable32
QLinearGradientData linear
QGradient::Spread spread
QConicalGradientData conical
AlphaRGBBlitFunc alphaRGBBlit
QRasterBuffer * rasterBuffer
void initTexture(const QImage *image, int alpha, QTextureData::Type=QTextureData::Plain, const QRect &sourceRect=QRect())
void setup(const QBrush &brush, int alpha, QPainter::CompositionMode compositionMode, bool isCosmetic)
BitmapBlitFunc bitmapBlit
std::shared_ptr< const void > cachedGradient
QImage * tempImage
QTextureData texture
signed int txop
RectFillFunc fillRect
ProcessSpans unclipped_blend
ProcessSpans blend
QColor solidColor
void init(QRasterBuffer *rb, const QRasterPaintEngine *pe)
QGradientData gradient
const QClipData * clip
AlphamapBlitFunc alphamapBlit
void setupMatrix(const QTransform &matrix, int bilinear)
QImage::Format format
const uchar * imageData
const uchar * scanLine(int y) const
const QList< QRgb > * colorTable
qsizetype bytesPerLine
quint16 bytemul(quint16 x) const
uchar alpha(uchar src) const
quint16 bytemul(quint16 spix) const
uchar alpha(uchar src) const
quint24()=default