qdrawhelper_sse2.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/gui/painting/qdrawhelper_sse2.cpp
Source codeSwitch to Preprocessed file
LineSourceCount
1/****************************************************************************-
2**-
3** Copyright (C) 2016 The Qt Company Ltd.-
4** Copyright (C) 2016 Intel Corporation.-
5** Contact: https://www.qt.io/licensing/-
6**-
7** This file is part of the QtGui module of the Qt Toolkit.-
8**-
9** $QT_BEGIN_LICENSE:LGPL$-
10** Commercial License Usage-
11** Licensees holding valid commercial Qt licenses may use this file in-
12** accordance with the commercial license agreement provided with the-
13** Software or, alternatively, in accordance with the terms contained in-
14** a written agreement between you and The Qt Company. For licensing terms-
15** and conditions see https://www.qt.io/terms-conditions. For further-
16** information use the contact form at https://www.qt.io/contact-us.-
17**-
18** GNU Lesser General Public License Usage-
19** Alternatively, this file may be used under the terms of the GNU Lesser-
20** General Public License version 3 as published by the Free Software-
21** Foundation and appearing in the file LICENSE.LGPL3 included in the-
22** packaging of this file. Please review the following information to-
23** ensure the GNU Lesser General Public License version 3 requirements-
24** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.-
25**-
26** GNU General Public License Usage-
27** Alternatively, this file may be used under the terms of the GNU-
28** General Public License version 2.0 or (at your option) the GNU General-
29** Public license version 3 or any later version approved by the KDE Free-
30** Qt Foundation. The licenses are as published by the Free Software-
31** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3-
32** included in the packaging of this file. Please review the following-
33** information to ensure the GNU General Public License requirements will-
34** be met: https://www.gnu.org/licenses/gpl-2.0.html and-
35** https://www.gnu.org/licenses/gpl-3.0.html.-
36**-
37** $QT_END_LICENSE$-
38**-
39****************************************************************************/-
40-
41#include <private/qdrawhelper_x86_p.h>-
42-
43#ifdef QT_COMPILER_SUPPORTS_SSE2-
44-
45#include <private/qdrawingprimitive_sse2_p.h>-
46#include <private/qpaintengine_raster_p.h>-
47-
48QT_BEGIN_NAMESPACE-
49-
50#ifndef QDRAWHELPER_AVX-
51// in AVX mode, we'll use the SSSE3 code-
52void qt_blend_argb32_on_argb32_sse2(uchar *destPixels, int dbpl,-
53 const uchar *srcPixels, int sbpl,-
54 int w, int h,-
55 int const_alpha)-
56{-
57 const quint32 *src = (const quint32 *) srcPixels;-
58 quint32 *dst = (quint32 *) destPixels;-
59 if (const_alpha == 256) {
const_alpha == 256Description
TRUEnever evaluated
FALSEnever evaluated
0
60 const __m128i alphaMask = _mm_set1_epi32(0xff000000);-
61 const __m128i nullVector = _mm_set1_epi32(0);-
62 const __m128i half = _mm_set1_epi16(0x80);-
63 const __m128i one = _mm_set1_epi16(0xff);-
64 const __m128i colorMask = _mm_set1_epi32(0x00ff00ff);-
65 for (int y = 0; y < h; ++y) {
y < hDescription
TRUEnever evaluated
FALSEnever evaluated
0
66 BLEND_SOURCE_OVER_ARGB32_SSE2(dst, src, w, nullVector, half, one, colorMask, alphaMask);
never executed: dst[x] = s;
never executed: dst[x] = s + BYTE_MUL(dst[x], qAlpha(~s));
never executed: end of block
never executed: end of block
never executed: end of block
never executed: end of block
never executed: dst[x] = s;
never executed: dst[x] = s + BYTE_MUL(dst[x], qAlpha(~s));
never executed: end of block
s != 0Description
TRUEnever evaluated
FALSEnever evaluated
_mm_movemask_e...or)) != 0xffffDescription
TRUEnever evaluated
FALSEnever evaluated
s != 0Description
TRUEnever evaluated
FALSEnever evaluated
s >= 0xff000000Description
TRUEnever evaluated
FALSEnever evaluated
_mm_movemask_e...sk)) == 0xffffDescription
TRUEnever evaluated
FALSEnever evaluated
s >= 0xff000000Description
TRUEnever evaluated
FALSEnever evaluated
x < static_cas...0x3)) & 0x3)))Description
TRUEnever evaluated
FALSEnever evaluated
x < w-3Description
TRUEnever evaluated
FALSEnever evaluated
x < wDescription
TRUEnever evaluated
FALSEnever evaluated
0
67 dst = (quint32 *)(((uchar *) dst) + dbpl);-
68 src = (const quint32 *)(((const uchar *) src) + sbpl);-
69 }
never executed: end of block
0
70 } else if (const_alpha != 0) {
never executed: end of block
const_alpha != 0Description
TRUEnever evaluated
FALSEnever evaluated
0
71 // dest = (s + d * sia) * ca + d * cia-
72 // = s * ca + d * (sia * ca + cia)-
73 // = s * ca + d * (1 - sa*ca)-
74 const_alpha = (const_alpha * 255) >> 8;-
75 const __m128i nullVector = _mm_set1_epi32(0);-
76 const __m128i half = _mm_set1_epi16(0x80);-
77 const __m128i one = _mm_set1_epi16(0xff);-
78 const __m128i colorMask = _mm_set1_epi32(0x00ff00ff);-
79 const __m128i constAlphaVector = _mm_set1_epi16(const_alpha);-
80 for (int y = 0; y < h; ++y) {
y < hDescription
TRUEnever evaluated
FALSEnever evaluated
0
81 BLEND_SOURCE_OVER_ARGB32_WITH_CONST_ALPHA_SSE2(dst, src, w, nullVector, half, one, colorMask, constAlphaVector)
never executed: end of block
never executed: end of block
never executed: end of block
never executed: end of block
never executed: end of block
never executed: end of block
s != 0Description
TRUEnever evaluated
FALSEnever evaluated
_mm_movemask_e...or)) != 0xffffDescription
TRUEnever evaluated
FALSEnever evaluated
s != 0Description
TRUEnever evaluated
FALSEnever evaluated
x < static_cas...0x3)) & 0x3)))Description
TRUEnever evaluated
FALSEnever evaluated
x < w-3Description
TRUEnever evaluated
FALSEnever evaluated
x < wDescription
TRUEnever evaluated
FALSEnever evaluated
0
82 dst = (quint32 *)(((uchar *) dst) + dbpl);-
83 src = (const quint32 *)(((const uchar *) src) + sbpl);-
84 }
never executed: end of block
0
85 }
never executed: end of block
0
86}
never executed: end of block
0
87#endif-
88-
89// qblendfunctions.cpp-
90void qt_blend_rgb32_on_rgb32(uchar *destPixels, int dbpl,-
91 const uchar *srcPixels, int sbpl,-
92 int w, int h,-
93 int const_alpha);-
94-
95void qt_blend_rgb32_on_rgb32_sse2(uchar *destPixels, int dbpl,-
96 const uchar *srcPixels, int sbpl,-
97 int w, int h,-
98 int const_alpha)-
99{-
100 const quint32 *src = (const quint32 *) srcPixels;-
101 quint32 *dst = (quint32 *) destPixels;-
102 if (const_alpha != 256) {
const_alpha != 256Description
TRUEnever evaluated
FALSEnever evaluated
0
103 if (const_alpha != 0) {
const_alpha != 0Description
TRUEnever evaluated
FALSEnever evaluated
0
104 const __m128i nullVector = _mm_set1_epi32(0);-
105 const __m128i half = _mm_set1_epi16(0x80);-
106 const __m128i colorMask = _mm_set1_epi32(0x00ff00ff);-
107-
108 const_alpha = (const_alpha * 255) >> 8;-
109 int one_minus_const_alpha = 255 - const_alpha;-
110 const __m128i constAlphaVector = _mm_set1_epi16(const_alpha);-
111 const __m128i oneMinusConstAlpha = _mm_set1_epi16(one_minus_const_alpha);-
112 for (int y = 0; y < h; ++y) {
y < hDescription
TRUEnever evaluated
FALSEnever evaluated
0
113 int x = 0;-
114-
115 // First, align dest to 16 bytes:-
116 ALIGNMENT_PROLOGUE_16BYTES(dst, x, w) {
x < static_cas...0x3)) & 0x3)))Description
TRUEnever evaluated
FALSEnever evaluated
0
117 dst[x] = INTERPOLATE_PIXEL_255(src[x], const_alpha, dst[x], one_minus_const_alpha);-
118 }
never executed: end of block
0
119-
120 for (; x < w-3; x += 4) {
x < w-3Description
TRUEnever evaluated
FALSEnever evaluated
0
121 __m128i srcVector = _mm_loadu_si128((const __m128i *)&src[x]);-
122 if (_mm_movemask_epi8(_mm_cmpeq_epi32(srcVector, nullVector)) != 0xffff) {
_mm_movemask_e...or)) != 0xffffDescription
TRUEnever evaluated
FALSEnever evaluated
0
123 const __m128i dstVector = _mm_load_si128((__m128i *)&dst[x]);-
124 __m128i result;-
125 INTERPOLATE_PIXEL_255_SSE2(result, srcVector, dstVector, constAlphaVector, oneMinusConstAlpha, colorMask, half);-
126 _mm_store_si128((__m128i *)&dst[x], result);-
127 }
never executed: end of block
0
128 }
never executed: end of block
0
129 for (; x<w; ++x) {
x<wDescription
TRUEnever evaluated
FALSEnever evaluated
0
130 dst[x] = INTERPOLATE_PIXEL_255(src[x], const_alpha, dst[x], one_minus_const_alpha);-
131 }
never executed: end of block
0
132 dst = (quint32 *)(((uchar *) dst) + dbpl);-
133 src = (const quint32 *)(((const uchar *) src) + sbpl);-
134 }
never executed: end of block
0
135 }
never executed: end of block
0
136 } else {
never executed: end of block
0
137 qt_blend_rgb32_on_rgb32(destPixels, dbpl, srcPixels, sbpl, w, h, const_alpha);-
138 }
never executed: end of block
0
139}-
140-
141void QT_FASTCALL comp_func_SourceOver_sse2(uint *destPixels, const uint *srcPixels, int length, uint const_alpha)-
142{-
143 Q_ASSERT(const_alpha < 256);-
144-
145 const quint32 *src = (const quint32 *) srcPixels;-
146 quint32 *dst = (quint32 *) destPixels;-
147-
148 const __m128i nullVector = _mm_set1_epi32(0);-
149 const __m128i half = _mm_set1_epi16(0x80);-
150 const __m128i one = _mm_set1_epi16(0xff);-
151 const __m128i colorMask = _mm_set1_epi32(0x00ff00ff);-
152 if (const_alpha == 255) {
const_alpha == 255Description
TRUEnever evaluated
FALSEnever evaluated
0
153 const __m128i alphaMask = _mm_set1_epi32(0xff000000);-
154 BLEND_SOURCE_OVER_ARGB32_SSE2(dst, src, length, nullVector, half, one, colorMask, alphaMask);
never executed: dst[x] = s;
never executed: dst[x] = s + BYTE_MUL(dst[x], qAlpha(~s));
never executed: end of block
never executed: end of block
never executed: end of block
never executed: end of block
never executed: dst[x] = s;
never executed: dst[x] = s + BYTE_MUL(dst[x], qAlpha(~s));
never executed: end of block
s != 0Description
TRUEnever evaluated
FALSEnever evaluated
_mm_movemask_e...or)) != 0xffffDescription
TRUEnever evaluated
FALSEnever evaluated
s != 0Description
TRUEnever evaluated
FALSEnever evaluated
s >= 0xff000000Description
TRUEnever evaluated
FALSEnever evaluated
_mm_movemask_e...sk)) == 0xffffDescription
TRUEnever evaluated
FALSEnever evaluated
s >= 0xff000000Description
TRUEnever evaluated
FALSEnever evaluated
x < static_cas...0x3)) & 0x3)))Description
TRUEnever evaluated
FALSEnever evaluated
x < length-3Description
TRUEnever evaluated
FALSEnever evaluated
x < lengthDescription
TRUEnever evaluated
FALSEnever evaluated
0
155 } else {
never executed: end of block
0
156 const __m128i constAlphaVector = _mm_set1_epi16(const_alpha);-
157 BLEND_SOURCE_OVER_ARGB32_WITH_CONST_ALPHA_SSE2(dst, src, length, nullVector, half, one, colorMask, constAlphaVector);
never executed: end of block
never executed: end of block
never executed: end of block
never executed: end of block
never executed: end of block
never executed: end of block
s != 0Description
TRUEnever evaluated
FALSEnever evaluated
_mm_movemask_e...or)) != 0xffffDescription
TRUEnever evaluated
FALSEnever evaluated
s != 0Description
TRUEnever evaluated
FALSEnever evaluated
x < static_cas...0x3)) & 0x3)))Description
TRUEnever evaluated
FALSEnever evaluated
x < length-3Description
TRUEnever evaluated
FALSEnever evaluated
x < lengthDescription
TRUEnever evaluated
FALSEnever evaluated
0
158 }
never executed: end of block
0
159}-
160-
161void QT_FASTCALL comp_func_Plus_sse2(uint *dst, const uint *src, int length, uint const_alpha)-
162{-
163 int x = 0;-
164-
165 if (const_alpha == 255) {
const_alpha == 255Description
TRUEnever evaluated
FALSEnever evaluated
0
166 // 1) Prologue: align destination on 16 bytes-
167 ALIGNMENT_PROLOGUE_16BYTES(dst, x, length)
x < static_cas...0x3)) & 0x3)))Description
TRUEnever evaluated
FALSEnever evaluated
0
168 dst[x] = comp_func_Plus_one_pixel(dst[x], src[x]);
never executed: dst[x] = comp_func_Plus_one_pixel(dst[x], src[x]);
0
169-
170 // 2) composition with SSE2-
171 for (; x < length - 3; x += 4) {
x < length - 3Description
TRUEnever evaluated
FALSEnever evaluated
0
172 const __m128i srcVector = _mm_loadu_si128((const __m128i *)&src[x]);-
173 const __m128i dstVector = _mm_load_si128((__m128i *)&dst[x]);-
174-
175 const __m128i result = _mm_adds_epu8(srcVector, dstVector);-
176 _mm_store_si128((__m128i *)&dst[x], result);-
177 }
never executed: end of block
0
178-
179 // 3) Epilogue:-
180 for (; x < length; ++x)
x < lengthDescription
TRUEnever evaluated
FALSEnever evaluated
0
181 dst[x] = comp_func_Plus_one_pixel(dst[x], src[x]);
never executed: dst[x] = comp_func_Plus_one_pixel(dst[x], src[x]);
0
182 } else {
never executed: end of block
0
183 const int one_minus_const_alpha = 255 - const_alpha;-
184 const __m128i constAlphaVector = _mm_set1_epi16(const_alpha);-
185 const __m128i oneMinusConstAlpha = _mm_set1_epi16(one_minus_const_alpha);-
186-
187 // 1) Prologue: align destination on 16 bytes-
188 ALIGNMENT_PROLOGUE_16BYTES(dst, x, length)
x < static_cas...0x3)) & 0x3)))Description
TRUEnever evaluated
FALSEnever evaluated
0
189 dst[x] = comp_func_Plus_one_pixel_const_alpha(dst[x], src[x], const_alpha, one_minus_const_alpha);
never executed: dst[x] = comp_func_Plus_one_pixel_const_alpha(dst[x], src[x], const_alpha, one_minus_const_alpha);
0
190-
191 const __m128i half = _mm_set1_epi16(0x80);-
192 const __m128i colorMask = _mm_set1_epi32(0x00ff00ff);-
193 // 2) composition with SSE2-
194 for (; x < length - 3; x += 4) {
x < length - 3Description
TRUEnever evaluated
FALSEnever evaluated
0
195 const __m128i srcVector = _mm_loadu_si128((const __m128i *)&src[x]);-
196 const __m128i dstVector = _mm_load_si128((__m128i *)&dst[x]);-
197-
198 __m128i result = _mm_adds_epu8(srcVector, dstVector);-
199 INTERPOLATE_PIXEL_255_SSE2(result, result, dstVector, constAlphaVector, oneMinusConstAlpha, colorMask, half)-
200 _mm_store_si128((__m128i *)&dst[x], result);-
201 }
never executed: end of block
0
202-
203 // 3) Epilogue:-
204 for (; x < length; ++x)
x < lengthDescription
TRUEnever evaluated
FALSEnever evaluated
0
205 dst[x] = comp_func_Plus_one_pixel_const_alpha(dst[x], src[x], const_alpha, one_minus_const_alpha);
never executed: dst[x] = comp_func_Plus_one_pixel_const_alpha(dst[x], src[x], const_alpha, one_minus_const_alpha);
0
206 }
never executed: end of block
0
207}-
208-
209void QT_FASTCALL comp_func_Source_sse2(uint *dst, const uint *src, int length, uint const_alpha)-
210{-
211 if (const_alpha == 255) {
const_alpha == 255Description
TRUEnever evaluated
FALSEnever evaluated
0
212 ::memcpy(dst, src, length * sizeof(uint));-
213 } else {
never executed: end of block
0
214 const int ialpha = 255 - const_alpha;-
215-
216 int x = 0;-
217-
218 // 1) prologue, align on 16 bytes-
219 ALIGNMENT_PROLOGUE_16BYTES(dst, x, length)
x < static_cas...0x3)) & 0x3)))Description
TRUEnever evaluated
FALSEnever evaluated
0
220 dst[x] = INTERPOLATE_PIXEL_255(src[x], const_alpha, dst[x], ialpha);
never executed: dst[x] = INTERPOLATE_PIXEL_255(src[x], const_alpha, dst[x], ialpha);
0
221-
222 // 2) interpolate pixels with SSE2-
223 const __m128i half = _mm_set1_epi16(0x80);-
224 const __m128i colorMask = _mm_set1_epi32(0x00ff00ff);-
225 const __m128i constAlphaVector = _mm_set1_epi16(const_alpha);-
226 const __m128i oneMinusConstAlpha = _mm_set1_epi16(ialpha);-
227 for (; x < length - 3; x += 4) {
x < length - 3Description
TRUEnever evaluated
FALSEnever evaluated
0
228 const __m128i srcVector = _mm_loadu_si128((const __m128i *)&src[x]);-
229 __m128i dstVector = _mm_load_si128((__m128i *)&dst[x]);-
230 INTERPOLATE_PIXEL_255_SSE2(dstVector, srcVector, dstVector, constAlphaVector, oneMinusConstAlpha, colorMask, half)-
231 _mm_store_si128((__m128i *)&dst[x], dstVector);-
232 }
never executed: end of block
0
233-
234 // 3) Epilogue-
235 for (; x < length; ++x)
x < lengthDescription
TRUEnever evaluated
FALSEnever evaluated
0
236 dst[x] = INTERPOLATE_PIXEL_255(src[x], const_alpha, dst[x], ialpha);
never executed: dst[x] = INTERPOLATE_PIXEL_255(src[x], const_alpha, dst[x], ialpha);
0
237 }
never executed: end of block
0
238}-
239-
240void qt_memfill32(quint32 *dest, quint32 value, int count)-
241{-
242 if (count < 7) {
count < 7Description
TRUEnever evaluated
FALSEnever evaluated
0
243 switch (count) {-
244 case 6: *dest++ = value;
never executed: case 6:
0
245 case 5: *dest++ = value;
code before this statement never executed: case 5:
never executed: case 5:
0
246 case 4: *dest++ = value;
code before this statement never executed: case 4:
never executed: case 4:
0
247 case 3: *dest++ = value;
code before this statement never executed: case 3:
never executed: case 3:
0
248 case 2: *dest++ = value;
code before this statement never executed: case 2:
never executed: case 2:
0
249 case 1: *dest = value;
code before this statement never executed: case 1:
never executed: case 1:
0
250 }
never executed: end of block
0
251 return;
never executed: return;
0
252 };-
253-
254 const int align = (quintptr)(dest) & 0xf;-
255 switch (align) {-
256 case 4: *dest++ = value; --count;
never executed: case 4:
0
257 case 8: *dest++ = value; --count;
code before this statement never executed: case 8:
never executed: case 8:
0
258 case 12: *dest++ = value; --count;
code before this statement never executed: case 12:
never executed: case 12:
0
259 }
never executed: end of block
0
260-
261 const int rest = count & 0x3;-
262 if (rest) {
restDescription
TRUEnever evaluated
FALSEnever evaluated
0
263 switch (rest) {-
264 case 3: dest[count - 3] = value;
never executed: case 3:
0
265 case 2: dest[count - 2] = value;
code before this statement never executed: case 2:
never executed: case 2:
0
266 case 1: dest[count - 1] = value;
code before this statement never executed: case 1:
never executed: case 1:
0
267 }
never executed: end of block
0
268 }
never executed: end of block
0
269-
270 int count128 = count / 4;-
271 __m128i *dst128 = reinterpret_cast<__m128i*>(dest);-
272 __m128i *end128 = dst128 + count128;-
273 const __m128i value128 = _mm_set_epi32(value, value, value, value);-
274-
275 while (dst128 + 3 < end128) {
dst128 + 3 < end128Description
TRUEnever evaluated
FALSEnever evaluated
0
276 _mm_stream_si128(dst128 + 0, value128);-
277 _mm_stream_si128(dst128 + 1, value128);-
278 _mm_stream_si128(dst128 + 2, value128);-
279 _mm_stream_si128(dst128 + 3, value128);-
280 dst128 += 4;-
281 }
never executed: end of block
0
282-
283 switch (count128 & 0x3) {-
284 case 3: _mm_stream_si128(dst128++, value128);
never executed: case 3:
0
285 case 2: _mm_stream_si128(dst128++, value128);
code before this statement never executed: case 2:
never executed: case 2:
0
286 case 1: _mm_stream_si128(dst128++, value128);
code before this statement never executed: case 1:
never executed: case 1:
0
287 }
never executed: end of block
0
288}
never executed: end of block
0
289-
290void QT_FASTCALL comp_func_solid_SourceOver_sse2(uint *destPixels, int length, uint color, uint const_alpha)-
291{-
292 if ((const_alpha & qAlpha(color)) == 255) {
(const_alpha &...color)) == 255Description
TRUEnever evaluated
FALSEnever evaluated
0
293 qt_memfill32(destPixels, color, length);-
294 } else {
never executed: end of block
0
295 if (const_alpha != 255)
const_alpha != 255Description
TRUEnever evaluated
FALSEnever evaluated
0
296 color = BYTE_MUL(color, const_alpha);
never executed: color = BYTE_MUL(color, const_alpha);
0
297-
298 const quint32 minusAlphaOfColor = qAlpha(~color);-
299 int x = 0;-
300-
301 quint32 *dst = (quint32 *) destPixels;-
302 const __m128i colorVector = _mm_set1_epi32(color);-
303 const __m128i colorMask = _mm_set1_epi32(0x00ff00ff);-
304 const __m128i half = _mm_set1_epi16(0x80);-
305 const __m128i minusAlphaOfColorVector = _mm_set1_epi16(minusAlphaOfColor);-
306-
307 ALIGNMENT_PROLOGUE_16BYTES(dst, x, length)
x < static_cas...0x3)) & 0x3)))Description
TRUEnever evaluated
FALSEnever evaluated
0
308 destPixels[x] = color + BYTE_MUL(destPixels[x], minusAlphaOfColor);
never executed: destPixels[x] = color + BYTE_MUL(destPixels[x], minusAlphaOfColor);
0
309-
310 for (; x < length-3; x += 4) {
x < length-3Description
TRUEnever evaluated
FALSEnever evaluated
0
311 __m128i dstVector = _mm_load_si128((__m128i *)&dst[x]);-
312 BYTE_MUL_SSE2(dstVector, dstVector, minusAlphaOfColorVector, colorMask, half);-
313 dstVector = _mm_add_epi8(colorVector, dstVector);-
314 _mm_store_si128((__m128i *)&dst[x], dstVector);-
315 }
never executed: end of block
0
316 for (;x < length; ++x)
x < lengthDescription
TRUEnever evaluated
FALSEnever evaluated
0
317 destPixels[x] = color + BYTE_MUL(destPixels[x], minusAlphaOfColor);
never executed: destPixels[x] = color + BYTE_MUL(destPixels[x], minusAlphaOfColor);
0
318 }
never executed: end of block
0
319}-
320-
321void qt_memfill16(quint16 *dest, quint16 value, int count)-
322{-
323 if (count < 3) {
count < 3Description
TRUEnever evaluated
FALSEnever evaluated
0
324 switch (count) {-
325 case 2: *dest++ = value;
never executed: case 2:
0
326 case 1: *dest = value;
code before this statement never executed: case 1:
never executed: case 1:
0
327 }
never executed: end of block
0
328 return;
never executed: return;
0
329 }-
330-
331 const int align = (quintptr)(dest) & 0x3;-
332 switch (align) {-
333 case 2: *dest++ = value; --count;
never executed: case 2:
0
334 }
never executed: end of block
0
335-
336 const quint32 value32 = (value << 16) | value;-
337 qt_memfill32(reinterpret_cast<quint32*>(dest), value32, count / 2);-
338-
339 if (count & 0x1)
count & 0x1Description
TRUEnever evaluated
FALSEnever evaluated
0
340 dest[count - 1] = value;
never executed: dest[count - 1] = value;
0
341}
never executed: end of block
0
342-
343void qt_bitmapblit32_sse2_base(QRasterBuffer *rasterBuffer, int x, int y,-
344 quint32 color,-
345 const uchar *src, int width, int height, int stride)-
346{-
347 quint32 *dest = reinterpret_cast<quint32*>(rasterBuffer->scanLine(y)) + x;-
348 const int destStride = rasterBuffer->bytesPerLine() / sizeof(quint32);-
349-
350 const __m128i c128 = _mm_set1_epi32(color);-
351 const __m128i maskmask1 = _mm_set_epi32(0x10101010, 0x20202020,-
352 0x40404040, 0x80808080);-
353 const __m128i maskadd1 = _mm_set_epi32(0x70707070, 0x60606060,-
354 0x40404040, 0x00000000);-
355-
356 if (width > 4) {
width > 4Description
TRUEnever evaluated
FALSEnever evaluated
0
357 const __m128i maskmask2 = _mm_set_epi32(0x01010101, 0x02020202,-
358 0x04040404, 0x08080808);-
359 const __m128i maskadd2 = _mm_set_epi32(0x7f7f7f7f, 0x7e7e7e7e,-
360 0x7c7c7c7c, 0x78787878);-
361 while (height--) {
height--Description
TRUEnever evaluated
FALSEnever evaluated
0
362 for (int x = 0; x < width; x += 8) {
x < widthDescription
TRUEnever evaluated
FALSEnever evaluated
0
363 const quint8 s = src[x >> 3];-
364 if (!s)
!sDescription
TRUEnever evaluated
FALSEnever evaluated
0
365 continue;
never executed: continue;
0
366 __m128i mask1 = _mm_set1_epi8(s);-
367 __m128i mask2 = mask1;-
368-
369 mask1 = _mm_and_si128(mask1, maskmask1);-
370 mask1 = _mm_add_epi8(mask1, maskadd1);-
371 _mm_maskmoveu_si128(c128, mask1, (char*)(dest + x));-
372 mask2 = _mm_and_si128(mask2, maskmask2);-
373 mask2 = _mm_add_epi8(mask2, maskadd2);-
374 _mm_maskmoveu_si128(c128, mask2, (char*)(dest + x + 4));-
375 }
never executed: end of block
0
376 dest += destStride;-
377 src += stride;-
378 }
never executed: end of block
0
379 } else {
never executed: end of block
0
380 while (height--) {
height--Description
TRUEnever evaluated
FALSEnever evaluated
0
381 const quint8 s = *src;-
382 if (s) {
sDescription
TRUEnever evaluated
FALSEnever evaluated
0
383 __m128i mask1 = _mm_set1_epi8(s);-
384 mask1 = _mm_and_si128(mask1, maskmask1);-
385 mask1 = _mm_add_epi8(mask1, maskadd1);-
386 _mm_maskmoveu_si128(c128, mask1, (char*)(dest));-
387 }
never executed: end of block
0
388 dest += destStride;-
389 src += stride;-
390 }
never executed: end of block
0
391 }
never executed: end of block
0
392}-
393-
394void qt_bitmapblit32_sse2(QRasterBuffer *rasterBuffer, int x, int y,-
395 const QRgba64 &color,-
396 const uchar *src, int width, int height, int stride)-
397{-
398 qt_bitmapblit32_sse2_base(rasterBuffer, x, y, color.toArgb32(), src, width, height, stride);-
399}
never executed: end of block
0
400-
401void qt_bitmapblit8888_sse2(QRasterBuffer *rasterBuffer, int x, int y,-
402 const QRgba64 &color,-
403 const uchar *src, int width, int height, int stride)-
404{-
405 qt_bitmapblit32_sse2_base(rasterBuffer, x, y, ARGB2RGBA(color.toArgb32()), src, width, height, stride);-
406}
never executed: end of block
0
407-
408void qt_bitmapblit16_sse2(QRasterBuffer *rasterBuffer, int x, int y,-
409 const QRgba64 &color,-
410 const uchar *src, int width, int height, int stride)-
411{-
412 const quint16 c = qConvertRgb32To16(color.toArgb32());-
413 quint16 *dest = reinterpret_cast<quint16*>(rasterBuffer->scanLine(y)) + x;-
414 const int destStride = rasterBuffer->bytesPerLine() / sizeof(quint16);-
415-
416 const __m128i c128 = _mm_set1_epi16(c);-
417QT_WARNING_DISABLE_MSVC(4309) // truncation of constant value-
418 const __m128i maskmask = _mm_set_epi16(0x0101, 0x0202, 0x0404, 0x0808,-
419 0x1010, 0x2020, 0x4040, 0x8080);-
420 const __m128i maskadd = _mm_set_epi16(0x7f7f, 0x7e7e, 0x7c7c, 0x7878,-
421 0x7070, 0x6060, 0x4040, 0x0000);-
422-
423 while (height--) {
height--Description
TRUEnever evaluated
FALSEnever evaluated
0
424 for (int x = 0; x < width; x += 8) {
x < widthDescription
TRUEnever evaluated
FALSEnever evaluated
0
425 const quint8 s = src[x >> 3];-
426 if (!s)
!sDescription
TRUEnever evaluated
FALSEnever evaluated
0
427 continue;
never executed: continue;
0
428 __m128i mask = _mm_set1_epi8(s);-
429 mask = _mm_and_si128(mask, maskmask);-
430 mask = _mm_add_epi8(mask, maskadd);-
431 _mm_maskmoveu_si128(c128, mask, (char*)(dest + x));-
432 }
never executed: end of block
0
433 dest += destStride;-
434 src += stride;-
435 }
never executed: end of block
0
436}
never executed: end of block
0
437-
438class QSimdSse2-
439{-
440public:-
441 typedef __m128i Int32x4;-
442 typedef __m128 Float32x4;-
443-
444 union Vect_buffer_i { Int32x4 v; int i[4]; };-
445 union Vect_buffer_f { Float32x4 v; float f[4]; };-
446-
447 static inline Float32x4 v_dup(float x) { return _mm_set1_ps(x); }
never executed: return _mm_set1_ps(x);
0
448 static inline Float32x4 v_dup(double x) { return _mm_set1_ps(x); }
never executed: return _mm_set1_ps(x);
0
449 static inline Int32x4 v_dup(int x) { return _mm_set1_epi32(x); }
never executed: return _mm_set1_epi32(x);
0
450 static inline Int32x4 v_dup(uint x) { return _mm_set1_epi32(x); }
never executed: return _mm_set1_epi32(x);
0
451-
452 static inline Float32x4 v_add(Float32x4 a, Float32x4 b) { return _mm_add_ps(a, b); }
never executed: return _mm_add_ps(a, b);
0
453 static inline Int32x4 v_add(Int32x4 a, Int32x4 b) { return _mm_add_epi32(a, b); }
never executed: return _mm_add_epi32(a, b);
0
454-
455 static inline Float32x4 v_max(Float32x4 a, Float32x4 b) { return _mm_max_ps(a, b); }
never executed: return _mm_max_ps(a, b);
0
456 static inline Float32x4 v_min(Float32x4 a, Float32x4 b) { return _mm_min_ps(a, b); }
never executed: return _mm_min_ps(a, b);
0
457 static inline Int32x4 v_min_16(Int32x4 a, Int32x4 b) { return _mm_min_epi16(a, b); }
never executed: return _mm_min_epi16(a, b);
0
458-
459 static inline Int32x4 v_and(Int32x4 a, Int32x4 b) { return _mm_and_si128(a, b); }
never executed: return _mm_and_si128(a, b);
0
460-
461 static inline Float32x4 v_sub(Float32x4 a, Float32x4 b) { return _mm_sub_ps(a, b); }
never executed: return _mm_sub_ps(a, b);
0
462 static inline Int32x4 v_sub(Int32x4 a, Int32x4 b) { return _mm_sub_epi32(a, b); }
never executed: return _mm_sub_epi32(a, b);
0
463-
464 static inline Float32x4 v_mul(Float32x4 a, Float32x4 b) { return _mm_mul_ps(a, b); }
never executed: return _mm_mul_ps(a, b);
0
465-
466 static inline Float32x4 v_sqrt(Float32x4 x) { return _mm_sqrt_ps(x); }
never executed: return _mm_sqrt_ps(x);
0
467-
468 static inline Int32x4 v_toInt(Float32x4 x) { return _mm_cvttps_epi32(x); }
never executed: return _mm_cvttps_epi32(x);
0
469-
470 static inline Int32x4 v_greaterOrEqual(Float32x4 a, Float32x4 b) { return _mm_castps_si128(_mm_cmpgt_ps(a, b)); }
never executed: return _mm_castps_si128(_mm_cmpgt_ps(a, b));
0
471};-
472-
473const uint * QT_FASTCALL qt_fetch_radial_gradient_sse2(uint *buffer, const Operator *op, const QSpanData *data,-
474 int y, int x, int length)-
475{-
476 return qt_fetch_radial_gradient_template<QRadialFetchSimd<QSimdSse2>,uint>(buffer, op, data, y, x, length);
never executed: return qt_fetch_radial_gradient_template<QRadialFetchSimd<QSimdSse2>,uint>(buffer, op, data, y, x, length);
0
477}-
478-
479void qt_scale_image_argb32_on_argb32_sse2(uchar *destPixels, int dbpl,-
480 const uchar *srcPixels, int sbpl, int srch,-
481 const QRectF &targetRect,-
482 const QRectF &sourceRect,-
483 const QRect &clip,-
484 int const_alpha)-
485{-
486 if (const_alpha != 256) {
const_alpha != 256Description
TRUEnever evaluated
FALSEnever evaluated
0
487 // from qblendfunctions.cpp-
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,-
492 const QRect &clip,-
493 int const_alpha);-
494 return qt_scale_image_argb32_on_argb32(destPixels, dbpl, srcPixels, sbpl, srch, targetRect, sourceRect, clip, const_alpha);
never executed: return qt_scale_image_argb32_on_argb32(destPixels, dbpl, srcPixels, sbpl, srch, targetRect, sourceRect, clip, const_alpha);
0
495 }-
496-
497 qreal sx = targetRect.width() / (qreal) sourceRect.width();-
498 qreal sy = targetRect.height() / (qreal) sourceRect.height();-
499-
500 int ix = 0x00010000 / sx;-
501 int iy = 0x00010000 / sy;-
502-
503 int cx1 = clip.x();-
504 int cx2 = clip.x() + clip.width();-
505 int cy1 = clip.top();-
506 int cy2 = clip.y() + clip.height();-
507-
508 int tx1 = qRound(targetRect.left());-
509 int tx2 = qRound(targetRect.right());-
510 int ty1 = qRound(targetRect.top());-
511 int ty2 = qRound(targetRect.bottom());-
512-
513 if (tx2 < tx1)
tx2 < tx1Description
TRUEnever evaluated
FALSEnever evaluated
0
514 qSwap(tx2, tx1);
never executed: qSwap(tx2, tx1);
0
515 if (ty2 < ty1)
ty2 < ty1Description
TRUEnever evaluated
FALSEnever evaluated
0
516 qSwap(ty2, ty1);
never executed: qSwap(ty2, ty1);
0
517-
518 if (tx1 < cx1)
tx1 < cx1Description
TRUEnever evaluated
FALSEnever evaluated
0
519 tx1 = cx1;
never executed: tx1 = cx1;
0
520 if (tx2 >= cx2)
tx2 >= cx2Description
TRUEnever evaluated
FALSEnever evaluated
0
521 tx2 = cx2;
never executed: tx2 = cx2;
0
522-
523 if (tx1 >= tx2)
tx1 >= tx2Description
TRUEnever evaluated
FALSEnever evaluated
0
524 return;
never executed: return;
0
525-
526 if (ty1 < cy1)
ty1 < cy1Description
TRUEnever evaluated
FALSEnever evaluated
0
527 ty1 = cy1;
never executed: ty1 = cy1;
0
528 if (ty2 >= cy2)
ty2 >= cy2Description
TRUEnever evaluated
FALSEnever evaluated
0
529 ty2 = cy2;
never executed: ty2 = cy2;
0
530 if (ty1 >= ty2)
ty1 >= ty2Description
TRUEnever evaluated
FALSEnever evaluated
0
531 return;
never executed: return;
0
532-
533 int h = ty2 - ty1;-
534 int w = tx2 - tx1;-
535-
536 quint32 basex;-
537 quint32 srcy;-
538-
539 if (sx < 0) {
sx < 0Description
TRUEnever evaluated
FALSEnever evaluated
0
540 int dstx = qFloor((tx1 + qreal(0.5) - targetRect.right()) * ix) + 1;-
541 basex = quint32(sourceRect.right() * 65536) + dstx;-
542 } else {
never executed: end of block
0
543 int dstx = qCeil((tx1 + qreal(0.5) - targetRect.left()) * ix) - 1;-
544 basex = quint32(sourceRect.left() * 65536) + dstx;-
545 }
never executed: end of block
0
546 if (sy < 0) {
sy < 0Description
TRUEnever evaluated
FALSEnever evaluated
0
547 int dsty = qFloor((ty1 + qreal(0.5) - targetRect.bottom()) * iy) + 1;-
548 srcy = quint32(sourceRect.bottom() * 65536) + dsty;-
549 } else {
never executed: end of block
0
550 int dsty = qCeil((ty1 + qreal(0.5) - targetRect.top()) * iy) - 1;-
551 srcy = quint32(sourceRect.top() * 65536) + dsty;-
552 }
never executed: end of block
0
553-
554 quint32 *dst = ((quint32 *) (destPixels + ty1 * dbpl)) + tx1;-
555-
556 const __m128i nullVector = _mm_set1_epi32(0);-
557 const __m128i half = _mm_set1_epi16(0x80);-
558 const __m128i one = _mm_set1_epi16(0xff);-
559 const __m128i colorMask = _mm_set1_epi32(0x00ff00ff);-
560 const __m128i alphaMask = _mm_set1_epi32(0xff000000);-
561 const __m128i ixVector = _mm_set1_epi32(4*ix);-
562-
563 // this bounds check here is required as floating point rounding above might in some cases lead to-
564 // w/h values that are one pixel too large, falling outside of the valid image area.-
565 int yend = (srcy + iy * (h - 1)) >> 16;-
566 if (yend < 0 || yend >= srch)
yend < 0Description
TRUEnever evaluated
FALSEnever evaluated
yend >= srchDescription
TRUEnever evaluated
FALSEnever evaluated
0
567 --h;
never executed: --h;
0
568 int xend = (basex + ix * (w - 1)) >> 16;-
569 if (xend < 0 || xend >= (int)(sbpl/sizeof(quint32)))
xend < 0Description
TRUEnever evaluated
FALSEnever evaluated
xend >= (int)(...zeof(quint32))Description
TRUEnever evaluated
FALSEnever evaluated
0
570 --w;
never executed: --w;
0
571-
572 while (h--) {
h--Description
TRUEnever evaluated
FALSEnever evaluated
0
573 const uint *src = (const quint32 *) (srcPixels + (srcy >> 16) * sbpl);-
574 int srcx = basex;-
575 int x = 0;-
576-
577 ALIGNMENT_PROLOGUE_16BYTES(dst, x, w) {
x < static_cas...0x3)) & 0x3)))Description
TRUEnever evaluated
FALSEnever evaluated
0
578 uint s = src[srcx >> 16];-
579 dst[x] = s + BYTE_MUL(dst[x], qAlpha(~s));-
580 srcx += ix;-
581 }
never executed: end of block
0
582-
583 __m128i srcxVector = _mm_set_epi32(srcx, srcx + ix, srcx + ix + ix, srcx + ix + ix + ix);-
584-
585 for (; x<w - 3; x += 4) {
x<w - 3Description
TRUEnever evaluated
FALSEnever evaluated
0
586 union Vect_buffer { __m128i vect; quint32 i[4]; };-
587 Vect_buffer addr;-
588 addr.vect = _mm_srli_epi32(srcxVector, 16);-
589 srcxVector = _mm_add_epi32(srcxVector, ixVector);-
590-
591 const __m128i srcVector = _mm_set_epi32(src[addr.i[0]], src[addr.i[1]], src[addr.i[2]], src[addr.i[3]]);-
592 BLEND_SOURCE_OVER_ARGB32_SSE2_helper(dst, srcVector, nullVector, half, one, colorMask, alphaMask);
never executed: end of block
never executed: end of block
_mm_movemask_e...or)) != 0xffffDescription
TRUEnever evaluated
FALSEnever evaluated
_mm_movemask_e...sk)) == 0xffffDescription
TRUEnever evaluated
FALSEnever evaluated
0
593 }
never executed: end of block
0
594-
595 for (; x<w; x++) {
x<wDescription
TRUEnever evaluated
FALSEnever evaluated
0
596 uint s = src[(basex + x*ix) >> 16];-
597 dst[x] = s + BYTE_MUL(dst[x], qAlpha(~s));-
598 }
never executed: end of block
0
599 dst = (quint32 *)(((uchar *) dst) + dbpl);-
600 srcy += iy;-
601 }
never executed: end of block
0
602}
never executed: end of block
0
603-
604-
605QT_END_NAMESPACE-
606-
607#endif // QT_COMPILER_SUPPORTS_SSE2-
Source codeSwitch to Preprocessed file

Generated by Squish Coco Non-Commercial 4.3.0-BETA-master-30-08-2018-4cb69e9