Line | Source | Count |
1 | | - |
2 | | - |
3 | | - |
4 | | - |
5 | | - |
6 | | - |
7 | | - |
8 | | - |
9 | | - |
10 | | - |
11 | | - |
12 | | - |
13 | | - |
14 | | - |
15 | | - |
16 | | - |
17 | | - |
18 | | - |
19 | | - |
20 | | - |
21 | | - |
22 | | - |
23 | | - |
24 | | - |
25 | | - |
26 | | - |
27 | | - |
28 | | - |
29 | | - |
30 | | - |
31 | | - |
32 | | - |
33 | | - |
34 | | - |
35 | | - |
36 | | - |
37 | | - |
38 | | - |
39 | | - |
40 | #include "qimage.h" | - |
41 | #include <private/qimage_p.h> | - |
42 | #include <private/qsimd_p.h> | - |
43 | #include <private/qdrawhelper_p.h> | - |
44 | #include <private/qdrawingprimitive_sse2_p.h> | - |
45 | | - |
46 | #ifdef QT_COMPILER_SUPPORTS_SSE2 | - |
47 | | - |
48 | QT_BEGIN_NAMESPACE | - |
49 | | - |
50 | bool convert_ARGB_to_ARGB_PM_inplace_sse2(QImageData *data, Qt::ImageConversionFlags) | - |
51 | { | - |
52 | Q_ASSERT(data->format == QImage::Format_ARGB32 || data->format == QImage::Format_RGBA8888); | - |
53 | | - |
54 | | - |
55 | const int spare = data->width & 3; | - |
56 | | - |
57 | const int pad = (data->bytes_per_line >> 2) - data->width; | - |
58 | const int iter = data->width >> 2; | - |
59 | int height = data->height; | - |
60 | | - |
61 | const __m128i alphaMask = _mm_set1_epi32(0xff000000); | - |
62 | const __m128i nullVector = _mm_setzero_si128(); | - |
63 | const __m128i half = _mm_set1_epi16(0x80); | - |
64 | const __m128i colorMask = _mm_set1_epi32(0x00ff00ff); | - |
65 | | - |
66 | __m128i *d = reinterpret_cast<__m128i*>(data->data); | - |
67 | while (height--) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
68 | const __m128i *end = d + iter; | - |
69 | | - |
70 | for (; d != end; ++d) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
71 | const __m128i srcVector = _mm_loadu_si128(d); | - |
72 | const __m128i srcVectorAlpha = _mm_and_si128(srcVector, alphaMask); | - |
73 | if (_mm_movemask_epi8(_mm_cmpeq_epi32(srcVectorAlpha, alphaMask)) == 0xffff) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
74 | | - |
75 | } else if (_mm_movemask_epi8(_mm_cmpeq_epi32(srcVectorAlpha, nullVector)) == 0xffff) { never executed: end of block TRUE | never evaluated | FALSE | never evaluated |
| 0 |
76 | | - |
77 | _mm_storeu_si128(d, nullVector); | - |
78 | } else { never executed: end of block | 0 |
79 | __m128i alphaChannel = _mm_srli_epi32(srcVector, 24); | - |
80 | alphaChannel = _mm_or_si128(alphaChannel, _mm_slli_epi32(alphaChannel, 16)); | - |
81 | | - |
82 | __m128i result; | - |
83 | BYTE_MUL_SSE2(result, srcVector, alphaChannel, colorMask, half); | - |
84 | result = _mm_or_si128(_mm_andnot_si128(alphaMask, result), srcVectorAlpha); | - |
85 | _mm_storeu_si128(d, result); | - |
86 | } never executed: end of block | 0 |
87 | } | - |
88 | | - |
89 | QRgb *p = reinterpret_cast<QRgb*>(d); | - |
90 | QRgb *pe = p+spare; | - |
91 | for (; p != pe; ++p) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
92 | if (*p < 0x00ffffff)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
93 | *p = 0; never executed: *p = 0; | 0 |
94 | else if (*p < 0xff000000)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
95 | *p = qPremultiply(*p); never executed: *p = qPremultiply(*p); | 0 |
96 | } never executed: end of block | 0 |
97 | | - |
98 | d = reinterpret_cast<__m128i*>(p+pad); | - |
99 | } never executed: end of block | 0 |
100 | | - |
101 | if (data->format == QImage::Format_ARGB32)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
102 | data->format = QImage::Format_ARGB32_Premultiplied; never executed: data->format = QImage::Format_ARGB32_Premultiplied; | 0 |
103 | else | - |
104 | data->format = QImage::Format_RGBA8888_Premultiplied; never executed: data->format = QImage::Format_RGBA8888_Premultiplied; | 0 |
105 | return true; never executed: return true; | 0 |
106 | } | - |
107 | | - |
108 | QT_END_NAMESPACE | - |
109 | | - |
110 | #endif // QT_COMPILER_SUPPORTS_SSE2 | - |
| | |