diff options
Diffstat (limited to 'src/gui/painting/qdrawhelper.cpp')
-rw-r--r-- | src/gui/painting/qdrawhelper.cpp | 304 |
1 files changed, 156 insertions, 148 deletions
diff --git a/src/gui/painting/qdrawhelper.cpp b/src/gui/painting/qdrawhelper.cpp index f0e5810b54..a325ee923e 100644 --- a/src/gui/painting/qdrawhelper.cpp +++ b/src/gui/painting/qdrawhelper.cpp @@ -1,31 +1,38 @@ /**************************************************************************** ** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2016 Intel Corporation. +** Contact: https://www.qt.io/licensing/ ** ** This file is part of the QtGui module of the Qt Toolkit. ** -** $QT_BEGIN_LICENSE:LGPL21$ +** $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 http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. +** 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 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** 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. ** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** 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$ ** @@ -128,10 +135,20 @@ template<> Q_DECL_CONSTEXPR uint blueShift<QImage::Format_ARGB4444_Premultiplied template<> Q_DECL_CONSTEXPR uint blueShift<QImage::Format_ARGB8555_Premultiplied>() { return 8; } template<> Q_DECL_CONSTEXPR uint blueShift<QImage::Format_ARGB8565_Premultiplied>() { return 8; } template<> Q_DECL_CONSTEXPR uint blueShift<QImage::Format_ARGB6666_Premultiplied>() { return 0; } +template<> Q_DECL_CONSTEXPR uint alphaWidth<QImage::Format_RGB16>() { return 0; } +template<> Q_DECL_CONSTEXPR uint alphaWidth<QImage::Format_RGB444>() { return 0; } +template<> Q_DECL_CONSTEXPR uint alphaWidth<QImage::Format_RGB555>() { return 0; } +template<> Q_DECL_CONSTEXPR uint alphaWidth<QImage::Format_RGB666>() { return 0; } +template<> Q_DECL_CONSTEXPR uint alphaWidth<QImage::Format_RGB888>() { return 0; } template<> Q_DECL_CONSTEXPR uint alphaWidth<QImage::Format_ARGB4444_Premultiplied>() { return 4; } template<> Q_DECL_CONSTEXPR uint alphaWidth<QImage::Format_ARGB8555_Premultiplied>() { return 8; } template<> Q_DECL_CONSTEXPR uint alphaWidth<QImage::Format_ARGB8565_Premultiplied>() { return 8; } template<> Q_DECL_CONSTEXPR uint alphaWidth<QImage::Format_ARGB6666_Premultiplied>() { return 6; } +template<> Q_DECL_CONSTEXPR uint alphaShift<QImage::Format_RGB16>() { return 0; } +template<> Q_DECL_CONSTEXPR uint alphaShift<QImage::Format_RGB444>() { return 0; } +template<> Q_DECL_CONSTEXPR uint alphaShift<QImage::Format_RGB555>() { return 0; } +template<> Q_DECL_CONSTEXPR uint alphaShift<QImage::Format_RGB666>() { return 0; } +template<> Q_DECL_CONSTEXPR uint alphaShift<QImage::Format_RGB888>() { return 0; } template<> Q_DECL_CONSTEXPR uint alphaShift<QImage::Format_ARGB4444_Premultiplied>() { return 12; } template<> Q_DECL_CONSTEXPR uint alphaShift<QImage::Format_ARGB8555_Premultiplied>() { return 0; } template<> Q_DECL_CONSTEXPR uint alphaShift<QImage::Format_ARGB8565_Premultiplied>() { return 0; } @@ -228,17 +245,36 @@ static const uint *QT_FASTCALL convertARGBPMToARGB32PM(uint *buffer, const uint Q_CONSTEXPR uchar greenRightShift = 2 * greenWidth<Format>() - 8; Q_CONSTEXPR uchar blueRightShift = 2 * blueWidth<Format>() - 8; - for (int i = 0; i < count; ++i) { - uint alpha = (src[i] >> alphaShift<Format>()) & alphaMask; - uint red = (src[i] >> redShift<Format>()) & redMask; - uint green = (src[i] >> greenShift<Format>()) & greenMask; - uint blue = (src[i] >> blueShift<Format>()) & blueMask; - - alpha = (alpha << alphaLeftShift) | (alpha >> alphaRightShift); - red = qMin(alpha, (red << redLeftShift) | (red >> redRightShift)); - green = qMin(alpha, (green << greenLeftShift) | (green >> greenRightShift)); - blue = qMin(alpha, (blue << blueLeftShift) | (blue >> blueRightShift)); - buffer[i] = (alpha << 24) | (red << 16) | (green << 8) | blue; + Q_CONSTEXPR bool mustMin = (alphaWidth<Format>() != redWidth<Format>()) || + (alphaWidth<Format>() != greenWidth<Format>()) || + (alphaWidth<Format>() != blueWidth<Format>()); + + if (mustMin) { + for (int i = 0; i < count; ++i) { + uint alpha = (src[i] >> alphaShift<Format>()) & alphaMask; + uint red = (src[i] >> redShift<Format>()) & redMask; + uint green = (src[i] >> greenShift<Format>()) & greenMask; + uint blue = (src[i] >> blueShift<Format>()) & blueMask; + + alpha = (alpha << alphaLeftShift) | (alpha >> alphaRightShift); + red = qMin(alpha, (red << redLeftShift) | (red >> redRightShift)); + green = qMin(alpha, (green << greenLeftShift) | (green >> greenRightShift)); + blue = qMin(alpha, (blue << blueLeftShift) | (blue >> blueRightShift)); + buffer[i] = (alpha << 24) | (red << 16) | (green << 8) | blue; + } + } else { + for (int i = 0; i < count; ++i) { + uint alpha = (src[i] >> alphaShift<Format>()) & alphaMask; + uint red = (src[i] >> redShift<Format>()) & redMask; + uint green = (src[i] >> greenShift<Format>()) & greenMask; + uint blue = (src[i] >> blueShift<Format>()) & blueMask; + + alpha = ((alpha << alphaLeftShift) | (alpha >> alphaRightShift)) << 24; + red = ((red << redLeftShift) | (red >> redRightShift)) << 16; + green = ((green << greenLeftShift) | (green >> greenRightShift)) << 8; + blue = (blue << blueLeftShift) | (blue >> blueRightShift); + buffer[i] = alpha | red | green | blue; + } } return buffer; @@ -263,108 +299,85 @@ static const QRgba64 *QT_FASTCALL convertARGBPMToARGB64PM(QRgba64 *buffer, const Q_CONSTEXPR uchar greenRightShift = 2 * greenWidth<Format>() - 8; Q_CONSTEXPR uchar blueRightShift = 2 * blueWidth<Format>() - 8; - for (int i = 0; i < count; ++i) { - uint alpha = (src[i] >> alphaShift<Format>()) & alphaMask; - uint red = (src[i] >> redShift<Format>()) & redMask; - uint green = (src[i] >> greenShift<Format>()) & greenMask; - uint blue = (src[i] >> blueShift<Format>()) & blueMask; - - alpha = (alpha << alphaLeftShift) | (alpha >> alphaRightShift); - red = qMin(alpha, (red << redLeftShift) | (red >> redRightShift)); - green = qMin(alpha, (green << greenLeftShift) | (green >> greenRightShift)); - blue = qMin(alpha, (blue << blueLeftShift) | (blue >> blueRightShift)); - buffer[i] = QRgba64::fromRgba(red, green, blue, alpha); + Q_CONSTEXPR bool mustMin = (alphaWidth<Format>() != redWidth<Format>()) || + (alphaWidth<Format>() != greenWidth<Format>()) || + (alphaWidth<Format>() != blueWidth<Format>()); + + if (mustMin) { + for (int i = 0; i < count; ++i) { + uint alpha = (src[i] >> alphaShift<Format>()) & alphaMask; + uint red = (src[i] >> redShift<Format>()) & redMask; + uint green = (src[i] >> greenShift<Format>()) & greenMask; + uint blue = (src[i] >> blueShift<Format>()) & blueMask; + + alpha = (alpha << alphaLeftShift) | (alpha >> alphaRightShift); + red = qMin(alpha, (red << redLeftShift) | (red >> redRightShift)); + green = qMin(alpha, (green << greenLeftShift) | (green >> greenRightShift)); + blue = qMin(alpha, (blue << blueLeftShift) | (blue >> blueRightShift)); + buffer[i] = QRgba64::fromRgba(red, green, blue, alpha); + } + } else { + for (int i = 0; i < count; ++i) { + uint alpha = (src[i] >> alphaShift<Format>()) & alphaMask; + uint red = (src[i] >> redShift<Format>()) & redMask; + uint green = (src[i] >> greenShift<Format>()) & greenMask; + uint blue = (src[i] >> blueShift<Format>()) & blueMask; + + alpha = (alpha << alphaLeftShift) | (alpha >> alphaRightShift); + red = (red << redLeftShift) | (red >> redRightShift); + green = (green << greenLeftShift) | (green >> greenRightShift); + blue = (blue << blueLeftShift) | (blue >> blueRightShift); + buffer[i] = QRgba64::fromRgba(red, green, blue, alpha); + } } return buffer; } -template<QImage::Format Format> +template<QImage::Format Format, bool fromRGB> static const uint *QT_FASTCALL convertRGBFromARGB32PM(uint *buffer, const uint *src, int count, const QPixelLayout *, const QRgb *) { - Q_CONSTEXPR uint redMask = ((1 << redWidth<Format>()) - 1); - Q_CONSTEXPR uint greenMask = ((1 << greenWidth<Format>()) - 1); - Q_CONSTEXPR uint blueMask = ((1 << blueWidth<Format>()) - 1); - - Q_CONSTEXPR uchar redRightShift = 24 - redWidth<Format>(); - Q_CONSTEXPR uchar greenRightShift = 16 - greenWidth<Format>(); - Q_CONSTEXPR uchar blueRightShift = 8 - blueWidth<Format>(); - - for (int i = 0; i < count; ++i) { - const uint color = qUnpremultiply(src[i]); - const uint red = ((color >> redRightShift) & redMask) << redShift<Format>(); - const uint green = ((color >> greenRightShift) & greenMask) << greenShift<Format>(); - const uint blue = ((color >> blueRightShift) & blueMask) << blueShift<Format>(); - buffer[i] = red | green | blue; - } - return buffer; -} - -template<QImage::Format Format> -static const uint *QT_FASTCALL convertRGBFromRGB32(uint *buffer, const uint *src, int count, - const QPixelLayout *, const QRgb *) -{ - Q_CONSTEXPR uint redMask = ((1 << redWidth<Format>()) - 1); - Q_CONSTEXPR uint greenMask = ((1 << greenWidth<Format>()) - 1); - Q_CONSTEXPR uint blueMask = ((1 << blueWidth<Format>()) - 1); + Q_CONSTEXPR uint rMask = ((1 << redWidth<Format>()) - 1); + Q_CONSTEXPR uint gMask = ((1 << greenWidth<Format>()) - 1); + Q_CONSTEXPR uint bMask = ((1 << blueWidth<Format>()) - 1); - Q_CONSTEXPR uchar redRightShift = 24 - redWidth<Format>(); - Q_CONSTEXPR uchar greenRightShift = 16 - greenWidth<Format>(); - Q_CONSTEXPR uchar blueRightShift = 8 - blueWidth<Format>(); + Q_CONSTEXPR uchar rRightShift = 24 - redWidth<Format>(); + Q_CONSTEXPR uchar gRightShift = 16 - greenWidth<Format>(); + Q_CONSTEXPR uchar bRightShift = 8 - blueWidth<Format>(); for (int i = 0; i < count; ++i) { - const uint red = ((src[i] >> redRightShift) & redMask) << redShift<Format>(); - const uint green = ((src[i] >> greenRightShift) & greenMask) << greenShift<Format>(); - const uint blue = ((src[i] >> blueRightShift) & blueMask) << blueShift<Format>(); - buffer[i] = red | green | blue; + const uint c = fromRGB ? src[i] : qUnpremultiply(src[i]); + const uint r = ((c >> rRightShift) & rMask) << redShift<Format>(); + const uint g = ((c >> gRightShift) & gMask) << greenShift<Format>(); + const uint b = ((c >> bRightShift) & bMask) << blueShift<Format>(); + buffer[i] = r | g | b; } return buffer; } -template<QImage::Format Format> -static const uint *QT_FASTCALL convertARGBPMFromRGB32(uint *buffer, const uint *src, int count, - const QPixelLayout *, const QRgb *) -{ - Q_CONSTEXPR uint alphaMask = ((1 << alphaWidth<Format>()) - 1); - Q_CONSTEXPR uint redMask = ((1 << redWidth<Format>()) - 1); - Q_CONSTEXPR uint greenMask = ((1 << greenWidth<Format>()) - 1); - Q_CONSTEXPR uint blueMask = ((1 << blueWidth<Format>()) - 1); - - Q_CONSTEXPR uchar redRightShift = 24 - redWidth<Format>(); - Q_CONSTEXPR uchar greenRightShift = 16 - greenWidth<Format>(); - Q_CONSTEXPR uchar blueRightShift = 8 - blueWidth<Format>(); - - for (int i = 0; i < count; ++i) { - Q_CONSTEXPR uint alpha = (0xff & alphaMask) << alphaShift<Format>(); - const uint red = ((src[i] >> redRightShift) & redMask) << redShift<Format>(); - const uint green = ((src[i] >> greenRightShift) & greenMask) << greenShift<Format>(); - const uint blue = ((src[i] >> blueRightShift) & blueMask) << blueShift<Format>(); - buffer[i] = alpha | red | green | blue; - } - return buffer; -} - -template<QImage::Format Format> +template<QImage::Format Format, bool fromRGB> static const uint *QT_FASTCALL convertARGBPMFromARGB32PM(uint *buffer, const uint *src, int count, const QPixelLayout *, const QRgb *) { - Q_CONSTEXPR uint alphaMask = ((1 << alphaWidth<Format>()) - 1); - Q_CONSTEXPR uint redMask = ((1 << redWidth<Format>()) - 1); - Q_CONSTEXPR uint greenMask = ((1 << greenWidth<Format>()) - 1); - Q_CONSTEXPR uint blueMask = ((1 << blueWidth<Format>()) - 1); + Q_CONSTEXPR uint aMask = ((1 << alphaWidth<Format>()) - 1); + Q_CONSTEXPR uint rMask = ((1 << redWidth<Format>()) - 1); + Q_CONSTEXPR uint gMask = ((1 << greenWidth<Format>()) - 1); + Q_CONSTEXPR uint bMask = ((1 << blueWidth<Format>()) - 1); - Q_CONSTEXPR uchar alphaRightShift = 32 - alphaWidth<Format>(); - Q_CONSTEXPR uchar redRightShift = 24 - redWidth<Format>(); - Q_CONSTEXPR uchar greenRightShift = 16 - greenWidth<Format>(); - Q_CONSTEXPR uchar blueRightShift = 8 - blueWidth<Format>(); + Q_CONSTEXPR uchar aRightShift = 32 - alphaWidth<Format>(); + Q_CONSTEXPR uchar rRightShift = 24 - redWidth<Format>(); + Q_CONSTEXPR uchar gRightShift = 16 - greenWidth<Format>(); + Q_CONSTEXPR uchar bRightShift = 8 - blueWidth<Format>(); + Q_CONSTEXPR uint aOpaque = (0xff & aMask) << alphaShift<Format>(); for (int i = 0; i < count; ++i) { - const uint alpha = ((src[i] >> alphaRightShift) & alphaMask) << alphaShift<Format>(); - const uint red = ((src[i] >> redRightShift) & redMask) << redShift<Format>(); - const uint green = ((src[i] >> greenRightShift) & greenMask) << greenShift<Format>(); - const uint blue = ((src[i] >> blueRightShift) & blueMask) << blueShift<Format>(); - buffer[i] = alpha | red | green | blue; + const uint c = src[i]; + const uint a = fromRGB ? aOpaque : (((c >> aRightShift) & aMask) << alphaShift<Format>()); + const uint r = ((c >> rRightShift) & rMask) << redShift<Format>(); + const uint g = ((c >> gRightShift) & gMask) << greenShift<Format>(); + const uint b = ((c >> bRightShift) & bMask) << blueShift<Format>(); + buffer[i] = a | r | g | b; } return buffer; } @@ -380,8 +393,8 @@ template<QImage::Format Format> Q_DECL_CONSTEXPR static inline QPixelLayout pixe 0, 0, false, bitsPerPixel<Format>(), convertToRGB32<Format>, - convertRGBFromARGB32PM<Format>, - convertRGBFromRGB32<Format>, + convertRGBFromARGB32PM<Format, false>, + convertRGBFromARGB32PM<Format, true>, convertToRGB64<Format> }; } @@ -395,8 +408,8 @@ template<QImage::Format Format> Q_DECL_CONSTEXPR static inline QPixelLayout pixe uchar(alphaWidth<Format>()), uchar(alphaShift<Format>()), true, bitsPerPixel<Format>(), convertARGBPMToARGB32PM<Format>, - convertARGBPMFromARGB32PM<Format>, - convertARGBPMFromRGB32<Format>, + convertARGBPMFromARGB32PM<Format, false>, + convertARGBPMFromARGB32PM<Format, true>, convertARGBPMToARGB64PM<Format> }; } @@ -874,56 +887,56 @@ QPixelLayout qPixelLayouts[QImage::NImageFormats] = { #else { 5, 11, 6, 5, 5, 0, 0, 0, false, QPixelLayout::BPP16, convertToRGB32<QImage::Format_RGB16>, - convertRGBFromARGB32PM<QImage::Format_RGB16>, - convertRGBFromRGB32<QImage::Format_RGB16>, + convertRGBFromARGB32PM<QImage::Format_RGB16, false>, + convertRGBFromARGB32PM<QImage::Format_RGB16, true>, convertToRGB64<QImage::Format_RGB16>, }, { 5, 19, 6, 13, 5, 8, 8, 0, true, QPixelLayout::BPP24, convertARGBPMToARGB32PM<QImage::Format_ARGB8565_Premultiplied>, - convertARGBPMFromARGB32PM<QImage::Format_ARGB8565_Premultiplied>, - convertARGBPMFromRGB32<QImage::Format_ARGB8565_Premultiplied>, + convertARGBPMFromARGB32PM<QImage::Format_ARGB8565_Premultiplied, false>, + convertARGBPMFromARGB32PM<QImage::Format_ARGB8565_Premultiplied, true>, convertARGBPMToARGB64PM<QImage::Format_ARGB8565_Premultiplied>, }, { 6, 12, 6, 6, 6, 0, 0, 0, false, QPixelLayout::BPP24, convertToRGB32<QImage::Format_RGB666>, - convertRGBFromARGB32PM<QImage::Format_RGB666>, - convertRGBFromRGB32<QImage::Format_RGB666>, + convertRGBFromARGB32PM<QImage::Format_RGB666, false>, + convertRGBFromARGB32PM<QImage::Format_RGB666, true>, convertToRGB64<QImage::Format_RGB666>, }, { 6, 12, 6, 6, 6, 0, 6, 18, true, QPixelLayout::BPP24, convertARGBPMToARGB32PM<QImage::Format_ARGB6666_Premultiplied>, - convertARGBPMFromARGB32PM<QImage::Format_ARGB6666_Premultiplied>, - convertARGBPMFromRGB32<QImage::Format_ARGB6666_Premultiplied>, + convertARGBPMFromARGB32PM<QImage::Format_ARGB6666_Premultiplied, false>, + convertARGBPMFromARGB32PM<QImage::Format_ARGB6666_Premultiplied, true>, convertARGBPMToARGB64PM<QImage::Format_ARGB6666_Premultiplied>, }, { 5, 10, 5, 5, 5, 0, 0, 0, false, QPixelLayout::BPP16, convertToRGB32<QImage::Format_RGB555>, - convertRGBFromARGB32PM<QImage::Format_RGB555>, - convertRGBFromRGB32<QImage::Format_RGB555>, + convertRGBFromARGB32PM<QImage::Format_RGB555, false>, + convertRGBFromARGB32PM<QImage::Format_RGB555, true>, convertToRGB64<QImage::Format_RGB555>, }, { 5, 18, 5, 13, 5, 8, 8, 0, true, QPixelLayout::BPP24, convertARGBPMToARGB32PM<QImage::Format_ARGB8555_Premultiplied>, - convertARGBPMFromARGB32PM<QImage::Format_ARGB8555_Premultiplied>, - convertARGBPMFromRGB32<QImage::Format_ARGB8555_Premultiplied>, + convertARGBPMFromARGB32PM<QImage::Format_ARGB8555_Premultiplied, false>, + convertARGBPMFromARGB32PM<QImage::Format_ARGB8555_Premultiplied, true>, convertARGBPMToARGB64PM<QImage::Format_ARGB8555_Premultiplied>, }, { 8, 16, 8, 8, 8, 0, 0, 0, false, QPixelLayout::BPP24, convertToRGB32<QImage::Format_RGB888>, - convertRGBFromARGB32PM<QImage::Format_RGB888>, - convertRGBFromRGB32<QImage::Format_RGB888>, + convertRGBFromARGB32PM<QImage::Format_RGB888, false>, + convertRGBFromARGB32PM<QImage::Format_RGB888, true>, convertToRGB64<QImage::Format_RGB888>, }, { 4, 8, 4, 4, 4, 0, 0, 0, false, QPixelLayout::BPP16, convertToRGB32<QImage::Format_RGB444>, - convertRGBFromARGB32PM<QImage::Format_RGB444>, - convertRGBFromRGB32<QImage::Format_RGB444>, + convertRGBFromARGB32PM<QImage::Format_RGB444, false>, + convertRGBFromARGB32PM<QImage::Format_RGB444, true>, convertToRGB64<QImage::Format_RGB444>, }, { 4, 8, 4, 4, 4, 0, 4, 12, true, QPixelLayout::BPP16, convertARGBPMToARGB32PM<QImage::Format_ARGB4444_Premultiplied>, - convertARGBPMFromARGB32PM<QImage::Format_ARGB4444_Premultiplied>, - convertARGBPMFromRGB32<QImage::Format_ARGB4444_Premultiplied>, + convertARGBPMFromARGB32PM<QImage::Format_ARGB4444_Premultiplied, false>, + convertARGBPMFromARGB32PM<QImage::Format_ARGB4444_Premultiplied, true>, convertARGBPMToARGB64PM<QImage::Format_ARGB4444_Premultiplied>, }, #endif @@ -954,7 +967,7 @@ const FetchPixelsFunc qFetchPixels[QPixelLayout::BPPCount] = { fetchPixels<QPixelLayout::BPP32> // BPP32 }; -const StorePixelsFunc qStorePixels[QPixelLayout::BPPCount] = { +StorePixelsFunc qStorePixels[QPixelLayout::BPPCount] = { 0, // BPPNone storePixels<QPixelLayout::BPP1MSB>, // BPP1MSB storePixels<QPixelLayout::BPP1LSB>, // BPP1LSB @@ -2338,8 +2351,8 @@ static const uint * QT_FASTCALL fetchTransformedBilinearARGB32PM(uint *buffer, c uint bl = s2[x1]; uint br = s2[x2]; -#if defined(__SSE2__) - // The SSE2 optimized interpolate_4_pixels is faster than interpolate_4_pixels_16. +#if defined(__SSE2__) || defined(__ARM_NEON__) + // The optimized interpolate_4_pixels are faster than interpolate_4_pixels_16. int distx = (fx & 0x0000ffff) >> 8; int disty = (fy & 0x0000ffff) >> 8; *b = interpolate_4_pixels(tl, tr, bl, br, distx, disty); @@ -2569,12 +2582,8 @@ static const uint *QT_FASTCALL fetchTransformedBilinear(uint *buffer, const Oper if ((fdx < 0 && fdx > -(fixed_scale / 8)) || std::abs(data->m22) < (1./8.)) { // scale up more than 8x int disty = (fy & 0x0000ffff) >> 8; for (int i = 0; i < len; ++i) { - uint tl = buf1[i * 2 + 0]; - uint tr = buf1[i * 2 + 1]; - uint bl = buf2[i * 2 + 0]; - uint br = buf2[i * 2 + 1]; int distx = (fracX & 0x0000ffff) >> 8; - b[i] = interpolate_4_pixels(tl, tr, bl, br, distx, disty); + b[i] = interpolate_4_pixels(buf1 + i * 2, buf2 + i * 2, distx, disty); fracX += fdx; } } else { //scale down @@ -2635,15 +2644,10 @@ static const uint *QT_FASTCALL fetchTransformedBilinear(uint *buffer, const Oper if (std::abs(data->m11) > 8 || std::abs(data->m22) > 8) { //if we are zooming more than 8 times, we use 8bit precision for the position. for (int i = 0; i < len; ++i) { - uint tl = buf1[i * 2 + 0]; - uint tr = buf1[i * 2 + 1]; - uint bl = buf2[i * 2 + 0]; - uint br = buf2[i * 2 + 1]; - int distx = (fracX & 0x0000ffff) >> 8; int disty = (fracY & 0x0000ffff) >> 8; - b[i] = interpolate_4_pixels(tl, tr, bl, br, distx, disty); + b[i] = interpolate_4_pixels(buf1 + i * 2, buf2 + i * 2, distx, disty); fracX += fdx; fracY += fdy; } @@ -2733,12 +2737,7 @@ static const uint *QT_FASTCALL fetchTransformedBilinear(uint *buffer, const Oper int distx = distxs[i]; int disty = distys[i]; - uint tl = buf1[i * 2 + 0]; - uint tr = buf1[i * 2 + 1]; - uint bl = buf2[i * 2 + 0]; - uint br = buf2[i * 2 + 1]; - - b[i] = interpolate_4_pixels(tl, tr, bl, br, distx, disty); + b[i] = interpolate_4_pixels(buf1 + i * 2, buf2 + i * 2, distx, disty); } length -= len; b += len; @@ -6382,10 +6381,16 @@ static void qInitDrawhelperFunctions() int w, int h, int const_alpha); + extern void QT_FASTCALL storePixelsBPP24_ssse3(uchar *dest, const uint *src, int index, int count); + extern const uint * QT_FASTCALL qt_fetchUntransformed_888_ssse3(uint *buffer, const Operator *, const QSpanData *data, + int y, int x, int length); qBlendFunctions[QImage::Format_RGB32][QImage::Format_ARGB32_Premultiplied] = qt_blend_argb32_on_argb32_ssse3; qBlendFunctions[QImage::Format_ARGB32_Premultiplied][QImage::Format_ARGB32_Premultiplied] = qt_blend_argb32_on_argb32_ssse3; 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; + qStorePixels[QPixelLayout::BPP24] = storePixelsBPP24_ssse3; + sourceFetch[BlendUntransformed][QImage::Format_RGB888] = qt_fetchUntransformed_888_ssse3; + sourceFetch[BlendTiled][QImage::Format_RGB888] = qt_fetchUntransformed_888_ssse3; } #endif // SSSE3 @@ -6448,6 +6453,9 @@ static void qInitDrawhelperFunctions() qt_fetch_radial_gradient = qt_fetch_radial_gradient_neon; + sourceFetch[BlendUntransformed][QImage::Format_RGB888] = qt_fetchUntransformed_888_neon; + sourceFetch[BlendTiled][QImage::Format_RGB888] = qt_fetchUntransformed_888_neon; + #if defined(ENABLE_PIXMAN_DRAWHELPERS) // The RGB16 helpers are using Arm32 assemblythat has not been ported to AArch64 qBlendFunctions[QImage::Format_RGB16][QImage::Format_ARGB32_Premultiplied] = qt_blend_argb32_on_rgb16_neon; |