diff options
Diffstat (limited to 'src/gui/painting')
-rw-r--r-- | src/gui/painting/qblendfunctions.cpp | 18 | ||||
-rw-r--r-- | src/gui/painting/qcolor.cpp | 23 | ||||
-rw-r--r-- | src/gui/painting/qcolor.h | 6 | ||||
-rw-r--r-- | src/gui/painting/qcompositionfunctions.cpp | 88 | ||||
-rw-r--r-- | src/gui/painting/qdrawhelper.cpp | 70 | ||||
-rw-r--r-- | src/gui/painting/qdrawhelper_mips_dsp.cpp | 2 | ||||
-rw-r--r-- | src/gui/painting/qdrawhelper_mips_dsp_p.h | 2 | ||||
-rw-r--r-- | src/gui/painting/qdrawhelper_neon.cpp | 32 | ||||
-rw-r--r-- | src/gui/painting/qdrawhelper_neon_p.h | 2 | ||||
-rw-r--r-- | src/gui/painting/qdrawhelper_p.h | 114 | ||||
-rw-r--r-- | src/gui/painting/qdrawhelper_sse2.cpp | 40 | ||||
-rw-r--r-- | src/gui/painting/qdrawhelper_x86_p.h | 3 | ||||
-rw-r--r-- | src/gui/painting/qmemrotate.cpp | 14 | ||||
-rw-r--r-- | src/gui/painting/qpaintengineex.cpp | 3 | ||||
-rw-r--r-- | src/gui/painting/qpainter.cpp | 7 | ||||
-rw-r--r-- | src/gui/painting/qpainter.h | 3 | ||||
-rw-r--r-- | src/gui/painting/qpdf.cpp | 15 | ||||
-rw-r--r-- | src/gui/painting/qpdf_p.h | 2 | ||||
-rw-r--r-- | src/gui/painting/qpdfwriter.cpp | 2 | ||||
-rw-r--r-- | src/gui/painting/qstroker.cpp | 5 | ||||
-rw-r--r-- | src/gui/painting/qstroker_p.h | 5 | ||||
-rw-r--r-- | src/gui/painting/qvectorpath_p.h | 6 |
22 files changed, 193 insertions, 269 deletions
diff --git a/src/gui/painting/qblendfunctions.cpp b/src/gui/painting/qblendfunctions.cpp index 2dd5144e40..348eceb47f 100644 --- a/src/gui/painting/qblendfunctions.cpp +++ b/src/gui/painting/qblendfunctions.cpp @@ -187,19 +187,11 @@ void qt_blend_rgb16_on_rgb16(uchar *dst, int dbpl, #endif if (const_alpha == 256) { - if (w <= 64) { - while (h--) { - QT_MEMCPY_USHORT(dst, src, w); - dst += dbpl; - src += sbpl; - } - } else { - int length = w << 1; - while (h--) { - memcpy(dst, src, length); - dst += dbpl; - src += sbpl; - } + int length = w << 1; + while (h--) { + memcpy(dst, src, length); + dst += dbpl; + src += sbpl; } } else if (const_alpha != 0) { quint16 *d = (quint16 *) dst; diff --git a/src/gui/painting/qcolor.cpp b/src/gui/painting/qcolor.cpp index 1d7375d1df..ef3296a6d4 100644 --- a/src/gui/painting/qcolor.cpp +++ b/src/gui/painting/qcolor.cpp @@ -2487,6 +2487,15 @@ QColor QColor::fromHslF(qreal h, qreal s, qreal l, qreal a) return color; } +/*! + \obsolete + + Use the \c const overload instead. +*/ +void QColor::getCmyk(int *c, int *m, int *y, int *k, int *a) +{ + const_cast<const QColor *>(this)->getCmyk(c, m, y, k, a); +} /*! Sets the contents pointed to by \a c, \a m, \a y, \a k, and \a a, to the @@ -2498,7 +2507,7 @@ QColor QColor::fromHslF(qreal h, qreal s, qreal l, qreal a) \sa setCmyk(), {QColor#The CMYK Color Model}{The CMYK Color Model} */ -void QColor::getCmyk(int *c, int *m, int *y, int *k, int *a) +void QColor::getCmyk(int *c, int *m, int *y, int *k, int *a) const { if (!c || !m || !y || !k) return; @@ -2518,6 +2527,16 @@ void QColor::getCmyk(int *c, int *m, int *y, int *k, int *a) } /*! + \obsolete + + Use the \c const overload instead. +*/ +void QColor::getCmykF(qreal *c, qreal *m, qreal *y, qreal *k, qreal *a) +{ + const_cast<const QColor *>(this)->getCmykF(c, m, y, k, a); +} + +/*! Sets the contents pointed to by \a c, \a m, \a y, \a k, and \a a, to the cyan, magenta, yellow, black, and alpha-channel (transparency) components of the color's CMYK value. @@ -2527,7 +2546,7 @@ void QColor::getCmyk(int *c, int *m, int *y, int *k, int *a) \sa setCmykF(), {QColor#The CMYK Color Model}{The CMYK Color Model} */ -void QColor::getCmykF(qreal *c, qreal *m, qreal *y, qreal *k, qreal *a) +void QColor::getCmykF(qreal *c, qreal *m, qreal *y, qreal *k, qreal *a) const { if (!c || !m || !y || !k) return; diff --git a/src/gui/painting/qcolor.h b/src/gui/painting/qcolor.h index f7a9e9db59..a9b05ae7e3 100644 --- a/src/gui/painting/qcolor.h +++ b/src/gui/painting/qcolor.h @@ -172,10 +172,12 @@ public: qreal yellowF() const Q_DECL_NOTHROW; qreal blackF() const Q_DECL_NOTHROW; - void getCmyk(int *c, int *m, int *y, int *k, int *a = nullptr); + void getCmyk(int *c, int *m, int *y, int *k, int *a = nullptr); // ### Qt 6: remove + void getCmyk(int *c, int *m, int *y, int *k, int *a = nullptr) const; void setCmyk(int c, int m, int y, int k, int a = 255); - void getCmykF(qreal *c, qreal *m, qreal *y, qreal *k, qreal *a = nullptr); + void getCmykF(qreal *c, qreal *m, qreal *y, qreal *k, qreal *a = nullptr); // ### Qt 6: remove + void getCmykF(qreal *c, qreal *m, qreal *y, qreal *k, qreal *a = nullptr) const; void setCmykF(qreal c, qreal m, qreal y, qreal k, qreal a = 1.0); int hslHue() const Q_DECL_NOTHROW; // 0 <= hue < 360 diff --git a/src/gui/painting/qcompositionfunctions.cpp b/src/gui/painting/qcompositionfunctions.cpp index 027bf23115..5c1afe8425 100644 --- a/src/gui/painting/qcompositionfunctions.cpp +++ b/src/gui/painting/qcompositionfunctions.cpp @@ -1107,7 +1107,7 @@ static inline uint multiply_op_rgb64(uint dst, uint src, uint da, uint sa) } template <typename T> -Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_solid_Multiply_impl(uint *dest, int length, uint color, const T &coverage) +static inline void comp_func_solid_Multiply_impl(uint *dest, int length, uint color, const T &coverage) { int sa = qAlpha(color); int sr = qRed(color); @@ -1130,7 +1130,7 @@ Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_solid_Multiply_impl(uint *dest, } template <typename T> -Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_solid_Multiply_impl(QRgba64 *dest, int length, QRgba64 color, const T &coverage) +static inline void comp_func_solid_Multiply_impl(QRgba64 *dest, int length, QRgba64 color, const T &coverage) { uint sa = color.alpha(); uint sr = color.red(); @@ -1169,7 +1169,7 @@ void QT_FASTCALL comp_func_solid_Multiply_rgb64(QRgba64 *dest, int length, QRgba } template <typename T> -Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_Multiply_impl(uint *Q_DECL_RESTRICT dest, const uint *Q_DECL_RESTRICT src, int length, const T &coverage) +static inline void comp_func_Multiply_impl(uint *Q_DECL_RESTRICT dest, const uint *Q_DECL_RESTRICT src, int length, const T &coverage) { for (int i = 0; i < length; ++i) { uint d = dest[i]; @@ -1190,7 +1190,7 @@ Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_Multiply_impl(uint *Q_DECL_REST } template <typename T> -Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_Multiply_impl(QRgba64 *Q_DECL_RESTRICT dest, const QRgba64 *Q_DECL_RESTRICT src, int length, const T &coverage) +static inline void comp_func_Multiply_impl(QRgba64 *Q_DECL_RESTRICT dest, const QRgba64 *Q_DECL_RESTRICT src, int length, const T &coverage) { for (int i = 0; i < length; ++i) { QRgba64 d = dest[i]; @@ -1231,7 +1231,7 @@ void QT_FASTCALL comp_func_Multiply_rgb64(QRgba64 *Q_DECL_RESTRICT dest, const Q = Sca + Dca - Sca.Dca */ template <typename T> -Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_solid_Screen_impl(uint *dest, int length, uint color, const T &coverage) +static inline void comp_func_solid_Screen_impl(uint *dest, int length, uint color, const T &coverage) { int sa = qAlpha(color); int sr = qRed(color); @@ -1254,7 +1254,7 @@ Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_solid_Screen_impl(uint *dest, i } template <typename T> -Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_solid_Screen_impl(QRgba64 *dest, int length, QRgba64 color, const T &coverage) +static inline void comp_func_solid_Screen_impl(QRgba64 *dest, int length, QRgba64 color, const T &coverage) { uint sa = color.alpha(); uint sr = color.red(); @@ -1293,7 +1293,7 @@ void QT_FASTCALL comp_func_solid_Screen_rgb64(QRgba64 *dest, int length, QRgba64 } template <typename T> -Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_Screen_impl(uint *Q_DECL_RESTRICT dest, const uint *Q_DECL_RESTRICT src, int length, const T &coverage) +static inline void comp_func_Screen_impl(uint *Q_DECL_RESTRICT dest, const uint *Q_DECL_RESTRICT src, int length, const T &coverage) { for (int i = 0; i < length; ++i) { uint d = dest[i]; @@ -1314,7 +1314,7 @@ Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_Screen_impl(uint *Q_DECL_RESTRI } template <typename T> -Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_Screen_impl(QRgba64 *Q_DECL_RESTRICT dest, const QRgba64 *Q_DECL_RESTRICT src, int length, const T &coverage) +static inline void comp_func_Screen_impl(QRgba64 *Q_DECL_RESTRICT dest, const QRgba64 *Q_DECL_RESTRICT src, int length, const T &coverage) { for (int i = 0; i < length; ++i) { QRgba64 d = dest[i]; @@ -1375,7 +1375,7 @@ static inline uint overlay_op_rgb64(uint dst, uint src, uint da, uint sa) } template <typename T> -Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_solid_Overlay_impl(uint *dest, int length, uint color, const T &coverage) +static inline void comp_func_solid_Overlay_impl(uint *dest, int length, uint color, const T &coverage) { int sa = qAlpha(color); int sr = qRed(color); @@ -1398,7 +1398,7 @@ Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_solid_Overlay_impl(uint *dest, } template <typename T> -Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_solid_Overlay_impl(QRgba64 *dest, int length, QRgba64 color, const T &coverage) +static inline void comp_func_solid_Overlay_impl(QRgba64 *dest, int length, QRgba64 color, const T &coverage) { uint sa = color.alpha(); uint sr = color.red(); @@ -1437,7 +1437,7 @@ void QT_FASTCALL comp_func_solid_Overlay_rgb64(QRgba64 *dest, int length, QRgba6 } template <typename T> -Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_Overlay_impl(uint *Q_DECL_RESTRICT dest, const uint *Q_DECL_RESTRICT src, int length, const T &coverage) +static inline void comp_func_Overlay_impl(uint *Q_DECL_RESTRICT dest, const uint *Q_DECL_RESTRICT src, int length, const T &coverage) { for (int i = 0; i < length; ++i) { uint d = dest[i]; @@ -1458,7 +1458,7 @@ Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_Overlay_impl(uint *Q_DECL_RESTR } template <typename T> -Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_Overlay_impl(QRgba64 *Q_DECL_RESTRICT dest, const QRgba64 *Q_DECL_RESTRICT src, int length, const T &coverage) +static inline void comp_func_Overlay_impl(QRgba64 *Q_DECL_RESTRICT dest, const QRgba64 *Q_DECL_RESTRICT src, int length, const T &coverage) { for (int i = 0; i < length; ++i) { QRgba64 d = dest[i]; @@ -1509,7 +1509,7 @@ static inline uint darken_op_rgb64(uint dst, uint src, uint da, uint sa) } template <typename T> -Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_solid_Darken_impl(uint *dest, int length, uint color, const T &coverage) +static inline void comp_func_solid_Darken_impl(uint *dest, int length, uint color, const T &coverage) { int sa = qAlpha(color); int sr = qRed(color); @@ -1532,7 +1532,7 @@ Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_solid_Darken_impl(uint *dest, i } template <typename T> -Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_solid_Darken_impl(QRgba64 *dest, int length, QRgba64 color, const T &coverage) +static inline void comp_func_solid_Darken_impl(QRgba64 *dest, int length, QRgba64 color, const T &coverage) { uint sa = color.alpha(); uint sr = color.red(); @@ -1571,7 +1571,7 @@ void QT_FASTCALL comp_func_solid_Darken_rgb64(QRgba64 *dest, int length, QRgba64 } template <typename T> -Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_Darken_impl(uint *Q_DECL_RESTRICT dest, const uint *Q_DECL_RESTRICT src, int length, const T &coverage) +static inline void comp_func_Darken_impl(uint *Q_DECL_RESTRICT dest, const uint *Q_DECL_RESTRICT src, int length, const T &coverage) { for (int i = 0; i < length; ++i) { uint d = dest[i]; @@ -1592,7 +1592,7 @@ Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_Darken_impl(uint *Q_DECL_RESTRI } template <typename T> -Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_Darken_impl(QRgba64 *Q_DECL_RESTRICT dest, const QRgba64 *Q_DECL_RESTRICT src, int length, const T &coverage) +static inline void comp_func_Darken_impl(QRgba64 *Q_DECL_RESTRICT dest, const QRgba64 *Q_DECL_RESTRICT src, int length, const T &coverage) { for (int i = 0; i < length; ++i) { QRgba64 d = dest[i]; @@ -1643,7 +1643,7 @@ static inline uint lighten_op_rgb64(uint dst, uint src, uint da, uint sa) } template <typename T> -Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_solid_Lighten_impl(uint *dest, int length, uint color, const T &coverage) +static inline void comp_func_solid_Lighten_impl(uint *dest, int length, uint color, const T &coverage) { int sa = qAlpha(color); int sr = qRed(color); @@ -1666,7 +1666,7 @@ Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_solid_Lighten_impl(uint *dest, } template <typename T> -Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_solid_Lighten_impl(QRgba64 *dest, int length, QRgba64 color, const T &coverage) +static inline void comp_func_solid_Lighten_impl(QRgba64 *dest, int length, QRgba64 color, const T &coverage) { uint sa = color.alpha(); uint sr = color.red(); @@ -1705,7 +1705,7 @@ void QT_FASTCALL comp_func_solid_Lighten_rgb64(QRgba64 *dest, int length, QRgba6 } template <typename T> -Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_Lighten_impl(uint *Q_DECL_RESTRICT dest, const uint *Q_DECL_RESTRICT src, int length, const T &coverage) +static inline void comp_func_Lighten_impl(uint *Q_DECL_RESTRICT dest, const uint *Q_DECL_RESTRICT src, int length, const T &coverage) { for (int i = 0; i < length; ++i) { uint d = dest[i]; @@ -1726,7 +1726,7 @@ Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_Lighten_impl(uint *Q_DECL_RESTR } template <typename T> -Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_Lighten_impl(QRgba64 *Q_DECL_RESTRICT dest, const QRgba64 *Q_DECL_RESTRICT src, int length, const T &coverage) +static inline void comp_func_Lighten_impl(QRgba64 *Q_DECL_RESTRICT dest, const QRgba64 *Q_DECL_RESTRICT src, int length, const T &coverage) { for (int i = 0; i < length; ++i) { QRgba64 d = dest[i]; @@ -1795,7 +1795,7 @@ static inline uint color_dodge_op_rgb64(qint64 dst, qint64 src, qint64 da, qint6 } template <typename T> -Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_solid_ColorDodge_impl(uint *dest, int length, uint color, const T &coverage) +static inline void comp_func_solid_ColorDodge_impl(uint *dest, int length, uint color, const T &coverage) { int sa = qAlpha(color); int sr = qRed(color); @@ -1818,7 +1818,7 @@ Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_solid_ColorDodge_impl(uint *des } template <typename T> -Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_solid_ColorDodge_impl(QRgba64 *dest, int length, QRgba64 color, const T &coverage) +static inline void comp_func_solid_ColorDodge_impl(QRgba64 *dest, int length, QRgba64 color, const T &coverage) { uint sa = color.alpha(); uint sr = color.red(); @@ -1857,7 +1857,7 @@ void QT_FASTCALL comp_func_solid_ColorDodge_rgb64(QRgba64 *dest, int length, QRg } template <typename T> -Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_ColorDodge_impl(uint *Q_DECL_RESTRICT dest, const uint *Q_DECL_RESTRICT src, int length, const T &coverage) +static inline void comp_func_ColorDodge_impl(uint *Q_DECL_RESTRICT dest, const uint *Q_DECL_RESTRICT src, int length, const T &coverage) { for (int i = 0; i < length; ++i) { uint d = dest[i]; @@ -1878,7 +1878,7 @@ Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_ColorDodge_impl(uint *Q_DECL_RE } template <typename T> -Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_ColorDodge_impl(QRgba64 *Q_DECL_RESTRICT dest, const QRgba64 *Q_DECL_RESTRICT src, int length, const T &coverage) +static inline void comp_func_ColorDodge_impl(QRgba64 *Q_DECL_RESTRICT dest, const QRgba64 *Q_DECL_RESTRICT src, int length, const T &coverage) { for (int i = 0; i < length; ++i) { QRgba64 d = dest[i]; @@ -1947,7 +1947,7 @@ static inline uint color_burn_op_rgb64(qint64 dst, qint64 src, qint64 da, qint64 } template <typename T> -Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_solid_ColorBurn_impl(uint *dest, int length, uint color, const T &coverage) +static inline void comp_func_solid_ColorBurn_impl(uint *dest, int length, uint color, const T &coverage) { int sa = qAlpha(color); int sr = qRed(color); @@ -1970,7 +1970,7 @@ Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_solid_ColorBurn_impl(uint *dest } template <typename T> -Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_solid_ColorBurn_impl(QRgba64 *dest, int length, QRgba64 color, const T &coverage) +static inline void comp_func_solid_ColorBurn_impl(QRgba64 *dest, int length, QRgba64 color, const T &coverage) { uint sa = color.alpha(); uint sr = color.red(); @@ -2009,7 +2009,7 @@ void QT_FASTCALL comp_func_solid_ColorBurn_rgb64(QRgba64 *dest, int length, QRgb } template <typename T> -Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_ColorBurn_impl(uint *Q_DECL_RESTRICT dest, const uint *Q_DECL_RESTRICT src, int length, const T &coverage) +static inline void comp_func_ColorBurn_impl(uint *Q_DECL_RESTRICT dest, const uint *Q_DECL_RESTRICT src, int length, const T &coverage) { for (int i = 0; i < length; ++i) { uint d = dest[i]; @@ -2030,7 +2030,7 @@ Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_ColorBurn_impl(uint *Q_DECL_RES } template <typename T> -Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_ColorBurn_impl(QRgba64 *Q_DECL_RESTRICT dest, const QRgba64 *Q_DECL_RESTRICT src, int length, const T &coverage) +static inline void comp_func_ColorBurn_impl(QRgba64 *Q_DECL_RESTRICT dest, const QRgba64 *Q_DECL_RESTRICT src, int length, const T &coverage) { for (int i = 0; i < length; ++i) { QRgba64 d = dest[i]; @@ -2093,7 +2093,7 @@ static inline uint hardlight_op_rgb64(uint dst, uint src, uint da, uint sa) } template <typename T> -Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_solid_HardLight_impl(uint *dest, int length, uint color, const T &coverage) +static inline void comp_func_solid_HardLight_impl(uint *dest, int length, uint color, const T &coverage) { int sa = qAlpha(color); int sr = qRed(color); @@ -2116,7 +2116,7 @@ Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_solid_HardLight_impl(uint *dest } template <typename T> -Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_solid_HardLight_impl(QRgba64 *dest, int length, QRgba64 color, const T &coverage) +static inline void comp_func_solid_HardLight_impl(QRgba64 *dest, int length, QRgba64 color, const T &coverage) { uint sa = color.alpha(); uint sr = color.red(); @@ -2155,7 +2155,7 @@ void QT_FASTCALL comp_func_solid_HardLight_rgb64(QRgba64 *dest, int length, QRgb } template <typename T> -Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_HardLight_impl(uint *Q_DECL_RESTRICT dest, const uint *Q_DECL_RESTRICT src, int length, const T &coverage) +static inline void comp_func_HardLight_impl(uint *Q_DECL_RESTRICT dest, const uint *Q_DECL_RESTRICT src, int length, const T &coverage) { for (int i = 0; i < length; ++i) { uint d = dest[i]; @@ -2176,7 +2176,7 @@ Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_HardLight_impl(uint *Q_DECL_RES } template <typename T> -Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_HardLight_impl(QRgba64 *Q_DECL_RESTRICT dest, const QRgba64 *Q_DECL_RESTRICT src, int length, const T &coverage) +static inline void comp_func_HardLight_impl(QRgba64 *Q_DECL_RESTRICT dest, const QRgba64 *Q_DECL_RESTRICT src, int length, const T &coverage) { for (int i = 0; i < length; ++i) { QRgba64 d = dest[i]; @@ -2252,7 +2252,7 @@ static inline uint soft_light_op_rgb64(qint64 dst, qint64 src, qint64 da, qint64 } template <typename T> -Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_solid_SoftLight_impl(uint *dest, int length, uint color, const T &coverage) +static inline void comp_func_solid_SoftLight_impl(uint *dest, int length, uint color, const T &coverage) { int sa = qAlpha(color); int sr = qRed(color); @@ -2275,7 +2275,7 @@ Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_solid_SoftLight_impl(uint *dest } template <typename T> -Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_solid_SoftLight_impl(QRgba64 *dest, int length, QRgba64 color, const T &coverage) +static inline void comp_func_solid_SoftLight_impl(QRgba64 *dest, int length, QRgba64 color, const T &coverage) { uint sa = color.alpha(); uint sr = color.red(); @@ -2314,7 +2314,7 @@ void QT_FASTCALL comp_func_solid_SoftLight_rgb64(QRgba64 *dest, int length, QRgb } template <typename T> -Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_SoftLight_impl(uint *Q_DECL_RESTRICT dest, const uint *Q_DECL_RESTRICT src, int length, const T &coverage) +static inline void comp_func_SoftLight_impl(uint *Q_DECL_RESTRICT dest, const uint *Q_DECL_RESTRICT src, int length, const T &coverage) { for (int i = 0; i < length; ++i) { uint d = dest[i]; @@ -2335,7 +2335,7 @@ Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_SoftLight_impl(uint *Q_DECL_RES } template <typename T> -Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_SoftLight_impl(QRgba64 *Q_DECL_RESTRICT dest, const QRgba64 *Q_DECL_RESTRICT src, int length, const T &coverage) +static inline void comp_func_SoftLight_impl(QRgba64 *Q_DECL_RESTRICT dest, const QRgba64 *Q_DECL_RESTRICT src, int length, const T &coverage) { for (int i = 0; i < length; ++i) { QRgba64 d = dest[i]; @@ -2386,7 +2386,7 @@ static inline uint difference_op_rgb64(qint64 dst, qint64 src, qint64 da, qint64 } template <typename T> -Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_solid_Difference_impl(uint *dest, int length, uint color, const T &coverage) +static inline void comp_func_solid_Difference_impl(uint *dest, int length, uint color, const T &coverage) { int sa = qAlpha(color); int sr = qRed(color); @@ -2409,7 +2409,7 @@ Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_solid_Difference_impl(uint *des } template <typename T> -Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_solid_Difference_impl(QRgba64 *dest, int length, QRgba64 color, const T &coverage) +static inline void comp_func_solid_Difference_impl(QRgba64 *dest, int length, QRgba64 color, const T &coverage) { uint sa = color.alpha(); uint sr = color.red(); @@ -2448,7 +2448,7 @@ void QT_FASTCALL comp_func_solid_Difference_rgb64(QRgba64 *dest, int length, QRg } template <typename T> -Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_Difference_impl(uint *Q_DECL_RESTRICT dest, const uint *Q_DECL_RESTRICT src, int length, const T &coverage) +static inline void comp_func_Difference_impl(uint *Q_DECL_RESTRICT dest, const uint *Q_DECL_RESTRICT src, int length, const T &coverage) { for (int i = 0; i < length; ++i) { uint d = dest[i]; @@ -2469,7 +2469,7 @@ Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_Difference_impl(uint *Q_DECL_RE } template <typename T> -Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_Difference_impl(QRgba64 *Q_DECL_RESTRICT dest, const QRgba64 *Q_DECL_RESTRICT src, int length, const T &coverage) +static inline void comp_func_Difference_impl(QRgba64 *Q_DECL_RESTRICT dest, const QRgba64 *Q_DECL_RESTRICT src, int length, const T &coverage) { for (int i = 0; i < length; ++i) { QRgba64 d = dest[i]; @@ -2509,7 +2509,7 @@ void QT_FASTCALL comp_func_Difference_rgb64(QRgba64 *Q_DECL_RESTRICT dest, const Dca' = (Sca.Da + Dca.Sa - 2.Sca.Dca) + Sca.(1 - Da) + Dca.(1 - Sa) */ template <typename T> -Q_STATIC_TEMPLATE_FUNCTION inline void QT_FASTCALL comp_func_solid_Exclusion_impl(uint *dest, int length, uint color, const T &coverage) +static inline void QT_FASTCALL comp_func_solid_Exclusion_impl(uint *dest, int length, uint color, const T &coverage) { int sa = qAlpha(color); int sr = qRed(color); @@ -2532,7 +2532,7 @@ Q_STATIC_TEMPLATE_FUNCTION inline void QT_FASTCALL comp_func_solid_Exclusion_imp } template <typename T> -Q_STATIC_TEMPLATE_FUNCTION inline void QT_FASTCALL comp_func_solid_Exclusion_impl(QRgba64 *dest, int length, QRgba64 color, const T &coverage) +static inline void QT_FASTCALL comp_func_solid_Exclusion_impl(QRgba64 *dest, int length, QRgba64 color, const T &coverage) { uint sa = color.alpha(); uint sr = color.red(); @@ -2572,7 +2572,7 @@ void QT_FASTCALL comp_func_solid_Exclusion_rgb64(QRgba64 *dest, int length, QRgb } template <typename T> -Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_Exclusion_impl(uint *Q_DECL_RESTRICT dest, const uint *Q_DECL_RESTRICT src, int length, const T &coverage) +static inline void comp_func_Exclusion_impl(uint *Q_DECL_RESTRICT dest, const uint *Q_DECL_RESTRICT src, int length, const T &coverage) { for (int i = 0; i < length; ++i) { uint d = dest[i]; @@ -2593,7 +2593,7 @@ Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_Exclusion_impl(uint *Q_DECL_RES } template <typename T> -Q_STATIC_TEMPLATE_FUNCTION inline void comp_func_Exclusion_impl(QRgba64 *Q_DECL_RESTRICT dest, const QRgba64 *Q_DECL_RESTRICT src, int length, const T &coverage) +static inline void comp_func_Exclusion_impl(QRgba64 *Q_DECL_RESTRICT dest, const QRgba64 *Q_DECL_RESTRICT src, int length, const T &coverage) { for (int i = 0; i < length; ++i) { QRgba64 d = dest[i]; diff --git a/src/gui/painting/qdrawhelper.cpp b/src/gui/painting/qdrawhelper.cpp index bbeb9fd9ea..fa1990ca60 100644 --- a/src/gui/painting/qdrawhelper.cpp +++ b/src/gui/painting/qdrawhelper.cpp @@ -1,7 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2018 The Qt Company Ltd. -** Copyright (C) 2016 Intel Corporation. +** Copyright (C) 2018 Intel Corporation. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the QtGui module of the Qt Toolkit. @@ -4343,7 +4343,7 @@ static void blend_color_argb(int count, const QSpan *spans, void *userData) while (count--) { uint *target = ((uint *)data->rasterBuffer->scanLine(spans->y)) + spans->x; if (spans->coverage == 255) { - QT_MEMFILL_UINT(target, spans->len, color); + qt_memfill(target, color, spans->len); } else { uint c = BYTE_MUL(color, spans->coverage); int ialpha = 255 - spans->coverage; @@ -4422,7 +4422,7 @@ static void blend_color_rgb16(int count, const QSpan *spans, void *userData) while (count--) { ushort *target = ((ushort *)data->rasterBuffer->scanLine(spans->y)) + spans->x; if (spans->coverage == 255) { - QT_MEMFILL_USHORT(target, spans->len, c); + qt_memfill(target, c, spans->len); } else { ushort color = BYTE_MUL_RGB16(c, spans->coverage); int ialpha = 255 - spans->coverage; @@ -5228,7 +5228,7 @@ void qBlendTexture(int count, const QSpan *spans, void *userData) proc(count, spans, userData); } -template <class DST> Q_STATIC_TEMPLATE_FUNCTION +template <class DST> static inline void qt_bitmapblit_template(QRasterBuffer *rasterBuffer, int x, int y, DST color, const uchar *map, @@ -6244,70 +6244,28 @@ DrawHelper qDrawHelper[QImage::NImageFormats] = }, }; -#if defined(Q_CC_MSVC) && !defined(_MIPS_) -template <class T> -inline void qt_memfill_template(T *dest, T color, int count) +void qt_memfill64(quint64 *dest, quint64 color, qsizetype count) { - while (count--) - *dest++ = color; -} - -#else - -template <class T> -inline void qt_memfill_template(T *dest, T color, int count) -{ - int n = (count + 7) / 8; - switch (count & 0x07) - { - case 0: do { *dest++ = color; Q_FALLTHROUGH(); - case 7: *dest++ = color; Q_FALLTHROUGH(); - case 6: *dest++ = color; Q_FALLTHROUGH(); - case 5: *dest++ = color; Q_FALLTHROUGH(); - case 4: *dest++ = color; Q_FALLTHROUGH(); - case 3: *dest++ = color; Q_FALLTHROUGH(); - case 2: *dest++ = color; Q_FALLTHROUGH(); - case 1: *dest++ = color; - } while (--n > 0); - } + qt_memfill_template<quint64>(dest, color, count); } -template <> -inline void qt_memfill_template(quint16 *dest, quint16 value, int count) +void qt_memfill16(quint16 *dest, quint16 value, qsizetype count) { - if (count < 3) { - switch (count) { - case 2: *dest++ = value; Q_FALLTHROUGH(); - case 1: *dest = value; - } - return; + const int align = quintptr(dest) & 0x3; + if (align) { + *dest++ = value; + --count; } - const int align = (quintptr)(dest) & 0x3; - switch (align) { - case 2: *dest++ = value; --count; - } - - const quint32 value32 = (value << 16) | value; - qt_memfill(reinterpret_cast<quint32*>(dest), value32, count / 2); if (count & 0x1) dest[count - 1] = value; -} -#endif -void qt_memfill64(quint64 *dest, quint64 color, int count) -{ - qt_memfill_template<quint64>(dest, color, count); + const quint32 value32 = (value << 16) | value; + qt_memfill32(reinterpret_cast<quint32*>(dest), value32, count / 2); } -#if !defined(__SSE2__) -void qt_memfill16(quint16 *dest, quint16 color, int count) -{ - qt_memfill_template<quint16>(dest, color, count); -} -#endif #if !defined(__SSE2__) && !defined(__ARM_NEON__) && !defined(__MIPS_DSP__) -void qt_memfill32(quint32 *dest, quint32 color, int count) +void qt_memfill32(quint32 *dest, quint32 color, qsizetype count) { qt_memfill_template<quint32>(dest, color, count); } diff --git a/src/gui/painting/qdrawhelper_mips_dsp.cpp b/src/gui/painting/qdrawhelper_mips_dsp.cpp index e92a6606de..17597deb1d 100644 --- a/src/gui/painting/qdrawhelper_mips_dsp.cpp +++ b/src/gui/painting/qdrawhelper_mips_dsp.cpp @@ -43,7 +43,7 @@ QT_BEGIN_NAMESPACE -void qt_memfill32(quint32 *dest, quint32 color, int count) +void qt_memfill32(quint32 *dest, quint32 color, qsizetype count) { qt_memfill32_asm_mips_dsp(dest, color, count); } diff --git a/src/gui/painting/qdrawhelper_mips_dsp_p.h b/src/gui/painting/qdrawhelper_mips_dsp_p.h index 36c4af2732..a3d0410274 100644 --- a/src/gui/painting/qdrawhelper_mips_dsp_p.h +++ b/src/gui/painting/qdrawhelper_mips_dsp_p.h @@ -57,7 +57,7 @@ QT_BEGIN_NAMESPACE #if defined(QT_COMPILER_SUPPORTS_MIPS_DSP) -extern "C" void qt_memfill32_asm_mips_dsp(quint32 *dest, quint32 value, int count); +extern "C" void qt_memfill32_asm_mips_dsp(quint32 *dest, quint32 value, qsizetype count); extern "C" void comp_func_SourceOver_asm_mips_dsp(uint *dest, const uint *src, int length, uint const_alpha); diff --git a/src/gui/painting/qdrawhelper_neon.cpp b/src/gui/painting/qdrawhelper_neon.cpp index 629dfe2358..e33af3b784 100644 --- a/src/gui/painting/qdrawhelper_neon.cpp +++ b/src/gui/painting/qdrawhelper_neon.cpp @@ -47,7 +47,7 @@ QT_BEGIN_NAMESPACE -void qt_memfill32(quint32 *dest, quint32 value, int count) +void qt_memfill32(quint32 *dest, quint32 value, qsizetype count) { const int epilogueSize = count % 16; #if !defined(Q_PROCESSOR_ARM_64) @@ -84,20 +84,20 @@ void qt_memfill32(quint32 *dest, quint32 value, int count) switch (epilogueSize) { - case 15: *dest++ = value; - case 14: *dest++ = value; - case 13: *dest++ = value; - case 12: *dest++ = value; - case 11: *dest++ = value; - case 10: *dest++ = value; - case 9: *dest++ = value; - case 8: *dest++ = value; - case 7: *dest++ = value; - case 6: *dest++ = value; - case 5: *dest++ = value; - case 4: *dest++ = value; - case 3: *dest++ = value; - case 2: *dest++ = value; + case 15: *dest++ = value; Q_FALLTHROUGH(); + case 14: *dest++ = value; Q_FALLTHROUGH(); + case 13: *dest++ = value; Q_FALLTHROUGH(); + case 12: *dest++ = value; Q_FALLTHROUGH(); + case 11: *dest++ = value; Q_FALLTHROUGH(); + case 10: *dest++ = value; Q_FALLTHROUGH(); + case 9: *dest++ = value; Q_FALLTHROUGH(); + case 8: *dest++ = value; Q_FALLTHROUGH(); + case 7: *dest++ = value; Q_FALLTHROUGH(); + case 6: *dest++ = value; Q_FALLTHROUGH(); + case 5: *dest++ = value; Q_FALLTHROUGH(); + case 4: *dest++ = value; Q_FALLTHROUGH(); + case 3: *dest++ = value; Q_FALLTHROUGH(); + case 2: *dest++ = value; Q_FALLTHROUGH(); case 1: *dest++ = value; } } @@ -791,7 +791,7 @@ void QT_FASTCALL qt_destStoreRGB16_neon(QRasterBuffer *rasterBuffer, int x, int void QT_FASTCALL comp_func_solid_SourceOver_neon(uint *destPixels, int length, uint color, uint const_alpha) { if ((const_alpha & qAlpha(color)) == 255) { - QT_MEMFILL_UINT(destPixels, length, color); + qt_memfill32(destPixels, color, length); } else { if (const_alpha != 255) color = BYTE_MUL(color, const_alpha); diff --git a/src/gui/painting/qdrawhelper_neon_p.h b/src/gui/painting/qdrawhelper_neon_p.h index 40475a9bde..19e1f21a3b 100644 --- a/src/gui/painting/qdrawhelper_neon_p.h +++ b/src/gui/painting/qdrawhelper_neon_p.h @@ -123,7 +123,7 @@ void qt_transform_image_rgb16_on_rgb16_neon(uchar *destPixels, int dbpl, const QTransform &targetRectTransform, int const_alpha); -void qt_memfill32_neon(quint32 *dest, quint32 value, int count); +void qt_memfill32_neon(quint32 *dest, quint32 value, qsizetype count); void qt_memrotate90_16_neon(const uchar *srcPixels, int w, int h, int sbpl, uchar *destPixels, int dbpl); void qt_memrotate270_16_neon(const uchar *srcPixels, int w, int h, int sbpl, uchar *destPixels, int dbpl); diff --git a/src/gui/painting/qdrawhelper_p.h b/src/gui/painting/qdrawhelper_p.h index fb08261205..a2cf36f20e 100644 --- a/src/gui/painting/qdrawhelper_p.h +++ b/src/gui/painting/qdrawhelper_p.h @@ -69,13 +69,10 @@ QT_BEGIN_NAMESPACE #if defined(Q_CC_GNU) -# define Q_STATIC_TEMPLATE_FUNCTION static # define Q_DECL_RESTRICT __restrict__ #elif defined(Q_CC_MSVC) -# define Q_STATIC_TEMPLATE_FUNCTION static # define Q_DECL_RESTRICT __restrict #else -# define Q_STATIC_TEMPLATE_FUNCTION static # define Q_DECL_RESTRICT #endif @@ -163,9 +160,9 @@ extern SrcOverTransformFunc qTransformFunctions[QImage::NImageFormats][QImage::N extern DrawHelper qDrawHelper[QImage::NImageFormats]; void qBlendTexture(int count, const QSpan *spans, void *userData); -extern void qt_memfill64(quint64 *dest, quint64 value, int count); -extern void qt_memfill32(quint32 *dest, quint32 value, int count); -extern void qt_memfill16(quint16 *dest, quint16 value, int count); +extern void qt_memfill64(quint64 *dest, quint64 value, qsizetype count); +extern void qt_memfill32(quint32 *dest, quint32 value, qsizetype count); +extern void qt_memfill16(quint16 *dest, quint16 value, qsizetype count); typedef void (QT_FASTCALL *CompositionFunction)(uint *Q_DECL_RESTRICT dest, const uint *Q_DECL_RESTRICT src, int length, uint const_alpha); typedef void (QT_FASTCALL *CompositionFunction64)(QRgba64 *Q_DECL_RESTRICT dest, const QRgba64 *Q_DECL_RESTRICT src, int length, uint const_alpha); @@ -887,57 +884,58 @@ inline quint24::operator uint() const return data[2] | (data[1] << 8) | (data[0] << 16); } -template <class T> Q_STATIC_TEMPLATE_FUNCTION -void qt_memfill(T *dest, T value, int count); +template <class T> inline void qt_memfill_template(T *dest, T color, qsizetype count) +{ + if (!count) + return; + + qsizetype n = (count + 7) / 8; + switch (count & 0x07) + { + case 0: do { *dest++ = color; Q_FALLTHROUGH(); + case 7: *dest++ = color; Q_FALLTHROUGH(); + case 6: *dest++ = color; Q_FALLTHROUGH(); + case 5: *dest++ = color; Q_FALLTHROUGH(); + case 4: *dest++ = color; Q_FALLTHROUGH(); + case 3: *dest++ = color; Q_FALLTHROUGH(); + case 2: *dest++ = color; Q_FALLTHROUGH(); + case 1: *dest++ = color; + } while (--n > 0); + } +} + +template <class T> inline void qt_memfill(T *dest, T value, qsizetype count) +{ + qt_memfill_template(dest, value, count); +} -template<> inline void qt_memfill(quint64 *dest, quint64 color, int count) +template<> inline void qt_memfill(quint64 *dest, quint64 color, qsizetype count) { qt_memfill64(dest, color, count); } -template<> inline void qt_memfill(quint32 *dest, quint32 color, int count) +template<> inline void qt_memfill(quint32 *dest, quint32 color, qsizetype count) { qt_memfill32(dest, color, count); } -template<> inline void qt_memfill(quint16 *dest, quint16 color, int count) +template<> inline void qt_memfill(quint16 *dest, quint16 color, qsizetype count) { qt_memfill16(dest, color, count); } -template<> inline void qt_memfill(quint8 *dest, quint8 color, int count) +template<> inline void qt_memfill(quint8 *dest, quint8 color, qsizetype count) { memset(dest, color, count); } -template <class T> -inline void qt_memfill(T *dest, T value, int count) -{ - if (!count) - return; - - int n = (count + 7) / 8; - switch (count & 0x07) - { - case 0: do { *dest++ = value; Q_FALLTHROUGH(); - case 7: *dest++ = value; Q_FALLTHROUGH(); - case 6: *dest++ = value; Q_FALLTHROUGH(); - case 5: *dest++ = value; Q_FALLTHROUGH(); - case 4: *dest++ = value; Q_FALLTHROUGH(); - case 3: *dest++ = value; Q_FALLTHROUGH(); - case 2: *dest++ = value; Q_FALLTHROUGH(); - case 1: *dest++ = value; - } while (--n > 0); - } -} - -template <class T> Q_STATIC_TEMPLATE_FUNCTION +template <class T> static inline void qt_rectfill(T *dest, T value, int x, int y, int width, int height, qsizetype stride) { char *d = reinterpret_cast<char*>(dest + x) + y * stride; if (uint(stride) == (width * sizeof(T))) { - qt_memfill(reinterpret_cast<T*>(d), value, width * height); + qt_memfill(reinterpret_cast<T*>(d), value, qsizetype(width) * height); } else { for (int j = 0; j < height; ++j) { dest = reinterpret_cast<T*>(d); @@ -947,52 +945,6 @@ inline void qt_rectfill(T *dest, T value, } } -#define QT_MEMFILL_UINT(dest, length, color) \ - qt_memfill<quint32>(dest, color, length); - -#define QT_MEMFILL_USHORT(dest, length, color) \ - qt_memfill<quint16>(dest, color, length); - -#define QT_MEMCPY_REV_UINT(dest, src, length) \ -do { \ - /* Duff's device */ \ - uint *_d = (uint*)(dest) + length; \ - const uint *_s = (uint*)(src) + length; \ - int n = ((length) + 7) / 8; \ - switch ((length) & 0x07) \ - { \ - case 0: do { *--_d = *--_s; Q_FALLTHROUGH(); \ - case 7: *--_d = *--_s; Q_FALLTHROUGH(); \ - case 6: *--_d = *--_s; Q_FALLTHROUGH(); \ - case 5: *--_d = *--_s; Q_FALLTHROUGH(); \ - case 4: *--_d = *--_s; Q_FALLTHROUGH(); \ - case 3: *--_d = *--_s; Q_FALLTHROUGH(); \ - case 2: *--_d = *--_s; Q_FALLTHROUGH(); \ - case 1: *--_d = *--_s; \ - } while (--n > 0); \ - } \ -} while (false) - -#define QT_MEMCPY_USHORT(dest, src, length) \ -do { \ - /* Duff's device */ \ - ushort *_d = (ushort*)(dest); \ - const ushort *_s = (const ushort*)(src); \ - int n = ((length) + 7) / 8; \ - switch ((length) & 0x07) \ - { \ - case 0: do { *_d++ = *_s++; Q_FALLTHROUGH(); \ - case 7: *_d++ = *_s++; Q_FALLTHROUGH(); \ - case 6: *_d++ = *_s++; Q_FALLTHROUGH(); \ - case 5: *_d++ = *_s++; Q_FALLTHROUGH(); \ - case 4: *_d++ = *_s++; Q_FALLTHROUGH(); \ - case 3: *_d++ = *_s++; Q_FALLTHROUGH(); \ - case 2: *_d++ = *_s++; Q_FALLTHROUGH(); \ - case 1: *_d++ = *_s++; \ - } while (--n > 0); \ - } \ -} while (false) - inline ushort qConvertRgb32To16(uint c) { return (((c) >> 3) & 0x001f) diff --git a/src/gui/painting/qdrawhelper_sse2.cpp b/src/gui/painting/qdrawhelper_sse2.cpp index 3212ffdd2d..34bdf7909a 100644 --- a/src/gui/painting/qdrawhelper_sse2.cpp +++ b/src/gui/painting/qdrawhelper_sse2.cpp @@ -233,7 +233,7 @@ void QT_FASTCALL comp_func_Source_sse2(uint *dst, const uint *src, int length, u } } -void qt_memfill32(quint32 *dest, quint32 value, int count) +void qt_memfill32(quint32 *dest, quint32 value, qsizetype count) { if (count < 7) { switch (count) { @@ -266,20 +266,20 @@ void qt_memfill32(quint32 *dest, quint32 value, int count) int count128 = count / 4; __m128i *dst128 = reinterpret_cast<__m128i*>(dest); __m128i *end128 = dst128 + count128; - const __m128i value128 = _mm_set_epi32(value, value, value, value); + const __m128i value128 = _mm_set1_epi32(value); while (dst128 + 3 < end128) { - _mm_stream_si128(dst128 + 0, value128); - _mm_stream_si128(dst128 + 1, value128); - _mm_stream_si128(dst128 + 2, value128); - _mm_stream_si128(dst128 + 3, value128); + _mm_store_si128(dst128 + 0, value128); + _mm_store_si128(dst128 + 1, value128); + _mm_store_si128(dst128 + 2, value128); + _mm_store_si128(dst128 + 3, value128); dst128 += 4; } switch (count128 & 0x3) { - case 3: _mm_stream_si128(dst128++, value128); Q_FALLTHROUGH(); - case 2: _mm_stream_si128(dst128++, value128); Q_FALLTHROUGH(); - case 1: _mm_stream_si128(dst128++, value128); + case 3: _mm_store_si128(dst128++, value128); Q_FALLTHROUGH(); + case 2: _mm_store_si128(dst128++, value128); Q_FALLTHROUGH(); + case 1: _mm_store_si128(dst128++, value128); } } @@ -314,28 +314,6 @@ void QT_FASTCALL comp_func_solid_SourceOver_sse2(uint *destPixels, int length, u } } -void qt_memfill16(quint16 *dest, quint16 value, int count) -{ - if (count < 3) { - switch (count) { - case 2: *dest++ = value; Q_FALLTHROUGH(); - case 1: *dest = value; - } - return; - } - - const int align = (quintptr)(dest) & 0x3; - switch (align) { - case 2: *dest++ = value; --count; - } - - const quint32 value32 = (value << 16) | value; - qt_memfill32(reinterpret_cast<quint32*>(dest), value32, count / 2); - - if (count & 0x1) - dest[count - 1] = value; -} - void qt_bitmapblit32_sse2_base(QRasterBuffer *rasterBuffer, int x, int y, quint32 color, const uchar *src, int width, int height, int stride) diff --git a/src/gui/painting/qdrawhelper_x86_p.h b/src/gui/painting/qdrawhelper_x86_p.h index cefc213999..12b95abe46 100644 --- a/src/gui/painting/qdrawhelper_x86_p.h +++ b/src/gui/painting/qdrawhelper_x86_p.h @@ -57,8 +57,7 @@ QT_BEGIN_NAMESPACE #ifdef __SSE2__ -void qt_memfill32(quint32 *dest, quint32 value, int count); -void qt_memfill16(quint16 *dest, quint16 value, int count); +void qt_memfill32(quint32 *dest, quint32 value, qsizetype count); void qt_bitmapblit32_sse2(QRasterBuffer *rasterBuffer, int x, int y, const QRgba64 &color, const uchar *src, int width, int height, int stride); diff --git a/src/gui/painting/qmemrotate.cpp b/src/gui/painting/qmemrotate.cpp index 43aeff3268..9cb787fb2c 100644 --- a/src/gui/painting/qmemrotate.cpp +++ b/src/gui/painting/qmemrotate.cpp @@ -44,7 +44,7 @@ QT_BEGIN_NAMESPACE static const int tileSize = 32; template <class T> -Q_STATIC_TEMPLATE_FUNCTION +static inline void qt_memrotate90_tiled(const T *src, int w, int h, int sstride, T *dest, int dstride) { sstride /= sizeof(T); @@ -103,7 +103,7 @@ inline void qt_memrotate90_tiled(const T *src, int w, int h, int sstride, T *des } template <class T> -Q_STATIC_TEMPLATE_FUNCTION +static inline void qt_memrotate90_tiled_unpacked(const T *src, int w, int h, int sstride, T *dest, int dstride) { @@ -131,7 +131,7 @@ inline void qt_memrotate90_tiled_unpacked(const T *src, int w, int h, int sstrid } template <class T> -Q_STATIC_TEMPLATE_FUNCTION +static inline void qt_memrotate270_tiled(const T *src, int w, int h, int sstride, T *dest, int dstride) { sstride /= sizeof(T); @@ -190,7 +190,7 @@ inline void qt_memrotate270_tiled(const T *src, int w, int h, int sstride, T *de } template <class T> -Q_STATIC_TEMPLATE_FUNCTION +static inline void qt_memrotate270_tiled_unpacked(const T *src, int w, int h, int sstride, T *dest, int dstride) { @@ -219,7 +219,7 @@ inline void qt_memrotate270_tiled_unpacked(const T *src, int w, int h, int sstri template <class T> -Q_STATIC_TEMPLATE_FUNCTION +static inline void qt_memrotate90_template(const T *src, int srcWidth, int srcHeight, int srcStride, T *dest, int dstStride) { @@ -246,7 +246,7 @@ inline void qt_memrotate90_template<quint64>(const quint64 *src, int w, int h, i } template <class T> -Q_STATIC_TEMPLATE_FUNCTION +static inline void qt_memrotate180_template(const T *src, int w, int h, int sstride, T *dest, int dstride) { const char *s = (const char*)(src) + (h - 1) * sstride; @@ -261,7 +261,7 @@ inline void qt_memrotate180_template(const T *src, int w, int h, int sstride, T } template <class T> -Q_STATIC_TEMPLATE_FUNCTION +static inline void qt_memrotate270_template(const T *src, int srcWidth, int srcHeight, int srcStride, T *dest, int dstStride) { diff --git a/src/gui/painting/qpaintengineex.cpp b/src/gui/painting/qpaintengineex.cpp index 9f07af92e4..81ce5c60c5 100644 --- a/src/gui/painting/qpaintengineex.cpp +++ b/src/gui/painting/qpaintengineex.cpp @@ -439,6 +439,9 @@ void QPaintEngineEx::stroke(const QVectorPath &path, const QPen &pen) } } + if (d->activeStroker == &d->stroker) + d->stroker.setForceOpen(path.hasExplicitOpen()); + const QPainterPath::ElementType *types = path.elements(); const qreal *points = path.points(); int pointCount = path.elementCount(); diff --git a/src/gui/painting/qpainter.cpp b/src/gui/painting/qpainter.cpp index b70b29e54e..df2f5e11d3 100644 --- a/src/gui/painting/qpainter.cpp +++ b/src/gui/painting/qpainter.cpp @@ -1437,6 +1437,13 @@ void QPainterPrivate::updateState(QPainterState *newState) by slightly less than half a pixel. Also will treat default constructed pens as cosmetic. Potentially useful when porting a Qt 4 application to Qt 5. + \value LosslessImageRendering Use a lossless image rendering, whenever possible. + Currently, this hint is only used when QPainter is employed to output a PDF + file through QPrinter or QPdfWriter, where drawImage()/drawPixmap() calls + will encode images using a lossless compression algorithm instead of lossy + JPEG compression. + This value was added in Qt 5.13. + \sa renderHints(), setRenderHint(), {QPainter#Rendering Quality}{Rendering Quality}, {Concentric Circles Example} diff --git a/src/gui/painting/qpainter.h b/src/gui/painting/qpainter.h index 482f5fb63d..87c4899f0b 100644 --- a/src/gui/painting/qpainter.h +++ b/src/gui/painting/qpainter.h @@ -91,7 +91,8 @@ public: SmoothPixmapTransform = 0x04, HighQualityAntialiasing = 0x08, NonCosmeticDefaultPen = 0x10, - Qt4CompatiblePainting = 0x20 + Qt4CompatiblePainting = 0x20, + LosslessImageRendering = 0x40, }; Q_FLAG(RenderHint) diff --git a/src/gui/painting/qpdf.cpp b/src/gui/painting/qpdf.cpp index e69726b617..0811dd9918 100644 --- a/src/gui/painting/qpdf.cpp +++ b/src/gui/painting/qpdf.cpp @@ -949,7 +949,8 @@ void QPdfEngine::drawPixmap (const QRectF &rectangle, const QPixmap &pixmap, con QPixmap pm = sourceRect != pixmap.rect() ? pixmap.copy(sourceRect) : pixmap; QImage image = pm.toImage(); bool bitmap = true; - const int object = d->addImage(image, &bitmap, pm.cacheKey()); + const bool lossless = painter()->testRenderHint(QPainter::LosslessImageRendering); + const int object = d->addImage(image, &bitmap, lossless, pm.cacheKey()); if (object < 0) return; @@ -988,7 +989,8 @@ void QPdfEngine::drawImage(const QRectF &rectangle, const QImage &image, const Q QRect sourceRect = sr.toRect(); QImage im = sourceRect != image.rect() ? image.copy(sourceRect) : image; bool bitmap = true; - const int object = d->addImage(im, &bitmap, im.cacheKey()); + const bool lossless = painter()->testRenderHint(QPainter::LosslessImageRendering); + const int object = d->addImage(im, &bitmap, lossless, im.cacheKey()); if (object < 0) return; @@ -2632,6 +2634,8 @@ int QPdfEnginePrivate::addConstantAlphaObject(int brushAlpha, int penAlpha) int QPdfEnginePrivate::addBrushPattern(const QTransform &m, bool *specifyColor, int *gStateObject) { + Q_Q(QPdfEngine); + int paintType = 2; // Uncolored tiling int w = 8; int h = 8; @@ -2661,7 +2665,8 @@ int QPdfEnginePrivate::addBrushPattern(const QTransform &m, bool *specifyColor, return 0; QImage image = brush.textureImage(); bool bitmap = true; - imageObject = addImage(image, &bitmap, image.cacheKey()); + const bool lossless = q->painter()->testRenderHint(QPainter::LosslessImageRendering); + imageObject = addImage(image, &bitmap, lossless, image.cacheKey()); if (imageObject != -1) { QImage::Format f = image.format(); if (f != QImage::Format_MonoLSB && f != QImage::Format_Mono) { @@ -2723,7 +2728,7 @@ static inline bool is_monochrome(const QVector<QRgb> &colorTable) /*! * Adds an image to the pdf and return the pdf-object id. Returns -1 if adding the image failed. */ -int QPdfEnginePrivate::addImage(const QImage &img, bool *bitmap, qint64 serial_no) +int QPdfEnginePrivate::addImage(const QImage &img, bool *bitmap, bool lossless, qint64 serial_no) { if (img.isNull()) return -1; @@ -2784,7 +2789,7 @@ int QPdfEnginePrivate::addImage(const QImage &img, bool *bitmap, qint64 serial_n bool hasAlpha = false; bool hasMask = false; - if (QImageWriter::supportedImageFormats().contains("jpeg") && !grayscale) { + if (QImageWriter::supportedImageFormats().contains("jpeg") && !grayscale && !lossless) { QBuffer buffer(&imageData); QImageWriter writer(&buffer, "jpeg"); writer.setQuality(94); diff --git a/src/gui/painting/qpdf_p.h b/src/gui/painting/qpdf_p.h index e2526de67d..e337c61f64 100644 --- a/src/gui/painting/qpdf_p.h +++ b/src/gui/painting/qpdf_p.h @@ -242,7 +242,7 @@ public: void writeHeader(); void writeTail(); - int addImage(const QImage &image, bool *bitmap, qint64 serial_no); + int addImage(const QImage &image, bool *bitmap, bool lossless, qint64 serial_no); int addConstantAlphaObject(int brushAlpha, int penAlpha = 255); int addBrushPattern(const QTransform &matrix, bool *specifyColor, int *gStateObject); diff --git a/src/gui/painting/qpdfwriter.cpp b/src/gui/painting/qpdfwriter.cpp index 6c85d65538..258939a763 100644 --- a/src/gui/painting/qpdfwriter.cpp +++ b/src/gui/painting/qpdfwriter.cpp @@ -76,7 +76,7 @@ public: : QPagedPaintDevicePrivate(), pd(d) {} - virtual ~QPdfPagedPaintDevicePrivate() + ~QPdfPagedPaintDevicePrivate() {} bool setPageLayout(const QPageLayout &newPageLayout) override diff --git a/src/gui/painting/qstroker.cpp b/src/gui/painting/qstroker.cpp index 4776545be6..0a3d802b21 100644 --- a/src/gui/painting/qstroker.cpp +++ b/src/gui/painting/qstroker.cpp @@ -369,7 +369,8 @@ void QStrokerOps::strokeEllipse(const QRectF &rect, void *data, const QTransform QStroker::QStroker() : m_capStyle(SquareJoin), m_joinStyle(FlatJoin), m_back1X(0), m_back1Y(0), - m_back2X(0), m_back2Y(0) + m_back2X(0), m_back2Y(0), + m_forceOpen(false) { m_strokeWidth = qt_real_to_fixed(1); m_miterLimit = qt_real_to_fixed(2); @@ -748,7 +749,7 @@ template <class Iterator> bool qt_stroke_side(Iterator *it, } } - if (start == prev) { + if (start == prev && !stroker->forceOpen()) { // closed subpath, join first and last point #ifdef QPP_STROKE_DEBUG qDebug("\n ---> (side) closed subpath"); diff --git a/src/gui/painting/qstroker_p.h b/src/gui/painting/qstroker_p.h index 1a7c184e1a..722a0904f3 100644 --- a/src/gui/painting/qstroker_p.h +++ b/src/gui/painting/qstroker_p.h @@ -222,6 +222,9 @@ public: void setMiterLimit(qfixed length) { m_miterLimit = length; } qfixed miterLimit() const { return m_miterLimit; } + void setForceOpen(bool state) { m_forceOpen = state; } + bool forceOpen() { return m_forceOpen; } + void joinPoints(qfixed x, qfixed y, const QLineF &nextLine, LineJoinMode join); inline void emitMoveTo(qfixed x, qfixed y); inline void emitLineTo(qfixed x, qfixed y); @@ -247,6 +250,8 @@ protected: qfixed m_back2X; qfixed m_back2Y; + + bool m_forceOpen; }; class Q_GUI_EXPORT QDashStroker : public QStrokerOps diff --git a/src/gui/painting/qvectorpath_p.h b/src/gui/painting/qvectorpath_p.h index d1b08ed423..8580598784 100644 --- a/src/gui/painting/qvectorpath_p.h +++ b/src/gui/painting/qvectorpath_p.h @@ -99,7 +99,8 @@ public: // Shape rendering specifiers... OddEvenFill = 0x1000, WindingFill = 0x2000, - ImplicitClose = 0x4000 + ImplicitClose = 0x4000, + ExplicitOpen = 0x8000 }; // ### Falcon: introduca a struct XY for points so lars is not so confused... @@ -124,6 +125,7 @@ public: inline bool isCacheable() const { return m_hints & ShouldUseCacheHint; } inline bool hasImplicitClose() const { return m_hints & ImplicitClose; } + inline bool hasExplicitOpen() const { return m_hints & ExplicitOpen; } inline bool hasWindingFill() const { return m_hints & WindingFill; } inline void makeCacheable() const { m_hints |= ShouldUseCacheHint; m_cache = 0; } @@ -142,7 +144,7 @@ public: case QPaintEngine::ConvexMode: return ConvexPolygonHint | ImplicitClose; case QPaintEngine::OddEvenMode: return PolygonHint | OddEvenFill | ImplicitClose; case QPaintEngine::WindingMode: return PolygonHint | WindingFill | ImplicitClose; - case QPaintEngine::PolylineMode: return PolygonHint; + case QPaintEngine::PolylineMode: return PolygonHint | ExplicitOpen; default: return 0; } } |