5#include <private/qdrawhelper_loongarch64_p.h>
7#ifdef QT_COMPILER_SUPPORTS_LSX
9#include <private/qblendfunctions_p.h>
10#include <private/qdrawingprimitive_lsx_p.h>
11#include <private/qpaintengine_raster_p.h>
15void qt_blend_argb32_on_argb32_lsx(uchar *destPixels,
int dbpl,
16 const uchar *srcPixels,
int sbpl,
20 const quint32 *src = (
const quint32 *) srcPixels;
21 quint32 *dst = (quint32 *) destPixels;
22 if (const_alpha == 256) {
23 for (
int y = 0; y < h; ++y) {
24 BLEND_SOURCE_OVER_ARGB32_LSX(dst, src, w);
25 dst = (quint32 *)(((uchar *) dst) + dbpl);
26 src = (
const quint32 *)(((
const uchar *) src) + sbpl);
28 }
else if (const_alpha != 0) {
32 const_alpha = (const_alpha * 255) >> 8;
34 for (
int y = 0; y < h; ++y) {
35 BLEND_SOURCE_OVER_ARGB32_WITH_CONST_ALPHA_LSX(dst, src, w, const_alpha);
36 dst = (quint32 *)(((uchar *) dst) + dbpl);
37 src = (
const quint32 *)(((
const uchar *) src) + sbpl);
43void qt_blend_rgb32_on_rgb32(uchar *destPixels,
int dbpl,
44 const uchar *srcPixels,
int sbpl,
48void qt_blend_rgb32_on_rgb32_lsx(uchar *destPixels,
int dbpl,
49 const uchar *srcPixels,
int sbpl,
53 const quint32 *src = (
const quint32 *) srcPixels;
54 quint32 *dst = (quint32 *) destPixels;
55 if (const_alpha != 256) {
56 if (const_alpha != 0) {
57 const __m128i half = __lsx_vreplgr2vr_h(0x80);
58 const __m128i colorMask = __lsx_vreplgr2vr_w(0x00ff00ff);
60 const_alpha = (const_alpha * 255) >> 8;
61 int one_minus_const_alpha = 255 - const_alpha;
62 const __m128i constAlphaVector = __lsx_vreplgr2vr_h(const_alpha);
63 const __m128i oneMinusConstAlpha = __lsx_vreplgr2vr_h(one_minus_const_alpha);
64 for (
int y = 0; y < h; ++y) {
68 ALIGNMENT_PROLOGUE_16BYTES(dst, x, w) {
69 dst[x] = INTERPOLATE_PIXEL_255(src[x], const_alpha,
70 dst[x], one_minus_const_alpha);
73 for (; x < w-3; x += 4) {
74 __m128i srcVector = __lsx_vld(&src[x], 0);
75 __m128i dstVector = __lsx_vld(&dst[x], 0);
76 INTERPOLATE_PIXEL_255_LSX(srcVector, dstVector, constAlphaVector,
77 oneMinusConstAlpha, colorMask, half);
78 __lsx_vst(dstVector, &dst[x], 0);
80 SIMD_EPILOGUE(x, w, 3)
81 dst[x] = INTERPOLATE_PIXEL_255(src[x], const_alpha,
82 dst[x], one_minus_const_alpha);
83 dst = (quint32 *)(((uchar *) dst) + dbpl);
84 src = (
const quint32 *)(((
const uchar *) src) + sbpl);
88 qt_blend_rgb32_on_rgb32(destPixels, dbpl, srcPixels, sbpl, w, h, const_alpha);
92void QT_FASTCALL comp_func_SourceOver_lsx(uint *destPixels,
const uint *srcPixels,
93 int length, uint const_alpha)
95 Q_ASSERT(const_alpha < 256);
97 const quint32 *src = (
const quint32 *) srcPixels;
98 quint32 *dst = (quint32 *) destPixels;
100 if (const_alpha == 255) {
101 BLEND_SOURCE_OVER_ARGB32_LSX(dst, src, length);
103 BLEND_SOURCE_OVER_ARGB32_WITH_CONST_ALPHA_LSX(dst, src, length, const_alpha);
107void QT_FASTCALL comp_func_Plus_lsx(uint *dst,
const uint *src,
int length, uint const_alpha)
111 if (const_alpha == 255) {
113 ALIGNMENT_PROLOGUE_16BYTES(dst, x, length)
114 dst[x] = comp_func_Plus_one_pixel(dst[x], src[x]);
117 for (; x < length - 3; x += 4) {
118 const __m128i srcVector = __lsx_vld(&src[x], 0);
119 const __m128i dstVector = __lsx_vld(&dst[x], 0);
121 const __m128i result = __lsx_vsadd_bu(srcVector, dstVector);
122 __lsx_vst(result, &dst[x], 0);
126 SIMD_EPILOGUE(x, length, 3)
127 dst[x] = comp_func_Plus_one_pixel(dst[x], src[x]);
129 const int one_minus_const_alpha = 255 - const_alpha;
130 const __m128i constAlphaVector = __lsx_vreplgr2vr_h(const_alpha);
131 const __m128i oneMinusConstAlpha = __lsx_vreplgr2vr_h(one_minus_const_alpha);
134 ALIGNMENT_PROLOGUE_16BYTES(dst, x, length)
135 dst[x] = comp_func_Plus_one_pixel_const_alpha(dst[x], src[x],
137 one_minus_const_alpha);
139 const __m128i half = __lsx_vreplgr2vr_h(0x80);
140 const __m128i colorMask = __lsx_vreplgr2vr_w(0x00ff00ff);
142 for (; x < length - 3; x += 4) {
143 const __m128i srcVector = __lsx_vld(&src[x], 0);
144 __m128i dstVector = __lsx_vld(&dst[x], 0);
145 __m128i result = __lsx_vsadd_bu(srcVector, dstVector);
146 INTERPOLATE_PIXEL_255_LSX(result, dstVector, constAlphaVector,
147 oneMinusConstAlpha, colorMask, half);
148 __lsx_vst(dstVector, &dst[x], 0);
152 SIMD_EPILOGUE(x, length, 3)
153 dst[x] = comp_func_Plus_one_pixel_const_alpha(dst[x], src[x],
154 const_alpha, one_minus_const_alpha);
158void QT_FASTCALL comp_func_Source_lsx(uint *dst,
const uint *src,
int length, uint const_alpha)
160 if (const_alpha == 255) {
161 ::memcpy(dst, src, length *
sizeof(uint));
163 const int ialpha = 255 - const_alpha;
168 ALIGNMENT_PROLOGUE_16BYTES(dst, x, length)
169 dst[x] = INTERPOLATE_PIXEL_255(src[x], const_alpha, dst[x], ialpha);
172 const __m128i half = __lsx_vreplgr2vr_h(0x80);
173 const __m128i colorMask = __lsx_vreplgr2vr_w(0x00ff00ff);
175 const __m128i constAlphaVector = __lsx_vreplgr2vr_h(const_alpha);
176 const __m128i oneMinusConstAlpha = __lsx_vreplgr2vr_h(ialpha);
177 for (; x < length - 3; x += 4) {
178 const __m128i srcVector = __lsx_vld(&src[x], 0);
179 __m128i dstVector = __lsx_vld(&dst[x], 0);
180 INTERPOLATE_PIXEL_255_LSX(srcVector, dstVector, constAlphaVector,
181 oneMinusConstAlpha, colorMask, half);
182 __lsx_vst(dstVector, &dst[x], 0);
186 SIMD_EPILOGUE(x, length, 3)
187 dst[x] = INTERPOLATE_PIXEL_255(src[x], const_alpha, dst[x], ialpha);
192void Q_DECL_VECTORCALL qt_memfillXX_aligned(
void *dest, __m128i value128, quintptr bytecount)
194 __m128i *dst128 =
reinterpret_cast<__m128i *>(dest);
195 __m128i *end128 =
reinterpret_cast<__m128i *>(
static_cast<uchar *>(dest) + bytecount);
197 while (dst128 + 4 <= end128) {
198 __lsx_vst(value128, dst128 + 0, 0);
199 __lsx_vst(value128, dst128 + 1, 0);
200 __lsx_vst(value128, dst128 + 2, 0);
201 __lsx_vst(value128, dst128 + 3, 0);
205 bytecount %= 4 *
sizeof(__m128i);
206 switch (bytecount /
sizeof(__m128i)) {
207 case 3: __lsx_vst(value128, dst128++, 0); Q_FALLTHROUGH();
208 case 2: __lsx_vst(value128, dst128++, 0); Q_FALLTHROUGH();
209 case 1: __lsx_vst(value128, dst128++, 0);
213void qt_memfill64_lsx(quint64 *dest, quint64 value, qsizetype count)
215 quintptr misaligned = quintptr(dest) %
sizeof(__m128i);
216 if (misaligned && count) {
222 dest[count - 1] = value;
226 qt_memfillXX_aligned(dest, __lsx_vreplgr2vr_d(value), count *
sizeof(quint64));
229void qt_memfill32_lsx(quint32 *dest, quint32 value, qsizetype count)
235 case 3: *dest++ = value; Q_FALLTHROUGH();
236 case 2: *dest++ = value; Q_FALLTHROUGH();
237 case 1: *dest = value;
242 const int align = (quintptr)(dest) & 0xf;
244 case 4: *dest++ = value; --count; Q_FALLTHROUGH();
245 case 8: *dest++ = value; --count; Q_FALLTHROUGH();
246 case 12: *dest++ = value; --count;
249 const int rest = count & 0x3;
252 case 3: dest[count - 3] = value; Q_FALLTHROUGH();
253 case 2: dest[count - 2] = value; Q_FALLTHROUGH();
254 case 1: dest[count - 1] = value;
258 qt_memfillXX_aligned(dest, __lsx_vreplgr2vr_w(value), count *
sizeof(quint32));
261void QT_FASTCALL comp_func_solid_Source_lsx(uint *destPixels,
int length,
262 uint color, uint const_alpha)
264 if (const_alpha == 255) {
265 qt_memfill32(destPixels, color, length);
267 const quint32 ialpha = 255 - const_alpha;
268 color = BYTE_MUL(color, const_alpha);
271 quint32 *dst = (quint32 *) destPixels;
272 const __m128i colorVector = __lsx_vreplgr2vr_w(color);
273 const __m128i colorMask = __lsx_vreplgr2vr_w(0x00ff00ff);
274 const __m128i half = __lsx_vreplgr2vr_h(0x80);
275 const __m128i iAlphaVector = __lsx_vreplgr2vr_h(ialpha);
277 ALIGNMENT_PROLOGUE_16BYTES(dst, x, length)
278 destPixels[x] = color + BYTE_MUL(destPixels[x], ialpha);
280 for (; x < length-3; x += 4) {
281 __m128i dstVector = __lsx_vld(&dst[x], 0);
282 BYTE_MUL_LSX(dstVector, iAlphaVector, colorMask, half);
283 dstVector = __lsx_vadd_b(colorVector, dstVector);
284 __lsx_vst(dstVector, &dst[x], 0);
286 SIMD_EPILOGUE(x, length, 3)
287 destPixels[x] = color + BYTE_MUL(destPixels[x], ialpha);
291void QT_FASTCALL comp_func_solid_SourceOver_lsx(uint *destPixels,
int length,
292 uint color, uint const_alpha)
294 if ((const_alpha & qAlpha(color)) == 255) {
295 qt_memfill32(destPixels, color, length);
297 if (const_alpha != 255)
298 color = BYTE_MUL(color, const_alpha);
300 const quint32 minusAlphaOfColor = qAlpha(~color);
303 quint32 *dst = (quint32 *) destPixels;
304 const __m128i colorVector = __lsx_vreplgr2vr_w(color);
305 const __m128i colorMask = __lsx_vreplgr2vr_w(0x00ff00ff);
306 const __m128i half = __lsx_vreplgr2vr_h(0x80);
307 const __m128i minusAlphaOfColorVector = __lsx_vreplgr2vr_h(minusAlphaOfColor);
309 ALIGNMENT_PROLOGUE_16BYTES(dst, x, length)
310 destPixels[x] = color + BYTE_MUL(destPixels[x], minusAlphaOfColor);
312 for (; x < length-3; x += 4) {
313 __m128i dstVector = __lsx_vld(&dst[x], 0);
314 BYTE_MUL_LSX(dstVector, minusAlphaOfColorVector, colorMask, half);
315 dstVector = __lsx_vadd_b(colorVector, dstVector);
316 __lsx_vst(dstVector, &dst[x], 0);
318 SIMD_EPILOGUE(x, length, 3)
319 destPixels[x] = color + BYTE_MUL(destPixels[x], minusAlphaOfColor);
323void qt_bitmapblit32_lsx_base(QRasterBuffer *rasterBuffer,
int x,
int y,
325 const uchar *src,
int width,
int height,
int stride)
327 quint32 *dest =
reinterpret_cast<quint32*>(rasterBuffer->scanLine(y)) + x;
328 const int destStride = rasterBuffer->stride<quint32>();
330 const __m128i c128 = __lsx_vreplgr2vr_w(color);
331 const __m128i maskmask1 = (__m128i)(v4u32){0x80808080, 0x40404040,
332 0x20202020, 0x10101010};
333 const __m128i maskadd1 = (__m128i)(v4i32){0x00000000, 0x40404040,
334 0x60606060, 0x70707070};
337 const __m128i maskmask2 = (__m128i)(v4i32){0x08080808, 0x04040404,
338 0x02020202, 0x01010101};
339 const __m128i maskadd2 = (__m128i)(v4i32){0x78787878, 0x7c7c7c7c,
340 0x7e7e7e7e, 0x7f7f7f7f};
342 for (
int x = 0; x < width; x += 8) {
343 const quint8 s = src[x >> 3];
346 __m128i mask1 = __lsx_vreplgr2vr_b(s);
347 __m128i mask2 = mask1;
349 mask1 = __lsx_vand_v(mask1, maskmask1);
350 mask1 = __lsx_vadd_b(mask1, maskadd1);
352 __m128i destSrc1 = __lsx_vld((
char*)(dest + x), 0);
354 mask1 = __lsx_vslti_b(mask1,0);
355 destSrc1 = __lsx_vbitsel_v(destSrc1, c128, mask1);
356 __lsx_vst(destSrc1, (
char*)(dest + x), 0);
358 __m128i destSrc2 = __lsx_vld((
char*)(dest + x + 4), 0);
360 mask2 = __lsx_vand_v(mask2, maskmask2);
361 mask2 = __lsx_vadd_b(mask2, maskadd2);
363 mask2 = __lsx_vslti_b(mask2,0);
364 destSrc2 = __lsx_vbitsel_v(destSrc2, c128, mask2);
365 __lsx_vst(destSrc2, (
char*)(dest + x + 4), 0);
372 const quint8 s = *src;
374 __m128i mask1 = __lsx_vreplgr2vr_b(s);
376 __m128i destSrc1 = __lsx_vld((
char*)(dest), 0);
377 mask1 = __lsx_vand_v(mask1, maskmask1);
378 mask1 = __lsx_vadd_b(mask1, maskadd1);
380 mask1 = __lsx_vslti_b(mask1, 0);
381 destSrc1 = __lsx_vbitsel_v(destSrc1, c128, mask1);
382 __lsx_vst(destSrc1, (
char*)(dest), 0);
390void qt_bitmapblit32_lsx(QRasterBuffer *rasterBuffer,
int x,
int y,
391 const QRgba64 &color,
392 const uchar *src,
int width,
int height,
int stride)
394 qt_bitmapblit32_lsx_base(rasterBuffer, x, y, color.toArgb32(), src, width, height, stride);
397void qt_bitmapblit8888_lsx(QRasterBuffer *rasterBuffer,
int x,
int y,
398 const QRgba64 &color,
399 const uchar *src,
int width,
int height,
int stride)
401 qt_bitmapblit32_lsx_base(rasterBuffer, x, y, ARGB2RGBA(color.toArgb32()), src, width, height, stride);
404void qt_bitmapblit16_lsx(QRasterBuffer *rasterBuffer,
int x,
int y,
405 const QRgba64 &color,
406 const uchar *src,
int width,
int height,
int stride)
408 const quint16 c = qConvertRgb32To16(color.toArgb32());
409 quint16 *dest =
reinterpret_cast<quint16*>(rasterBuffer->scanLine(y)) + x;
410 const int destStride = rasterBuffer->stride<quint32>();
412 const __m128i c128 = __lsx_vreplgr2vr_h(c);
413 const __m128i maskmask = (__m128i)(v8u16){0x8080, 0x4040, 0x2020, 0x1010,
414 0x0808, 0x0404, 0x0202, 0x0101};
416 const __m128i maskadd = (__m128i)(v8i16){0x0000, 0x4040, 0x6060, 0x7070,
417 0x7878, 0x7c7c, 0x7e7e, 0x7f7f};
418 while (--height >= 0) {
419 for (
int x = 0; x < width; x += 8) {
420 const quint8 s = src[x >> 3];
423 __m128i mask = __lsx_vreplgr2vr_b(s);
424 __m128i destSrc = __lsx_vld((
char*)(dest + x), 0);
425 mask = __lsx_vand_v(mask, maskmask);
426 mask = __lsx_vadd_b(mask, maskadd);
427 mask = __lsx_vslti_b(mask, 0);
428 destSrc = __lsx_vbitsel_v(destSrc, c128, mask);
429 __lsx_vst(destSrc, (
char*)(dest + x), 0);
439 typedef __m128i Int32x4;
440 typedef __m128 Float32x4;
442 union Vect_buffer_i { Int32x4 v;
int i[4]; };
443 union Vect_buffer_f { Float32x4 v;
float f[4]; };
445 static inline Float32x4 Q_DECL_VECTORCALL v_dup(
float x) {
return __lsx_vreplfr2vr_s(x); }
446 static inline Float32x4 Q_DECL_VECTORCALL v_dup(
double x) {
return __lsx_vreplfr2vr_s(x); }
447 static inline Int32x4 Q_DECL_VECTORCALL v_dup(
int x) {
return __lsx_vreplgr2vr_w(x); }
448 static inline Int32x4 Q_DECL_VECTORCALL v_dup(uint x) {
return __lsx_vreplgr2vr_w(x); }
450 static inline Float32x4 Q_DECL_VECTORCALL v_add(Float32x4 a, Float32x4 b) {
return __lsx_vfadd_s(a, b); }
451 static inline Int32x4 Q_DECL_VECTORCALL v_add(Int32x4 a, Int32x4 b) {
return __lsx_vadd_w(a, b); }
453 static inline Float32x4 Q_DECL_VECTORCALL v_max(Float32x4 a, Float32x4 b) {
return __lsx_vfmax_s(a, b); }
454 static inline Float32x4 Q_DECL_VECTORCALL v_min(Float32x4 a, Float32x4 b) {
return __lsx_vfmin_s(a, b); }
455 static inline Int32x4 Q_DECL_VECTORCALL v_min_16(Int32x4 a, Int32x4 b) {
return __lsx_vmin_h(a, b); }
457 static inline Int32x4 Q_DECL_VECTORCALL v_and(Int32x4 a, Int32x4 b) {
return __lsx_vand_v(a, b); }
459 static inline Float32x4 Q_DECL_VECTORCALL v_sub(Float32x4 a, Float32x4 b) {
return __lsx_vfsub_s(a, b); }
460 static inline Int32x4 Q_DECL_VECTORCALL v_sub(Int32x4 a, Int32x4 b) {
return __lsx_vsub_w(a, b); }
462 static inline Float32x4 Q_DECL_VECTORCALL v_mul(Float32x4 a, Float32x4 b) {
return __lsx_vfmul_s(a, b); }
464 static inline Float32x4 Q_DECL_VECTORCALL v_sqrt(Float32x4 x) {
return __lsx_vfsqrt_s(x); }
466 static inline Int32x4 Q_DECL_VECTORCALL v_toInt(Float32x4 x) {
return __lsx_vftintrz_w_s(x); }
468 static inline Int32x4 Q_DECL_VECTORCALL v_greaterOrEqual(Float32x4 a, Float32x4 b) {
return __lsx_vfcmp_clt_s(b, a); }
471const uint * QT_FASTCALL qt_fetch_radial_gradient_lsx(uint *buffer,
const Operator *op,
472 const QSpanData *data,
473 int y,
int x,
int length)
475 return qt_fetch_radial_gradient_template<QRadialFetchSimd<QSimdLsx>,uint>(buffer, op, data, y, x, length);
478void qt_scale_image_argb32_on_argb32_lsx(uchar *destPixels,
int dbpl,
479 const uchar *srcPixels,
int sbpl,
int srch,
480 const QRectF &targetRect,
481 const QRectF &sourceRect,
486 if (const_alpha != 256 || !q20::in_range<int16_t>((
int)sourceRect.right()) || !q20::in_range<int16_t>((
int)sourceRect.left())) {
488 extern void qt_scale_image_argb32_on_argb32(uchar *destPixels,
int dbpl,
489 const uchar *srcPixels,
int sbpl,
int srch,
490 const QRectF &targetRect,
491 const QRectF &sourceRect,
494 return qt_scale_image_argb32_on_argb32(destPixels, dbpl, srcPixels, sbpl, srch,
495 targetRect, sourceRect, clip, const_alpha);
498 if (targetRect.width() == 0 || targetRect.height() == 0)
501 const qreal sx = sourceRect.width() / (qreal)targetRect.width();
502 const qreal sy = sourceRect.height() / (qreal)targetRect.height();
504 const int ix = 0x00010000 * sx;
505 const int64_t iy = 0x00010000 * sy;
507 QRect tr = targetRect.normalized().toRect();
508 tr = tr.intersected(clip);
511 const int tx1 = tr.left();
512 const int ty1 = tr.top();
520 int dstx = qFloor((tx1 + qreal(0.5) - targetRect.right()) * sx * 65536) + 1;
521 basex = quint32(sourceRect.right() * 65536) + dstx;
523 int dstx = qCeil((tx1 + qreal(0.5) - targetRect.left()) * sx * 65536) - 1;
524 basex = quint32(sourceRect.left() * 65536) + dstx;
527 int64_t dsty = qFloor64((ty1 + qreal(0.5) - targetRect.bottom()) * sy * 65536) + 1;
528 srcy = quint64(sourceRect.bottom() * 65536) + dsty;
530 int64_t dsty = qCeil64((ty1 + qreal(0.5) - targetRect.top()) * sy * 65536) - 1;
531 srcy = quint64(sourceRect.top() * 65536) + dsty;
534 quint32 *dst = ((quint32 *) (destPixels + qsizetype(ty1) * dbpl)) + tx1;
536 const __m128i nullVector = __lsx_vreplgr2vr_w(0);
537 const __m128i half = __lsx_vreplgr2vr_h(0x80);
538 const __m128i one = __lsx_vreplgr2vr_h(0xff);
539 const __m128i colorMask = __lsx_vreplgr2vr_w(0x00ff00ff);
540 const __m128i alphaMask = __lsx_vreplgr2vr_w(0xff000000);
541 const __m128i ixVector = __lsx_vreplgr2vr_w(4*
static_cast<
unsigned>(ix));
545 const int ystart =
static_cast<
int>(srcy >> 16);
546 if (ystart >= srch && iy < 0) {
550 const int xstart = basex >> 16;
551 if (xstart >= (
int)(sbpl/
sizeof(quint32)) && ix < 0) {
555 int yend =
static_cast<
int>((srcy + iy * (h - 1)) >> 16);
556 if (yend < 0 || yend >= srch)
558 int xend = (basex + ix * (w - 1)) >> 16;
559 if (xend < 0 || xend >= (
int)(sbpl/
sizeof(quint32)))
563 const uint *src = (
const quint32 *) (srcPixels + (srcy >> 16) * sbpl);
567 ALIGNMENT_PROLOGUE_16BYTES(dst, x, w) {
568 uint s = src[srcx >> 16];
569 dst[x] = s + BYTE_MUL(dst[x], qAlpha(~s));
573 __m128i srcxVector = (__m128i)(v4i32){srcx + ix + ix + ix, srcx + ix + ix, srcx + ix, srcx};
575 for (; x < (w - 3); x += 4) {
576 const int idx0 = __lsx_vpickve2gr_h(srcxVector, 1);
577 const int idx1 = __lsx_vpickve2gr_h(srcxVector, 3);
578 const int idx2 = __lsx_vpickve2gr_h(srcxVector, 5);
579 const int idx3 = __lsx_vpickve2gr_h(srcxVector, 7);
580 srcxVector = __lsx_vadd_w(srcxVector, ixVector);
582 const __m128i srcVector = (__m128i)((v4u32){src[idx3], src[idx2], src[idx1], src[idx0]});
584 BLEND_SOURCE_OVER_ARGB32_LSX_helper(dst, x, srcVector, nullVector, half, one, colorMask, alphaMask);
587 SIMD_EPILOGUE(x, w, 3) {
588 uint s = src[(basex + x*ix) >> 16];
589 dst[x] = s + BYTE_MUL(dst[x], qAlpha(~s));
591 dst = (quint32 *)(((uchar *) dst) + dbpl);
596const uint *QT_FASTCALL fetchPixelsBPP24_lsx(uint *buffer,
const uchar *src,
int index,
int count)
598 const quint24 *s =
reinterpret_cast<
const quint24 *>(src);
599 for (
int i = 0; i < count; ++i)
600 buffer[i] = s[index + i];
604const uint * QT_FASTCALL qt_fetchUntransformed_888_lsx(uint *buffer,
const Operator *,
605 const QSpanData *data,
606 int y,
int x,
int length)
608 const uchar *line = data->texture.scanLine(y) + x * 3;
610 extern void QT_FASTCALL qt_convert_rgb888_to_rgb32_lsx(quint32 *dst,
const uchar *src,
int len);
611 qt_convert_rgb888_to_rgb32_lsx(buffer, line, length);
615void qt_memfill24_lsx(quint24 *dest, quint24 color, qsizetype count)
619 __m128i m = __lsx_vinsgr2vr_w(__lsx_vldi(0), v, 0);
620 quint24 *end = dest + count;
622 constexpr uchar x = 2, y = 1, z = 0;
623 alignas(__m128i)
static const uchar
624 shuffleMask[16 + 1] = { x, y, z, x, y, z, x, y, z, x, y, z, x, y, z, x, y };
625 __m128i indexMask = (__m128i)(v16i8){2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17};
627 __m128i mval1 = __lsx_vshuf_b(m, m, __lsx_vld(
reinterpret_cast<
const __m128i *>(shuffleMask), 0));
628 __m128i mval2 = __lsx_vshuf_b(m, m, __lsx_vld(
reinterpret_cast<
const __m128i *>(shuffleMask + 1), 0));
629 __m128i mval3 = __lsx_vshuf_b(mval2, mval1, indexMask);
631 for ( ; dest + 16 <= end; dest += 16) {
632 __lsx_vst(mval1,
reinterpret_cast<__m128i *>(dest) + 0, 0);
633 __lsx_vst(mval2,
reinterpret_cast<__m128i *>(dest) + 1, 0);
634 __lsx_vst(mval3,
reinterpret_cast<__m128i *>(dest) + 2, 0);
646 uchar *ptr =
reinterpret_cast<uchar *>(dest);
647 uchar *ptr_end =
reinterpret_cast<uchar *>(end);
648 qptrdiff left = ptr_end - ptr;
651 __lsx_vst(mval1,
reinterpret_cast<__m128i *>(ptr) + 0, 0);
652 __lsx_vstelm_d(mval2,
reinterpret_cast<__m128i *>(ptr) + 1, 0, 0);
661 __lsx_vst(mval1,
reinterpret_cast<__m128i *>(ptr) , 0);
662 }
else if (left >= 8) {
664 __lsx_vstelm_d(mval1,
reinterpret_cast<__m128i *>(ptr), 0, 0);
670 __lsx_vstelm_d(mval2,
reinterpret_cast<__m128i *>(ptr_end - 8), 0, 0);
674void QT_FASTCALL rbSwap_888_lsx(uchar *dst,
const uchar *src,
int count)
677 const static __m128i shuffleMask1 = (__m128i)(v16i8){2, 1, 0, 5, 4, 3, 8, 7, 6, 11, 10, 9, 14, 13, 12, 15};
678 const static __m128i shuffleMask2 = (__m128i)(v16i8){0, 1, 4, 3, 2, 7, 6, 5, 10, 9, 8, 13, 12, 11, 14, 15};
679 const static __m128i shuffleMask3 = (__m128i)(v16i8){0, 3, 2, 1, 6, 5, 4, 9, 8, 7, 12, 11, 10, 15, 14, 13};
681 for (; i + 15 < count; i += 16) {
682 __m128i s1 = __lsx_vld(src, 0);
683 __m128i s2 = __lsx_vld((src + 16), 0);
684 __m128i s3 = __lsx_vld((src + 32), 0);
685 s1 = __lsx_vshuf_b(s1, s1, shuffleMask1);
686 s2 = __lsx_vshuf_b(s2, s2, shuffleMask2);
687 s3 = __lsx_vshuf_b(s3, s3, shuffleMask3);
688 __lsx_vst(s1, dst, 0);
689 __lsx_vst(s2, (dst + 16), 0);
690 __lsx_vst(s3, (dst + 32), 0);
693 std::swap(dst[15], dst[17]);
694 std::swap(dst[30], dst[32]);
701 SIMD_EPILOGUE(i, count, 15) {
709 SIMD_EPILOGUE(i, count, 15) {
710 std::swap(dst[0], dst[2]);
717static void convertARGBToARGB32PM_lsx(uint *buffer,
const uint *src,
int count)
720 const __m128i alphaMask = __lsx_vreplgr2vr_w(0xff000000);
721 const __m128i rgbaMask = (__m128i)(v16i8){2, 1, 0, 3, 6, 5, 4, 7, 10, 9, 8, 11, 14, 13, 12, 15};
722 const __m128i shuffleMask = (__m128i)(v16i8){6, 7, 6, 7, 6, 7, 6, 7, 14, 15, 14, 15, 14, 15, 14, 15};
723 const __m128i half = __lsx_vreplgr2vr_h(0x0080);
724 const __m128i zero = __lsx_vldi(0);
726 for (; i < count - 3; i += 4) {
727 __m128i srcVector = __lsx_vld(&src[i], 0);
728 const v4i32 testz = (v4i32)__lsx_vmsknz_b(__lsx_vand_v(srcVector, alphaMask));
730 const v4i32 testc = (v4i32)__lsx_vmsknz_b(__lsx_vandn_v(srcVector, alphaMask));
733 srcVector = __lsx_vshuf_b(zero, srcVector, rgbaMask);
734 __m128i src1 = __lsx_vilvl_b(zero, srcVector);
735 __m128i src2 = __lsx_vilvh_b(zero, srcVector);
736 __m128i alpha1 = __lsx_vshuf_b(zero, src1, shuffleMask);
737 __m128i alpha2 = __lsx_vshuf_b(zero, src2, shuffleMask);
738 src1 = __lsx_vmul_h(src1, alpha1);
739 src2 = __lsx_vmul_h(src2, alpha2);
740 src1 = __lsx_vadd_h(src1, __lsx_vsrli_h(src1, 8));
741 src2 = __lsx_vadd_h(src2, __lsx_vsrli_h(src2, 8));
742 src1 = __lsx_vadd_h(src1, half);
743 src2 = __lsx_vadd_h(src2, half);
744 src1 = __lsx_vsrli_h(src1, 8);
745 src2 = __lsx_vsrli_h(src2, 8);
746 __m128i blendMask = (__m128i)(v8i16){0, 1, 2, 11, 4, 5, 6, 15};
747 src1 = __lsx_vshuf_h(blendMask, alpha1, src1);
748 src2 = __lsx_vshuf_h(blendMask, alpha2, src2);
749 src1 = __lsx_vmaxi_h(src1, 0);
750 src2 = __lsx_vmaxi_h(src2, 0);
751 srcVector = __lsx_vpickev_b(__lsx_vsat_hu(src2, 7), __lsx_vsat_hu(src1, 7));
752 __lsx_vst(srcVector, &buffer[i], 0);
755 __lsx_vst(__lsx_vshuf_b(zero, srcVector, rgbaMask), &buffer[i], 0);
756 else if (buffer != src)
757 __lsx_vst(srcVector, &buffer[i], 0);
760 __lsx_vst(zero, &buffer[i], 0);
764 SIMD_EPILOGUE(i, count, 3) {
765 uint v = qPremultiply(src[i]);
766 buffer[i] = RGBA ? RGBA2ARGB(v) : v;
771static void convertARGBToRGBA64PM_lsx(QRgba64 *buffer,
const uint *src,
int count)
774 const __m128i alphaMask = __lsx_vreplgr2vr_w(0xff000000);
775 const __m128i rgbaMask = (__m128i)(v16i8){2, 1, 0, 3, 6, 5, 4, 7, 10, 9, 8, 11, 14, 13, 12, 15};
776 const __m128i shuffleMask = (__m128i)(v16i8){6, 7, 6, 7, 6, 7, 6, 7, 14, 15, 14, 15, 14, 15, 14, 15};
777 const __m128i zero = __lsx_vldi(0);
779 for (; i < count - 3; i += 4) {
780 __m128i srcVector = __lsx_vld(&src[i], 0);
781 const v4i32 testz = (v4i32)__lsx_vmsknz_b(__lsx_vand_v(srcVector, alphaMask));
783 const v4i32 testc = (v4i32)__lsx_vmsknz_b(__lsx_vandn_v(srcVector, alphaMask));
785 srcVector = __lsx_vshuf_b(zero, srcVector, rgbaMask);
786 const __m128i src1 = __lsx_vilvl_b(srcVector, srcVector);
787 const __m128i src2 = __lsx_vilvh_b(srcVector, srcVector);
789 __m128i alpha1 = __lsx_vshuf_b(zero, src1, shuffleMask);
790 __m128i alpha2 = __lsx_vshuf_b(zero, src2, shuffleMask);
791 __m128i dst1 = __lsx_vmuh_hu(src1, alpha1);
792 __m128i dst2 = __lsx_vmuh_hu(src2, alpha2);
794 dst1 = __lsx_vadd_h(dst1, __lsx_vsrli_h(dst1, 15));
795 dst2 = __lsx_vadd_h(dst2, __lsx_vsrli_h(dst2, 15));
797 const __m128i blendMask = (__m128i)(v8i16){0, 1, 2, 11, 4, 5, 6, 15};
798 dst1 = __lsx_vshuf_h(blendMask, src1, dst1);
799 dst2 = __lsx_vshuf_h(blendMask, src2, dst2);
800 __lsx_vst(dst1, &buffer[i], 0);
801 __lsx_vst(dst2, &buffer[i + 2], 0);
803 __lsx_vst(src1, &buffer[i], 0);
804 __lsx_vst(src2, &buffer[i + 2], 0);
807 __lsx_vst(zero, &buffer[i], 0);
808 __lsx_vst(zero, &buffer[i + 2], 0);
812 SIMD_EPILOGUE(i, count, 3) {
813 const uint s = RGBA ? RGBA2ARGB(src[i]) : src[i];
814 buffer[i] = QRgba64::fromArgb32(s).premultiplied();
818template<
bool RGBA,
bool RGBx>
819static inline void convertARGBFromARGB32PM_lsx(uint *buffer,
const uint *src,
int count)
822 const __m128i alphaMask = __lsx_vreplgr2vr_w(0xff000000);
823 const __m128i rgbaMask = (__m128i)(v16i8){2, 1, 0, 3, 6, 5, 4, 7, 10, 9, 8, 11, 14, 13, 12, 15};
824 const __m128i zero = __lsx_vldi(0);
826 for (; i < count - 3; i += 4) {
827 __m128i srcVector = __lsx_vld(&src[i], 0);
828 const v4i32 testz = (v4i32)__lsx_vmsknz_b(__lsx_vand_v(srcVector, alphaMask));
830 const v4i32 testc = (v4i32)__lsx_vmsknz_b(__lsx_vandn_v(srcVector, alphaMask));
832 __m128i srcVectorAlpha = __lsx_vsrli_w(srcVector, 24);
834 srcVector = __lsx_vshuf_b(zero, srcVector, rgbaMask);
835 const __m128 a = __lsx_vffint_s_w(srcVectorAlpha);
836 const __m128 ia = reciprocal_mul_ps(a, 255.0f);
837 __m128i src1 = __lsx_vilvl_b(zero, srcVector);
838 __m128i src3 = __lsx_vilvh_b(zero, srcVector);
839 __m128i src2 = __lsx_vilvh_h(zero, src1);
840 __m128i src4 = __lsx_vilvh_h(zero, src3);
841 src1 = __lsx_vilvl_h(zero, src1);
842 src3 = __lsx_vilvl_h(zero, src3);
843 __m128 ia1 = (__m128)__lsx_vreplvei_w(ia, 0);
844 __m128 ia2 = (__m128)__lsx_vreplvei_w(ia, 1);
845 __m128 ia3 = (__m128)__lsx_vreplvei_w(ia, 2);
846 __m128 ia4 = (__m128)__lsx_vreplvei_w(ia, 3);
847 src1 = __lsx_vftintrne_w_s(__lsx_vfmul_s(__lsx_vffint_s_w(src1), ia1));
848 src2 = __lsx_vftintrne_w_s(__lsx_vfmul_s(__lsx_vffint_s_w(src2), ia2));
849 src3 = __lsx_vftintrne_w_s(__lsx_vfmul_s(__lsx_vffint_s_w(src3), ia3));
850 src4 = __lsx_vftintrne_w_s(__lsx_vfmul_s(__lsx_vffint_s_w(src4), ia4));
851 src1 = __lsx_vpickev_h(__lsx_vsat_wu(src2, 15), __lsx_vsat_wu(src1, 15));
852 src3 = __lsx_vpickev_h(__lsx_vsat_wu(src4, 15), __lsx_vsat_wu(src3, 15));
853 src1 = __lsx_vmaxi_h(src1, 0);
854 src3 = __lsx_vmaxi_h(src3, 0);
855 src1 = __lsx_vpickev_b(__lsx_vsat_hu(src3, 7), __lsx_vsat_hu(src1, 7));
857 __m128i srcVectorAlphaMask = __lsx_vseq_w(srcVectorAlpha, zero);
858 src1 = __lsx_vandn_v(srcVectorAlphaMask, src1);
861 srcVector = __lsx_vor_v(src1, alphaMask);
863 srcVector = __lsx_vbitsel_v(src1, srcVector, __lsx_vslti_b(alphaMask, 0));
864 __lsx_vst(srcVector, &buffer[i], 0);
867 __lsx_vst(__lsx_vshuf_b(zero, srcVector, rgbaMask), &buffer[i], 0);
868 else if (buffer != src)
869 __lsx_vst(srcVector, &buffer[i], 0);
873 __lsx_vst(alphaMask, &buffer[i], 0);
875 __lsx_vst(zero, &buffer[i], 0);
879 SIMD_EPILOGUE(i, count, 3) {
880 uint v = qUnpremultiply_lsx(src[i]);
890static inline void convertARGBFromRGBA64PM_lsx(uint *buffer,
const QRgba64 *src,
int count)
893 const __m128i alphaMask = __lsx_vreplgr2vr_d(qint64(Q_UINT64_C(0xffff) << 48));
894 const __m128i alphaMask32 = __lsx_vreplgr2vr_w(0xff000000);
895 const __m128i rgbaMask = (__m128i)(v16i8){2, 1, 0, 3, 6, 5, 4, 7, 10, 9, 8, 11, 14, 13, 12, 15};
896 const __m128i zero = __lsx_vldi(0);
898 for (; i < count - 3; i += 4) {
899 __m128i srcVector1 = __lsx_vld(&src[i], 0);
900 __m128i srcVector2 = __lsx_vld(&src[i + 2], 0);
901 const v4i32 testz1 = (v4i32)__lsx_vmsknz_b(__lsx_vand_v(srcVector1, alphaMask));
902 bool transparent1 = testz1[0]==0;
903 const v4i32 testc1 = (v4i32)__lsx_vmsknz_b(__lsx_vandn_v(srcVector1, alphaMask));
904 bool opaque1 = testc1[0]==0;
905 const v4i32 testz2 = (v4i32)__lsx_vmsknz_b(__lsx_vand_v(srcVector2, alphaMask));
906 bool transparent2 = testz2[0]==0;
907 const v4i32 testc2 = (v4i32)__lsx_vmsknz_b(__lsx_vandn_v(srcVector2, alphaMask));
908 bool opaque2 = testc2[0]==0;
910 if (!(transparent1 && transparent2)) {
911 if (!(opaque1 && opaque2)) {
912 __m128i srcVector1Alpha = __lsx_vsrli_d(srcVector1, 48);
913 __m128i srcVector2Alpha = __lsx_vsrli_d(srcVector2, 48);
914 __m128i srcVectorAlpha = __lsx_vpickev_h(__lsx_vsat_wu(srcVector2Alpha, 15),
915 __lsx_vsat_wu(srcVector1Alpha, 15));
916 const __m128 a = __lsx_vffint_s_w(srcVectorAlpha);
918 srcVectorAlpha = __lsx_vadd_w(srcVectorAlpha, __lsx_vreplgr2vr_w(128));
919 srcVectorAlpha = __lsx_vsub_w(srcVectorAlpha, __lsx_vsrli_w(srcVectorAlpha, 8));
920 srcVectorAlpha = __lsx_vsrli_w(srcVectorAlpha, 8);
921 srcVectorAlpha = __lsx_vslli_w(srcVectorAlpha, 24);
922 const __m128 ia = reciprocal_mul_ps(a, 255.0f);
923 __m128i src1 = __lsx_vilvl_h(zero, srcVector1);
924 __m128i src2 = __lsx_vilvh_h(zero, srcVector1);
925 __m128i src3 = __lsx_vilvl_h(zero, srcVector2);
926 __m128i src4 = __lsx_vilvh_h(zero, srcVector2);
927 __m128 ia1 = (__m128)__lsx_vreplvei_w(ia, 0);
928 __m128 ia2 = (__m128)__lsx_vreplvei_w(ia, 1);
929 __m128 ia3 = (__m128)__lsx_vreplvei_w(ia, 2);
930 __m128 ia4 = (__m128)__lsx_vreplvei_w(ia, 3);
931 src1 = __lsx_vftintrne_w_s(__lsx_vfmul_s(__lsx_vffint_s_w(src1), ia1));
932 src2 = __lsx_vftintrne_w_s(__lsx_vfmul_s(__lsx_vffint_s_w(src2), ia2));
933 src3 = __lsx_vftintrne_w_s(__lsx_vfmul_s(__lsx_vffint_s_w(src3), ia3));
934 src4 = __lsx_vftintrne_w_s(__lsx_vfmul_s(__lsx_vffint_s_w(src4), ia4));
935 src1 = __lsx_vpickev_h(__lsx_vsat_wu(src2, 15), __lsx_vsat_wu(src1, 15));
936 src3 = __lsx_vpickev_h(__lsx_vsat_wu(src4, 15), __lsx_vsat_wu(src3, 15));
938 __m128i srcVector1AlphaMask = __lsx_vseq_d(srcVector1Alpha, zero);
939 __m128i srcVector2AlphaMask = __lsx_vseq_d(srcVector2Alpha, zero);
940 src1 = __lsx_vandn_v(srcVector1AlphaMask, src1);
941 src3 = __lsx_vandn_v(srcVector2AlphaMask, src3);
942 src1 = __lsx_vmaxi_h(src1, 0);
943 src3 = __lsx_vmaxi_h(src3, 0);
944 src1 = __lsx_vpickev_b(__lsx_vsat_hu(src3, 7), __lsx_vsat_hu(src1, 7));
946 src1 = __lsx_vbitsel_v(src1, srcVectorAlpha, __lsx_vslti_b(alphaMask32, 0));
949 src1 = __lsx_vshuf_b(zero, src1, rgbaMask);}
950 __lsx_vst(src1, (__m128i *)&buffer[i], 0);
952 __m128i src1 = __lsx_vilvl_h(zero, srcVector1);
953 __m128i src2 = __lsx_vilvh_h(zero, srcVector1);
954 __m128i src3 = __lsx_vilvl_h(zero, srcVector2);
955 __m128i src4 = __lsx_vilvh_h(zero, srcVector2);
956 src1 = __lsx_vadd_w(src1, __lsx_vreplgr2vr_w(128));
957 src2 = __lsx_vadd_w(src2, __lsx_vreplgr2vr_w(128));
958 src3 = __lsx_vadd_w(src3, __lsx_vreplgr2vr_w(128));
959 src4 = __lsx_vadd_w(src4, __lsx_vreplgr2vr_w(128));
960 src1 = __lsx_vsub_w(src1, __lsx_vsrli_w(src1, 8));
961 src2 = __lsx_vsub_w(src2, __lsx_vsrli_w(src2, 8));
962 src3 = __lsx_vsub_w(src3, __lsx_vsrli_w(src3, 8));
963 src4 = __lsx_vsub_w(src4, __lsx_vsrli_w(src4, 8));
964 src1 = __lsx_vsrli_w(src1, 8);
965 src2 = __lsx_vsrli_w(src2, 8);
966 src3 = __lsx_vsrli_w(src3, 8);
967 src4 = __lsx_vsrli_w(src4, 8);
968 src1 = __lsx_vpickev_h(__lsx_vsat_wu(src2, 15), __lsx_vsat_wu(src1, 15));
969 src3 = __lsx_vpickev_h(__lsx_vsat_wu(src4, 15), __lsx_vsat_wu(src3, 15));
970 src1 = __lsx_vmaxi_h(src1, 0);
971 src3 = __lsx_vmaxi_h(src3, 0);
972 src1 = __lsx_vpickev_b(__lsx_vsat_hu(src3, 7), __lsx_vsat_hu(src1, 15));
974 src1 = __lsx_vshuf_b(zero, src1, rgbaMask);}
975 __lsx_vst(src1, &buffer[i], 0);
978 __lsx_vst(zero, &buffer[i], 0);
982 SIMD_EPILOGUE(i, count, 3) {
983 buffer[i] = qConvertRgba64ToRgb32_lsx<RGBA ? PixelOrderRGB : PixelOrderBGR>(src[i]);
988static inline void convertRGBA64FromRGBA64PM_lsx(QRgba64 *buffer,
const QRgba64 *src,
int count)
991 const __m128i alphaMask = __lsx_vreplgr2vr_d(qint64(Q_UINT64_C(0xffff) << 48));
992 const __m128i zero = __lsx_vldi(0);
994 for (; i < count - 3; i += 4) {
995 __m128i srcVector1 = __lsx_vld(&src[i + 0], 0);
996 __m128i srcVector2 = __lsx_vld(&src[i + 2], 0);
997 const v4i32 testz1 = (v4i32)__lsx_vmsknz_b(__lsx_vand_v(srcVector1, alphaMask));
998 bool transparent1 = testz1[0]==0;
999 const v4i32 testc1 = (v4i32)__lsx_vmsknz_b(__lsx_vandn_v(srcVector1, alphaMask));
1000 bool opaque1 = testc1[0]==0;
1001 const v4i32 testz2 = (v4i32)__lsx_vmsknz_b(__lsx_vand_v(srcVector2, alphaMask));
1002 bool transparent2 = testz2[0]==0;
1003 const v4i32 testc2 = (v4i32)__lsx_vmsknz_b(__lsx_vandn_v(srcVector2, alphaMask));
1004 bool opaque2 = testc2[0]==0;
1006 if (!(transparent1 && transparent2)) {
1007 if (!(opaque1 && opaque2)) {
1008 __m128i srcVector1Alpha = __lsx_vsrli_d(srcVector1, 48);
1009 __m128i srcVector2Alpha = __lsx_vsrli_d(srcVector2, 48);
1010 __m128i srcVectorAlpha = __lsx_vpickev_h(__lsx_vsat_wu(srcVector2Alpha, 15),
1011 __lsx_vsat_wu(srcVector1Alpha, 15));
1012 const __m128 a = __lsx_vffint_s_w(srcVectorAlpha);
1013 const __m128 ia = reciprocal_mul_ps(a, 65535.0f);
1014 __m128i src1 = __lsx_vilvl_h(zero, srcVector1);
1015 __m128i src2 = __lsx_vilvh_h(zero, srcVector1);
1016 __m128i src3 = __lsx_vilvl_h(zero, srcVector2);
1017 __m128i src4 = __lsx_vilvh_h(zero, srcVector2);
1018 __m128 ia1 = (__m128)__lsx_vreplvei_w(ia, 0);
1019 __m128 ia2 = (__m128)__lsx_vreplvei_w(ia, 1);
1020 __m128 ia3 = (__m128)__lsx_vreplvei_w(ia, 2);
1021 __m128 ia4 = (__m128)__lsx_vreplvei_w(ia, 3);
1022 src1 = __lsx_vftintrne_w_s(__lsx_vfmul_s(__lsx_vffint_s_w(src1), ia1));
1023 src2 = __lsx_vftintrne_w_s(__lsx_vfmul_s(__lsx_vffint_s_w(src2), ia2));
1024 src3 = __lsx_vftintrne_w_s(__lsx_vfmul_s(__lsx_vffint_s_w(src3), ia3));
1025 src4 = __lsx_vftintrne_w_s(__lsx_vfmul_s(__lsx_vffint_s_w(src4), ia4));
1026 src1 = __lsx_vpickev_h(__lsx_vsat_wu(src2, 15), __lsx_vsat_wu(src1, 15));
1027 src3 = __lsx_vpickev_h(__lsx_vsat_wu(src4, 15), __lsx_vsat_wu(src3, 15));
1029 __m128i srcVector1AlphaMask = __lsx_vseq_d(srcVector1Alpha, zero);
1030 __m128i srcVector2AlphaMask = __lsx_vseq_d(srcVector2Alpha, zero);
1031 src1 = __lsx_vandn_v(srcVector1AlphaMask, src1);
1032 src3 = __lsx_vandn_v(srcVector2AlphaMask, src3);
1035 src1 = __lsx_vor_v(src1, alphaMask);
1036 src3 = __lsx_vor_v(src3, alphaMask);
1038 src1 = __lsx_vbitsel_v(src1, srcVector1, __lsx_vslti_b(alphaMask, 0));
1039 src3 = __lsx_vbitsel_v(src3, srcVector2, __lsx_vslti_b(alphaMask, 0));
1041 __lsx_vst(src1, &buffer[i + 0], 0);
1042 __lsx_vst(src3, &buffer[i + 2], 0);
1045 srcVector1 = __lsx_vor_v(srcVector1, alphaMask);
1046 srcVector2 = __lsx_vor_v(srcVector2, alphaMask);
1048 if (mask || src != buffer) {
1049 __lsx_vst(srcVector1, &buffer[i + 0], 0);
1050 __lsx_vst(srcVector2, &buffer[i + 2], 0);
1054 __lsx_vst(zero, &buffer[i + 0], 0);
1055 __lsx_vst(zero, &buffer[i + 2], 0);
1059 SIMD_EPILOGUE(i, count, 3) {
1060 QRgba64 v = src[i].unpremultiplied();
1067void QT_FASTCALL convertARGB32ToARGB32PM_lsx(uint *buffer,
int count,
const QList<QRgb> *)
1069 convertARGBToARGB32PM_lsx<
false>(buffer, buffer, count);
1072void QT_FASTCALL convertRGBA8888ToARGB32PM_lsx(uint *buffer,
int count,
const QList<QRgb> *)
1074 convertARGBToARGB32PM_lsx<
true>(buffer, buffer, count);
1077const QRgba64 * QT_FASTCALL convertARGB32ToRGBA64PM_lsx(QRgba64 *buffer,
const uint *src,
int count,
1078 const QList<QRgb> *, QDitherInfo *)
1080 convertARGBToRGBA64PM_lsx<
false>(buffer, src, count);
1084const QRgba64 * QT_FASTCALL convertRGBA8888ToRGBA64PM_lsx(QRgba64 *buffer,
const uint *src,
int count,
1085 const QList<QRgb> *, QDitherInfo *)
1087 convertARGBToRGBA64PM_lsx<
true>(buffer, src, count);
1091const uint *QT_FASTCALL fetchARGB32ToARGB32PM_lsx(uint *buffer,
const uchar *src,
int index,
int count,
1092 const QList<QRgb> *, QDitherInfo *)
1094 convertARGBToARGB32PM_lsx<
false>(buffer,
reinterpret_cast<
const uint *>(src) + index, count);
1098const uint *QT_FASTCALL fetchRGBA8888ToARGB32PM_lsx(uint *buffer,
const uchar *src,
int index,
int count,
1099 const QList<QRgb> *, QDitherInfo *)
1101 convertARGBToARGB32PM_lsx<
true>(buffer,
reinterpret_cast<
const uint *>(src) + index, count);
1105const QRgba64 *QT_FASTCALL fetchARGB32ToRGBA64PM_lsx(QRgba64 *buffer,
const uchar *src,
int index,
int count,
1106 const QList<QRgb> *, QDitherInfo *)
1108 convertARGBToRGBA64PM_lsx<
false>(buffer,
reinterpret_cast<
const uint *>(src) + index, count);
1112const QRgba64 *QT_FASTCALL fetchRGBA8888ToRGBA64PM_lsx(QRgba64 *buffer,
const uchar *src,
int index,
int count,
1113 const QList<QRgb> *, QDitherInfo *)
1115 convertARGBToRGBA64PM_lsx<
true>(buffer,
reinterpret_cast<
const uint *>(src) + index, count);
1119void QT_FASTCALL storeRGB32FromARGB32PM_lsx(uchar *dest,
const uint *src,
int index,
int count,
1120 const QList<QRgb> *, QDitherInfo *)
1122 uint *d =
reinterpret_cast<uint *>(dest) + index;
1123 convertARGBFromARGB32PM_lsx<
false,
true>(d, src, count);
1126void QT_FASTCALL storeARGB32FromARGB32PM_lsx(uchar *dest,
const uint *src,
int index,
int count,
1127 const QList<QRgb> *, QDitherInfo *)
1129 uint *d =
reinterpret_cast<uint *>(dest) + index;
1130 convertARGBFromARGB32PM_lsx<
false,
false>(d, src, count);
1133void QT_FASTCALL storeRGBA8888FromARGB32PM_lsx(uchar *dest,
const uint *src,
int index,
int count,
1134 const QList<QRgb> *, QDitherInfo *)
1136 uint *d =
reinterpret_cast<uint *>(dest) + index;
1137 convertARGBFromARGB32PM_lsx<
true,
false>(d, src, count);
1140void QT_FASTCALL storeRGBXFromARGB32PM_lsx(uchar *dest,
const uint *src,
int index,
int count,
1141 const QList<QRgb> *, QDitherInfo *)
1143 uint *d =
reinterpret_cast<uint *>(dest) + index;
1144 convertARGBFromARGB32PM_lsx<
true,
true>(d, src, count);
1147template<QtPixelOrder PixelOrder>
1148void QT_FASTCALL storeA2RGB30PMFromARGB32PM_lsx(uchar *dest,
const uint *src,
int index,
int count,
1149 const QList<QRgb> *, QDitherInfo *)
1151 uint *d =
reinterpret_cast<uint *>(dest) + index;
1152 for (
int i = 0; i < count; ++i)
1153 d[i] = qConvertArgb32ToA2rgb30_lsx<PixelOrder>(src[i]);
1156#if QT_CONFIG(raster_64bit)
1157void QT_FASTCALL destStore64ARGB32_lsx(QRasterBuffer *rasterBuffer,
int x,
1158 int y,
const QRgba64 *buffer,
int length)
1160 uint *dest = (uint*)rasterBuffer->scanLine(y) + x;
1161 convertARGBFromRGBA64PM_lsx<
false>(dest, buffer, length);
1164void QT_FASTCALL destStore64RGBA8888_lsx(QRasterBuffer *rasterBuffer,
int x,
1165 int y,
const QRgba64 *buffer,
int length)
1167 uint *dest = (uint*)rasterBuffer->scanLine(y) + x;
1168 convertARGBFromRGBA64PM_lsx<
true>(dest, buffer, length);
1172void QT_FASTCALL storeARGB32FromRGBA64PM_lsx(uchar *dest,
const QRgba64 *src,
int index,
int count,
1173 const QList<QRgb> *, QDitherInfo *)
1175 uint *d = (uint*)dest + index;
1176 convertARGBFromRGBA64PM_lsx<
false>(d, src, count);
1179void QT_FASTCALL storeRGBA8888FromRGBA64PM_lsx(uchar *dest,
const QRgba64 *src,
int index,
int count,
1180 const QList<QRgb> *, QDitherInfo *)
1182 uint *d = (uint*)dest + index;
1183 convertARGBFromRGBA64PM_lsx<
true>(d, src, count);
1187void QT_FASTCALL storeA2RGB30PMFromARGB32PM_lsx<PixelOrderBGR>(uchar *dest,
const uint *src,
int index,
int count,
1188 const QList<QRgb> *, QDitherInfo *);
1190void QT_FASTCALL storeA2RGB30PMFromARGB32PM_lsx<PixelOrderRGB>(uchar *dest,
const uint *src,
int index,
int count,
1191 const QList<QRgb> *, QDitherInfo *);
1193void QT_FASTCALL storeRGBA64FromRGBA64PM_lsx(uchar *dest,
const QRgba64 *src,
int index,
int count,
1194 const QList<QRgb> *, QDitherInfo *)
1196 QRgba64 *d = (QRgba64 *)dest + index;
1197 convertRGBA64FromRGBA64PM_lsx<
false>(d, src, count);
1200void QT_FASTCALL storeRGBx64FromRGBA64PM_lsx(uchar *dest,
const QRgba64 *src,
int index,
int count,
1201 const QList<QRgb> *, QDitherInfo *)
1203 QRgba64 *d = (QRgba64 *)dest + index;
1204 convertRGBA64FromRGBA64PM_lsx<
true>(d, src, count);
1207#if QT_CONFIG(raster_fp)
1208const QRgbaFloat32 *QT_FASTCALL fetchRGBA32FToRGBA32F_lsx(QRgbaFloat32 *buffer,
const uchar *src,
1209 int index,
int count,
1210 const QList<QRgb> *, QDitherInfo *)
1212 const QRgbaFloat32 *s =
reinterpret_cast<
const QRgbaFloat32 *>(src) + index;
1213 for (
int i = 0; i < count; ++i) {
1214 __m128 vsf = (__m128)__lsx_vld(
reinterpret_cast<
const float *>(s + i), 0);
1215 __m128 vsa = (__m128)__lsx_vreplvei_w(vsf, 3);
1216 vsf = __lsx_vfmul_s(vsf, vsa);
1217 vsf = (__m128)__lsx_vextrins_w(vsf, vsa, 0x30);
1218 __lsx_vst(vsf,
reinterpret_cast<
float *>(buffer + i), 0);
1223void QT_FASTCALL storeRGBX32FFromRGBA32F_lsx(uchar *dest,
const QRgbaFloat32 *src,
1224 int index,
int count,
1225 const QList<QRgb> *, QDitherInfo *)
1227 QRgbaFloat32 *d =
reinterpret_cast<QRgbaFloat32 *>(dest) + index;
1228 const __m128 zero = (__m128)(v4f32){0.0f, 0.0f, 0.0f, 1.0f};
1229 for (
int i = 0; i < count; ++i) {
1230 __m128 vsf = (__m128)__lsx_vld(
reinterpret_cast<
const float *>(src + i), 0);
1231 const __m128 vsa = (__m128)__lsx_vreplvei_w(vsf, 3);
1233 a.i = __lsx_vpickve2gr_w(vsa, 0);
1236 else if (a.f == 0.0f)
1239 __m128 vsr = __lsx_vfrecip_s(vsa);
1240 vsr = __lsx_vfsub_s(__lsx_vfadd_s(vsr, vsr),
1241 __lsx_vfmul_s(vsr, __lsx_vfmul_s(vsr, vsa)));
1242 vsf = __lsx_vfmul_s(vsf, vsr);
1243 FloatInt b = {.f = 1.0f};
1244 vsf = (__m128)__lsx_vinsgr2vr_w(vsf, b.i, 3);
1246 __lsx_vst(vsf,
reinterpret_cast<
float *>(d + i), 0);
1250void QT_FASTCALL storeRGBA32FFromRGBA32F_lsx(uchar *dest,
const QRgbaFloat32 *src,
1251 int index,
int count,
1252 const QList<QRgb> *, QDitherInfo *)
1254 QRgbaFloat32 *d =
reinterpret_cast<QRgbaFloat32 *>(dest) + index;
1255 const __m128 zero = (__m128)__lsx_vldi(0);
1256 for (
int i = 0; i < count; ++i) {
1257 __m128 vsf = (__m128)__lsx_vld(
reinterpret_cast<
const float *>(src + i), 0);
1258 const __m128 vsa = (__m128)__lsx_vreplvei_w(vsf, 3);
1260 a.i = __lsx_vpickve2gr_w(vsa, 0);
1263 else if (a.f == 0.0f)
1266 __m128 vsr = __lsx_vfrecip_s(vsa);
1267 vsr = __lsx_vfsub_s(__lsx_vfadd_s(vsr, vsr),
1268 __lsx_vfmul_s(vsr, __lsx_vfmul_s(vsr, vsa)));
1269 FloatInt b = {.f = 1.0f};
1270 vsr = (__m128)__lsx_vinsgr2vr_w(vsr, b.i, 3);
1271 vsf = __lsx_vfmul_s(vsf, vsr);
1273 __lsx_vst(vsf,
reinterpret_cast<
float *>(d + i), 0);