diff options
Diffstat (limited to 'src/gui/painting/qpixellayout.cpp')
-rw-r--r-- | src/gui/painting/qpixellayout.cpp | 70 |
1 files changed, 22 insertions, 48 deletions
diff --git a/src/gui/painting/qpixellayout.cpp b/src/gui/painting/qpixellayout.cpp index 99fb229fba..e6dc774b2d 100644 --- a/src/gui/painting/qpixellayout.cpp +++ b/src/gui/painting/qpixellayout.cpp @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2021 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtGui module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include <qglobal.h> @@ -248,8 +212,7 @@ inline void QT_FASTCALL storePixel<QPixelLayout::BPP24>(uchar *dest, int index, template <QPixelLayout::BPP bpp> static inline uint QT_FASTCALL fetchPixel(const uchar *, int) { - Q_UNREACHABLE(); - return 0; + Q_UNREACHABLE_RETURN(0); } template <> @@ -1224,10 +1187,12 @@ static const QRgba64 *QT_FASTCALL fetchRGBA64ToRGBA64PM(QRgba64 *buffer, const u const QRgba64 *s = reinterpret_cast<const QRgba64 *>(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) @@ -1696,7 +1661,7 @@ static const QRgba64 *QT_FASTCALL fetchRGBA32FPMToRGBA64PM(QRgba64 *buffer, cons // convertToArgb32() assumes that no color channel is less than 4 bits. // storeRGBFromARGB32PM() assumes that no color channel is more than 8 bits. // QImage::rgbSwapped() assumes that the red and blue color channels have the same number of bits. -QPixelLayout qPixelLayouts[QImage::NImageFormats] = { +QPixelLayout qPixelLayouts[] = { { false, false, QPixelLayout::BPPNone, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr }, // Format_Invalid { false, false, QPixelLayout::BPP1MSB, nullptr, convertIndexedToARGB32PM, convertIndexedTo<QRgba64>, @@ -1816,7 +1781,7 @@ QPixelLayout qPixelLayouts[QImage::NImageFormats] = { storeRGB32FFromRGB32, storeRGB32FFromRGB32 }, // Format_RGBA32FPx4_Premultiplied }; -static_assert(sizeof(qPixelLayouts) / sizeof(*qPixelLayouts) == QImage::NImageFormats); +static_assert(std::size(qPixelLayouts) == QImage::NImageFormats); static void QT_FASTCALL convertFromRgb64(uint *dest, const QRgba64 *src, int length) { @@ -1951,7 +1916,7 @@ static void QT_FASTCALL storeRGBA32FPMFromRGBA64PM(uchar *dest, const QRgba64 *s d[i] = qConvertRgb64ToRgbaF32(src[i]); } -ConvertAndStorePixelsFunc64 qStoreFromRGBA64PM[QImage::NImageFormats] = { +ConvertAndStorePixelsFunc64 qStoreFromRGBA64PM[] = { nullptr, nullptr, nullptr, @@ -1990,6 +1955,8 @@ ConvertAndStorePixelsFunc64 qStoreFromRGBA64PM[QImage::NImageFormats] = { storeRGBA32FPMFromRGBA64PM, }; +static_assert(std::size(qStoreFromRGBA64PM) == QImage::NImageFormats); + #if QT_CONFIG(raster_fp) static void QT_FASTCALL convertToRgbaF32(QRgbaFloat32 *dest, const uint *src, int length) { @@ -2035,7 +2002,7 @@ static const QRgbaFloat32 * QT_FASTCALL convertRGB30ToRGBA32F(QRgbaFloat32 *buff return buffer; } -ConvertToFPFunc qConvertToRGBA32F[QImage::NImageFormats] = { +ConvertToFPFunc qConvertToRGBA32F[] = { nullptr, convertIndexedTo<QRgbaFloat32>, convertIndexedTo<QRgbaFloat32>, @@ -2074,6 +2041,8 @@ ConvertToFPFunc qConvertToRGBA32F[QImage::NImageFormats] = { nullptr, }; +static_assert(std::size(qConvertToRGBA32F) == QImage::NImageFormats); + static const QRgbaFloat32 *QT_FASTCALL fetchRGBX64ToRGBA32F(QRgbaFloat32 *buffer, const uchar *src, int index, int count, const QList<QRgb> *, QDitherInfo *) { @@ -2138,7 +2107,7 @@ static const QRgbaFloat32 *QT_FASTCALL fetchRGBA32F(QRgbaFloat32 *, const uchar return s; } -FetchAndConvertPixelsFuncFP qFetchToRGBA32F[QImage::NImageFormats] = { +FetchAndConvertPixelsFuncFP qFetchToRGBA32F[] = { nullptr, fetchIndexedToRGBA32F<QPixelLayout::BPP1MSB>, fetchIndexedToRGBA32F<QPixelLayout::BPP1LSB>, @@ -2177,6 +2146,8 @@ FetchAndConvertPixelsFuncFP qFetchToRGBA32F[QImage::NImageFormats] = { fetchRGBA32F, }; +static_assert(std::size(qFetchToRGBA32F) == QImage::NImageFormats); + static void QT_FASTCALL convertFromRgba32f(uint *dest, const QRgbaFloat32 *src, int length) { for (int i = 0; i < length; ++i) @@ -2263,7 +2234,7 @@ static void QT_FASTCALL storeRGBX16FFromRGBA32F(uchar *dest, const QRgbaFloat32 QRgbaFloat16 *d = reinterpret_cast<QRgbaFloat16 *>(dest) + index; for (int i = 0; i < count; ++i) { auto s = src[i].unpremultiplied(); - d[i] = QRgbaFloat16{ s.r, s.g, s.b, 1.0f }; + d[i] = QRgbaFloat16{ qfloat16(s.r), qfloat16(s.g), qfloat16(s.b), qfloat16(1.0f) }; } } @@ -2273,7 +2244,7 @@ static void QT_FASTCALL storeRGBA16FFromRGBA32F(uchar *dest, const QRgbaFloat32 QRgbaFloat16 *d = reinterpret_cast<QRgbaFloat16 *>(dest) + index; for (int i = 0; i < count; ++i) { auto s = src[i].unpremultiplied(); - d[i] = QRgbaFloat16{ s.r, s.g, s.b, s.a }; + d[i] = QRgbaFloat16{ qfloat16(s.r), qfloat16(s.g), qfloat16(s.b), qfloat16(s.a) }; } } @@ -2313,7 +2284,7 @@ static void QT_FASTCALL storeRGBA32FPMFromRGBA32F(uchar *dest, const QRgbaFloat3 } } -ConvertAndStorePixelsFuncFP qStoreFromRGBA32F[QImage::NImageFormats] = { +ConvertAndStorePixelsFuncFP qStoreFromRGBA32F[] = { nullptr, nullptr, nullptr, @@ -2351,6 +2322,9 @@ ConvertAndStorePixelsFuncFP qStoreFromRGBA32F[QImage::NImageFormats] = { storeRGBA32FFromRGBA32F, storeRGBA32FPMFromRGBA32F, }; + +static_assert(std::size(qStoreFromRGBA32F) == QImage::NImageFormats); + #endif // QT_CONFIG(raster_fp) QT_END_NAMESPACE |