diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2019-07-05 12:49:04 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2019-09-05 17:41:21 +0200 |
commit | f92d8fd64ebbb0405363c745dbd3c084946ed039 (patch) | |
tree | 4a05087bbdee5330c872826e365c2b709b905a70 /src/gui/painting | |
parent | 236d4637b2258def1e678e515b42632943eb888d (diff) |
Combine BGR30_to_RGB30 and BGR888_to_RGB888
And let the meat of the function be shared with the rbSwap routine.
Change-Id: I0ea18b30c26ff050c17dcb3ad4d654bfbb8c6221
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
Diffstat (limited to 'src/gui/painting')
-rw-r--r-- | src/gui/painting/qdrawhelper.cpp | 6 | ||||
-rw-r--r-- | src/gui/painting/qdrawhelper_ssse3.cpp | 45 |
2 files changed, 48 insertions, 3 deletions
diff --git a/src/gui/painting/qdrawhelper.cpp b/src/gui/painting/qdrawhelper.cpp index c17bf2ddfd..edb363ac69 100644 --- a/src/gui/painting/qdrawhelper.cpp +++ b/src/gui/painting/qdrawhelper.cpp @@ -669,8 +669,7 @@ static void QT_FASTCALL rbSwap_rgb30(uchar *d, const uchar *s, int count) { const uint *src = reinterpret_cast<const uint *>(s); uint *dest = reinterpret_cast<uint *>(d); - for (int i = 0; i < count; ++i) - dest[i] = qRgbSwapRgb30(src[i]); + UNALIASED_CONVERSION_LOOP(dest, src, count, qRgbSwapRgb30); } template<QImage::Format Format> Q_DECL_CONSTEXPR static inline QPixelLayout pixelLayoutRGB() @@ -6774,6 +6773,9 @@ static void qInitDrawhelperFunctions() qBlendFunctions[QImage::Format_RGBX8888][QImage::Format_RGBA8888_Premultiplied] = qt_blend_argb32_on_argb32_ssse3; qBlendFunctions[QImage::Format_RGBA8888_Premultiplied][QImage::Format_RGBA8888_Premultiplied] = qt_blend_argb32_on_argb32_ssse3; sourceFetchUntransformed[QImage::Format_RGB888] = qt_fetchUntransformed_888_ssse3; + extern void QT_FASTCALL rbSwap_888_ssse3(uchar *dst, const uchar *src, int count); + qPixelLayouts[QImage::Format_RGB888].rbSwap = rbSwap_888_ssse3; + qPixelLayouts[QImage::Format_BGR888].rbSwap = rbSwap_888_ssse3; } #endif // SSSE3 diff --git a/src/gui/painting/qdrawhelper_ssse3.cpp b/src/gui/painting/qdrawhelper_ssse3.cpp index 35d61c3e6c..14d7047bb6 100644 --- a/src/gui/painting/qdrawhelper_ssse3.cpp +++ b/src/gui/painting/qdrawhelper_ssse3.cpp @@ -40,7 +40,7 @@ #include <private/qdrawhelper_x86_p.h> -#ifdef QT_COMPILER_SUPPORTS_SSSE3 +#if defined(QT_COMPILER_SUPPORTS_SSSE3) #include <private/qdrawingprimitive_sse2_p.h> @@ -254,6 +254,49 @@ void qt_memfill24_ssse3(quint24 *dest, quint24 color, qsizetype count) } } +void QT_FASTCALL rbSwap_888_ssse3(uchar *dst, const uchar *src, int count) +{ + int i = 0; + + const static __m128i shuffleMask1 = _mm_setr_epi8(2, 1, 0, 5, 4, 3, 8, 7, 6, 11, 10, 9, 14, 13, 12, /*!!*/15); + const static __m128i shuffleMask2 = _mm_setr_epi8(0, /*!!*/1, 4, 3, 2, 7, 6, 5, 10, 9, 8, 13, 12, 11, /*!!*/14, 15); + const static __m128i shuffleMask3 = _mm_setr_epi8(/*!!*/0, 3, 2, 1, 6, 5, 4, 9, 8, 7, 12, 11, 10, 15, 14, 13); + + for (; i + 15 < count; i += 16) { + __m128i s1 = _mm_loadu_si128((const __m128i *)src); + __m128i s2 = _mm_loadu_si128((const __m128i *)(src + 16)); + __m128i s3 = _mm_loadu_si128((const __m128i *)(src + 32)); + s1 = _mm_shuffle_epi8(s1, shuffleMask1); + s2 = _mm_shuffle_epi8(s2, shuffleMask2); + s3 = _mm_shuffle_epi8(s3, shuffleMask3); + _mm_storeu_si128((__m128i *)dst, s1); + _mm_storeu_si128((__m128i *)(dst + 16), s2); + _mm_storeu_si128((__m128i *)(dst + 32), s3); + + // Now fix the last four misplaced values + std::swap(dst[15], dst[17]); + std::swap(dst[30], dst[32]); + + src += 48; + dst += 48; + } + + if (src != dst) { + SIMD_EPILOGUE(i, count, 15) { + dst[0] = src[2]; + dst[1] = src[1]; + dst[2] = src[0]; + dst += 3; + src += 3; + } + } else { + SIMD_EPILOGUE(i, count, 15) { + std::swap(dst[0], dst[2]); + dst += 3; + } + } +} + QT_END_NAMESPACE #endif // QT_COMPILER_SUPPORTS_SSSE3 |