diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2021-06-09 13:55:30 +0200 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2021-06-10 18:55:04 +0000 |
commit | 054a74d0ddb6a6104a56ed5db1827813e363247e (patch) | |
tree | 728786b4185de8243c956df40a28cfd5ee7d5097 /src/gui | |
parent | c33211ee6af79c73ae28d7797e328ec3fe84659a (diff) |
Fix QColorTransform on RGBA64_Premultiplied
The lack of an unsigned pack 32bit->16bit without SSE4, meant
the premultiplied path would saturate color values over 32735.
Change-Id: Ia76e0369fd11a6767e8db78bf9a10eea30d91d2c
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit 19faa03620d030dd406dff353866526ad6b9b653)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/painting/qcolortransform.cpp | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/src/gui/painting/qcolortransform.cpp b/src/gui/painting/qcolortransform.cpp index ff8261989e..f1f8019a15 100644 --- a/src/gui/painting/qcolortransform.cpp +++ b/src/gui/painting/qcolortransform.cpp @@ -594,16 +594,27 @@ void loadUnpremultiplied<QRgba64>(QColorVector *buffer, const QRgba64 *src, cons #if defined(__SSE2__) template<typename T> -static inline void storeP(T &p, const __m128i &v); +static inline void storeP(T &p, __m128i &v, int a); template<> -inline void storeP<QRgb>(QRgb &p, const __m128i &v) +inline void storeP<QRgb>(QRgb &p, __m128i &v, int a) { + v = _mm_packs_epi32(v, v); + v = _mm_insert_epi16(v, a, 3); p = _mm_cvtsi128_si32(_mm_packus_epi16(v, v)); } template<> -inline void storeP<QRgba64>(QRgba64 &p, const __m128i &v) +inline void storeP<QRgba64>(QRgba64 &p, __m128i &v, int a) { +#if defined(__SSE4_1__) + v = _mm_packus_epi32(v, v); + v = _mm_insert_epi16(v, a, 3); _mm_storel_epi64((__m128i *)&p, v); +#else + const int r = _mm_extract_epi16(v, 0); + const int g = _mm_extract_epi16(v, 2); + const int b = _mm_extract_epi16(v, 4); + p = qRgba64(r, g, b, a); +#endif } template<typename T> @@ -627,9 +638,7 @@ static void storePremultiplied(T *dst, const T *src, const QColorVector *buffer, vf = _mm_cvtepi32_ps(v); vf = _mm_mul_ps(vf, va); v = _mm_cvtps_epi32(vf); - v = _mm_packs_epi32(v, v); - v = _mm_insert_epi16(v, a, 3); - storeP<T>(dst[i], v); + storeP<T>(dst[i], v, a); } } |