From 6f0df02d002356625f10683ef84da7685d92a2c4 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Wed, 12 Aug 2020 14:14:02 +0200 Subject: Replace Qt CONSTEXPR defines with constexpr Both normal and relaxed constexpr are required by our new minimum of C++17. Change-Id: Ic028b88a2e7a6cb7d5925f3133b9d54859a81744 Reviewed-by: Sona Kurazyan --- src/gui/painting/qbrush.cpp | 2 +- src/gui/painting/qcolor.h | 10 +- src/gui/painting/qcolormatrix_p.h | 12 +- src/gui/painting/qdrawhelper.cpp | 2 +- src/gui/painting/qdrawhelper_p.h | 10 +- src/gui/painting/qdrawingprimitive_sse2_p.h | 2 +- src/gui/painting/qfixed_p.h | 136 +++++----- src/gui/painting/qpixellayout.cpp | 370 ++++++++++++++-------------- src/gui/painting/qpixellayout_p.h | 4 +- src/gui/painting/qrgb.h | 20 +- src/gui/painting/qrgba64.h | 66 ++--- src/gui/painting/webgradients.cpp | 2 +- 12 files changed, 318 insertions(+), 318 deletions(-) (limited to 'src/gui/painting') diff --git a/src/gui/painting/qbrush.cpp b/src/gui/painting/qbrush.cpp index c9113cdc75..b2f610c188 100644 --- a/src/gui/painting/qbrush.cpp +++ b/src/gui/painting/qbrush.cpp @@ -576,7 +576,7 @@ void QBrush::cleanUp(QBrushData *x) QBrushDataPointerDeleter::deleteData(x); } -static Q_DECL_CONSTEXPR inline bool use_same_brushdata(Qt::BrushStyle lhs, Qt::BrushStyle rhs) +static constexpr inline bool use_same_brushdata(Qt::BrushStyle lhs, Qt::BrushStyle rhs) { return lhs == rhs // includes Qt::TexturePattern || (lhs >= Qt::NoBrush && lhs <= Qt::DiagCrossPattern && rhs >= Qt::NoBrush && rhs <= Qt::DiagCrossPattern) diff --git a/src/gui/painting/qcolor.h b/src/gui/painting/qcolor.h index 683826fbe7..dbced35996 100644 --- a/src/gui/painting/qcolor.h +++ b/src/gui/painting/qcolor.h @@ -69,10 +69,10 @@ public: enum Spec { Invalid, Rgb, Hsv, Cmyk, Hsl, ExtendedRgb }; enum NameFormat { HexRgb, HexArgb }; - Q_DECL_CONSTEXPR QColor() noexcept + constexpr QColor() noexcept : cspec(Invalid), ct(USHRT_MAX, 0, 0, 0, 0) {} QColor(Qt::GlobalColor color) noexcept; - Q_DECL_CONSTEXPR QColor(int r, int g, int b, int a = 255) noexcept + constexpr QColor(int r, int g, int b, int a = 255) noexcept : cspec(isRgbaValid(r, g, b, a) ? Rgb : Invalid), ct(ushort(cspec == Rgb ? a * 0x0101 : 0), ushort(cspec == Rgb ? r * 0x0101 : 0), @@ -235,7 +235,7 @@ private: template bool setColorFromString(String name); - static Q_DECL_CONSTEXPR bool isRgbaValid(int r, int g, int b, int a = 255) noexcept Q_DECL_CONST_FUNCTION + static constexpr bool isRgbaValid(int r, int g, int b, int a = 255) noexcept Q_DECL_CONST_FUNCTION { return uint(r) <= 255 && uint(g) <= 255 && uint(b) <= 255 && uint(a) <= 255; } @@ -244,7 +244,7 @@ private: union CT { #ifdef Q_COMPILER_UNIFORM_INIT CT() {} // doesn't init anything, thus can't be constexpr - Q_DECL_CONSTEXPR explicit CT(ushort a1, ushort a2, ushort a3, ushort a4, ushort a5) noexcept + constexpr explicit CT(ushort a1, ushort a2, ushort a3, ushort a4, ushort a5) noexcept : array{a1, a2, a3, a4, a5} {} #endif struct { @@ -293,7 +293,7 @@ private: #ifdef Q_COMPILER_UNIFORM_INIT public: // can't give friendship to a namespace, so it needs to be public - Q_DECL_CONSTEXPR explicit QColor(Spec spec, ushort a1, ushort a2, ushort a3, ushort a4, ushort a5=0) noexcept + constexpr explicit QColor(Spec spec, ushort a1, ushort a2, ushort a3, ushort a4, ushort a5=0) noexcept : cspec(spec), ct(a1, a2, a3, a4, a5) {} #endif // Q_COMPILER_UNIFORM_INIT }; diff --git a/src/gui/painting/qcolormatrix_p.h b/src/gui/painting/qcolormatrix_p.h index 749aad3b2c..87a61ab219 100644 --- a/src/gui/painting/qcolormatrix_p.h +++ b/src/gui/painting/qcolormatrix_p.h @@ -62,8 +62,8 @@ class QColorVector { public: QColorVector() = default; - Q_DECL_CONSTEXPR QColorVector(float x, float y, float z) : x(x), y(y), z(z) { } - explicit Q_DECL_CONSTEXPR QColorVector(const QPointF &chr) // from XY chromaticity + constexpr QColorVector(float x, float y, float z) : x(x), y(y), z(z) { } + explicit constexpr QColorVector(const QPointF &chr) // from XY chromaticity : x(chr.x() / chr.y()) , y(1.0f) , z((1.0 - chr.x() - chr.y()) / chr.y()) @@ -92,10 +92,10 @@ public: } // Common whitepoints: - static Q_DECL_CONSTEXPR QPointF D50Chromaticity() { return QPointF(0.34567, 0.35850); } - static Q_DECL_CONSTEXPR QPointF D65Chromaticity() { return QPointF(0.31271, 0.32902); } - static Q_DECL_CONSTEXPR QColorVector D50() { return QColorVector(D50Chromaticity()); } - static Q_DECL_CONSTEXPR QColorVector D65() { return QColorVector(D65Chromaticity()); } + static constexpr QPointF D50Chromaticity() { return QPointF(0.34567, 0.35850); } + static constexpr QPointF D65Chromaticity() { return QPointF(0.31271, 0.32902); } + static constexpr QColorVector D50() { return QColorVector(D50Chromaticity()); } + static constexpr QColorVector D65() { return QColorVector(D65Chromaticity()); } }; inline bool operator==(const QColorVector &v1, const QColorVector &v2) diff --git a/src/gui/painting/qdrawhelper.cpp b/src/gui/painting/qdrawhelper.cpp index b4dc2d3ae3..1ef881efee 100644 --- a/src/gui/painting/qdrawhelper.cpp +++ b/src/gui/painting/qdrawhelper.cpp @@ -1484,7 +1484,7 @@ static const uint * QT_FASTCALL fetchTransformedBilinearARGB32PM(uint *buffer, c { const qreal cx = x + qreal(0.5); const qreal cy = y + qreal(0.5); - Q_CONSTEXPR int tiled = (blendType == BlendTransformedBilinearTiled) ? 1 : 0; + constexpr int tiled = (blendType == BlendTransformedBilinearTiled) ? 1 : 0; uint *end = buffer + length; uint *b = buffer; diff --git a/src/gui/painting/qdrawhelper_p.h b/src/gui/painting/qdrawhelper_p.h index 99a3534545..72eba9ea6d 100644 --- a/src/gui/painting/qdrawhelper_p.h +++ b/src/gui/painting/qdrawhelper_p.h @@ -858,10 +858,10 @@ static inline uint BYTE_MUL_RGB16_32(uint x, uint a) { } // qt_div_255 is a fast rounded division by 255 using an approximation that is accurate for all positive 16-bit integers -static Q_DECL_CONSTEXPR inline int qt_div_255(int x) { return (x + (x>>8) + 0x80) >> 8; } -static Q_DECL_CONSTEXPR inline uint qt_div_257_floor(uint x) { return (x - (x >> 8)) >> 8; } -static Q_DECL_CONSTEXPR inline uint qt_div_257(uint x) { return qt_div_257_floor(x + 128); } -static Q_DECL_CONSTEXPR inline uint qt_div_65535(uint x) { return (x + (x>>16) + 0x8000U) >> 16; } +static constexpr inline int qt_div_255(int x) { return (x + (x>>8) + 0x80) >> 8; } +static constexpr inline uint qt_div_257_floor(uint x) { return (x - (x >> 8)) >> 8; } +static constexpr inline uint qt_div_257(uint x) { return qt_div_257_floor(x + 128); } +static constexpr inline uint qt_div_65535(uint x) { return (x + (x>>16) + 0x8000U) >> 16; } template inline void qt_memfill_template(T *dest, T color, qsizetype count) { @@ -1008,7 +1008,7 @@ inline uint comp_func_Plus_one_pixel(uint d, const uint s) #undef AMIX // must be multiple of 4 for easier SIMD implementations -static Q_CONSTEXPR int BufferSize = 2048; +static constexpr int BufferSize = 2048; // A buffer of intermediate results used by simple bilinear scaling. struct IntermediateBuffer diff --git a/src/gui/painting/qdrawingprimitive_sse2_p.h b/src/gui/painting/qdrawingprimitive_sse2_p.h index 8b91c590b8..b3bb22fe1b 100644 --- a/src/gui/painting/qdrawingprimitive_sse2_p.h +++ b/src/gui/painting/qdrawingprimitive_sse2_p.h @@ -269,7 +269,7 @@ static inline uint qConvertArgb32ToA2rgb30_sse4(QRgb p) return qConvertRgb32ToRgb30(p); if (alpha == 0) return 0; - Q_CONSTEXPR float mult = 1023.0f / (255 >> 6); + constexpr float mult = 1023.0f / (255 >> 6); const uint newalpha = (alpha >> 6); const __m128 va = _mm_set1_ps(alpha); __m128 via; diff --git a/src/gui/painting/qfixed_p.h b/src/gui/painting/qfixed_p.h index 846592881c..90d214fe96 100644 --- a/src/gui/painting/qfixed_p.h +++ b/src/gui/painting/qfixed_p.h @@ -60,49 +60,49 @@ QT_BEGIN_NAMESPACE struct QFixed { private: - Q_DECL_CONSTEXPR QFixed(int val, int) : val(val) {} // 2nd int is just a dummy for disambiguation + constexpr QFixed(int val, int) : val(val) {} // 2nd int is just a dummy for disambiguation public: - Q_DECL_CONSTEXPR QFixed() : val(0) {} - Q_DECL_CONSTEXPR QFixed(int i) : val(i * 64) {} - Q_DECL_CONSTEXPR QFixed(long i) : val(i * 64) {} + constexpr QFixed() : val(0) {} + constexpr QFixed(int i) : val(i * 64) {} + constexpr QFixed(long i) : val(i * 64) {} QFixed &operator=(int i) { val = i * 64; return *this; } QFixed &operator=(long i) { val = i * 64; return *this; } - Q_DECL_CONSTEXPR static QFixed fromReal(qreal r) { return fromFixed((int)(r*qreal(64))); } - Q_DECL_CONSTEXPR static QFixed fromFixed(int fixed) { return QFixed(fixed,0); } // uses private ctor + constexpr static QFixed fromReal(qreal r) { return fromFixed((int)(r*qreal(64))); } + constexpr static QFixed fromFixed(int fixed) { return QFixed(fixed,0); } // uses private ctor - Q_DECL_CONSTEXPR inline int value() const { return val; } + constexpr inline int value() const { return val; } inline void setValue(int value) { val = value; } - Q_DECL_CONSTEXPR inline int toInt() const { return (((val)+32) & -64)>>6; } - Q_DECL_CONSTEXPR inline qreal toReal() const { return ((qreal)val)/(qreal)64; } + constexpr inline int toInt() const { return (((val)+32) & -64)>>6; } + constexpr inline qreal toReal() const { return ((qreal)val)/(qreal)64; } - Q_DECL_CONSTEXPR inline int truncate() const { return val>>6; } - Q_DECL_CONSTEXPR inline QFixed round() const { return fromFixed(((val)+32) & -64); } - Q_DECL_CONSTEXPR inline QFixed floor() const { return fromFixed((val) & -64); } - Q_DECL_CONSTEXPR inline QFixed ceil() const { return fromFixed((val+63) & -64); } + constexpr inline int truncate() const { return val>>6; } + constexpr inline QFixed round() const { return fromFixed(((val)+32) & -64); } + constexpr inline QFixed floor() const { return fromFixed((val) & -64); } + constexpr inline QFixed ceil() const { return fromFixed((val+63) & -64); } - Q_DECL_CONSTEXPR inline QFixed operator+(int i) const { return fromFixed(val + i * 64); } - Q_DECL_CONSTEXPR inline QFixed operator+(uint i) const { return fromFixed((val + (i<<6))); } - Q_DECL_CONSTEXPR inline QFixed operator+(const QFixed &other) const { return fromFixed((val + other.val)); } + constexpr inline QFixed operator+(int i) const { return fromFixed(val + i * 64); } + constexpr inline QFixed operator+(uint i) const { return fromFixed((val + (i<<6))); } + constexpr inline QFixed operator+(const QFixed &other) const { return fromFixed((val + other.val)); } inline QFixed &operator+=(int i) { val += i * 64; return *this; } inline QFixed &operator+=(uint i) { val += (i<<6); return *this; } inline QFixed &operator+=(const QFixed &other) { val += other.val; return *this; } - Q_DECL_CONSTEXPR inline QFixed operator-(int i) const { return fromFixed(val - i * 64); } - Q_DECL_CONSTEXPR inline QFixed operator-(uint i) const { return fromFixed((val - (i<<6))); } - Q_DECL_CONSTEXPR inline QFixed operator-(const QFixed &other) const { return fromFixed((val - other.val)); } + constexpr inline QFixed operator-(int i) const { return fromFixed(val - i * 64); } + constexpr inline QFixed operator-(uint i) const { return fromFixed((val - (i<<6))); } + constexpr inline QFixed operator-(const QFixed &other) const { return fromFixed((val - other.val)); } inline QFixed &operator-=(int i) { val -= i * 64; return *this; } inline QFixed &operator-=(uint i) { val -= (i<<6); return *this; } inline QFixed &operator-=(const QFixed &other) { val -= other.val; return *this; } - Q_DECL_CONSTEXPR inline QFixed operator-() const { return fromFixed(-val); } + constexpr inline QFixed operator-() const { return fromFixed(-val); } - Q_DECL_CONSTEXPR inline bool operator==(const QFixed &other) const { return val == other.val; } - Q_DECL_CONSTEXPR inline bool operator!=(const QFixed &other) const { return val != other.val; } - Q_DECL_CONSTEXPR inline bool operator<(const QFixed &other) const { return val < other.val; } - Q_DECL_CONSTEXPR inline bool operator>(const QFixed &other) const { return val > other.val; } - Q_DECL_CONSTEXPR inline bool operator<=(const QFixed &other) const { return val <= other.val; } - Q_DECL_CONSTEXPR inline bool operator>=(const QFixed &other) const { return val >= other.val; } - Q_DECL_CONSTEXPR inline bool operator!() const { return !val; } + constexpr inline bool operator==(const QFixed &other) const { return val == other.val; } + constexpr inline bool operator!=(const QFixed &other) const { return val != other.val; } + constexpr inline bool operator<(const QFixed &other) const { return val < other.val; } + constexpr inline bool operator>(const QFixed &other) const { return val > other.val; } + constexpr inline bool operator<=(const QFixed &other) const { return val <= other.val; } + constexpr inline bool operator>=(const QFixed &other) const { return val >= other.val; } + constexpr inline bool operator!() const { return !val; } inline QFixed &operator/=(int x) { val /= x; return *this; } inline QFixed &operator/=(const QFixed &o) { @@ -121,7 +121,7 @@ public: } return *this; } - Q_DECL_CONSTEXPR inline QFixed operator/(int d) const { return fromFixed(val/d); } + constexpr inline QFixed operator/(int d) const { return fromFixed(val/d); } inline QFixed operator/(QFixed b) const { QFixed f = *this; return (f /= b); } inline QFixed operator>>(int d) const { QFixed f = *this; f.val >>= d; return f; } inline QFixed &operator*=(int i) { val *= i; return *this; } @@ -137,50 +137,50 @@ public: val = neg ? -res : res; return *this; } - Q_DECL_CONSTEXPR inline QFixed operator*(int i) const { return fromFixed(val * i); } - Q_DECL_CONSTEXPR inline QFixed operator*(uint i) const { return fromFixed(val * i); } + constexpr inline QFixed operator*(int i) const { return fromFixed(val * i); } + constexpr inline QFixed operator*(uint i) const { return fromFixed(val * i); } inline QFixed operator*(const QFixed &o) const { QFixed f = *this; return (f *= o); } private: - Q_DECL_CONSTEXPR QFixed(qreal i) : val((int)(i*qreal(64))) {} + constexpr QFixed(qreal i) : val((int)(i*qreal(64))) {} QFixed &operator=(qreal i) { val = (int)(i*qreal(64)); return *this; } - Q_DECL_CONSTEXPR inline QFixed operator+(qreal i) const { return fromFixed((val + (int)(i*qreal(64)))); } + constexpr inline QFixed operator+(qreal i) const { return fromFixed((val + (int)(i*qreal(64)))); } inline QFixed &operator+=(qreal i) { val += (int)(i*64); return *this; } - Q_DECL_CONSTEXPR inline QFixed operator-(qreal i) const { return fromFixed((val - (int)(i*qreal(64)))); } + constexpr inline QFixed operator-(qreal i) const { return fromFixed((val - (int)(i*qreal(64)))); } inline QFixed &operator-=(qreal i) { val -= (int)(i*64); return *this; } inline QFixed &operator/=(qreal r) { val = (int)(val/r); return *this; } - Q_DECL_CONSTEXPR inline QFixed operator/(qreal d) const { return fromFixed((int)(val/d)); } + constexpr inline QFixed operator/(qreal d) const { return fromFixed((int)(val/d)); } inline QFixed &operator*=(qreal d) { val = (int) (val*d); return *this; } - Q_DECL_CONSTEXPR inline QFixed operator*(qreal d) const { return fromFixed((int) (val*d)); } + constexpr inline QFixed operator*(qreal d) const { return fromFixed((int) (val*d)); } int val; }; Q_DECLARE_TYPEINFO(QFixed, Q_PRIMITIVE_TYPE); #define QFIXED_MAX (INT_MAX/256) -Q_DECL_CONSTEXPR inline int qRound(const QFixed &f) { return f.toInt(); } -Q_DECL_CONSTEXPR inline int qFloor(const QFixed &f) { return f.floor().truncate(); } - -Q_DECL_CONSTEXPR inline QFixed operator*(int i, const QFixed &d) { return d*i; } -Q_DECL_CONSTEXPR inline QFixed operator+(int i, const QFixed &d) { return d+i; } -Q_DECL_CONSTEXPR inline QFixed operator-(int i, const QFixed &d) { return -(d-i); } -Q_DECL_CONSTEXPR inline QFixed operator*(uint i, const QFixed &d) { return d*i; } -Q_DECL_CONSTEXPR inline QFixed operator+(uint i, const QFixed &d) { return d+i; } -Q_DECL_CONSTEXPR inline QFixed operator-(uint i, const QFixed &d) { return -(d-i); } -// Q_DECL_CONSTEXPR inline QFixed operator*(qreal d, const QFixed &d2) { return d2*d; } - -Q_DECL_CONSTEXPR inline bool operator==(const QFixed &f, int i) { return f.value() == i * 64; } -Q_DECL_CONSTEXPR inline bool operator==(int i, const QFixed &f) { return f.value() == i * 64; } -Q_DECL_CONSTEXPR inline bool operator!=(const QFixed &f, int i) { return f.value() != i * 64; } -Q_DECL_CONSTEXPR inline bool operator!=(int i, const QFixed &f) { return f.value() != i * 64; } -Q_DECL_CONSTEXPR inline bool operator<=(const QFixed &f, int i) { return f.value() <= i * 64; } -Q_DECL_CONSTEXPR inline bool operator<=(int i, const QFixed &f) { return i * 64 <= f.value(); } -Q_DECL_CONSTEXPR inline bool operator>=(const QFixed &f, int i) { return f.value() >= i * 64; } -Q_DECL_CONSTEXPR inline bool operator>=(int i, const QFixed &f) { return i * 64 >= f.value(); } -Q_DECL_CONSTEXPR inline bool operator<(const QFixed &f, int i) { return f.value() < i * 64; } -Q_DECL_CONSTEXPR inline bool operator<(int i, const QFixed &f) { return i * 64 < f.value(); } -Q_DECL_CONSTEXPR inline bool operator>(const QFixed &f, int i) { return f.value() > i * 64; } -Q_DECL_CONSTEXPR inline bool operator>(int i, const QFixed &f) { return i * 64 > f.value(); } +constexpr inline int qRound(const QFixed &f) { return f.toInt(); } +constexpr inline int qFloor(const QFixed &f) { return f.floor().truncate(); } + +constexpr inline QFixed operator*(int i, const QFixed &d) { return d*i; } +constexpr inline QFixed operator+(int i, const QFixed &d) { return d+i; } +constexpr inline QFixed operator-(int i, const QFixed &d) { return -(d-i); } +constexpr inline QFixed operator*(uint i, const QFixed &d) { return d*i; } +constexpr inline QFixed operator+(uint i, const QFixed &d) { return d+i; } +constexpr inline QFixed operator-(uint i, const QFixed &d) { return -(d-i); } +// constexpr inline QFixed operator*(qreal d, const QFixed &d2) { return d2*d; } + +constexpr inline bool operator==(const QFixed &f, int i) { return f.value() == i * 64; } +constexpr inline bool operator==(int i, const QFixed &f) { return f.value() == i * 64; } +constexpr inline bool operator!=(const QFixed &f, int i) { return f.value() != i * 64; } +constexpr inline bool operator!=(int i, const QFixed &f) { return f.value() != i * 64; } +constexpr inline bool operator<=(const QFixed &f, int i) { return f.value() <= i * 64; } +constexpr inline bool operator<=(int i, const QFixed &f) { return i * 64 <= f.value(); } +constexpr inline bool operator>=(const QFixed &f, int i) { return f.value() >= i * 64; } +constexpr inline bool operator>=(int i, const QFixed &f) { return i * 64 >= f.value(); } +constexpr inline bool operator<(const QFixed &f, int i) { return f.value() < i * 64; } +constexpr inline bool operator<(int i, const QFixed &f) { return i * 64 < f.value(); } +constexpr inline bool operator>(const QFixed &f, int i) { return f.value() > i * 64; } +constexpr inline bool operator>(int i, const QFixed &f) { return i * 64 > f.value(); } #ifndef QT_NO_DEBUG_STREAM inline QDebug &operator<<(QDebug &dbg, const QFixed &f) @@ -190,27 +190,27 @@ inline QDebug &operator<<(QDebug &dbg, const QFixed &f) struct QFixedPoint { QFixed x; QFixed y; - Q_DECL_CONSTEXPR inline QFixedPoint() {} - Q_DECL_CONSTEXPR inline QFixedPoint(const QFixed &_x, const QFixed &_y) : x(_x), y(_y) {} - Q_DECL_CONSTEXPR QPointF toPointF() const { return QPointF(x.toReal(), y.toReal()); } - Q_DECL_CONSTEXPR static QFixedPoint fromPointF(const QPointF &p) { + constexpr inline QFixedPoint() {} + constexpr inline QFixedPoint(const QFixed &_x, const QFixed &_y) : x(_x), y(_y) {} + constexpr QPointF toPointF() const { return QPointF(x.toReal(), y.toReal()); } + constexpr static QFixedPoint fromPointF(const QPointF &p) { return QFixedPoint(QFixed::fromReal(p.x()), QFixed::fromReal(p.y())); } }; Q_DECLARE_TYPEINFO(QFixedPoint, Q_PRIMITIVE_TYPE); -Q_DECL_CONSTEXPR inline QFixedPoint operator-(const QFixedPoint &p1, const QFixedPoint &p2) +constexpr inline QFixedPoint operator-(const QFixedPoint &p1, const QFixedPoint &p2) { return QFixedPoint(p1.x - p2.x, p1.y - p2.y); } -Q_DECL_CONSTEXPR inline QFixedPoint operator+(const QFixedPoint &p1, const QFixedPoint &p2) +constexpr inline QFixedPoint operator+(const QFixedPoint &p1, const QFixedPoint &p2) { return QFixedPoint(p1.x + p2.x, p1.y + p2.y); } struct QFixedSize { QFixed width; QFixed height; - Q_DECL_CONSTEXPR QFixedSize() {} - Q_DECL_CONSTEXPR QFixedSize(QFixed _width, QFixed _height) : width(_width), height(_height) {} - Q_DECL_CONSTEXPR QSizeF toSizeF() const { return QSizeF(width.toReal(), height.toReal()); } - Q_DECL_CONSTEXPR static QFixedSize fromSizeF(const QSizeF &s) { + constexpr QFixedSize() {} + constexpr QFixedSize(QFixed _width, QFixed _height) : width(_width), height(_height) {} + constexpr QSizeF toSizeF() const { return QSizeF(width.toReal(), height.toReal()); } + constexpr static QFixedSize fromSizeF(const QSizeF &s) { return QFixedSize(QFixed::fromReal(s.width()), QFixed::fromReal(s.height())); } }; diff --git a/src/gui/painting/qpixellayout.cpp b/src/gui/painting/qpixellayout.cpp index ad6df37228..c931cc0a09 100644 --- a/src/gui/painting/qpixellayout.cpp +++ b/src/gui/painting/qpixellayout.cpp @@ -46,146 +46,146 @@ QT_BEGIN_NAMESPACE -template Q_DECL_CONSTEXPR uint redWidth(); -template Q_DECL_CONSTEXPR uint redShift(); -template Q_DECL_CONSTEXPR uint greenWidth(); -template Q_DECL_CONSTEXPR uint greenShift(); -template Q_DECL_CONSTEXPR uint blueWidth(); -template Q_DECL_CONSTEXPR uint blueShift(); -template Q_DECL_CONSTEXPR uint alphaWidth(); -template Q_DECL_CONSTEXPR uint alphaShift(); - -template<> Q_DECL_CONSTEXPR uint redWidth() { return 5; } -template<> Q_DECL_CONSTEXPR uint redWidth() { return 4; } -template<> Q_DECL_CONSTEXPR uint redWidth() { return 5; } -template<> Q_DECL_CONSTEXPR uint redWidth() { return 6; } -template<> Q_DECL_CONSTEXPR uint redWidth() { return 8; } -template<> Q_DECL_CONSTEXPR uint redWidth() { return 8; } -template<> Q_DECL_CONSTEXPR uint redWidth() { return 4; } -template<> Q_DECL_CONSTEXPR uint redWidth() { return 5; } -template<> Q_DECL_CONSTEXPR uint redWidth() { return 5; } -template<> Q_DECL_CONSTEXPR uint redWidth() { return 6; } -template<> Q_DECL_CONSTEXPR uint redWidth() { return 8; } -template<> Q_DECL_CONSTEXPR uint redWidth() { return 8; } -template<> Q_DECL_CONSTEXPR uint redWidth() { return 8; } - -template<> Q_DECL_CONSTEXPR uint redShift() { return 11; } -template<> Q_DECL_CONSTEXPR uint redShift() { return 8; } -template<> Q_DECL_CONSTEXPR uint redShift() { return 10; } -template<> Q_DECL_CONSTEXPR uint redShift() { return 12; } -template<> Q_DECL_CONSTEXPR uint redShift() { return 16; } -template<> Q_DECL_CONSTEXPR uint redShift() { return 0; } -template<> Q_DECL_CONSTEXPR uint redShift() { return 8; } -template<> Q_DECL_CONSTEXPR uint redShift() { return 18; } -template<> Q_DECL_CONSTEXPR uint redShift() { return 19; } -template<> Q_DECL_CONSTEXPR uint redShift() { return 12; } +template constexpr uint redWidth(); +template constexpr uint redShift(); +template constexpr uint greenWidth(); +template constexpr uint greenShift(); +template constexpr uint blueWidth(); +template constexpr uint blueShift(); +template constexpr uint alphaWidth(); +template constexpr uint alphaShift(); + +template<> constexpr uint redWidth() { return 5; } +template<> constexpr uint redWidth() { return 4; } +template<> constexpr uint redWidth() { return 5; } +template<> constexpr uint redWidth() { return 6; } +template<> constexpr uint redWidth() { return 8; } +template<> constexpr uint redWidth() { return 8; } +template<> constexpr uint redWidth() { return 4; } +template<> constexpr uint redWidth() { return 5; } +template<> constexpr uint redWidth() { return 5; } +template<> constexpr uint redWidth() { return 6; } +template<> constexpr uint redWidth() { return 8; } +template<> constexpr uint redWidth() { return 8; } +template<> constexpr uint redWidth() { return 8; } + +template<> constexpr uint redShift() { return 11; } +template<> constexpr uint redShift() { return 8; } +template<> constexpr uint redShift() { return 10; } +template<> constexpr uint redShift() { return 12; } +template<> constexpr uint redShift() { return 16; } +template<> constexpr uint redShift() { return 0; } +template<> constexpr uint redShift() { return 8; } +template<> constexpr uint redShift() { return 18; } +template<> constexpr uint redShift() { return 19; } +template<> constexpr uint redShift() { return 12; } #if Q_BYTE_ORDER == Q_BIG_ENDIAN -template<> Q_DECL_CONSTEXPR uint redShift() { return 24; } -template<> Q_DECL_CONSTEXPR uint redShift() { return 24; } -template<> Q_DECL_CONSTEXPR uint redShift() { return 24; } +template<> constexpr uint redShift() { return 24; } +template<> constexpr uint redShift() { return 24; } +template<> constexpr uint redShift() { return 24; } #else -template<> Q_DECL_CONSTEXPR uint redShift() { return 0; } -template<> Q_DECL_CONSTEXPR uint redShift() { return 0; } -template<> Q_DECL_CONSTEXPR uint redShift() { return 0; } +template<> constexpr uint redShift() { return 0; } +template<> constexpr uint redShift() { return 0; } +template<> constexpr uint redShift() { return 0; } #endif -template<> Q_DECL_CONSTEXPR uint greenWidth() { return 6; } -template<> Q_DECL_CONSTEXPR uint greenWidth() { return 4; } -template<> Q_DECL_CONSTEXPR uint greenWidth() { return 5; } -template<> Q_DECL_CONSTEXPR uint greenWidth() { return 6; } -template<> Q_DECL_CONSTEXPR uint greenWidth() { return 8; } -template<> Q_DECL_CONSTEXPR uint greenWidth() { return 8; } -template<> Q_DECL_CONSTEXPR uint greenWidth() { return 4; } -template<> Q_DECL_CONSTEXPR uint greenWidth() { return 5; } -template<> Q_DECL_CONSTEXPR uint greenWidth() { return 6; } -template<> Q_DECL_CONSTEXPR uint greenWidth() { return 6; } -template<> Q_DECL_CONSTEXPR uint greenWidth() { return 8; } -template<> Q_DECL_CONSTEXPR uint greenWidth() { return 8; } -template<> Q_DECL_CONSTEXPR uint greenWidth() { return 8; } - -template<> Q_DECL_CONSTEXPR uint greenShift() { return 5; } -template<> Q_DECL_CONSTEXPR uint greenShift() { return 4; } -template<> Q_DECL_CONSTEXPR uint greenShift() { return 5; } -template<> Q_DECL_CONSTEXPR uint greenShift() { return 6; } -template<> Q_DECL_CONSTEXPR uint greenShift() { return 8; } -template<> Q_DECL_CONSTEXPR uint greenShift() { return 8; } -template<> Q_DECL_CONSTEXPR uint greenShift() { return 4; } -template<> Q_DECL_CONSTEXPR uint greenShift() { return 13; } -template<> Q_DECL_CONSTEXPR uint greenShift() { return 13; } -template<> Q_DECL_CONSTEXPR uint greenShift() { return 6; } +template<> constexpr uint greenWidth() { return 6; } +template<> constexpr uint greenWidth() { return 4; } +template<> constexpr uint greenWidth() { return 5; } +template<> constexpr uint greenWidth() { return 6; } +template<> constexpr uint greenWidth() { return 8; } +template<> constexpr uint greenWidth() { return 8; } +template<> constexpr uint greenWidth() { return 4; } +template<> constexpr uint greenWidth() { return 5; } +template<> constexpr uint greenWidth() { return 6; } +template<> constexpr uint greenWidth() { return 6; } +template<> constexpr uint greenWidth() { return 8; } +template<> constexpr uint greenWidth() { return 8; } +template<> constexpr uint greenWidth() { return 8; } + +template<> constexpr uint greenShift() { return 5; } +template<> constexpr uint greenShift() { return 4; } +template<> constexpr uint greenShift() { return 5; } +template<> constexpr uint greenShift() { return 6; } +template<> constexpr uint greenShift() { return 8; } +template<> constexpr uint greenShift() { return 8; } +template<> constexpr uint greenShift() { return 4; } +template<> constexpr uint greenShift() { return 13; } +template<> constexpr uint greenShift() { return 13; } +template<> constexpr uint greenShift() { return 6; } #if Q_BYTE_ORDER == Q_BIG_ENDIAN -template<> Q_DECL_CONSTEXPR uint greenShift() { return 16; } -template<> Q_DECL_CONSTEXPR uint greenShift() { return 16; } -template<> Q_DECL_CONSTEXPR uint greenShift() { return 16; } +template<> constexpr uint greenShift() { return 16; } +template<> constexpr uint greenShift() { return 16; } +template<> constexpr uint greenShift() { return 16; } #else -template<> Q_DECL_CONSTEXPR uint greenShift() { return 8; } -template<> Q_DECL_CONSTEXPR uint greenShift() { return 8; } -template<> Q_DECL_CONSTEXPR uint greenShift() { return 8; } +template<> constexpr uint greenShift() { return 8; } +template<> constexpr uint greenShift() { return 8; } +template<> constexpr uint greenShift() { return 8; } #endif -template<> Q_DECL_CONSTEXPR uint blueWidth() { return 5; } -template<> Q_DECL_CONSTEXPR uint blueWidth() { return 4; } -template<> Q_DECL_CONSTEXPR uint blueWidth() { return 5; } -template<> Q_DECL_CONSTEXPR uint blueWidth() { return 6; } -template<> Q_DECL_CONSTEXPR uint blueWidth() { return 8; } -template<> Q_DECL_CONSTEXPR uint blueWidth() { return 8; } -template<> Q_DECL_CONSTEXPR uint blueWidth() { return 4; } -template<> Q_DECL_CONSTEXPR uint blueWidth() { return 5; } -template<> Q_DECL_CONSTEXPR uint blueWidth() { return 5; } -template<> Q_DECL_CONSTEXPR uint blueWidth() { return 6; } -template<> Q_DECL_CONSTEXPR uint blueWidth() { return 8; } -template<> Q_DECL_CONSTEXPR uint blueWidth() { return 8; } -template<> Q_DECL_CONSTEXPR uint blueWidth() { return 8; } - -template<> Q_DECL_CONSTEXPR uint blueShift() { return 0; } -template<> Q_DECL_CONSTEXPR uint blueShift() { return 0; } -template<> Q_DECL_CONSTEXPR uint blueShift() { return 0; } -template<> Q_DECL_CONSTEXPR uint blueShift() { return 0; } -template<> Q_DECL_CONSTEXPR uint blueShift() { return 0; } -template<> Q_DECL_CONSTEXPR uint blueShift() { return 16; } -template<> Q_DECL_CONSTEXPR uint blueShift() { return 0; } -template<> Q_DECL_CONSTEXPR uint blueShift() { return 8; } -template<> Q_DECL_CONSTEXPR uint blueShift() { return 8; } -template<> Q_DECL_CONSTEXPR uint blueShift() { return 0; } +template<> constexpr uint blueWidth() { return 5; } +template<> constexpr uint blueWidth() { return 4; } +template<> constexpr uint blueWidth() { return 5; } +template<> constexpr uint blueWidth() { return 6; } +template<> constexpr uint blueWidth() { return 8; } +template<> constexpr uint blueWidth() { return 8; } +template<> constexpr uint blueWidth() { return 4; } +template<> constexpr uint blueWidth() { return 5; } +template<> constexpr uint blueWidth() { return 5; } +template<> constexpr uint blueWidth() { return 6; } +template<> constexpr uint blueWidth() { return 8; } +template<> constexpr uint blueWidth() { return 8; } +template<> constexpr uint blueWidth() { return 8; } + +template<> constexpr uint blueShift() { return 0; } +template<> constexpr uint blueShift() { return 0; } +template<> constexpr uint blueShift() { return 0; } +template<> constexpr uint blueShift() { return 0; } +template<> constexpr uint blueShift() { return 0; } +template<> constexpr uint blueShift() { return 16; } +template<> constexpr uint blueShift() { return 0; } +template<> constexpr uint blueShift() { return 8; } +template<> constexpr uint blueShift() { return 8; } +template<> constexpr uint blueShift() { return 0; } #if Q_BYTE_ORDER == Q_BIG_ENDIAN -template<> Q_DECL_CONSTEXPR uint blueShift() { return 8; } -template<> Q_DECL_CONSTEXPR uint blueShift() { return 8; } -template<> Q_DECL_CONSTEXPR uint blueShift() { return 8; } +template<> constexpr uint blueShift() { return 8; } +template<> constexpr uint blueShift() { return 8; } +template<> constexpr uint blueShift() { return 8; } #else -template<> Q_DECL_CONSTEXPR uint blueShift() { return 16; } -template<> Q_DECL_CONSTEXPR uint blueShift() { return 16; } -template<> Q_DECL_CONSTEXPR uint blueShift() { return 16; } +template<> constexpr uint blueShift() { return 16; } +template<> constexpr uint blueShift() { return 16; } +template<> constexpr uint blueShift() { return 16; } #endif -template<> Q_DECL_CONSTEXPR uint alphaWidth() { return 0; } -template<> Q_DECL_CONSTEXPR uint alphaWidth() { return 0; } -template<> Q_DECL_CONSTEXPR uint alphaWidth() { return 0; } -template<> Q_DECL_CONSTEXPR uint alphaWidth() { return 0; } -template<> Q_DECL_CONSTEXPR uint alphaWidth() { return 0; } -template<> Q_DECL_CONSTEXPR uint alphaWidth() { return 0; } -template<> Q_DECL_CONSTEXPR uint alphaWidth() { return 4; } -template<> Q_DECL_CONSTEXPR uint alphaWidth() { return 8; } -template<> Q_DECL_CONSTEXPR uint alphaWidth() { return 8; } -template<> Q_DECL_CONSTEXPR uint alphaWidth() { return 6; } -template<> Q_DECL_CONSTEXPR uint alphaWidth() { return 0; } -template<> Q_DECL_CONSTEXPR uint alphaWidth() { return 8; } -template<> Q_DECL_CONSTEXPR uint alphaWidth() { return 8; } - -template<> Q_DECL_CONSTEXPR uint alphaShift() { return 0; } -template<> Q_DECL_CONSTEXPR uint alphaShift() { return 0; } -template<> Q_DECL_CONSTEXPR uint alphaShift() { return 0; } -template<> Q_DECL_CONSTEXPR uint alphaShift() { return 0; } -template<> Q_DECL_CONSTEXPR uint alphaShift() { return 0; } -template<> Q_DECL_CONSTEXPR uint alphaShift() { return 0; } -template<> Q_DECL_CONSTEXPR uint alphaShift() { return 12; } -template<> Q_DECL_CONSTEXPR uint alphaShift() { return 0; } -template<> Q_DECL_CONSTEXPR uint alphaShift() { return 0; } -template<> Q_DECL_CONSTEXPR uint alphaShift() { return 18; } +template<> constexpr uint alphaWidth() { return 0; } +template<> constexpr uint alphaWidth() { return 0; } +template<> constexpr uint alphaWidth() { return 0; } +template<> constexpr uint alphaWidth() { return 0; } +template<> constexpr uint alphaWidth() { return 0; } +template<> constexpr uint alphaWidth() { return 0; } +template<> constexpr uint alphaWidth() { return 4; } +template<> constexpr uint alphaWidth() { return 8; } +template<> constexpr uint alphaWidth() { return 8; } +template<> constexpr uint alphaWidth() { return 6; } +template<> constexpr uint alphaWidth() { return 0; } +template<> constexpr uint alphaWidth() { return 8; } +template<> constexpr uint alphaWidth() { return 8; } + +template<> constexpr uint alphaShift() { return 0; } +template<> constexpr uint alphaShift() { return 0; } +template<> constexpr uint alphaShift() { return 0; } +template<> constexpr uint alphaShift() { return 0; } +template<> constexpr uint alphaShift() { return 0; } +template<> constexpr uint alphaShift() { return 0; } +template<> constexpr uint alphaShift() { return 12; } +template<> constexpr uint alphaShift() { return 0; } +template<> constexpr uint alphaShift() { return 0; } +template<> constexpr uint alphaShift() { return 18; } #if Q_BYTE_ORDER == Q_BIG_ENDIAN -template<> Q_DECL_CONSTEXPR uint alphaShift() { return 0; } -template<> Q_DECL_CONSTEXPR uint alphaShift() { return 0; } -template<> Q_DECL_CONSTEXPR uint alphaShift() { return 0; } +template<> constexpr uint alphaShift() { return 0; } +template<> constexpr uint alphaShift() { return 0; } +template<> constexpr uint alphaShift() { return 0; } #else -template<> Q_DECL_CONSTEXPR uint alphaShift() { return 24; } -template<> Q_DECL_CONSTEXPR uint alphaShift() { return 24; } -template<> Q_DECL_CONSTEXPR uint alphaShift() { return 24; } +template<> constexpr uint alphaShift() { return 24; } +template<> constexpr uint alphaShift() { return 24; } +template<> constexpr uint alphaShift() { return 24; } #endif template constexpr QPixelLayout::BPP bitsPerPixel(); @@ -221,17 +221,17 @@ inline void QT_FASTCALL storePixel(uchar *dest, int index, template static inline uint convertPixelToRGB32(uint s) { - Q_CONSTEXPR uint redMask = ((1 << redWidth()) - 1); - Q_CONSTEXPR uint greenMask = ((1 << greenWidth()) - 1); - Q_CONSTEXPR uint blueMask = ((1 << blueWidth()) - 1); + constexpr uint redMask = ((1 << redWidth()) - 1); + constexpr uint greenMask = ((1 << greenWidth()) - 1); + constexpr uint blueMask = ((1 << blueWidth()) - 1); - Q_CONSTEXPR uchar redLeftShift = 8 - redWidth(); - Q_CONSTEXPR uchar greenLeftShift = 8 - greenWidth(); - Q_CONSTEXPR uchar blueLeftShift = 8 - blueWidth(); + constexpr uchar redLeftShift = 8 - redWidth(); + constexpr uchar greenLeftShift = 8 - greenWidth(); + constexpr uchar blueLeftShift = 8 - blueWidth(); - Q_CONSTEXPR uchar redRightShift = 2 * redWidth() - 8; - Q_CONSTEXPR uchar greenRightShift = 2 * greenWidth() - 8; - Q_CONSTEXPR uchar blueRightShift = 2 * blueWidth() - 8; + constexpr uchar redRightShift = 2 * redWidth() - 8; + constexpr uchar greenRightShift = 2 * greenWidth() - 8; + constexpr uchar blueRightShift = 2 * blueWidth() - 8; uint red = (s >> redShift()) & redMask; uint green = (s >> greenShift()) & greenMask; @@ -300,22 +300,22 @@ static const QRgba64 *QT_FASTCALL fetchRGBToRGB64(QRgba64 *buffer, const uchar * template static inline uint convertPixelToARGB32PM(uint s) { - Q_CONSTEXPR uint alphaMask = ((1 << alphaWidth()) - 1); - Q_CONSTEXPR uint redMask = ((1 << redWidth()) - 1); - Q_CONSTEXPR uint greenMask = ((1 << greenWidth()) - 1); - Q_CONSTEXPR uint blueMask = ((1 << blueWidth()) - 1); + constexpr uint alphaMask = ((1 << alphaWidth()) - 1); + constexpr uint redMask = ((1 << redWidth()) - 1); + constexpr uint greenMask = ((1 << greenWidth()) - 1); + constexpr uint blueMask = ((1 << blueWidth()) - 1); - Q_CONSTEXPR uchar alphaLeftShift = 8 - alphaWidth(); - Q_CONSTEXPR uchar redLeftShift = 8 - redWidth(); - Q_CONSTEXPR uchar greenLeftShift = 8 - greenWidth(); - Q_CONSTEXPR uchar blueLeftShift = 8 - blueWidth(); + constexpr uchar alphaLeftShift = 8 - alphaWidth(); + constexpr uchar redLeftShift = 8 - redWidth(); + constexpr uchar greenLeftShift = 8 - greenWidth(); + constexpr uchar blueLeftShift = 8 - blueWidth(); - Q_CONSTEXPR uchar alphaRightShift = 2 * alphaWidth() - 8; - Q_CONSTEXPR uchar redRightShift = 2 * redWidth() - 8; - Q_CONSTEXPR uchar greenRightShift = 2 * greenWidth() - 8; - Q_CONSTEXPR uchar blueRightShift = 2 * blueWidth() - 8; + constexpr uchar alphaRightShift = 2 * alphaWidth() - 8; + constexpr uchar redRightShift = 2 * redWidth() - 8; + constexpr uchar greenRightShift = 2 * greenWidth() - 8; + constexpr uchar blueRightShift = 2 * blueWidth() - 8; - Q_CONSTEXPR bool mustMin = (alphaWidth() != redWidth()) || + constexpr bool mustMin = (alphaWidth() != redWidth()) || (alphaWidth() != greenWidth()) || (alphaWidth() != blueWidth()); @@ -393,19 +393,19 @@ template static void QT_FASTCALL storeRGBFromARGB32PM(uchar *dest, const uint *src, int index, int count, const QList *, QDitherInfo *dither) { - Q_CONSTEXPR uchar rWidth = redWidth(); - Q_CONSTEXPR uchar gWidth = greenWidth(); - Q_CONSTEXPR uchar bWidth = blueWidth(); + constexpr uchar rWidth = redWidth(); + constexpr uchar gWidth = greenWidth(); + constexpr uchar bWidth = blueWidth(); constexpr QPixelLayout::BPP BPP = bitsPerPixel(); // RGB32 -> RGB888 is not a precision loss. if (!dither || (rWidth == 8 && gWidth == 8 && bWidth == 8)) { - Q_CONSTEXPR uint rMask = (1 << redWidth()) - 1; - Q_CONSTEXPR uint gMask = (1 << greenWidth()) - 1; - Q_CONSTEXPR uint bMask = (1 << blueWidth()) - 1; - Q_CONSTEXPR uchar rRightShift = 24 - redWidth(); - Q_CONSTEXPR uchar gRightShift = 16 - greenWidth(); - Q_CONSTEXPR uchar bRightShift = 8 - blueWidth(); + constexpr uint rMask = (1 << redWidth()) - 1; + constexpr uint gMask = (1 << greenWidth()) - 1; + constexpr uint bMask = (1 << blueWidth()) - 1; + constexpr uchar rRightShift = 24 - redWidth(); + constexpr uchar gRightShift = 16 - greenWidth(); + constexpr uchar bRightShift = 8 - blueWidth(); for (int i = 0; i < count; ++i) { const uint c = fromRGB ? src[i] : qUnpremultiply(src[i]); @@ -447,17 +447,17 @@ static void QT_FASTCALL storeARGBPMFromARGB32PM(uchar *dest, const uint *src, in { constexpr QPixelLayout::BPP BPP = bitsPerPixel(); if (!dither) { - Q_CONSTEXPR uint aMask = (1 << alphaWidth()) - 1; - Q_CONSTEXPR uint rMask = (1 << redWidth()) - 1; - Q_CONSTEXPR uint gMask = (1 << greenWidth()) - 1; - Q_CONSTEXPR uint bMask = (1 << blueWidth()) - 1; + constexpr uint aMask = (1 << alphaWidth()) - 1; + constexpr uint rMask = (1 << redWidth()) - 1; + constexpr uint gMask = (1 << greenWidth()) - 1; + constexpr uint bMask = (1 << blueWidth()) - 1; - Q_CONSTEXPR uchar aRightShift = 32 - alphaWidth(); - Q_CONSTEXPR uchar rRightShift = 24 - redWidth(); - Q_CONSTEXPR uchar gRightShift = 16 - greenWidth(); - Q_CONSTEXPR uchar bRightShift = 8 - blueWidth(); + constexpr uchar aRightShift = 32 - alphaWidth(); + constexpr uchar rRightShift = 24 - redWidth(); + constexpr uchar gRightShift = 16 - greenWidth(); + constexpr uchar bRightShift = 8 - blueWidth(); - Q_CONSTEXPR uint aOpaque = aMask << alphaShift(); + constexpr uint aOpaque = aMask << alphaShift(); for (int i = 0; i < count; ++i) { const uint c = src[i]; const uint a = fromRGB ? aOpaque : (((c >> aRightShift) & aMask) << alphaShift()); @@ -467,10 +467,10 @@ static void QT_FASTCALL storeARGBPMFromARGB32PM(uchar *dest, const uint *src, in storePixel(dest, index + i, a | r | g | b); }; } else { - Q_CONSTEXPR uchar aWidth = alphaWidth(); - Q_CONSTEXPR uchar rWidth = redWidth(); - Q_CONSTEXPR uchar gWidth = greenWidth(); - Q_CONSTEXPR uchar bWidth = blueWidth(); + constexpr uchar aWidth = alphaWidth(); + constexpr uchar rWidth = redWidth(); + constexpr uchar gWidth = greenWidth(); + constexpr uchar bWidth = blueWidth(); const uint *bayer_line = qt_bayer_matrix[dither->y & 15]; for (int i = 0; i < count; ++i) { @@ -503,19 +503,19 @@ static void QT_FASTCALL storeARGBPMFromARGB32PM(uchar *dest, const uint *src, in template static void QT_FASTCALL rbSwap(uchar *dst, const uchar *src, int count) { - Q_CONSTEXPR uchar aWidth = alphaWidth(); - Q_CONSTEXPR uchar aShift = alphaShift(); - Q_CONSTEXPR uchar rWidth = redWidth(); - Q_CONSTEXPR uchar rShift = redShift(); - Q_CONSTEXPR uchar gWidth = greenWidth(); - Q_CONSTEXPR uchar gShift = greenShift(); - Q_CONSTEXPR uchar bWidth = blueWidth(); - Q_CONSTEXPR uchar bShift = blueShift(); + constexpr uchar aWidth = alphaWidth(); + constexpr uchar aShift = alphaShift(); + constexpr uchar rWidth = redWidth(); + constexpr uchar rShift = redShift(); + constexpr uchar gWidth = greenWidth(); + constexpr uchar gShift = greenShift(); + constexpr uchar bWidth = blueWidth(); + constexpr uchar bShift = blueShift(); #ifdef Q_COMPILER_CONSTEXPR static_assert(rWidth == bWidth); #endif - Q_CONSTEXPR uint redBlueMask = (1 << rWidth) - 1; - Q_CONSTEXPR uint alphaGreenMask = (((1 << aWidth) - 1) << aShift) + constexpr uint redBlueMask = (1 << rWidth) - 1; + constexpr uint alphaGreenMask = (((1 << aWidth) - 1) << aShift) | (((1 << gWidth) - 1) << gShift); constexpr QPixelLayout::BPP bpp = bitsPerPixel(); @@ -570,7 +570,7 @@ static void QT_FASTCALL rbSwap_rgb30(uchar *d, const uchar *s, int count) UNALIASED_CONVERSION_LOOP(dest, src, count, qRgbSwapRgb30); } -template Q_DECL_CONSTEXPR static inline QPixelLayout pixelLayoutRGB() +template constexpr static inline QPixelLayout pixelLayoutRGB() { return QPixelLayout{ false, @@ -586,7 +586,7 @@ template Q_DECL_CONSTEXPR static inline QPixelLayout pixe }; } -template Q_DECL_CONSTEXPR static inline QPixelLayout pixelLayoutARGBPM() +template constexpr static inline QPixelLayout pixelLayoutARGBPM() { return QPixelLayout{ true, diff --git a/src/gui/painting/qpixellayout_p.h b/src/gui/painting/qpixellayout_p.h index 99d98ac36e..6d20131efe 100644 --- a/src/gui/painting/qpixellayout_p.h +++ b/src/gui/painting/qpixellayout_p.h @@ -77,7 +77,7 @@ inline QRgb qRepremultiply(QRgb p) if (alpha == 255 || alpha == 0) return p; p = qUnpremultiply(p); - Q_CONSTEXPR uint mult = 255 / (255 >> Shift); + constexpr uint mult = 255 / (255 >> Shift); const uint newAlpha = mult * (alpha >> Shift); p = (p & ~0xff000000) | (newAlpha<<24); return qPremultiply(p); @@ -90,7 +90,7 @@ inline QRgba64 qRepremultiply(QRgba64 p) if (alpha == 65535 || alpha == 0) return p; p = p.unpremultiplied(); - Q_CONSTEXPR uint mult = 65535 / (65535 >> Shift); + constexpr uint mult = 65535 / (65535 >> Shift); p.setAlpha(mult * (alpha >> Shift)); return p.premultiplied(); } diff --git a/src/gui/painting/qrgb.h b/src/gui/painting/qrgb.h index fe8306109b..c6caa62c75 100644 --- a/src/gui/painting/qrgb.h +++ b/src/gui/painting/qrgb.h @@ -51,34 +51,34 @@ typedef unsigned int QRgb; // RGB triplet // non-namespaced Qt global variable const Q_DECL_UNUSED QRgb RGB_MASK = 0x00ffffff; // masks RGB values -inline Q_DECL_CONSTEXPR int qRed(QRgb rgb) // get red part of RGB +inline constexpr int qRed(QRgb rgb) // get red part of RGB { return ((rgb >> 16) & 0xff); } -inline Q_DECL_CONSTEXPR int qGreen(QRgb rgb) // get green part of RGB +inline constexpr int qGreen(QRgb rgb) // get green part of RGB { return ((rgb >> 8) & 0xff); } -inline Q_DECL_CONSTEXPR int qBlue(QRgb rgb) // get blue part of RGB +inline constexpr int qBlue(QRgb rgb) // get blue part of RGB { return (rgb & 0xff); } -inline Q_DECL_CONSTEXPR int qAlpha(QRgb rgb) // get alpha part of RGBA +inline constexpr int qAlpha(QRgb rgb) // get alpha part of RGBA { return rgb >> 24; } -inline Q_DECL_CONSTEXPR QRgb qRgb(int r, int g, int b)// set RGB value +inline constexpr QRgb qRgb(int r, int g, int b) // set RGB value { return (0xffu << 24) | ((r & 0xffu) << 16) | ((g & 0xffu) << 8) | (b & 0xffu); } -inline Q_DECL_CONSTEXPR QRgb qRgba(int r, int g, int b, int a)// set RGBA value +inline constexpr QRgb qRgba(int r, int g, int b, int a) // set RGBA value { return ((a & 0xffu) << 24) | ((r & 0xffu) << 16) | ((g & 0xffu) << 8) | (b & 0xffu); } -inline Q_DECL_CONSTEXPR int qGray(int r, int g, int b)// convert R,G,B to gray 0..255 +inline constexpr int qGray(int r, int g, int b) // convert R,G,B to gray 0..255 { return (r*11+g*16+b*5)/32; } -inline Q_DECL_CONSTEXPR int qGray(QRgb rgb) // convert RGB to gray 0..255 +inline constexpr int qGray(QRgb rgb) // convert RGB to gray 0..255 { return qGray(qRed(rgb), qGreen(rgb), qBlue(rgb)); } -inline Q_DECL_CONSTEXPR bool qIsGray(QRgb rgb) +inline constexpr bool qIsGray(QRgb rgb) { return qRed(rgb) == qGreen(rgb) && qRed(rgb) == qBlue(rgb); } -inline Q_DECL_RELAXED_CONSTEXPR QRgb qPremultiply(QRgb x) +inline constexpr QRgb qPremultiply(QRgb x) { const uint a = qAlpha(x); uint t = (x & 0xff00ff) * a; diff --git a/src/gui/painting/qrgba64.h b/src/gui/painting/qrgba64.h index 30d5e244b8..2c644c4cf0 100644 --- a/src/gui/painting/qrgba64.h +++ b/src/gui/painting/qrgba64.h @@ -64,16 +64,16 @@ class QRgba64 { #endif }; - explicit Q_ALWAYS_INLINE Q_DECL_CONSTEXPR QRgba64(quint64 c) : rgba(c) { } + explicit Q_ALWAYS_INLINE constexpr QRgba64(quint64 c) : rgba(c) { } public: QRgba64() = default; - Q_DECL_CONSTEXPR static + constexpr static QRgba64 fromRgba64(quint64 c) { return QRgba64(c); } - Q_DECL_CONSTEXPR static + constexpr static QRgba64 fromRgba64(quint16 red, quint16 green, quint16 blue, quint16 alpha) { return fromRgba64(quint64(red) << RedShift @@ -81,42 +81,42 @@ public: | quint64(blue) << BlueShift | quint64(alpha) << AlphaShift); } - Q_DECL_RELAXED_CONSTEXPR static QRgba64 fromRgba(quint8 red, quint8 green, quint8 blue, quint8 alpha) + constexpr static QRgba64 fromRgba(quint8 red, quint8 green, quint8 blue, quint8 alpha) { QRgba64 rgb64 = fromRgba64(red, green, blue, alpha); // Expand the range so that 0x00 maps to 0x0000 and 0xff maps to 0xffff. rgb64.rgba |= rgb64.rgba << 8; return rgb64; } - Q_DECL_RELAXED_CONSTEXPR static + constexpr static QRgba64 fromArgb32(uint rgb) { return fromRgba(quint8(rgb >> 16), quint8(rgb >> 8), quint8(rgb), quint8(rgb >> 24)); } - Q_DECL_CONSTEXPR bool isOpaque() const + constexpr bool isOpaque() const { return (rgba & alphaMask()) == alphaMask(); } - Q_DECL_CONSTEXPR bool isTransparent() const + constexpr bool isTransparent() const { return (rgba & alphaMask()) == 0; } - Q_DECL_CONSTEXPR quint16 red() const { return quint16(rgba >> RedShift); } - Q_DECL_CONSTEXPR quint16 green() const { return quint16(rgba >> GreenShift); } - Q_DECL_CONSTEXPR quint16 blue() const { return quint16(rgba >> BlueShift); } - Q_DECL_CONSTEXPR quint16 alpha() const { return quint16(rgba >> AlphaShift); } + constexpr quint16 red() const { return quint16(rgba >> RedShift); } + constexpr quint16 green() const { return quint16(rgba >> GreenShift); } + constexpr quint16 blue() const { return quint16(rgba >> BlueShift); } + constexpr quint16 alpha() const { return quint16(rgba >> AlphaShift); } void setRed(quint16 _red) { rgba = (rgba & ~(Q_UINT64_C(0xffff) << RedShift)) | (quint64(_red) << RedShift); } void setGreen(quint16 _green) { rgba = (rgba & ~(Q_UINT64_C(0xffff) << GreenShift)) | (quint64(_green) << GreenShift); } void setBlue(quint16 _blue) { rgba = (rgba & ~(Q_UINT64_C(0xffff) << BlueShift)) | (quint64(_blue) << BlueShift); } void setAlpha(quint16 _alpha) { rgba = (rgba & ~(Q_UINT64_C(0xffff) << AlphaShift)) | (quint64(_alpha) << AlphaShift); } - Q_DECL_CONSTEXPR quint8 red8() const { return div_257(red()); } - Q_DECL_CONSTEXPR quint8 green8() const { return div_257(green()); } - Q_DECL_CONSTEXPR quint8 blue8() const { return div_257(blue()); } - Q_DECL_CONSTEXPR quint8 alpha8() const { return div_257(alpha()); } - Q_DECL_CONSTEXPR uint toArgb32() const + constexpr quint8 red8() const { return div_257(red()); } + constexpr quint8 green8() const { return div_257(green()); } + constexpr quint8 blue8() const { return div_257(blue()); } + constexpr quint8 alpha8() const { return div_257(alpha()); } + constexpr uint toArgb32() const { #if defined(__cpp_constexpr) && __cpp_constexpr-0 >= 201304 quint64 br = rgba & Q_UINT64_C(0xffff0000ffff); @@ -140,12 +140,12 @@ public: return uint((alpha8() << 24) | (red8() << 16) | (green8() << 8) | blue8()); #endif } - Q_DECL_CONSTEXPR ushort toRgb16() const + constexpr ushort toRgb16() const { return ushort((red() & 0xf800) | ((green() >> 10) << 5) | (blue() >> 11)); } - Q_DECL_RELAXED_CONSTEXPR QRgba64 premultiplied() const + constexpr QRgba64 premultiplied() const { if (isOpaque()) return *this; @@ -167,7 +167,7 @@ public: #endif } - Q_DECL_RELAXED_CONSTEXPR QRgba64 unpremultiplied() const + constexpr QRgba64 unpremultiplied() const { #if Q_PROCESSOR_WORDSIZE < 8 return unpremultiplied_32bit(); @@ -176,7 +176,7 @@ public: #endif } - Q_DECL_CONSTEXPR operator quint64() const + constexpr operator quint64() const { return rgba; } @@ -188,11 +188,11 @@ public: } private: - static Q_DECL_CONSTEXPR Q_ALWAYS_INLINE quint64 alphaMask() { return Q_UINT64_C(0xffff) << AlphaShift; } + static constexpr Q_ALWAYS_INLINE quint64 alphaMask() { return Q_UINT64_C(0xffff) << AlphaShift; } - static Q_DECL_CONSTEXPR Q_ALWAYS_INLINE quint8 div_257_floor(uint x) { return quint8((x - (x >> 8)) >> 8); } - static Q_DECL_CONSTEXPR Q_ALWAYS_INLINE quint8 div_257(quint16 x) { return div_257_floor(x + 128U); } - Q_DECL_RELAXED_CONSTEXPR Q_ALWAYS_INLINE QRgba64 unpremultiplied_32bit() const + static constexpr Q_ALWAYS_INLINE quint8 div_257_floor(uint x) { return quint8((x - (x >> 8)) >> 8); } + static constexpr Q_ALWAYS_INLINE quint8 div_257(quint16 x) { return div_257_floor(x + 128U); } + constexpr Q_ALWAYS_INLINE QRgba64 unpremultiplied_32bit() const { if (isOpaque() || isTransparent()) return *this; @@ -202,7 +202,7 @@ private: const quint16 b = quint16((blue() * 0xffff + a/2) / a); return fromRgba64(r, g, b, quint16(a)); } - Q_DECL_RELAXED_CONSTEXPR Q_ALWAYS_INLINE QRgba64 unpremultiplied_64bit() const + constexpr Q_ALWAYS_INLINE QRgba64 unpremultiplied_64bit() const { if (isOpaque() || isTransparent()) return *this; @@ -217,36 +217,36 @@ private: Q_DECLARE_TYPEINFO(QRgba64, Q_PRIMITIVE_TYPE); -Q_DECL_CONSTEXPR inline QRgba64 qRgba64(quint16 r, quint16 g, quint16 b, quint16 a) +constexpr inline QRgba64 qRgba64(quint16 r, quint16 g, quint16 b, quint16 a) { return QRgba64::fromRgba64(r, g, b, a); } -Q_DECL_CONSTEXPR inline QRgba64 qRgba64(quint64 c) +constexpr inline QRgba64 qRgba64(quint64 c) { return QRgba64::fromRgba64(c); } -Q_DECL_RELAXED_CONSTEXPR inline QRgba64 qPremultiply(QRgba64 c) +constexpr inline QRgba64 qPremultiply(QRgba64 c) { return c.premultiplied(); } -Q_DECL_RELAXED_CONSTEXPR inline QRgba64 qUnpremultiply(QRgba64 c) +constexpr inline QRgba64 qUnpremultiply(QRgba64 c) { return c.unpremultiplied(); } -inline Q_DECL_CONSTEXPR uint qRed(QRgba64 rgb) +inline constexpr uint qRed(QRgba64 rgb) { return rgb.red8(); } -inline Q_DECL_CONSTEXPR uint qGreen(QRgba64 rgb) +inline constexpr uint qGreen(QRgba64 rgb) { return rgb.green8(); } -inline Q_DECL_CONSTEXPR uint qBlue(QRgba64 rgb) +inline constexpr uint qBlue(QRgba64 rgb) { return rgb.blue8(); } -inline Q_DECL_CONSTEXPR uint qAlpha(QRgba64 rgb) +inline constexpr uint qAlpha(QRgba64 rgb) { return rgb.alpha8(); } QT_END_NAMESPACE diff --git a/src/gui/painting/webgradients.cpp b/src/gui/painting/webgradients.cpp index d837c4383c..8800523367 100644 --- a/src/gui/painting/webgradients.cpp +++ b/src/gui/painting/webgradients.cpp @@ -386,7 +386,7 @@ static QList qt_preset_gradient_stops(QGradient::Preset preset) return {}; } -static Q_CONSTEXPR QGradient::QGradientData qt_preset_gradient_data[] = { +static constexpr QGradient::QGradientData qt_preset_gradient_data[] = { { { 0, 1, 1, 0 } }, { { 0.5, 1, 0.5, 0 } }, { { 0.5, 1, 0.5, 0 } }, -- cgit v1.2.3