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