Make blendPixel function general

Moves the blendPixel function from the SSSE3 file and use it more
generally, also adds a const_alpha version.

Change-Id: Ia29d1ab3879a845d5b65e0610b7836507e33c7ed
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
bb10
Allan Sandfeld Jensen 2016-09-06 11:03:33 +02:00 committed by Allan Sandfeld Jensen
parent fe82f50a65
commit 806b45e7c7
3 changed files with 20 additions and 29 deletions

View File

@ -636,6 +636,22 @@ static Q_ALWAYS_INLINE uint BYTE_MUL(uint x, uint a) {
}
#endif
static Q_ALWAYS_INLINE void blend_pixel(quint32 &dst, const quint32 src)
{
if (src >= 0xff000000)
dst = src;
else if (src != 0)
dst = src + BYTE_MUL(dst, qAlpha(~src));
}
static Q_ALWAYS_INLINE void blend_pixel(quint32 &dst, const quint32 src, const int const_alpha)
{
if (src != 0) {
const quint32 s = BYTE_MUL(src, const_alpha);
dst = s + BYTE_MUL(dst, qAlpha(~s));
}
}
#if defined(__SSE2__)
static Q_ALWAYS_INLINE uint interpolate_4_pixels_sse2(__m128i vt, __m128i vb, uint distx, uint disty)
{

View File

@ -45,15 +45,6 @@
QT_BEGIN_NAMESPACE
inline static void blend_pixel(quint32 &dst, const quint32 src)
{
if (src >= 0xff000000)
dst = src;
else if (src != 0)
dst = src + BYTE_MUL(dst, qAlpha(~src));
}
/* The instruction palignr uses direct arguments, so we have to generate the code fo the different
shift (4, 8, 12). Checking the alignment inside the loop is unfortunatelly way too slow.
*/

View File

@ -171,11 +171,7 @@ QT_BEGIN_NAMESPACE
\
/* First, get dst aligned. */ \
ALIGNMENT_PROLOGUE_16BYTES(dst, x, length) { \
uint s = src[x]; \
if (s >= 0xff000000) \
dst[x] = s; \
else if (s != 0) \
dst[x] = s + BYTE_MUL(dst[x], qAlpha(~s)); \
blend_pixel(dst[x], src[x]); \
} \
\
for (; x < length-3; x += 4) { \
@ -183,11 +179,7 @@ QT_BEGIN_NAMESPACE
BLEND_SOURCE_OVER_ARGB32_SSE2_helper(dst, srcVector, nullVector, half, one, colorMask, alphaMask) \
} \
for (; x < length; ++x) { \
uint s = src[x]; \
if (s >= 0xff000000) \
dst[x] = s; \
else if (s != 0) \
dst[x] = s + BYTE_MUL(dst[x], qAlpha(~s)); \
blend_pixel(dst[x], src[x]); \
} \
}
@ -207,11 +199,7 @@ QT_BEGIN_NAMESPACE
int x = 0; \
\
ALIGNMENT_PROLOGUE_16BYTES(dst, x, length) { \
quint32 s = src[x]; \
if (s != 0) { \
s = BYTE_MUL(s, const_alpha); \
dst[x] = s + BYTE_MUL(dst[x], qAlpha(~s)); \
} \
blend_pixel(dst[x], src[x], const_alpha); \
} \
\
for (; x < length-3; x += 4) { \
@ -232,11 +220,7 @@ QT_BEGIN_NAMESPACE
} \
} \
for (; x < length; ++x) { \
quint32 s = src[x]; \
if (s != 0) { \
s = BYTE_MUL(s, const_alpha); \
dst[x] = s + BYTE_MUL(dst[x], qAlpha(~s)); \
} \
blend_pixel(dst[x], src[x], const_alpha); \
} \
}