diff options
Diffstat (limited to 'src/gui/painting/qcompositionfunctions.cpp')
-rw-r--r-- | src/gui/painting/qcompositionfunctions.cpp | 78 |
1 files changed, 21 insertions, 57 deletions
diff --git a/src/gui/painting/qcompositionfunctions.cpp b/src/gui/painting/qcompositionfunctions.cpp index 560f7b4d2d..00fd749fe6 100644 --- a/src/gui/painting/qcompositionfunctions.cpp +++ b/src/gui/painting/qcompositionfunctions.cpp @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 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) 2016 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> @@ -433,25 +397,25 @@ struct RgbaFPOperationsSSE2 : public RgbaFPOperationsBase typedef __m128 OptimalType; typedef __m128 OptimalScalar; - static OptimalType load(const Type *ptr) + static OptimalType Q_DECL_VECTORCALL load(const Type *ptr) { - return _mm_load_ps(reinterpret_cast<const float *>(ptr)); + return _mm_loadu_ps(reinterpret_cast<const float *>(ptr)); } - static OptimalType convert(const Type &value) + static OptimalType Q_DECL_VECTORCALL convert(const Type &value) { return load(&value); } - static void store(Type *ptr, OptimalType value) + static void Q_DECL_VECTORCALL store(Type *ptr, OptimalType value) { - _mm_store_ps(reinterpret_cast<float *>(ptr), value); + _mm_storeu_ps(reinterpret_cast<float *>(ptr), value); } - static OptimalType add(OptimalType a, OptimalType b) + static OptimalType Q_DECL_VECTORCALL add(OptimalType a, OptimalType b) { return _mm_add_ps(a, b); } // same as above: // static OptimalScalar add(OptimalScalar a, OptimalScalar b) - static OptimalType plus(OptimalType a, OptimalType b) + static OptimalType Q_DECL_VECTORCALL plus(OptimalType a, OptimalType b) { a = _mm_add_ps(a, b); __m128 aa = _mm_min_ps(a, _mm_set1_ps(1.0f)); @@ -461,37 +425,37 @@ struct RgbaFPOperationsSSE2 : public RgbaFPOperationsBase a = _mm_shuffle_ps(a, aa, _MM_SHUFFLE(0, 2, 1, 0)); return a; } - static OptimalScalar alpha(OptimalType c) + static OptimalScalar Q_DECL_VECTORCALL alpha(OptimalType c) { return _mm_shuffle_ps(c, c, _MM_SHUFFLE(3, 3, 3, 3)); } - static OptimalScalar invAlpha(Scalar c) + static OptimalScalar Q_DECL_VECTORCALL invAlpha(Scalar c) { return _mm_set1_ps(1.0f - float(c)); } - static OptimalScalar invAlpha(OptimalType c) + static OptimalScalar Q_DECL_VECTORCALL invAlpha(OptimalType c) { return _mm_sub_ps(_mm_set1_ps(1.0f), alpha(c)); } - static OptimalScalar scalar(Scalar n) + static OptimalScalar Q_DECL_VECTORCALL scalar(Scalar n) { return _mm_set1_ps(float(n)); } - static OptimalType multiplyAlpha(OptimalType val, OptimalScalar a) + static OptimalType Q_DECL_VECTORCALL multiplyAlpha(OptimalType val, OptimalScalar a) { return _mm_mul_ps(val, a); } - static OptimalType interpolate(OptimalType x, OptimalScalar a1, OptimalType y, OptimalScalar a2) + static OptimalType Q_DECL_VECTORCALL interpolate(OptimalType x, OptimalScalar a1, OptimalType y, OptimalScalar a2) { return add(multiplyAlpha(x, a1), multiplyAlpha(y, a2)); } - static OptimalType multiplyAlpha8bit(OptimalType val, uint8_t a) + static OptimalType Q_DECL_VECTORCALL multiplyAlpha8bit(OptimalType val, uint8_t a) { return multiplyAlpha(val, _mm_set1_ps(a * (1.0f / 255.0f))); } // same as above: // static OptimalScalar multiplyAlpha8bit(OptimalScalar a, uint8_t a) - static OptimalType interpolate8bit(OptimalType x, uint8_t a1, OptimalType y, uint8_t a2) + static OptimalType Q_DECL_VECTORCALL interpolate8bit(OptimalType x, uint8_t a1, OptimalType y, uint8_t a2) { return add(multiplyAlpha8bit(x, a1), multiplyAlpha8bit(y, a2)); } @@ -1391,13 +1355,13 @@ private: static inline int mix_alpha(int da, int sa) { - return 255 - ((255 - sa) * (255 - da) >> 8); + return 255 - qt_div_255((255 - sa) * (255 - da)); } #if QT_CONFIG(raster_64bit) static inline uint mix_alpha_rgb64(uint da, uint sa) { - return 65535U - ((65535U - sa) * (65535U - da) >> 16); + return 65535U - qt_div_65535((65535U - sa) * (65535U - da)); } #endif @@ -1807,7 +1771,7 @@ static inline void comp_func_Screen_impl(uint *Q_DECL_RESTRICT dest, const uint int da = qAlpha(d); int sa = qAlpha(s); -#define OP(a, b) 255 - (((255-a) * (255-b)) >> 8) +#define OP(a, b) 255 - qt_div_255((255-a) * (255-b)) int r = OP( qRed(d), qRed(s)); int b = OP( qBlue(d), qBlue(s)); int g = OP(qGreen(d), qGreen(s)); @@ -1837,7 +1801,7 @@ static inline void comp_func_Screen_impl(QRgba64 *Q_DECL_RESTRICT dest, const QR uint da = d.alpha(); uint sa = s.alpha(); -#define OP(a, b) 65535U - (((65535U-a) * (65535U-b)) >> 16) +#define OP(a, b) 65535U - qt_div_65535((65535U-a) * (65535U-b)) uint r = OP( d.red(), s.red()); uint b = OP( d.blue(), s.blue()); uint g = OP(d.green(), s.green()); |