diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2020-12-04 11:38:06 +0100 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2020-12-04 19:21:38 +0100 |
commit | 2b9a8b8d6973363d35b381bb5ec7e7ceb53cbae4 (patch) | |
tree | f71d82679665665bc9ea193f1047b134562d61c1 /src/gui/painting | |
parent | a3e5efa8a2f66a0171b8bf3519155c521cf68792 (diff) |
Add generic rb swap for RGB64 formats
Will also be needed by half-float formats.
Change-Id: Ia735b29b65287c63da5f1b5ec25428562d743800
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'src/gui/painting')
-rw-r--r-- | src/gui/painting/qpixellayout.cpp | 27 |
1 files changed, 24 insertions, 3 deletions
diff --git a/src/gui/painting/qpixellayout.cpp b/src/gui/painting/qpixellayout.cpp index 0b1e736ec8..3bc0d3333d 100644 --- a/src/gui/painting/qpixellayout.cpp +++ b/src/gui/painting/qpixellayout.cpp @@ -568,6 +568,27 @@ static void QT_FASTCALL rbSwap_rgb30(uchar *d, const uchar *s, int count) UNALIASED_CONVERSION_LOOP(dest, src, count, qRgbSwapRgb30); } +static void QT_FASTCALL rbSwap_4x16(uchar *d, const uchar *s, int count) +{ + const ushort *src = reinterpret_cast<const ushort *>(s); + ushort *dest = reinterpret_cast<ushort *>(d); + if (src != dest) { + for (int i = 0; i < count; ++i) { + dest[i * 4 + 0] = src[i * 4 + 2]; + dest[i * 4 + 1] = src[i * 4 + 1]; + dest[i * 4 + 2] = src[i * 4 + 0]; + dest[i * 4 + 3] = src[i * 4 + 3]; + } + } else { + for (int i = 0; i < count; ++i) { + const ushort r = src[i * 4 + 0]; + const ushort b = src[i * 4 + 2]; + dest[i * 4 + 0] = b; + dest[i * 4 + 2] = r; + } + } +} + template<QImage::Format Format> constexpr static inline QPixelLayout pixelLayoutRGB() { return QPixelLayout{ @@ -1405,15 +1426,15 @@ QPixelLayout qPixelLayouts[QImage::NImageFormats] = { convertGrayscale8ToRGB32, convertGrayscale8ToRGB64, fetchGrayscale8ToRGB32, fetchGrayscale8ToRGB64, storeGrayscale8FromARGB32PM, storeGrayscale8FromRGB32 }, // Format_Grayscale8 - { false, false, QPixelLayout::BPP64, nullptr, + { false, false, QPixelLayout::BPP64, rbSwap_4x16, convertPassThrough, nullptr, fetchRGB64ToRGB32, fetchPassThrough64, storeRGB64FromRGB32, storeRGB64FromRGB32 }, // Format_RGBX64 - { true, false, QPixelLayout::BPP64, nullptr, + { true, false, QPixelLayout::BPP64, rbSwap_4x16, convertARGB32ToARGB32PM, nullptr, fetchRGBA64ToARGB32PM, fetchRGBA64ToRGBA64PM, storeRGBA64FromARGB32PM, storeRGB64FromRGB32 }, // Format_RGBA64 - { true, true, QPixelLayout::BPP64, nullptr, + { true, true, QPixelLayout::BPP64, rbSwap_4x16, convertPassThrough, nullptr, fetchRGB64ToRGB32, fetchPassThrough64, storeRGB64FromRGB32, storeRGB64FromRGB32 }, // Format_RGBA64_Premultiplied |