43 #include <private/qimage_p.h> 44 #include <private/qsimd_p.h> 45 #include <private/qdrawhelper_p.h> 46 #include <private/qdrawingprimitive_sse2_p.h> 52 bool convert_ARGB_to_ARGB_PM_inplace_sse2(
QImageData *
data, Qt::ImageConversionFlags)
57 const int spare = data->
width & 3;
60 const int iter = data->
width >> 2;
63 const __m128i alphaMask = _mm_set1_epi32(0xff000000);
64 const __m128i nullVector = _mm_setzero_si128();
65 const __m128i half = _mm_set1_epi16(0x80);
66 const __m128i colorMask = _mm_set1_epi32(0x00ff00ff);
68 __m128i *
d =
reinterpret_cast<__m128i*
>(data->
data);
70 const __m128i *
end = d + iter;
72 for (; d !=
end; ++
d) {
73 const __m128i srcVector = _mm_loadu_si128(d);
74 const __m128i srcVectorAlpha = _mm_and_si128(srcVector, alphaMask);
75 if (_mm_movemask_epi8(_mm_cmpeq_epi32(srcVectorAlpha, alphaMask)) == 0xffff) {
77 }
else if (_mm_movemask_epi8(_mm_cmpeq_epi32(srcVectorAlpha, nullVector)) == 0xffff) {
79 _mm_storeu_si128(d, nullVector);
81 __m128i alphaChannel = _mm_srli_epi32(srcVector, 24);
82 alphaChannel = _mm_or_si128(alphaChannel, _mm_slli_epi32(alphaChannel, 16));
85 BYTE_MUL_SSE2(result, srcVector, alphaChannel, colorMask, half);
86 result = _mm_or_si128(_mm_andnot_si128(alphaMask, result), srcVectorAlpha);
87 _mm_storeu_si128(d, result);
93 for (; p != pe; ++p) {
96 else if (*p < 0xff000000)
100 d =
reinterpret_cast<__m128i*
>(p+pad);
109 #endif // QT_HAVE_SSE2
#define QT_END_NAMESPACE
This macro expands to.
#define QT_BEGIN_NAMESPACE
This macro expands to.
Q_STATIC_INLINE_FUNCTION uint PREMUL(uint x)
static const char * data(const QByteArray &arr)
static const KeyPair *const end