From 45ac7c962b4c196bba796c1dc7fc345f84c4b74e Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Thu, 25 Feb 2016 13:31:15 +0100 Subject: Merge convert from routines These four methods do not need to be separate, the compiler can figure generate the optimal version from the template arguments. Change-Id: I45b30a9c2f2ce4da46c47f2e6e1fbd7561213c4a Reviewed-by: Gunnar Sletta --- src/gui/painting/qdrawhelper.cpp | 152 ++++++++++++++++----------------------- 1 file changed, 60 insertions(+), 92 deletions(-) (limited to 'src/gui/painting') diff --git a/src/gui/painting/qdrawhelper.cpp b/src/gui/painting/qdrawhelper.cpp index 112dbd4738..933ff407e2 100644 --- a/src/gui/painting/qdrawhelper.cpp +++ b/src/gui/painting/qdrawhelper.cpp @@ -135,10 +135,20 @@ template<> Q_DECL_CONSTEXPR uint blueShift Q_DECL_CONSTEXPR uint blueShift() { return 8; } template<> Q_DECL_CONSTEXPR uint blueShift() { return 8; } template<> Q_DECL_CONSTEXPR uint blueShift() { 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 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; } @@ -286,92 +296,50 @@ static const QRgba64 *QT_FASTCALL convertARGBPMToARGB64PM(QRgba64 *buffer, const return buffer; } -template +template static const uint *QT_FASTCALL convertRGBFromARGB32PM(uint *buffer, const uint *src, int count, const QPixelLayout *, const QRgb *) { - Q_CONSTEXPR uint redMask = ((1 << redWidth()) - 1); - Q_CONSTEXPR uint greenMask = ((1 << greenWidth()) - 1); - Q_CONSTEXPR uint blueMask = ((1 << blueWidth()) - 1); - - Q_CONSTEXPR uchar redRightShift = 24 - redWidth(); - Q_CONSTEXPR uchar greenRightShift = 16 - greenWidth(); - Q_CONSTEXPR uchar blueRightShift = 8 - blueWidth(); - - for (int i = 0; i < count; ++i) { - const uint color = qUnpremultiply(src[i]); - const uint red = ((color >> redRightShift) & redMask) << redShift(); - const uint green = ((color >> greenRightShift) & greenMask) << greenShift(); - const uint blue = ((color >> blueRightShift) & blueMask) << blueShift(); - buffer[i] = red | green | blue; - } - return buffer; -} - -template -static const uint *QT_FASTCALL convertRGBFromRGB32(uint *buffer, const uint *src, int count, - const QPixelLayout *, const QRgb *) -{ - Q_CONSTEXPR uint redMask = ((1 << redWidth()) - 1); - Q_CONSTEXPR uint greenMask = ((1 << greenWidth()) - 1); - Q_CONSTEXPR uint blueMask = ((1 << blueWidth()) - 1); + Q_CONSTEXPR uint rMask = ((1 << redWidth()) - 1); + Q_CONSTEXPR uint gMask = ((1 << greenWidth()) - 1); + Q_CONSTEXPR uint bMask = ((1 << blueWidth()) - 1); - Q_CONSTEXPR uchar redRightShift = 24 - redWidth(); - Q_CONSTEXPR uchar greenRightShift = 16 - greenWidth(); - Q_CONSTEXPR uchar blueRightShift = 8 - blueWidth(); + Q_CONSTEXPR uchar rRightShift = 24 - redWidth(); + Q_CONSTEXPR uchar gRightShift = 16 - greenWidth(); + Q_CONSTEXPR uchar bRightShift = 8 - blueWidth(); for (int i = 0; i < count; ++i) { - const uint red = ((src[i] >> redRightShift) & redMask) << redShift(); - const uint green = ((src[i] >> greenRightShift) & greenMask) << greenShift(); - const uint blue = ((src[i] >> blueRightShift) & blueMask) << blueShift(); - buffer[i] = red | green | blue; + const uint c = fromRGB ? src[i] : qUnpremultiply(src[i]); + const uint r = ((c >> rRightShift) & rMask) << redShift(); + const uint g = ((c >> gRightShift) & gMask) << greenShift(); + const uint b = ((c >> bRightShift) & bMask) << blueShift(); + buffer[i] = r | g | b; } return buffer; } -template -static const uint *QT_FASTCALL convertARGBPMFromRGB32(uint *buffer, const uint *src, int count, - const QPixelLayout *, const QRgb *) -{ - 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); - - Q_CONSTEXPR uchar redRightShift = 24 - redWidth(); - Q_CONSTEXPR uchar greenRightShift = 16 - greenWidth(); - Q_CONSTEXPR uchar blueRightShift = 8 - blueWidth(); - - for (int i = 0; i < count; ++i) { - Q_CONSTEXPR uint alpha = (0xff & alphaMask) << alphaShift(); - const uint red = ((src[i] >> redRightShift) & redMask) << redShift(); - const uint green = ((src[i] >> greenRightShift) & greenMask) << greenShift(); - const uint blue = ((src[i] >> blueRightShift) & blueMask) << blueShift(); - buffer[i] = alpha | red | green | blue; - } - return buffer; -} - -template +template static const uint *QT_FASTCALL convertARGBPMFromARGB32PM(uint *buffer, const uint *src, int count, const QPixelLayout *, const QRgb *) { - 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); + 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); - Q_CONSTEXPR uchar alphaRightShift = 32 - alphaWidth(); - Q_CONSTEXPR uchar redRightShift = 24 - redWidth(); - Q_CONSTEXPR uchar greenRightShift = 16 - greenWidth(); - Q_CONSTEXPR uchar blueRightShift = 8 - blueWidth(); + Q_CONSTEXPR uchar aRightShift = 32 - alphaWidth(); + Q_CONSTEXPR uchar rRightShift = 24 - redWidth(); + Q_CONSTEXPR uchar gRightShift = 16 - greenWidth(); + Q_CONSTEXPR uchar bRightShift = 8 - blueWidth(); + Q_CONSTEXPR uint aOpaque = (0xff & aMask) << alphaShift(); for (int i = 0; i < count; ++i) { - const uint alpha = ((src[i] >> alphaRightShift) & alphaMask) << alphaShift(); - const uint red = ((src[i] >> redRightShift) & redMask) << redShift(); - const uint green = ((src[i] >> greenRightShift) & greenMask) << greenShift(); - const uint blue = ((src[i] >> blueRightShift) & blueMask) << blueShift(); - buffer[i] = alpha | red | green | blue; + const uint c = src[i]; + const uint a = fromRGB ? aOpaque : (((c >> aRightShift) & aMask) << alphaShift()); + const uint r = ((c >> rRightShift) & rMask) << redShift(); + const uint g = ((c >> gRightShift) & gMask) << greenShift(); + const uint b = ((c >> bRightShift) & bMask) << blueShift(); + buffer[i] = a | r | g | b; } return buffer; } @@ -387,8 +355,8 @@ template Q_DECL_CONSTEXPR static inline QPixelLayout pixe 0, 0, false, bitsPerPixel(), convertToRGB32, - convertRGBFromARGB32PM, - convertRGBFromRGB32, + convertRGBFromARGB32PM, + convertRGBFromARGB32PM, convertToRGB64 }; } @@ -402,8 +370,8 @@ template Q_DECL_CONSTEXPR static inline QPixelLayout pixe uchar(alphaWidth()), uchar(alphaShift()), true, bitsPerPixel(), convertARGBPMToARGB32PM, - convertARGBPMFromARGB32PM, - convertARGBPMFromRGB32, + convertARGBPMFromARGB32PM, + convertARGBPMFromARGB32PM, convertARGBPMToARGB64PM }; } @@ -881,56 +849,56 @@ QPixelLayout qPixelLayouts[QImage::NImageFormats] = { #else { 5, 11, 6, 5, 5, 0, 0, 0, false, QPixelLayout::BPP16, convertToRGB32, - convertRGBFromARGB32PM, - convertRGBFromRGB32, + convertRGBFromARGB32PM, + convertRGBFromARGB32PM, convertToRGB64, }, { 5, 19, 6, 13, 5, 8, 8, 0, true, QPixelLayout::BPP24, convertARGBPMToARGB32PM, - convertARGBPMFromARGB32PM, - convertARGBPMFromRGB32, + convertARGBPMFromARGB32PM, + convertARGBPMFromARGB32PM, convertARGBPMToARGB64PM, }, { 6, 12, 6, 6, 6, 0, 0, 0, false, QPixelLayout::BPP24, convertToRGB32, - convertRGBFromARGB32PM, - convertRGBFromRGB32, + convertRGBFromARGB32PM, + convertRGBFromARGB32PM, convertToRGB64, }, { 6, 12, 6, 6, 6, 0, 6, 18, true, QPixelLayout::BPP24, convertARGBPMToARGB32PM, - convertARGBPMFromARGB32PM, - convertARGBPMFromRGB32, + convertARGBPMFromARGB32PM, + convertARGBPMFromARGB32PM, convertARGBPMToARGB64PM, }, { 5, 10, 5, 5, 5, 0, 0, 0, false, QPixelLayout::BPP16, convertToRGB32, - convertRGBFromARGB32PM, - convertRGBFromRGB32, + convertRGBFromARGB32PM, + convertRGBFromARGB32PM, convertToRGB64, }, { 5, 18, 5, 13, 5, 8, 8, 0, true, QPixelLayout::BPP24, convertARGBPMToARGB32PM, - convertARGBPMFromARGB32PM, - convertARGBPMFromRGB32, + convertARGBPMFromARGB32PM, + convertARGBPMFromARGB32PM, convertARGBPMToARGB64PM, }, { 8, 16, 8, 8, 8, 0, 0, 0, false, QPixelLayout::BPP24, convertToRGB32, - convertRGBFromARGB32PM, - convertRGBFromRGB32, + convertRGBFromARGB32PM, + convertRGBFromARGB32PM, convertToRGB64, }, { 4, 8, 4, 4, 4, 0, 0, 0, false, QPixelLayout::BPP16, convertToRGB32, - convertRGBFromARGB32PM, - convertRGBFromRGB32, + convertRGBFromARGB32PM, + convertRGBFromARGB32PM, convertToRGB64, }, { 4, 8, 4, 4, 4, 0, 4, 12, true, QPixelLayout::BPP16, convertARGBPMToARGB32PM, - convertARGBPMFromARGB32PM, - convertARGBPMFromRGB32, + convertARGBPMFromARGB32PM, + convertARGBPMFromARGB32PM, convertARGBPMToARGB64PM, }, #endif -- cgit v1.2.3 From 6cc050c969b6dde1566f2b71f32829e680557350 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Thu, 25 Feb 2016 14:08:11 +0100 Subject: Avoid qMin in format conversions when possible Calling qMin often prevents effective vectorization, and it is only necessary when converting from formats with mixed color-channel widths. Change-Id: I2a0f3f3fb528d45be1fd025758f9d915ee1736c0 Reviewed-by: Gunnar Sletta --- src/gui/painting/qdrawhelper.cpp | 82 +++++++++++++++++++++++++++++----------- 1 file changed, 60 insertions(+), 22 deletions(-) (limited to 'src/gui/painting') diff --git a/src/gui/painting/qdrawhelper.cpp b/src/gui/painting/qdrawhelper.cpp index 933ff407e2..85c023f1ff 100644 --- a/src/gui/painting/qdrawhelper.cpp +++ b/src/gui/painting/qdrawhelper.cpp @@ -245,17 +245,36 @@ static const uint *QT_FASTCALL convertARGBPMToARGB32PM(uint *buffer, const uint Q_CONSTEXPR uchar greenRightShift = 2 * greenWidth() - 8; Q_CONSTEXPR uchar blueRightShift = 2 * blueWidth() - 8; - for (int i = 0; i < count; ++i) { - uint alpha = (src[i] >> alphaShift()) & alphaMask; - uint red = (src[i] >> redShift()) & redMask; - uint green = (src[i] >> greenShift()) & greenMask; - uint blue = (src[i] >> blueShift()) & blueMask; - - alpha = (alpha << alphaLeftShift) | (alpha >> alphaRightShift); - red = qMin(alpha, (red << redLeftShift) | (red >> redRightShift)); - green = qMin(alpha, (green << greenLeftShift) | (green >> greenRightShift)); - blue = qMin(alpha, (blue << blueLeftShift) | (blue >> blueRightShift)); - buffer[i] = (alpha << 24) | (red << 16) | (green << 8) | blue; + Q_CONSTEXPR bool mustMin = (alphaWidth() != redWidth()) || + (alphaWidth() != greenWidth()) || + (alphaWidth() != blueWidth()); + + if (mustMin) { + for (int i = 0; i < count; ++i) { + uint alpha = (src[i] >> alphaShift()) & alphaMask; + uint red = (src[i] >> redShift()) & redMask; + uint green = (src[i] >> greenShift()) & greenMask; + uint blue = (src[i] >> blueShift()) & blueMask; + + alpha = (alpha << alphaLeftShift) | (alpha >> alphaRightShift); + red = qMin(alpha, (red << redLeftShift) | (red >> redRightShift)); + green = qMin(alpha, (green << greenLeftShift) | (green >> greenRightShift)); + blue = qMin(alpha, (blue << blueLeftShift) | (blue >> blueRightShift)); + buffer[i] = (alpha << 24) | (red << 16) | (green << 8) | blue; + } + } else { + for (int i = 0; i < count; ++i) { + uint alpha = (src[i] >> alphaShift()) & alphaMask; + uint red = (src[i] >> redShift()) & redMask; + uint green = (src[i] >> greenShift()) & greenMask; + uint blue = (src[i] >> blueShift()) & blueMask; + + alpha = ((alpha << alphaLeftShift) | (alpha >> alphaRightShift)) << 24; + red = ((red << redLeftShift) | (red >> redRightShift)) << 16; + green = ((green << greenLeftShift) | (green >> greenRightShift)) << 8; + blue = (blue << blueLeftShift) | (blue >> blueRightShift); + buffer[i] = alpha | red | green | blue; + } } return buffer; @@ -280,17 +299,36 @@ static const QRgba64 *QT_FASTCALL convertARGBPMToARGB64PM(QRgba64 *buffer, const Q_CONSTEXPR uchar greenRightShift = 2 * greenWidth() - 8; Q_CONSTEXPR uchar blueRightShift = 2 * blueWidth() - 8; - for (int i = 0; i < count; ++i) { - uint alpha = (src[i] >> alphaShift()) & alphaMask; - uint red = (src[i] >> redShift()) & redMask; - uint green = (src[i] >> greenShift()) & greenMask; - uint blue = (src[i] >> blueShift()) & blueMask; - - alpha = (alpha << alphaLeftShift) | (alpha >> alphaRightShift); - red = qMin(alpha, (red << redLeftShift) | (red >> redRightShift)); - green = qMin(alpha, (green << greenLeftShift) | (green >> greenRightShift)); - blue = qMin(alpha, (blue << blueLeftShift) | (blue >> blueRightShift)); - buffer[i] = QRgba64::fromRgba(red, green, blue, alpha); + Q_CONSTEXPR bool mustMin = (alphaWidth() != redWidth()) || + (alphaWidth() != greenWidth()) || + (alphaWidth() != blueWidth()); + + if (mustMin) { + for (int i = 0; i < count; ++i) { + uint alpha = (src[i] >> alphaShift()) & alphaMask; + uint red = (src[i] >> redShift()) & redMask; + uint green = (src[i] >> greenShift()) & greenMask; + uint blue = (src[i] >> blueShift()) & blueMask; + + alpha = (alpha << alphaLeftShift) | (alpha >> alphaRightShift); + red = qMin(alpha, (red << redLeftShift) | (red >> redRightShift)); + green = qMin(alpha, (green << greenLeftShift) | (green >> greenRightShift)); + blue = qMin(alpha, (blue << blueLeftShift) | (blue >> blueRightShift)); + buffer[i] = QRgba64::fromRgba(red, green, blue, alpha); + } + } else { + for (int i = 0; i < count; ++i) { + uint alpha = (src[i] >> alphaShift()) & alphaMask; + uint red = (src[i] >> redShift()) & redMask; + uint green = (src[i] >> greenShift()) & greenMask; + uint blue = (src[i] >> blueShift()) & blueMask; + + alpha = (alpha << alphaLeftShift) | (alpha >> alphaRightShift); + red = (red << redLeftShift) | (red >> redRightShift); + green = (green << greenLeftShift) | (green >> greenRightShift); + blue = (blue << blueLeftShift) | (blue >> blueRightShift); + buffer[i] = QRgba64::fromRgba(red, green, blue, alpha); + } } return buffer; -- cgit v1.2.3 From 1bd24e5b0c7c329e8e6b00e85d2d360abf5630c6 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Wed, 24 Jun 2015 09:48:50 +0200 Subject: QtGui: Mark some more types as shared for Qt 6. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Marking them shared (which implies movable) now would make QLists of these BiC. Change-Id: If5638e8d9f43e0ad549aedf08934de31e1e189f1 Reviewed-by: Lars Knoll Reviewed-by: Jędrzej Nowacki --- src/gui/painting/qpainterpath.h | 1 + src/gui/painting/qpolygon.h | 2 ++ 2 files changed, 3 insertions(+) (limited to 'src/gui/painting') diff --git a/src/gui/painting/qpainterpath.h b/src/gui/painting/qpainterpath.h index 8513e6d407..882918fc87 100644 --- a/src/gui/painting/qpainterpath.h +++ b/src/gui/painting/qpainterpath.h @@ -230,6 +230,7 @@ private: #endif }; +Q_DECLARE_SHARED_NOT_MOVABLE_UNTIL_QT6(QPainterPath) Q_DECLARE_TYPEINFO(QPainterPath::Element, Q_PRIMITIVE_TYPE); #ifndef QT_NO_DATASTREAM diff --git a/src/gui/painting/qpolygon.h b/src/gui/painting/qpolygon.h index 7b77ee5014..23bdd1933f 100644 --- a/src/gui/painting/qpolygon.h +++ b/src/gui/painting/qpolygon.h @@ -98,6 +98,7 @@ public: QPolygon intersected(const QPolygon &r) const Q_REQUIRED_RESULT; QPolygon subtracted(const QPolygon &r) const Q_REQUIRED_RESULT; }; +Q_DECLARE_SHARED_NOT_MOVABLE_UNTIL_QT6(QPolygon) inline QPolygon::QPolygon(int asize) : QVector(asize) {} @@ -174,6 +175,7 @@ public: QPolygonF intersected(const QPolygonF &r) const Q_REQUIRED_RESULT; QPolygonF subtracted(const QPolygonF &r) const Q_REQUIRED_RESULT; }; +Q_DECLARE_SHARED_NOT_MOVABLE_UNTIL_QT6(QPolygonF) inline QPolygonF::QPolygonF(int asize) : QVector(asize) {} -- cgit v1.2.3 From 53abb8267bfa4c261a1aa543f1ad50ed0851bcbf Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Sun, 5 Jul 2015 22:37:40 +0200 Subject: QtGui: mark some more types as movable/primitive MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit These are already held in QVectors. Public API types need to wait until Qt 6, for BC reasons. Even though Q_RELOCATABLE_TYPE deals with most of them, we lack a way to mark a type as primitive, but still isStatic - for QList. Change-Id: I91392b01ae6f94cc847007636e12d4e64c43b2bc Reviewed-by: Jędrzej Nowacki --- src/gui/painting/qpathclipper.cpp | 1 + src/gui/painting/qpdf.cpp | 1 + 2 files changed, 2 insertions(+) (limited to 'src/gui/painting') diff --git a/src/gui/painting/qpathclipper.cpp b/src/gui/painting/qpathclipper.cpp index cdc9838dbe..861d651756 100644 --- a/src/gui/painting/qpathclipper.cpp +++ b/src/gui/painting/qpathclipper.cpp @@ -1761,6 +1761,7 @@ struct QCrossingEdge return x < edge.x; } }; +Q_DECLARE_TYPEINFO(QCrossingEdge, Q_PRIMITIVE_TYPE); static bool bool_op(bool a, bool b, QPathClipper::Operation op) { diff --git a/src/gui/painting/qpdf.cpp b/src/gui/painting/qpdf.cpp index 52bf44c64a..0c3069db97 100644 --- a/src/gui/painting/qpdf.cpp +++ b/src/gui/painting/qpdf.cpp @@ -1976,6 +1976,7 @@ struct QGradientBound { int function; bool reverse; }; +Q_DECLARE_TYPEINFO(QGradientBound, Q_PRIMITIVE_TYPE); int QPdfEnginePrivate::createShadingFunction(const QGradient *gradient, int from, int to, bool reflect, bool alpha) { -- cgit v1.2.3 From b6b3803b213787a04dfc7542caeb541a5535d90f Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Wed, 2 Mar 2016 14:00:20 +0100 Subject: Optimized fetchUntransformed RGB888 Reuses the optimized routines from qimage to make painting RGB888 images faster on SSSE3 and NEON. Change-Id: I99116b318322ba4cb0ddc2cb90bcf17a0350ef99 Reviewed-by: Gunnar Sletta --- src/gui/painting/qdrawhelper.cpp | 7 +++++++ src/gui/painting/qdrawhelper_neon.cpp | 10 ++++++++++ src/gui/painting/qdrawhelper_neon_p.h | 3 +++ src/gui/painting/qdrawhelper_ssse3.cpp | 10 ++++++++++ 4 files changed, 30 insertions(+) (limited to 'src/gui/painting') diff --git a/src/gui/painting/qdrawhelper.cpp b/src/gui/painting/qdrawhelper.cpp index 85c023f1ff..a325ee923e 100644 --- a/src/gui/painting/qdrawhelper.cpp +++ b/src/gui/painting/qdrawhelper.cpp @@ -6382,11 +6382,15 @@ static void qInitDrawhelperFunctions() int const_alpha); extern void QT_FASTCALL storePixelsBPP24_ssse3(uchar *dest, const uint *src, int index, int count); + extern const uint * QT_FASTCALL qt_fetchUntransformed_888_ssse3(uint *buffer, const Operator *, const QSpanData *data, + int y, int x, int length); qBlendFunctions[QImage::Format_RGB32][QImage::Format_ARGB32_Premultiplied] = qt_blend_argb32_on_argb32_ssse3; qBlendFunctions[QImage::Format_ARGB32_Premultiplied][QImage::Format_ARGB32_Premultiplied] = qt_blend_argb32_on_argb32_ssse3; qBlendFunctions[QImage::Format_RGBX8888][QImage::Format_RGBA8888_Premultiplied] = qt_blend_argb32_on_argb32_ssse3; qBlendFunctions[QImage::Format_RGBA8888_Premultiplied][QImage::Format_RGBA8888_Premultiplied] = qt_blend_argb32_on_argb32_ssse3; qStorePixels[QPixelLayout::BPP24] = storePixelsBPP24_ssse3; + sourceFetch[BlendUntransformed][QImage::Format_RGB888] = qt_fetchUntransformed_888_ssse3; + sourceFetch[BlendTiled][QImage::Format_RGB888] = qt_fetchUntransformed_888_ssse3; } #endif // SSSE3 @@ -6449,6 +6453,9 @@ static void qInitDrawhelperFunctions() qt_fetch_radial_gradient = qt_fetch_radial_gradient_neon; + sourceFetch[BlendUntransformed][QImage::Format_RGB888] = qt_fetchUntransformed_888_neon; + sourceFetch[BlendTiled][QImage::Format_RGB888] = qt_fetchUntransformed_888_neon; + #if defined(ENABLE_PIXMAN_DRAWHELPERS) // The RGB16 helpers are using Arm32 assemblythat has not been ported to AArch64 qBlendFunctions[QImage::Format_RGB16][QImage::Format_ARGB32_Premultiplied] = qt_blend_argb32_on_rgb16_neon; diff --git a/src/gui/painting/qdrawhelper_neon.cpp b/src/gui/painting/qdrawhelper_neon.cpp index 7dbfa4fa9c..f5b794ace6 100644 --- a/src/gui/painting/qdrawhelper_neon.cpp +++ b/src/gui/painting/qdrawhelper_neon.cpp @@ -1061,6 +1061,16 @@ const uint * QT_FASTCALL qt_fetch_radial_gradient_neon(uint *buffer, const Opera return qt_fetch_radial_gradient_template,uint>(buffer, op, data, y, x, length); } +extern void QT_FASTCALL qt_convert_rgb888_to_rgb32_neon(quint32 *dst, const uchar *src, int len); + +const uint * QT_FASTCALL qt_fetchUntransformed_888_neon(uint *buffer, const Operator *, const QSpanData *data, + int y, int x, int length) +{ + const uchar *line = data->texture.scanLine(y) + x * 3; + qt_convert_rgb888_to_rgb32_neon(buffer, line, length); + return buffer; +} + QT_END_NAMESPACE #endif // __ARM_NEON__ diff --git a/src/gui/painting/qdrawhelper_neon_p.h b/src/gui/painting/qdrawhelper_neon_p.h index 0134960fa1..3cf949fc32 100644 --- a/src/gui/painting/qdrawhelper_neon_p.h +++ b/src/gui/painting/qdrawhelper_neon_p.h @@ -137,6 +137,9 @@ void QT_FASTCALL qt_destStoreRGB16_neon(QRasterBuffer *rasterBuffer, void QT_FASTCALL comp_func_solid_SourceOver_neon(uint *destPixels, int length, uint color, uint const_alpha); void QT_FASTCALL comp_func_Plus_neon(uint *dst, const uint *src, int length, uint const_alpha); +const uint * QT_FASTCALL qt_fetchUntransformed_888_neon(uint *buffer, const Operator *, const QSpanData *data, + int y, int x, int length); + #endif // __ARM_NEON__ QT_END_NAMESPACE diff --git a/src/gui/painting/qdrawhelper_ssse3.cpp b/src/gui/painting/qdrawhelper_ssse3.cpp index e0d1bac6b1..7cd3e9ca1b 100644 --- a/src/gui/painting/qdrawhelper_ssse3.cpp +++ b/src/gui/painting/qdrawhelper_ssse3.cpp @@ -233,6 +233,16 @@ void QT_FASTCALL storePixelsBPP24_ssse3(uchar *dest, const uint *src, int index, store_uint24_ssse3(dest + index * 3, src, count); } +extern void QT_FASTCALL qt_convert_rgb888_to_rgb32_ssse3(quint32 *dst, const uchar *src, int len); + +const uint * QT_FASTCALL qt_fetchUntransformed_888_ssse3(uint *buffer, const Operator *, const QSpanData *data, + int y, int x, int length) +{ + const uchar *line = data->texture.scanLine(y) + x * 3; + qt_convert_rgb888_to_rgb32_ssse3(buffer, line, length); + return buffer; +} + QT_END_NAMESPACE #endif // QT_COMPILER_SUPPORTS_SSSE3 -- cgit v1.2.3 From 600529e07a46d8e20f4302dc988125f3fee36ec4 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Sat, 17 Oct 2015 17:48:34 +0200 Subject: QtGui: use printf-style qWarning/qDebug where possible (I) The printf-style version of QDebug expands to a lot less code than the std::ostream-style version. Of course, you pay in type safety (but compilers warn about it these days), you cannot stream complex Qt types and streaming QStrings is awkward, but in many cases you actually improve on readability. But the main reason is that something that's not supposed to be executed under normal operation has no business bloating executable code size. This is not an attempt at converting all qWarnings() to printf-style, only the low-hanging fruit. In this first part, replace qWarning() << "..."; with qWarning("..."); In QTransform shared warning strings. Saves 3KiB in text size on optimized GCC 5.3 AMD64 builds. Change-Id: I142a8020eaab043d78465178192f2c8c6d1cc4f9 Reviewed-by: Friedemann Kleint Reviewed-by: Kai Koehne --- src/gui/painting/qpaintengine_raster.cpp | 2 +- src/gui/painting/qpdf.cpp | 4 ++-- src/gui/painting/qtransform.cpp | 22 +++++++++++++++------- 3 files changed, 18 insertions(+), 10 deletions(-) (limited to 'src/gui/painting') diff --git a/src/gui/painting/qpaintengine_raster.cpp b/src/gui/painting/qpaintengine_raster.cpp index 34b4d97758..4ab029cf7a 100644 --- a/src/gui/painting/qpaintengine_raster.cpp +++ b/src/gui/painting/qpaintengine_raster.cpp @@ -1163,7 +1163,7 @@ void QRasterPaintEngine::clip(const QVectorPath &path, Qt::ClipOperation op) if (s->matrix.type() <= QTransform::TxScale && path.isRect()) { #ifdef QT_DEBUG_DRAW - qDebug() << " --- optimizing vector clip to rect clip..."; + qDebug(" --- optimizing vector clip to rect clip..."); #endif const qreal *points = path.points(); QRectF r(points[0], points[1], points[4]-points[0], points[5]-points[1]); diff --git a/src/gui/painting/qpdf.cpp b/src/gui/painting/qpdf.cpp index 0c3069db97..f83f1c997e 100644 --- a/src/gui/painting/qpdf.cpp +++ b/src/gui/painting/qpdf.cpp @@ -1951,7 +1951,7 @@ int QPdfEnginePrivate::writeImage(const QByteArray &data, int width, int height, xprintf("/Interpolate true\n"); int len = 0; if (dct) { - //qDebug() << "DCT"; + //qDebug("DCT"); xprintf("/Filter /DCTDecode\n>>\nstream\n"); write(data); len = data.length(); @@ -2215,7 +2215,7 @@ int QPdfEnginePrivate::generateGradientShader(const QGradient *gradient, const Q return generateRadialGradientShader(static_cast(gradient), matrix, alpha); case QGradient::ConicalGradient: default: - qWarning() << "Implement me!"; + qWarning("Implement me!"); } return 0; } diff --git a/src/gui/painting/qtransform.cpp b/src/gui/painting/qtransform.cpp index a0596d1a07..6058811176 100644 --- a/src/gui/painting/qtransform.cpp +++ b/src/gui/painting/qtransform.cpp @@ -53,6 +53,14 @@ QT_BEGIN_NAMESPACE +#ifndef QT_NO_DEBUG +Q_NEVER_INLINE +static void nanWarning(const char *func) +{ + qWarning("QTransform::%s with NaN called", func); +} +#endif // QT_NO_DEBUG + #define Q_NEAR_CLIP (sizeof(qreal) == sizeof(double) ? 0.000001 : 0.0001) #ifdef MAP @@ -418,7 +426,7 @@ QTransform &QTransform::translate(qreal dx, qreal dy) return *this; #ifndef QT_NO_DEBUG if (qIsNaN(dx) | qIsNaN(dy)) { - qWarning() << "QTransform::translate with NaN called"; + nanWarning("translate"); return *this; } #endif @@ -461,7 +469,7 @@ QTransform QTransform::fromTranslate(qreal dx, qreal dy) { #ifndef QT_NO_DEBUG if (qIsNaN(dx) | qIsNaN(dy)) { - qWarning() << "QTransform::fromTranslate with NaN called"; + nanWarning("fromTranslate"); return QTransform(); } #endif @@ -486,7 +494,7 @@ QTransform & QTransform::scale(qreal sx, qreal sy) return *this; #ifndef QT_NO_DEBUG if (qIsNaN(sx) | qIsNaN(sy)) { - qWarning() << "QTransform::scale with NaN called"; + nanWarning("scale"); return *this; } #endif @@ -527,7 +535,7 @@ QTransform QTransform::fromScale(qreal sx, qreal sy) { #ifndef QT_NO_DEBUG if (qIsNaN(sx) | qIsNaN(sy)) { - qWarning() << "QTransform::fromScale with NaN called"; + nanWarning("fromScale"); return QTransform(); } #endif @@ -552,7 +560,7 @@ QTransform & QTransform::shear(qreal sh, qreal sv) return *this; #ifndef QT_NO_DEBUG if (qIsNaN(sh) | qIsNaN(sv)) { - qWarning() << "QTransform::shear with NaN called"; + nanWarning("shear"); return *this; } #endif @@ -613,7 +621,7 @@ QTransform & QTransform::rotate(qreal a, Qt::Axis axis) return *this; #ifndef QT_NO_DEBUG if (qIsNaN(a)) { - qWarning() << "QTransform::rotate with NaN called"; + nanWarning("rotate"); return *this; } #endif @@ -704,7 +712,7 @@ QTransform & QTransform::rotateRadians(qreal a, Qt::Axis axis) { #ifndef QT_NO_DEBUG if (qIsNaN(a)) { - qWarning() << "QTransform::rotateRadians with NaN called"; + nanWarning("rotateRadians"); return *this; } #endif -- cgit v1.2.3 From 4f577051676ad8ff161d481030f016d0c6bb324f Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Sat, 5 Mar 2016 00:34:01 +0100 Subject: Fix GCC 6 -Wunused-functions warnings GCC 6 is able to identify member functions that are unused. Remove them. Change-Id: Ic77548164b38a1cd3c957d2c57a5bccb979bc02e Reviewed-by: Olivier Goffart (Woboq GmbH) --- src/gui/painting/qpathclipper.cpp | 8 -------- 1 file changed, 8 deletions(-) (limited to 'src/gui/painting') diff --git a/src/gui/painting/qpathclipper.cpp b/src/gui/painting/qpathclipper.cpp index 3a686bd209..a5557c99ff 100644 --- a/src/gui/painting/qpathclipper.cpp +++ b/src/gui/painting/qpathclipper.cpp @@ -252,8 +252,6 @@ class SegmentTree public: SegmentTree(QPathSegments &segments); - QRectF boundingRect() const; - void produceIntersections(int segment); private: @@ -304,12 +302,6 @@ SegmentTree::SegmentTree(QPathSegments &segments) m_tree[0] = root; } -QRectF SegmentTree::boundingRect() const -{ - return QRectF(QPointF(m_bounds.x1, m_bounds.y1), - QPointF(m_bounds.x2, m_bounds.y2)); -} - static inline qreal coordinate(const QPointF &pos, int axis) { return axis == 0 ? pos.x() : pos.y(); -- cgit v1.2.3 From 8135e52cb45bd24c288c29da470828fe4fe5e3de Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Wed, 2 Mar 2016 11:34:44 +0100 Subject: Fix MIPS DSP optimized fetchUntransformed These have been wrong since being introduced in 5.3. Change-Id: I5b4aa198c8d4c6726f1c5097abe8d43275722dab Reviewed-by: Ljubomir Papuga Reviewed-by: Gunnar Sletta --- src/gui/painting/qdrawhelper_mips_dsp.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/gui/painting') diff --git a/src/gui/painting/qdrawhelper_mips_dsp.cpp b/src/gui/painting/qdrawhelper_mips_dsp.cpp index 721b228395..c28b594de3 100644 --- a/src/gui/painting/qdrawhelper_mips_dsp.cpp +++ b/src/gui/painting/qdrawhelper_mips_dsp.cpp @@ -489,7 +489,7 @@ void QT_FASTCALL comp_func_SourceOut_mips_dsp(uint *dest, const uint *src, int l const uint * QT_FASTCALL qt_fetchUntransformed_888_mips_dsp (uint *buffer, const Operator *, const QSpanData *data, int y, int x, int length) { - uchar *line = (uchar *)data->texture.scanLine(y) + x; + const uchar *line = data->texture.scanLine(y) + x * 3; fetchUntransformed_888_asm_mips_dsp(buffer, line, length); return buffer; } @@ -497,7 +497,7 @@ const uint * QT_FASTCALL qt_fetchUntransformed_888_mips_dsp (uint *buffer, const const uint * QT_FASTCALL qt_fetchUntransformed_444_mips_dsp (uint *buffer, const Operator *, const QSpanData *data, int y, int x, int length) { - uchar *line = (uchar *)data->texture.scanLine(y) + x; + const uchar *line = data->texture.scanLine(y) + x * 2; fetchUntransformed_444_asm_mips_dsp(buffer, line, length); return buffer; } @@ -505,7 +505,7 @@ const uint * QT_FASTCALL qt_fetchUntransformed_444_mips_dsp (uint *buffer, const const uint * QT_FASTCALL qt_fetchUntransformed_argb8565_premultiplied_mips_dsp (uint *buffer, const Operator *, const QSpanData *data, int y, int x, int length) { - uchar *line = (uchar *)data->texture.scanLine(y) + x; + const uchar *line = data->texture.scanLine(y) + x * 3; fetchUntransformed_argb8565_premultiplied_asm_mips_dsp(buffer, line, length); return buffer; } -- cgit v1.2.3 From fb7ef2b9f5cbc375fb35690326501be6a117314d Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Sun, 6 Mar 2016 15:06:48 +0100 Subject: QCosmeticStroker: fix out-of-bounds access in drawPixel() Found by UBSan: src/gui/painting/qcosmeticstroker.cpp:150:55: runtime error: index -1 out of bounds for type 'QT_FT_Span_ [255]' src/gui/painting/qcosmeticstroker.cpp:150:99: runtime error: index -1 out of bounds for type 'QT_FT_Span_ [255]' src/gui/painting/qcosmeticstroker.cpp:151:55: runtime error: index -1 out of bounds for type 'QT_FT_Span_ [255]' That code path makes no sense if no span has been populated yet, so skip the whole block if current_span == 0. Change-Id: I832b989e89c118dc48ab5add3a28bb44c1936a76 Reviewed-by: Allan Sandfeld Jensen --- src/gui/painting/qcosmeticstroker.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'src/gui/painting') diff --git a/src/gui/painting/qcosmeticstroker.cpp b/src/gui/painting/qcosmeticstroker.cpp index 8c3fd2ce4f..b310336b9b 100644 --- a/src/gui/painting/qcosmeticstroker.cpp +++ b/src/gui/painting/qcosmeticstroker.cpp @@ -141,12 +141,14 @@ inline void drawPixel(QCosmeticStroker *stroker, int x, int y, int coverage) if (x < cl.x() || x > cl.right() || y < cl.y() || y > cl.bottom()) return; - int lastx = stroker->spans[stroker->current_span-1].x + stroker->spans[stroker->current_span-1].len ; - int lasty = stroker->spans[stroker->current_span-1].y; + if (stroker->current_span > 0) { + const int lastx = stroker->spans[stroker->current_span-1].x + stroker->spans[stroker->current_span-1].len ; + const int lasty = stroker->spans[stroker->current_span-1].y; - if (stroker->current_span == QCosmeticStroker::NSPANS || y < lasty || (y == lasty && x < lastx)) { - stroker->blend(stroker->current_span, stroker->spans, &stroker->state->penData); - stroker->current_span = 0; + if (stroker->current_span == QCosmeticStroker::NSPANS || y < lasty || (y == lasty && x < lastx)) { + stroker->blend(stroker->current_span, stroker->spans, &stroker->state->penData); + stroker->current_span = 0; + } } stroker->spans[stroker->current_span].x = ushort(x); -- cgit v1.2.3 From 62e0a98282081911616a8c005464d483a3a480d2 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 15 Dec 2015 17:15:15 +0100 Subject: Fix debug operators for QPageSize/QPageLayout. Remove placeholder formatting and add noquote. Change-Id: I4a89f88778caf007ce42bbf57edfb514fe76bcdb Reviewed-by: Kai Koehne --- src/gui/painting/qpagelayout.cpp | 33 +++++++++++++++------------------ src/gui/painting/qpagesize.cpp | 14 +++++++------- 2 files changed, 22 insertions(+), 25 deletions(-) (limited to 'src/gui/painting') diff --git a/src/gui/painting/qpagelayout.cpp b/src/gui/painting/qpagelayout.cpp index f443bbd5ac..15dfa6f8c1 100644 --- a/src/gui/painting/qpagelayout.cpp +++ b/src/gui/painting/qpagelayout.cpp @@ -943,40 +943,37 @@ QRect QPageLayout::paintRectPixels(int resolution) const QDebug operator<<(QDebug dbg, const QPageLayout &layout) { QDebugStateSaver saver(dbg); + dbg.nospace(); + dbg.noquote(); + dbg << "QPageLayout("; if (layout.isValid()) { - QString output = QStringLiteral("QPageLayout(%1, %2, l:%3 r:%4 t:%5 b:%6 %7)"); - QString units; + const QMarginsF margins = layout.margins(); + dbg << '"' << layout.pageSize().name() << "\", " + << (layout.orientation() == QPageLayout::Portrait ? "Portrait" : "Landscape") + << ", l:" << margins.left() << " r:" << margins.right() << " t:" + << margins.top() << " b:" << margins.bottom() << ' '; switch (layout.units()) { case QPageLayout::Millimeter: - units = QStringLiteral("mm"); + dbg << "mm"; break; case QPageLayout::Point: - units = QStringLiteral("pt"); + dbg << "pt"; break; case QPageLayout::Inch: - units = QStringLiteral("in"); + dbg << "in"; break; case QPageLayout::Pica: - units = QStringLiteral("pc"); + dbg << "pc"; break; case QPageLayout::Didot: - units = QStringLiteral("DD"); + dbg << "DD"; break; case QPageLayout::Cicero: - units = QStringLiteral("CC"); + dbg << "CC"; break; } - output = output.arg(layout.pageSize().name()) - .arg(layout.orientation() == QPageLayout::Portrait ? QStringLiteral("Portrait") : QStringLiteral("Landscape")) - .arg(layout.margins().left()) - .arg(layout.margins().right()) - .arg(layout.margins().top()) - .arg(layout.margins().bottom()) - .arg(units); - dbg.nospace() << output; - } else { - dbg.nospace() << "QPageLayout()"; } + dbg << ')'; return dbg; } #endif diff --git a/src/gui/painting/qpagesize.cpp b/src/gui/painting/qpagesize.cpp index c0aae603b7..17f6b7bb64 100644 --- a/src/gui/painting/qpagesize.cpp +++ b/src/gui/painting/qpagesize.cpp @@ -1855,17 +1855,17 @@ QSize QPageSize::sizePixels(PageSizeId pageSizeId, int resolution) QDebug operator<<(QDebug dbg, const QPageSize &pageSize) { QDebugStateSaver saver(dbg); + dbg.nospace(); + dbg.noquote(); + dbg << "QPageSize("; if (pageSize.isValid()) { - QString output = QStringLiteral("QPageSize(\"%1\", \"%2\", %3x%4pt, %5)"); - output = output.arg(pageSize.name()) - .arg(pageSize.key()) - .arg(pageSize.sizePoints().width()) - .arg(pageSize.sizePoints().height()) - .arg(pageSize.id()); - dbg.nospace() << output; + dbg << '"' << pageSize.name() << "\", key=\"" << pageSize.key() + << "\", " << pageSize.sizePoints().width() << 'x' + << pageSize.sizePoints().height() << "pt, id=" << pageSize.id(); } else { dbg.nospace() << "QPageSize()"; } + dbg << ')'; return dbg; } #endif -- cgit v1.2.3 From 52a599bb56e5e5e625909c25edee8487b0a3754d Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Sat, 12 Mar 2016 11:34:48 +0100 Subject: QCosmeticStroker: fix several UBs involving << with a negative LHS Left-shifts of negative values are undefined in C++. In particular, they don't behave arithmetically. Reported by UBSan: qcosmeticstroker.cpp: 72:15: runtime error: left shift of negative value -14/-19/-32/-33/-34/-37/-38/-63/-64/-192/-384/-1280 qcosmeticstroker.cpp:444:20: runtime error: left shift of negative value -64 qcosmeticstroker.cpp:451:26: runtime error: left shift of negative value -1 qcosmeticstroker.cpp:483:26: runtime error: left shift of negative value -1 qcosmeticstroker.cpp:762:20: runtime error: left shift of negative value -64 qcosmeticstroker.cpp:774:26: runtime error: left shift of negative value -1 qcosmeticstroker.cpp:813:47: runtime error: left shift of negative value -1 qcosmeticstroker.cpp:839:20: runtime error: left shift of negative value -64 qcosmeticstroker.cpp:851:26: runtime error: left shift of negative value -1 qcosmeticstroker.cpp:889:47: runtime error: left shift of negative value -1 qcosmeticstroker.cpp:932:27: runtime error: left shift of negative value -64 qcosmeticstroker.cpp:995:27: runtime error: left shift of negative value -3/-64 Fix by using ordinary multiplication instead, because negative left-hand-side values don't look like they are an error. Change-Id: Icbebd41f6ddd3dca4abd385585fc0f82064fe8b6 Reviewed-by: Allan Sandfeld Jensen --- src/gui/painting/qcosmeticstroker.cpp | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'src/gui/painting') diff --git a/src/gui/painting/qcosmeticstroker.cpp b/src/gui/painting/qcosmeticstroker.cpp index b310336b9b..64da03f13a 100644 --- a/src/gui/painting/qcosmeticstroker.cpp +++ b/src/gui/painting/qcosmeticstroker.cpp @@ -62,8 +62,8 @@ static inline uint sourceOver(uint d, uint color) inline static int F16Dot16FixedDiv(int x, int y) { if (qAbs(x) > 0x7fff) - return (((qlonglong)x) << 16) / y; - return (x << 16) / y; + return qlonglong(x) * (1<<16) / y; + return x * (1<<16) / y; } typedef void (*DrawPixel)(QCosmeticStroker *stroker, int x, int y, int coverage); @@ -435,14 +435,14 @@ void QCosmeticStroker::calculateLastPoint(qreal rx1, qreal ry1, qreal rx2, qreal qSwap(x1, x2); } int xinc = F16Dot16FixedDiv(x2 - x1, y2 - y1); - int x = x1 << 10; + int x = x1 * (1<<10); int y = (y1 + 32) >> 6; int ys = (y2 + 32) >> 6; int round = (xinc > 0) ? 32 : 0; if (y != ys) { - x += ( ((((y << 6) + round - y1))) * xinc ) >> 6; + x += ((y * (1<<6)) + round - y1) * xinc >> 6; if (swapped) { lastPixel.x = x >> 16; @@ -474,7 +474,7 @@ void QCosmeticStroker::calculateLastPoint(qreal rx1, qreal ry1, qreal rx2, qreal int round = (yinc > 0) ? 32 : 0; if (x != xs) { - y += ( ((((x << 6) + round - x1))) * yinc ) >> 6; + y += ((x * (1<<6)) + round - x1) * yinc >> 6; if (swapped) { lastPixel.x = x; @@ -753,7 +753,7 @@ static bool drawLine(QCosmeticStroker *stroker, qreal rx1, qreal ry1, qreal rx2, dir = QCosmeticStroker::BottomToTop; } int xinc = F16Dot16FixedDiv(x2 - x1, y2 - y1); - int x = x1 << 10; + int x = x1 * (1<<10); if ((stroker->lastDir ^ QCosmeticStroker::VerticalMask) == dir) caps |= swapped ? QCosmeticStroker::CapEnd : QCosmeticStroker::CapBegin; @@ -765,7 +765,7 @@ static bool drawLine(QCosmeticStroker *stroker, qreal rx1, qreal ry1, qreal rx2, int round = (xinc > 0) ? 32 : 0; if (y != ys) { - x += ( ((((y << 6) + round - y1))) * xinc ) >> 6; + x += ((y * (1<<6)) + round - y1) * xinc >> 6; // calculate first and last pixel and perform dropout control QCosmeticStroker::Point first; @@ -804,7 +804,7 @@ static bool drawLine(QCosmeticStroker *stroker, qreal rx1, qreal ry1, qreal rx2, stroker->lastDir = dir; stroker->lastAxisAligned = axisAligned; - Dasher dasher(stroker, swapped, y << 6, ys << 6); + Dasher dasher(stroker, swapped, y * (1<<6), ys * (1<<6)); do { if (dasher.on()) @@ -830,7 +830,7 @@ static bool drawLine(QCosmeticStroker *stroker, qreal rx1, qreal ry1, qreal rx2, dir = QCosmeticStroker::RightToLeft; } int yinc = F16Dot16FixedDiv(y2 - y1, x2 - x1); - int y = y1 << 10; + int y = y1 * (1<<10); if ((stroker->lastDir ^ QCosmeticStroker::HorizontalMask) == dir) caps |= swapped ? QCosmeticStroker::CapEnd : QCosmeticStroker::CapBegin; @@ -842,7 +842,7 @@ static bool drawLine(QCosmeticStroker *stroker, qreal rx1, qreal ry1, qreal rx2, int round = (yinc > 0) ? 32 : 0; if (x != xs) { - y += ( ((((x << 6) + round - x1))) * yinc ) >> 6; + y += ((x * (1<<6)) + round - x1) * yinc >> 6; // calculate first and last pixel to perform dropout control QCosmeticStroker::Point first; @@ -880,7 +880,7 @@ static bool drawLine(QCosmeticStroker *stroker, qreal rx1, qreal ry1, qreal rx2, stroker->lastDir = dir; stroker->lastAxisAligned = axisAligned; - Dasher dasher(stroker, swapped, x << 6, xs << 6); + Dasher dasher(stroker, swapped, x * (1<<6), xs * (1<<6)); do { if (dasher.on()) @@ -923,7 +923,7 @@ static bool drawLineAA(QCosmeticStroker *stroker, qreal rx1, qreal ry1, qreal rx caps = swapCaps(caps); } - int x = (x1 - 32) << 10; + int x = (x1 - 32) * (1<<10); x -= ( ((y1 & 63) - 32) * xinc ) >> 6; capAdjust(caps, y1, y2, x, xinc); @@ -986,7 +986,7 @@ static bool drawLineAA(QCosmeticStroker *stroker, qreal rx1, qreal ry1, qreal rx caps = swapCaps(caps); } - int y = (y1 - 32) << 10; + int y = (y1 - 32) * (1<<10); y -= ( ((x1 & 63) - 32) * yinc ) >> 6; capAdjust(caps, x1, x2, y, yinc); -- cgit v1.2.3