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