diff options
author | Liang Qi <liang.qi@theqtcompany.com> | 2015-09-25 14:02:04 +0200 |
---|---|---|
committer | Liang Qi <liang.qi@theqtcompany.com> | 2015-09-25 14:02:04 +0200 |
commit | a1ad9a74ebb3c556c5f70f7e03be68b09598ac53 (patch) | |
tree | 615a96db418219a57a745a5899e39a9ac90744ec /src/gui/painting | |
parent | 6d78b7a0c46ea04f4bb771d960e2f7dff1362341 (diff) | |
parent | 462f355e4fb16cc7a1838fa2dda0f763eee58c84 (diff) |
Merge remote-tracking branch 'origin/5.6' into dev
Conflicts:
src/corelib/io/io.pri
src/corelib/io/qdatastream.cpp
src/corelib/io/qdatastream.h
src/network/socket/qabstractsocket.cpp
src/plugins/platforminputcontexts/ibus/qibusplatforminputcontext.cpp
src/plugins/platforms/cocoa/qcocoaaccessibilityelement.h
src/widgets/styles/qgtkstyle.cpp
tests/auto/corelib/mimetypes/qmimedatabase/qmimedatabase-cache/qmimedatabase-cache.pro
tests/auto/corelib/mimetypes/qmimedatabase/qmimedatabase-xml/qmimedatabase-xml.pro
tests/auto/dbus/qdbusconnection/qdbusconnection.pro
tests/auto/dbus/qdbuspendingcall/tst_qdbuspendingcall.cpp
tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp
Change-Id: I347549a024eb5bfa986699e0a11f96cc55c797a7
Diffstat (limited to 'src/gui/painting')
-rw-r--r-- | src/gui/painting/qdrawhelper.cpp | 6 | ||||
-rw-r--r-- | src/gui/painting/qimagescale.cpp | 5 | ||||
-rw-r--r-- | src/gui/painting/qpaintdevice.h | 2 | ||||
-rw-r--r-- | src/gui/painting/qpaintdevice.qdoc | 8 | ||||
-rw-r--r-- | src/gui/painting/qplatformbackingstore.cpp | 7 | ||||
-rw-r--r-- | src/gui/painting/qrasterizer.cpp | 28 | ||||
-rw-r--r-- | src/gui/painting/qrgba64.h | 65 | ||||
-rw-r--r-- | src/gui/painting/qrgba64.qdoc | 64 |
8 files changed, 125 insertions, 60 deletions
diff --git a/src/gui/painting/qdrawhelper.cpp b/src/gui/painting/qdrawhelper.cpp index 0cf7e20605..64a363868a 100644 --- a/src/gui/painting/qdrawhelper.cpp +++ b/src/gui/painting/qdrawhelper.cpp @@ -6326,8 +6326,6 @@ template<QtPixelOrder> const uint *QT_FASTCALL convertA2RGB30PMFromARGB32PM_sse4 void qInitDrawhelperAsm() { - const uint features = qCpuFeatures(); - Q_UNUSED(features); #ifdef __SSE2__ qDrawHelper[QImage::Format_RGB32].bitmapBlit = qt_bitmapblit32_sse2; qDrawHelper[QImage::Format_ARGB32].bitmapBlit = qt_bitmapblit32_sse2; @@ -6372,7 +6370,7 @@ void qInitDrawhelperAsm() qt_fetch_radial_gradient = qt_fetch_radial_gradient_sse2; #ifdef QT_COMPILER_SUPPORTS_SSSE3 - if (features & SSSE3) { + if (qCpuHasFeature(SSSE3)) { extern void qt_blend_argb32_on_argb32_ssse3(uchar *destPixels, int dbpl, const uchar *srcPixels, int sbpl, int w, int h, @@ -6466,7 +6464,7 @@ void qInitDrawhelperAsm() #endif // Q_PROCESSOR_MIPS_32 #if defined(QT_COMPILER_SUPPORTS_MIPS_DSP) || defined(QT_COMPILER_SUPPORTS_MIPS_DSPR2) - if (features & (DSP | DSPR2)) { + if (qCpuHasFeature(DSP) && qCpuHasFeature(DSPR2)) { // Composition functions are all DSP r1 qt_functionForMode_C[QPainter::CompositionMode_SourceOver] = comp_func_SourceOver_asm_mips_dsp; qt_functionForMode_C[QPainter::CompositionMode_Source] = comp_func_Source_mips_dsp; diff --git a/src/gui/painting/qimagescale.cpp b/src/gui/painting/qimagescale.cpp index 7b6a71737d..33dccc5374 100644 --- a/src/gui/painting/qimagescale.cpp +++ b/src/gui/painting/qimagescale.cpp @@ -305,7 +305,10 @@ static void qt_qimageScaleAARGBA_up_xy(QImageScaleInfo *isi, unsigned int *dest, for (int x = 0; x < dw; x++) { const unsigned int *pix = sptr + xpoints[x]; const int xap = xapoints[x]; - *dptr = INTERPOLATE_PIXEL_256(pix[0], 256 - xap, pix[1], xap); + if (xap > 0) + *dptr = INTERPOLATE_PIXEL_256(pix[0], 256 - xap, pix[1], xap); + else + *dptr = pix[0]; dptr++; } } diff --git a/src/gui/painting/qpaintdevice.h b/src/gui/painting/qpaintdevice.h index c360573e78..72a6ca4cb3 100644 --- a/src/gui/painting/qpaintdevice.h +++ b/src/gui/painting/qpaintdevice.h @@ -81,7 +81,7 @@ public: int colorCount() const { return metric(PdmNumColors); } int depth() const { return metric(PdmDepth); } - static inline qreal devicePixelRatioFScale() {return 10000000.0; } + static inline qreal devicePixelRatioFScale() { return 0x10000; } protected: QPaintDevice() Q_DECL_NOEXCEPT; virtual int metric(PaintDeviceMetric metric) const; diff --git a/src/gui/painting/qpaintdevice.qdoc b/src/gui/painting/qpaintdevice.qdoc index a83acdd21a..ef5deb154d 100644 --- a/src/gui/painting/qpaintdevice.qdoc +++ b/src/gui/painting/qpaintdevice.qdoc @@ -118,7 +118,13 @@ values are 1 for normal-dpi displays and 2 for high-dpi "retina" displays. - \sa metric() + \value PdmDevicePixelRatioScaled The scaled device pixel ratio for the device. + This is identical to PdmDevicePixelRatio, except that the value is scaled by a + constant factor in order to support paint devices with fractional scale factors. + The constant scaling factor used is devicePixelRatioFScale(). This enum value + has been introduced in Qt 5.6. + + \sa metric(), devicePixelRatioF() */ /*! diff --git a/src/gui/painting/qplatformbackingstore.cpp b/src/gui/painting/qplatformbackingstore.cpp index e765a9e402..c86fdebea5 100644 --- a/src/gui/painting/qplatformbackingstore.cpp +++ b/src/gui/painting/qplatformbackingstore.cpp @@ -300,11 +300,7 @@ void QPlatformBackingStore::composeAndFlush(QWindow *window, const QRegion ®i } funcs->glEnable(GL_BLEND); - funcs->glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - // Do not write out alpha. We need blending, but only for RGB. The toplevel may have - // alpha enabled in which case blending (writing out < 1.0 alpha values) would lead to - // semi-transparency even when it is not wanted. - funcs->glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_FALSE); + funcs->glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE); // Backingstore texture with the normal widgets. GLuint textureId = 0; @@ -364,7 +360,6 @@ void QPlatformBackingStore::composeAndFlush(QWindow *window, const QRegion ®i blit(textures, i, window, deviceWindowRect, d_ptr->blitter); } - funcs->glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); funcs->glDisable(GL_BLEND); d_ptr->blitter->release(); diff --git a/src/gui/painting/qrasterizer.cpp b/src/gui/painting/qrasterizer.cpp index 75bf31cde1..34d72bf493 100644 --- a/src/gui/painting/qrasterizer.cpp +++ b/src/gui/painting/qrasterizer.cpp @@ -863,8 +863,8 @@ void QRasterizer::rasterizeLine(const QPointF &a, const QPointF &b, qreal width, const Q16Dot16 iLeft = int(left); const Q16Dot16 iRight = int(right); const Q16Dot16 leftWidth = IntToQ16Dot16(iLeft + 1) - - FloatToQ16Dot16(left); - const Q16Dot16 rightWidth = FloatToQ16Dot16(right) + - qSafeFloatToQ16Dot16(left); + const Q16Dot16 rightWidth = qSafeFloatToQ16Dot16(right) - IntToQ16Dot16(iRight); Q16Dot16 coverage[3]; @@ -898,8 +898,8 @@ void QRasterizer::rasterizeLine(const QPointF &a, const QPointF &b, qreal width, const Q16Dot16 iTopFP = IntToQ16Dot16(int(pa.y())); const Q16Dot16 iBottomFP = IntToQ16Dot16(int(pb.y())); - const Q16Dot16 yPa = FloatToQ16Dot16(pa.y()); - const Q16Dot16 yPb = FloatToQ16Dot16(pb.y()); + const Q16Dot16 yPa = qSafeFloatToQ16Dot16(pa.y()); + const Q16Dot16 yPb = qSafeFloatToQ16Dot16(pb.y()); for (Q16Dot16 yFP = iTopFP; yFP <= iBottomFP; yFP += Q16Dot16Factor) { const Q16Dot16 rowHeight = qMin(yFP + Q16Dot16Factor, yPb) - qMax(yFP, yPa); @@ -983,16 +983,16 @@ void QRasterizer::rasterizeLine(const QPointF &a, const QPointF &b, qreal width, const Q16Dot16 iRightFP = IntToQ16Dot16(int(right.y())); const Q16Dot16 iBottomFP = IntToQ16Dot16(int(bottomBound)); - Q16Dot16 leftIntersectAf = FloatToQ16Dot16(top.x() + (int(topBound) - top.y()) * topLeftSlope); - Q16Dot16 rightIntersectAf = FloatToQ16Dot16(top.x() + (int(topBound) - top.y()) * topRightSlope); + Q16Dot16 leftIntersectAf = qSafeFloatToQ16Dot16(top.x() + (int(topBound) - top.y()) * topLeftSlope); + Q16Dot16 rightIntersectAf = qSafeFloatToQ16Dot16(top.x() + (int(topBound) - top.y()) * topRightSlope); Q16Dot16 leftIntersectBf = 0; Q16Dot16 rightIntersectBf = 0; if (iLeftFP < iTopFP) - leftIntersectBf = FloatToQ16Dot16(left.x() + (int(topBound) - left.y()) * bottomLeftSlope); + leftIntersectBf = qSafeFloatToQ16Dot16(left.x() + (int(topBound) - left.y()) * bottomLeftSlope); if (iRightFP < iTopFP) - rightIntersectBf = FloatToQ16Dot16(right.x() + (int(topBound) - right.y()) * bottomRightSlope); + rightIntersectBf = qSafeFloatToQ16Dot16(right.x() + (int(topBound) - right.y()) * bottomRightSlope); Q16Dot16 rowTop, rowBottomLeft, rowBottomRight, rowTopLeft, rowTopRight, rowBottom; Q16Dot16 topLeftIntersectAf, topLeftIntersectBf, topRightIntersectAf, topRightIntersectBf; @@ -1000,10 +1000,10 @@ void QRasterizer::rasterizeLine(const QPointF &a, const QPointF &b, qreal width, int leftMin, leftMax, rightMin, rightMax; - const Q16Dot16 yTopFP = FloatToQ16Dot16(top.y()); - const Q16Dot16 yLeftFP = FloatToQ16Dot16(left.y()); - const Q16Dot16 yRightFP = FloatToQ16Dot16(right.y()); - const Q16Dot16 yBottomFP = FloatToQ16Dot16(bottom.y()); + const Q16Dot16 yTopFP = qSafeFloatToQ16Dot16(top.y()); + const Q16Dot16 yLeftFP = qSafeFloatToQ16Dot16(left.y()); + const Q16Dot16 yRightFP = qSafeFloatToQ16Dot16(right.y()); + const Q16Dot16 yBottomFP = qSafeFloatToQ16Dot16(bottom.y()); rowTop = qMax(iTopFP, yTopFP); topLeftIntersectAf = leftIntersectAf + @@ -1021,7 +1021,7 @@ void QRasterizer::rasterizeLine(const QPointF &a, const QPointF &b, qreal width, if (yFP == iLeftFP) { const int y = Q16Dot16ToInt(yFP); - leftIntersectBf = FloatToQ16Dot16(left.x() + (y - left.y()) * bottomLeftSlope); + leftIntersectBf = qSafeFloatToQ16Dot16(left.x() + (y - left.y()) * bottomLeftSlope); topLeftIntersectBf = leftIntersectBf + Q16Dot16Multiply(bottomLeftSlopeFP, rowTopLeft - yFP); bottomLeftIntersectAf = leftIntersectAf + Q16Dot16Multiply(topLeftSlopeFP, rowBottomLeft - yFP); } else { @@ -1031,7 +1031,7 @@ void QRasterizer::rasterizeLine(const QPointF &a, const QPointF &b, qreal width, if (yFP == iRightFP) { const int y = Q16Dot16ToInt(yFP); - rightIntersectBf = FloatToQ16Dot16(right.x() + (y - right.y()) * bottomRightSlope); + rightIntersectBf = qSafeFloatToQ16Dot16(right.x() + (y - right.y()) * bottomRightSlope); topRightIntersectBf = rightIntersectBf + Q16Dot16Multiply(bottomRightSlopeFP, rowTopRight - yFP); bottomRightIntersectAf = rightIntersectAf + Q16Dot16Multiply(topRightSlopeFP, rowBottomRight - yFP); } else { diff --git a/src/gui/painting/qrgba64.h b/src/gui/painting/qrgba64.h index b701b224be..264ec394cd 100644 --- a/src/gui/painting/qrgba64.h +++ b/src/gui/painting/qrgba64.h @@ -58,33 +58,34 @@ class QRgba64 { #endif }; + // No constructors are allowed in C++98, since this needs to be usable in a union. + // We however require one for constexprs in C++11/C++14 +#ifdef Q_COMPILER_CONSTEXPR + explicit Q_ALWAYS_INLINE Q_DECL_CONSTEXPR QRgba64(quint64 c) : rgba(c) { } +#endif public: - // No constructors are allowed, since this needs to be usable in a union in no-c++11 mode. - // When c++11 is mandatory, we can add all but a copy constructor. - Q_DECL_RELAXED_CONSTEXPR static - QRgba64 fromRgba64(quint16 red, quint16 green, quint16 blue, quint16 alpha) - { - QRgba64 rgba64 -#ifdef Q_COMPILER_UNIFORM_INIT - = {} +#ifdef Q_COMPILER_CONSTEXPR + Q_ALWAYS_INLINE Q_DECL_CONSTEXPR QRgba64() : rgba(0) { } #endif - ; - rgba64.rgba = quint64(red) << RedShift - | quint64(green) << GreenShift - | quint64(blue) << BlueShift - | quint64(alpha) << AlphaShift; - return rgba64; - } - Q_DECL_RELAXED_CONSTEXPR static + + Q_DECL_CONSTEXPR static QRgba64 fromRgba64(quint64 c) { - QRgba64 rgba64 -#ifdef Q_COMPILER_UNIFORM_INIT - = {} -#endif - ; +#ifdef Q_COMPILER_CONSTEXPR + return QRgba64(c); +#else + QRgba64 rgba64; rgba64.rgba = c; return rgba64; +#endif + } + Q_DECL_CONSTEXPR static + QRgba64 fromRgba64(quint16 red, quint16 green, quint16 blue, quint16 alpha) + { + return fromRgba64(quint64(red) << RedShift + | quint64(green) << GreenShift + | quint64(blue) << BlueShift + | quint64(alpha) << AlphaShift); } Q_DECL_RELAXED_CONSTEXPR static QRgba64 fromRgba(quint8 red, quint8 green, quint8 blue, quint8 alpha) { @@ -112,10 +113,10 @@ public: Q_DECL_CONSTEXPR quint16 green() const { return rgba >> GreenShift; } Q_DECL_CONSTEXPR quint16 blue() const { return rgba >> BlueShift; } Q_DECL_CONSTEXPR quint16 alpha() const { return rgba >> AlphaShift; } - void setRed(quint16 _red) { *this = fromRgba64(_red, green(), blue(), alpha()); } - void setGreen(quint16 _green) { *this = fromRgba64(red(), _green, blue(), alpha()); } - void setBlue(quint16 _blue) { *this = fromRgba64(red(), green(), _blue, alpha()); } - void setAlpha(quint16 _alpha) { *this = fromRgba64(red(), green(), blue(), _alpha); } + void setRed(quint16 _red) { rgba = (rgba & ~(Q_UINT64_C(0xffff) << RedShift)) | (quint64(_red) << RedShift); } + void setGreen(quint16 _green) { rgba = (rgba & ~(Q_UINT64_C(0xffff) << GreenShift)) | (quint64(_green) << GreenShift); } + void setBlue(quint16 _blue) { rgba = (rgba & ~(Q_UINT64_C(0xffff) << BlueShift)) | (quint64(_blue) << BlueShift); } + void setAlpha(quint16 _alpha) { rgba = (rgba & ~(Q_UINT64_C(0xffff) << AlphaShift)) | (quint64(_alpha) << AlphaShift); } Q_DECL_CONSTEXPR quint8 red8() const { return div_257(red()); } Q_DECL_CONSTEXPR quint8 green8() const { return div_257(green()); } @@ -160,16 +161,16 @@ public: } private: - static Q_DECL_CONSTEXPR quint64 alphaMask() { return quint64(0xffff) << AlphaShift; } + static Q_DECL_CONSTEXPR quint64 alphaMask() { return Q_UINT64_C(0xffff) << AlphaShift; } static Q_DECL_CONSTEXPR uint div_257_floor(uint x) { return (x - (x >> 8)) >> 8; } static Q_DECL_CONSTEXPR uint div_257(uint x) { return div_257_floor(x + 128); } static Q_DECL_CONSTEXPR uint div_65535(uint x) { return (x + (x>>16) + 0x8000U) >> 16; } Q_DECL_RELAXED_CONSTEXPR QRgba64 unpremultiplied_32bit() const { - const quint16 a = alpha(); - if (a == 0xffff || a == 0) + if (isOpaque() || isTransparent()) return *this; + const quint32 a = alpha(); const quint16 r = (quint32(red()) * 0xffff + a/2) / a; const quint16 g = (quint32(green()) * 0xffff + a/2) / a; const quint16 b = (quint32(blue()) * 0xffff + a/2) / a; @@ -177,9 +178,9 @@ private: } Q_DECL_RELAXED_CONSTEXPR QRgba64 unpremultiplied_64bit() const { - const quint16 a = alpha(); - if (a == 0xffff || a == 0) + if (isOpaque() || isTransparent()) return *this; + const quint64 a = alpha(); const quint64 fa = (Q_UINT64_C(0xffff00008000) + a/2) / a; const quint16 r = (red() * fa + 0x80000000) >> 32; const quint16 g = (green() * fa + 0x80000000) >> 32; @@ -190,12 +191,12 @@ private: Q_DECLARE_TYPEINFO(QRgba64, Q_PRIMITIVE_TYPE); -Q_DECL_RELAXED_CONSTEXPR inline QRgba64 qRgba64(quint16 r, quint16 g, quint16 b, quint16 a) +Q_DECL_CONSTEXPR inline QRgba64 qRgba64(quint16 r, quint16 g, quint16 b, quint16 a) { return QRgba64::fromRgba64(r, g, b, a); } -Q_DECL_RELAXED_CONSTEXPR inline QRgba64 qRgba64(quint64 c) +Q_DECL_CONSTEXPR inline QRgba64 qRgba64(quint64 c) { return QRgba64::fromRgba64(c); } diff --git a/src/gui/painting/qrgba64.qdoc b/src/gui/painting/qrgba64.qdoc index 29da0aa390..b786e91b03 100644 --- a/src/gui/painting/qrgba64.qdoc +++ b/src/gui/painting/qrgba64.qdoc @@ -36,13 +36,19 @@ QRgba64 is a 64-bit data-structure containing four 16-bit color channels: Red, green, blue and alpha. QRgba64 can be used a replacement for QRgb when higher precision is needed. In particular a - premultiplied QRgba64 can operate on unpremultipled QRgb without loss of precision except + premultiplied QRgba64 can operate on unpremultiplied QRgb without loss of precision except for alpha 0. \sa QRgb, QColor */ /*! + \fn QRgba64 QRgba64::operator=(quint64 rgba) + + Assigns the value \a rgba to this instance of QRgba64 and returns it. +*/ + +/*! \fn static QRgba64 QRgba64::fromRgba64(quint16 r, quint16 g, quint16 b, quint16 a) Returns the QRgba64 quadruplet (\a{r}, \a{g}, \a{b}, \a{a}). @@ -75,27 +81,83 @@ */ /*! + \fn bool QRgba64::isOpaque() const + + Returns whether the color is fully opaque. + + \sa isTransparent(), alpha() +*/ + +/*! + \fn bool QRgba64::isTransparent() const + + Returns whether the color is transparent. + + \sa isOpaque(), alpha() +*/ + +/*! \fn quint16 QRgba64::red() const Returns the 16-bit red color component. + + \sa setRed() +*/ + +/*! + \fn QRgba64::setRed(quint16 red) + + Sets the red color component of this color to \a red. + + \sa red() */ /*! \fn quint16 QRgba64::green() const Returns the 16-bit green color component. + + \sa setGreen() +*/ + +/*! + \fn QRgba64::setGreen(quint16 green) + + Sets the green color component of this color to \a green. + + \sa green() */ /*! \fn quint16 QRgba64::blue() const Returns the 16-bit blue color component. + + \sa setBlue() +*/ + +/*! + \fn QRgba64::setBlue(quint16 blue) + + Sets the blue color component of this color to \a blue. + + \sa blue() */ /*! \fn quint16 QRgba64::alpha() const Returns the 16-bit alpha channel. + + \sa setAlpha() +*/ + +/*! + \fn QRgba64::setAlpha(quint16 alpha) + + Sets the alpha of this color to \a alpha. + + \sa alpha() */ /*! |