From c0a448d5c38557adac915342034263ae8a4908e1 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Tue, 9 Jan 2024 12:29:49 +0100 Subject: Fix premultiply of RGB64 formats Alpha was also multiplied, leading to wrong alpha values. Change-Id: Ic452b21f5f02898074552afd68440193b60799c1 Pick-to: 6.7 6.6 6.5 6.2 Fixes: QTBUG-120614 Reviewed-by: Qt CI Bot Reviewed-by: Eirik Aavitsland --- src/gui/painting/qdrawhelper_avx2.cpp | 3 +++ src/gui/painting/qpixellayout.cpp | 2 ++ 2 files changed, 5 insertions(+) (limited to 'src/gui/painting') diff --git a/src/gui/painting/qdrawhelper_avx2.cpp b/src/gui/painting/qdrawhelper_avx2.cpp index 17a52402ae..fa1033256f 100644 --- a/src/gui/painting/qdrawhelper_avx2.cpp +++ b/src/gui/painting/qdrawhelper_avx2.cpp @@ -1345,13 +1345,16 @@ const QRgba64 *QT_FASTCALL fetchRGBA64ToRGBA64PM_avx2(QRgba64 *buffer, const uch vslo = _mm256_srli_epi32(vslo, 16); vshi = _mm256_srli_epi32(vshi, 16); vs256 = _mm256_packus_epi32(vslo, vshi); + vs256 = _mm256_blend_epi16(vs256, va256, 0x88); _mm256_storeu_si256((__m256i *)(buffer + i), vs256); } for (; i < count; ++i) { + const auto a = s[i].alpha(); __m128i vs = _mm_loadl_epi64((const __m128i *)(s + i)); __m128i va = _mm_shufflelo_epi16(vs, _MM_SHUFFLE(3, 3, 3, 3)); vs = multiplyAlpha65535(vs, va); _mm_storel_epi64((__m128i *)(buffer + i), vs); + buffer[i].setAlpha(a); } return buffer; } diff --git a/src/gui/painting/qpixellayout.cpp b/src/gui/painting/qpixellayout.cpp index b196f48617..9e08bbd15a 100644 --- a/src/gui/painting/qpixellayout.cpp +++ b/src/gui/painting/qpixellayout.cpp @@ -1187,10 +1187,12 @@ static const QRgba64 *QT_FASTCALL fetchRGBA64ToRGBA64PM(QRgba64 *buffer, const u const QRgba64 *s = reinterpret_cast(src) + index; #ifdef __SSE2__ for (int i = 0; i < count; ++i) { + const auto a = s[i].alpha(); __m128i vs = _mm_loadl_epi64((const __m128i *)(s + i)); __m128i va = _mm_shufflelo_epi16(vs, _MM_SHUFFLE(3, 3, 3, 3)); vs = multiplyAlpha65535(vs, va); _mm_storel_epi64((__m128i *)(buffer + i), vs); + buffer[i].setAlpha(a); } #else for (int i = 0; i < count; ++i) -- cgit v1.2.3