diff options
Diffstat (limited to 'src/gui/painting')
-rw-r--r-- | src/gui/painting/qcolor.h | 10 | ||||
-rw-r--r-- | src/gui/painting/qcolor_p.cpp | 10 | ||||
-rw-r--r-- | src/gui/painting/qdrawhelper.cpp | 16 | ||||
-rw-r--r-- | src/gui/painting/qmatrix.h | 2 | ||||
-rw-r--r-- | src/gui/painting/qpaintengine.h | 2 | ||||
-rw-r--r-- | src/gui/painting/qpaintengine_raster_p.h | 2 | ||||
-rw-r--r-- | src/gui/painting/qpainter.cpp | 2 | ||||
-rw-r--r-- | src/gui/painting/qpainterpath.cpp | 3 | ||||
-rw-r--r-- | src/gui/painting/qpen.cpp | 18 | ||||
-rw-r--r-- | src/gui/painting/qpen.h | 2 | ||||
-rw-r--r-- | src/gui/painting/qpolygon.h | 10 | ||||
-rw-r--r-- | src/gui/painting/qregion.h | 28 | ||||
-rw-r--r-- | src/gui/painting/qtextureglyphcache.cpp | 20 | ||||
-rw-r--r-- | src/gui/painting/qtransform.h | 6 |
14 files changed, 72 insertions, 59 deletions
diff --git a/src/gui/painting/qcolor.h b/src/gui/painting/qcolor.h index 1ede5a3682..e5de2678a4 100644 --- a/src/gui/painting/qcolor.h +++ b/src/gui/painting/qcolor.h @@ -173,7 +173,7 @@ public: QColor toCmyk() const; QColor toHsl() const; - QColor convertTo(Spec colorSpec) const; + QColor convertTo(Spec colorSpec) const Q_REQUIRED_RESULT; static QColor fromRgb(QRgb rgb); static QColor fromRgba(QRgb rgba); @@ -190,10 +190,10 @@ public: static QColor fromHsl(int h, int s, int l, int a = 255); static QColor fromHslF(qreal h, qreal s, qreal l, qreal a = 1.0); - QColor light(int f = 150) const; - QColor lighter(int f = 150) const; - QColor dark(int f = 200) const; - QColor darker(int f = 200) const; + QColor light(int f = 150) const Q_REQUIRED_RESULT; + QColor lighter(int f = 150) const Q_REQUIRED_RESULT; + QColor dark(int f = 200) const Q_REQUIRED_RESULT; + QColor darker(int f = 200) const Q_REQUIRED_RESULT; QColor &operator=(const QColor &); QColor &operator=(Qt::GlobalColor color); diff --git a/src/gui/painting/qcolor_p.cpp b/src/gui/painting/qcolor_p.cpp index 72b6279b2f..adc81582e2 100644 --- a/src/gui/painting/qcolor_p.cpp +++ b/src/gui/painting/qcolor_p.cpp @@ -301,9 +301,8 @@ inline bool operator<(const RGBData &data, const char *name) static bool get_named_rgb(const char *name_no_space, QRgb *rgb) { - QByteArray name = QByteArray(name_no_space).toLower(); - const RGBData *r = std::lower_bound(rgbTbl, rgbTbl + rgbTblSize, name.constData()); - if ((r != rgbTbl + rgbTblSize) && !(name.constData() < *r)) { + const RGBData *r = std::lower_bound(rgbTbl, rgbTbl + rgbTblSize, name_no_space); + if ((r != rgbTbl + rgbTblSize) && !(name_no_space < *r)) { *rgb = r->value; return true; } @@ -319,7 +318,7 @@ bool qt_get_named_rgb(const char *name, QRgb* rgb) int pos = 0; for(int i = 0; i < len; i++) { if(name[i] != '\t' && name[i] != ' ') - name_no_space[pos++] = name[i]; + name_no_space[pos++] = QChar::toLower(name[i]); } name_no_space[pos] = 0; @@ -334,7 +333,7 @@ bool qt_get_named_rgb(const QChar *name, int len, QRgb *rgb) int pos = 0; for(int i = 0; i < len; i++) { if(name[i] != QLatin1Char('\t') && name[i] != QLatin1Char(' ')) - name_no_space[pos++] = name[i].toLatin1(); + name_no_space[pos++] = name[i].toLower().toLatin1(); } name_no_space[pos] = 0; return get_named_rgb(name_no_space, rgb); @@ -352,6 +351,7 @@ QStringList qt_get_colornames() { int i = 0; QStringList lst; + lst.reserve(rgbTblSize); for (i = 0; i < rgbTblSize; i++) lst << QLatin1String(rgbTbl[i].name); return lst; diff --git a/src/gui/painting/qdrawhelper.cpp b/src/gui/painting/qdrawhelper.cpp index 9293fc32dc..44b38dcf1c 100644 --- a/src/gui/painting/qdrawhelper.cpp +++ b/src/gui/painting/qdrawhelper.cpp @@ -6588,10 +6588,13 @@ void qt_memfill16(quint16 *dest, quint16 color, int count) } #endif #if !defined(__SSE2__) && !defined(__ARM_NEON__) +# ifdef QT_COMPILER_SUPPORTS_MIPS_DSP +extern "C" void qt_memfill32_asm_mips_dsp(quint32 *, quint32, int); +# endif + void qt_memfill32(quint32 *dest, quint32 color, int count) { # ifdef QT_COMPILER_SUPPORTS_MIPS_DSP - extern "C" qt_memfill32_asm_mips_dsp(quint32 *, quint32, int); qt_memfill32_asm_mips_dsp(dest, color, count); # else qt_memfill_template<quint32>(dest, color, count); @@ -6713,7 +6716,13 @@ void qInitDrawhelperAsm() qt_fetch_radial_gradient = qt_fetch_radial_gradient_neon; #endif -#if defined(QT_COMPILER_SUPPORTS_MIPS_DSP) +#ifdef Q_PROCESSOR_MIPS_32 + qt_memfill32 = qt_memfill32_asm_mips_dsp; +#endif // Q_PROCESSOR_MIPS_32 + +#if defined(QT_COMPILER_SUPPORTS_MIPS_DSP) || defined(QT_COMPILER_SUPPORTS_MIPS_DSPR2) + if (features & (DSP | DSPR2)) { + // Composition functions are all DSP r1 functionForMode_C[QPainter::CompositionMode_SourceOver] = comp_func_SourceOver_asm_mips_dsp; functionForMode_C[QPainter::CompositionMode_Source] = comp_func_Source_mips_dsp; functionForMode_C[QPainter::CompositionMode_DestinationOver] = comp_func_DestinationOver_mips_dsp; @@ -6757,8 +6766,9 @@ void qInitDrawhelperAsm() #else qBlendFunctions[QImage::Format_RGB16][QImage::Format_RGB16] = qt_blend_rgb16_on_rgb16_mips_dsp; #endif // QT_COMPILER_SUPPORTS_MIPS_DSPR2 + } +#endif // QT_COMPILER_SUPPORTS_MIPS_DSP || QT_COMPILER_SUPPORTS_MIPS_DSPR2 -#endif // QT_COMPILER_SUPPORTS_MIPS_DSP if (functionForModeSolidAsm) { const int destinationMode = QPainter::CompositionMode_Destination; functionForModeSolidAsm[destinationMode] = functionForModeSolid_C[destinationMode]; diff --git a/src/gui/painting/qmatrix.h b/src/gui/painting/qmatrix.h index d2c1ae3a3c..93062899d3 100644 --- a/src/gui/painting/qmatrix.h +++ b/src/gui/painting/qmatrix.h @@ -100,7 +100,7 @@ public: bool isInvertible() const { return !qFuzzyIsNull(_m11*_m22 - _m12*_m21); } qreal determinant() const { return _m11*_m22 - _m12*_m21; } - QMatrix inverted(bool *invertible = 0) const; + QMatrix inverted(bool *invertible = 0) const Q_REQUIRED_RESULT; bool operator==(const QMatrix &) const; bool operator!=(const QMatrix &) const; diff --git a/src/gui/painting/qpaintengine.h b/src/gui/painting/qpaintengine.h index 7b928ba5f6..2a17a13517 100644 --- a/src/gui/painting/qpaintengine.h +++ b/src/gui/painting/qpaintengine.h @@ -250,7 +250,7 @@ private: friend class QFontEngineWin; friend class QMacPrintEngine; friend class QMacPrintEnginePrivate; - friend class QFontEngineQPA; + friend class QFontEngineQPF2; friend class QPainter; friend class QPainterPrivate; friend class QWidget; diff --git a/src/gui/painting/qpaintengine_raster_p.h b/src/gui/painting/qpaintengine_raster_p.h index 4bfdbd91e0..c4703b3712 100644 --- a/src/gui/painting/qpaintengine_raster_p.h +++ b/src/gui/painting/qpaintengine_raster_p.h @@ -250,7 +250,7 @@ private: QRect toNormalizedFillRect(const QRectF &rect); inline void ensureBrush(const QBrush &brush) { - if (!qbrush_fast_equals(state()->lastBrush, brush) || (brush.style() != Qt::NoBrush && state()->fillFlags)) + if (!qbrush_fast_equals(state()->lastBrush, brush) || state()->fillFlags) updateBrush(brush); } inline void ensureBrush() { ensureBrush(state()->brush); } diff --git a/src/gui/painting/qpainter.cpp b/src/gui/painting/qpainter.cpp index 3f387d575b..7c691c9670 100644 --- a/src/gui/painting/qpainter.cpp +++ b/src/gui/painting/qpainter.cpp @@ -6422,6 +6422,7 @@ void QPainterPrivate::drawTextItem(const QPointF &p, const QTextItem &_ti, QText continue; + multi->ensureEngineAt(which); QTextItemInt ti2 = ti.midItem(multi->engine(which), start, end - start); ti2.width = 0; // set the high byte to zero and calc the width @@ -6449,6 +6450,7 @@ void QPainterPrivate::drawTextItem(const QPointF &p, const QTextItem &_ti, QText which = e; } + multi->ensureEngineAt(which); QTextItemInt ti2 = ti.midItem(multi->engine(which), start, end - start); ti2.width = 0; // set the high byte to zero and calc the width diff --git a/src/gui/painting/qpainterpath.cpp b/src/gui/painting/qpainterpath.cpp index aa2b9bea54..7a29bb87b4 100644 --- a/src/gui/painting/qpainterpath.cpp +++ b/src/gui/painting/qpainterpath.cpp @@ -1644,7 +1644,8 @@ QList<QPolygonF> QPainterPath::toFillPolygons(const QTransform &matrix) const if (count == 0) return polys; - QList<QRectF> bounds; + QVector<QRectF> bounds; + bounds.reserve(count); for (int i=0; i<count; ++i) bounds += subpaths.at(i).boundingRect(); diff --git a/src/gui/painting/qpen.cpp b/src/gui/painting/qpen.cpp index c0b3769c2d..b661057f64 100644 --- a/src/gui/painting/qpen.cpp +++ b/src/gui/painting/qpen.cpp @@ -327,17 +327,29 @@ QPen::QPen(const QBrush &brush, qreal width, Qt::PenStyle s, Qt::PenCapStyle c, QPen::QPen(const QPen &p) { d = p.d; - d->ref.ref(); + if (d) + d->ref.ref(); } /*! + \fn QPen::QPen(QPen &&pen) + \since 5.4 + + Constructs a pen that is moved from the given \a pen. + + The moved-from pen can only be assigned to, copied, or + destroyed. Any other operation (prior to assignment) leads to + undefined behavior. +*/ + +/*! Destroys the pen. */ QPen::~QPen() { - if (!d->ref.deref()) + if (d && !d->ref.deref()) delete d; } @@ -373,7 +385,7 @@ void QPen::detach() QPen &QPen::operator=(const QPen &p) { - qAtomicAssign(d, p.d); + QPen(p).swap(*this); return *this; } diff --git a/src/gui/painting/qpen.h b/src/gui/painting/qpen.h index c5144f784f..486f699476 100644 --- a/src/gui/painting/qpen.h +++ b/src/gui/painting/qpen.h @@ -72,6 +72,8 @@ public: QPen &operator=(const QPen &pen); #ifdef Q_COMPILER_RVALUE_REFS + inline QPen(QPen &&other) + : d(other.d) { other.d = 0; } inline QPen &operator=(QPen &&other) { qSwap(d, other.d); return *this; } #endif diff --git a/src/gui/painting/qpolygon.h b/src/gui/painting/qpolygon.h index 1039e842ab..b696fe279a 100644 --- a/src/gui/painting/qpolygon.h +++ b/src/gui/painting/qpolygon.h @@ -71,8 +71,8 @@ public: void translate(int dx, int dy); void translate(const QPoint &offset); - QPolygon translated(int dx, int dy) const; - inline QPolygon translated(const QPoint &offset) const; + QPolygon translated(int dx, int dy) const Q_REQUIRED_RESULT; + inline QPolygon translated(const QPoint &offset) const Q_REQUIRED_RESULT; QRect boundingRect() const; @@ -88,9 +88,9 @@ public: bool containsPoint(const QPoint &pt, Qt::FillRule fillRule) const; - QPolygon united(const QPolygon &r) const; - QPolygon intersected(const QPolygon &r) const; - QPolygon subtracted(const QPolygon &r) const; + QPolygon united(const QPolygon &r) const Q_REQUIRED_RESULT; + QPolygon intersected(const QPolygon &r) const Q_REQUIRED_RESULT; + QPolygon subtracted(const QPolygon &r) const Q_REQUIRED_RESULT; }; inline QPolygon::QPolygon(int asize) : QVector<QPoint>(asize) {} diff --git a/src/gui/painting/qregion.h b/src/gui/painting/qregion.h index 0e436e3fb4..323a1858fa 100644 --- a/src/gui/painting/qregion.h +++ b/src/gui/painting/qregion.h @@ -86,23 +86,23 @@ public: void translate(int dx, int dy); inline void translate(const QPoint &p) { translate(p.x(), p.y()); } - QRegion translated(int dx, int dy) const; - inline QRegion translated(const QPoint &p) const { return translated(p.x(), p.y()); } + QRegion translated(int dx, int dy) const Q_REQUIRED_RESULT; + inline QRegion translated(const QPoint &p) const Q_REQUIRED_RESULT { return translated(p.x(), p.y()); } - QRegion united(const QRegion &r) const; - QRegion united(const QRect &r) const; - QRegion intersected(const QRegion &r) const; - QRegion intersected(const QRect &r) const; - QRegion subtracted(const QRegion &r) const; - QRegion xored(const QRegion &r) const; + QRegion united(const QRegion &r) const Q_REQUIRED_RESULT; + QRegion united(const QRect &r) const Q_REQUIRED_RESULT; + QRegion intersected(const QRegion &r) const Q_REQUIRED_RESULT; + QRegion intersected(const QRect &r) const Q_REQUIRED_RESULT; + QRegion subtracted(const QRegion &r) const Q_REQUIRED_RESULT; + QRegion xored(const QRegion &r) const Q_REQUIRED_RESULT; #if QT_DEPRECATED_SINCE(5, 0) - inline QT_DEPRECATED QRegion unite(const QRegion &r) const { return united(r); } - inline QT_DEPRECATED QRegion unite(const QRect &r) const { return united(r); } - inline QT_DEPRECATED QRegion intersect(const QRegion &r) const { return intersected(r); } - inline QT_DEPRECATED QRegion intersect(const QRect &r) const { return intersected(r); } - inline QT_DEPRECATED QRegion subtract(const QRegion &r) const { return subtracted(r); } - inline QT_DEPRECATED QRegion eor(const QRegion &r) const { return xored(r); } + inline QT_DEPRECATED QRegion unite(const QRegion &r) const Q_REQUIRED_RESULT { return united(r); } + inline QT_DEPRECATED QRegion unite(const QRect &r) const Q_REQUIRED_RESULT { return united(r); } + inline QT_DEPRECATED QRegion intersect(const QRegion &r) const Q_REQUIRED_RESULT { return intersected(r); } + inline QT_DEPRECATED QRegion intersect(const QRect &r) const Q_REQUIRED_RESULT { return intersected(r); } + inline QT_DEPRECATED QRegion subtract(const QRegion &r) const Q_REQUIRED_RESULT { return subtracted(r); } + inline QT_DEPRECATED QRegion eor(const QRegion &r) const Q_REQUIRED_RESULT { return xored(r); } #endif bool intersects(const QRegion &r) const; diff --git a/src/gui/painting/qtextureglyphcache.cpp b/src/gui/painting/qtextureglyphcache.cpp index 83edeb41a6..fb8c23835d 100644 --- a/src/gui/painting/qtextureglyphcache.cpp +++ b/src/gui/painting/qtextureglyphcache.cpp @@ -50,20 +50,6 @@ QT_BEGIN_NAMESPACE // #define CACHE_DEBUG -// returns the highest number closest to v, which is a power of 2 -// NB! assumes 32 bit ints -static inline int qt_next_power_of_two(int v) -{ - v--; - v |= v >> 1; - v |= v >> 2; - v |= v >> 4; - v |= v >> 8; - v |= v >> 16; - ++v; - return v; -} - int QTextureGlyphCache::calculateSubPixelPositionCount(glyph_t glyph) const { // Test 12 different subpixel positions since it factors into 3*4 so it gives @@ -199,7 +185,7 @@ bool QTextureGlyphCache::populate(QFontEngine *fontEngine, int numGlyphs, const if (fontEngine->maxCharWidth() <= QT_DEFAULT_TEXTURE_GLYPH_CACHE_WIDTH) m_w = QT_DEFAULT_TEXTURE_GLYPH_CACHE_WIDTH; else - m_w = qt_next_power_of_two(fontEngine->maxCharWidth()); + m_w = qNextPowerOfTwo(qCeil(fontEngine->maxCharWidth()) - 1); } // now actually use the coords and paint the wanted glyps into cache. @@ -261,9 +247,9 @@ void QTextureGlyphCache::fillInPendingGlyphs() if (isNull() || requiredHeight > m_h || requiredWidth > m_w) { if (isNull()) - createCache(qt_next_power_of_two(requiredWidth), qt_next_power_of_two(requiredHeight)); + createCache(qNextPowerOfTwo(requiredWidth - 1), qNextPowerOfTwo(requiredHeight - 1)); else - resizeCache(qt_next_power_of_two(requiredWidth), qt_next_power_of_two(requiredHeight)); + resizeCache(qNextPowerOfTwo(requiredWidth - 1), qNextPowerOfTwo(requiredHeight - 1)); } { diff --git a/src/gui/painting/qtransform.h b/src/gui/painting/qtransform.h index 060362f63e..e6acbe0490 100644 --- a/src/gui/painting/qtransform.h +++ b/src/gui/painting/qtransform.h @@ -104,9 +104,9 @@ public: qreal m21, qreal m22, qreal m23, qreal m31, qreal m32, qreal m33); - QTransform inverted(bool *invertible = 0) const; - QTransform adjoint() const; - QTransform transposed() const; + QTransform inverted(bool *invertible = 0) const Q_REQUIRED_RESULT; + QTransform adjoint() const Q_REQUIRED_RESULT; + QTransform transposed() const Q_REQUIRED_RESULT; QTransform &translate(qreal dx, qreal dy); QTransform &scale(qreal sx, qreal sy); |