diff options
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/accessible/qaccessible.cpp | 9 | ||||
-rw-r--r-- | src/gui/image/qimage_conversions.cpp | 6 | ||||
-rw-r--r-- | src/gui/image/qimage_mips_dspr2.cpp | 20 | ||||
-rw-r--r-- | src/gui/image/qimage_mips_dspr2_asm.S | 92 | ||||
-rw-r--r-- | src/gui/image/qimagereader.cpp | 27 | ||||
-rw-r--r-- | src/gui/image/qimagewriter.cpp | 31 | ||||
-rw-r--r-- | src/gui/image/qjpeghandler.cpp | 4 | ||||
-rw-r--r-- | src/gui/image/qpicture.cpp | 2 | ||||
-rw-r--r-- | src/gui/opengl/opengl.pri | 1 | ||||
-rw-r--r-- | src/gui/opengl/qopenglextensions_p.h | 2 | ||||
-rw-r--r-- | src/gui/painting/qcolor_p.cpp | 10 | ||||
-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/text/qfont.cpp | 35 | ||||
-rw-r--r-- | src/gui/text/qfont_p.h | 2 | ||||
-rw-r--r-- | src/gui/util/qgridlayoutengine.cpp | 26 | ||||
-rw-r--r-- | src/gui/util/qgridlayoutengine_p.h | 12 |
19 files changed, 235 insertions, 69 deletions
diff --git a/src/gui/accessible/qaccessible.cpp b/src/gui/accessible/qaccessible.cpp index 776320a517..f7a4a53716 100644 --- a/src/gui/accessible/qaccessible.cpp +++ b/src/gui/accessible/qaccessible.cpp @@ -97,6 +97,15 @@ QT_BEGIN_NAMESPACE Accessibility, and the Unix/X11 AT-SPI standard. Other backends can be supported using QAccessibleBridge. + In the Unix/X11 AT-SPI implementation, applications become accessible + when two conditions are met: + \list + \li org.a11y.Status.IsEnabled DBus property is true + \li org.a11y.Status.ScreenReaderEnabled DBus property is true + \endlist + An alternative to setting the DBus AT-SPI properties is to set + the QT_LINUX_ACCESSIBILITY_ALWAYS_ON environment variable. + In addition to QAccessible's static functions, Qt offers one generic interface, QAccessibleInterface, that can be used to wrap all widgets and objects (e.g., QPushButton). This single diff --git a/src/gui/image/qimage_conversions.cpp b/src/gui/image/qimage_conversions.cpp index 629a7c9b69..cf61d2d84b 100644 --- a/src/gui/image/qimage_conversions.cpp +++ b/src/gui/image/qimage_conversions.cpp @@ -2176,7 +2176,11 @@ void qInitImageConversions() #ifdef QT_COMPILER_SUPPORTS_MIPS_DSPR2 extern bool convert_ARGB_to_ARGB_PM_inplace_mips_dspr2(QImageData *data, Qt::ImageConversionFlags); inplace_converter_map[QImage::Format_ARGB32][QImage::Format_ARGB32_Premultiplied] = convert_ARGB_to_ARGB_PM_inplace_mips_dspr2; - return; + + extern void convert_RGB888_to_RGB32_mips_dspr2(QImageData *dest, const QImageData *src, Qt::ImageConversionFlags); + qimage_converter_map[QImage::Format::RGB888][QImage::Format_RGB32] = convert_RGB888_to_RGB32_mips_dspr2; + qimage_converter_map[QImage::Format::RGB888][QImage::Format_ARGB32] = convert_RGB888_to_RGB32_mips_dspr2; + qimage_converter_map[QImage::Format::RGB888][QImage::Format_ARGB32_Premultiplied] = convert_RGB888_to_RGB32_mips_dspr2; #endif } diff --git a/src/gui/image/qimage_mips_dspr2.cpp b/src/gui/image/qimage_mips_dspr2.cpp index a1c40a16df..f61a2262d2 100644 --- a/src/gui/image/qimage_mips_dspr2.cpp +++ b/src/gui/image/qimage_mips_dspr2.cpp @@ -66,4 +66,24 @@ bool convert_ARGB_to_ARGB_PM_inplace_mips_dspr2(QImageData *data, Qt::ImageConve return true; } +extern "C" void qt_convert_rgb888_to_rgb32_mips_dspr2_asm(uint *dst, const uchar *src, int len); + +void convert_RGB888_to_RGB32_mips_dspr2(QImageData *dest, const QImageData *src, Qt::ImageConversionFlags) +{ + Q_ASSERT(src->format == QImage::Format_RGB888); + Q_ASSERT(dest->format == QImage::Format_RGB32 || dest->format == QImage::Format_ARGB32 || dest->format == QImage::Format_ARGB32_Premultiplied); + Q_ASSERT(src->width == dest->width); + Q_ASSERT(src->height == dest->height); + + const uchar *src_data = (const uchar*) src->data; + quint32 *dest_data = (quint32*) dest->data; + + for (int i = 0; i < src->height; ++i) { + qt_convert_rgb888_to_rgb32_mips_dspr2_asm(dest_data, src_data, src->width); + src_data += src->bytes_per_line; + dest_data = (quint32*) ((uchar*) dest_data + dest->bytes_per_line); + } +} + QT_END_NAMESPACE + diff --git a/src/gui/image/qimage_mips_dspr2_asm.S b/src/gui/image/qimage_mips_dspr2_asm.S index 1f03b72dd4..df626586dc 100644 --- a/src/gui/image/qimage_mips_dspr2_asm.S +++ b/src/gui/image/qimage_mips_dspr2_asm.S @@ -205,3 +205,95 @@ LEAF_MIPS_DSPR2(premultiply_argb_inplace_mips_asm) END(premultiply_argb_inplace_mips_asm) + +LEAF_MIPS_DSPR2(qt_convert_rgb888_to_rgb32_mips_dspr2_asm) +/* + * Parameters: + * a0 - dst *a8r8g8b8 + * a1 - src *r8g8b8 + * a2 - len + * + * R G B r g b R G B r g b R G B r g b . . . -- input + * ------- ------- ------- ------- ------- + * _ R G B _ r g b _ R G B _ r g b _ R G . . -- output + * + * Register usage: + * a2 - tail (len % 4) == (len & 0x3) + * t0 - batches (len / 4) == (len >> 2) + * t1-t7, s1-s3 - temporary + */ + + srl t0, a2, 2 /* batches = len / 4 */ + andi a2, a2, 0x3 /* tail = len % 4 */ + + beqz t0, 5f /* if !batches: tail */ + lui t7, 0xff00 /* [FF 00 00 00] */ + SAVE_REGS_ON_STACK 8, s1, s2, s3, s0, v0, v1 + +1: pref 4, 0 (a1) /* hint: read-streamed */ + pref 5, 0 (a0) /* hint: prepare-write */ + addiu t0, t0, -1 /* batches-- */ + + lbu t1, 0 (a1) /* [__ __ __ R1] */ + lbu t2, 1 (a1) /* [__ __ __ G1] */ + lbu t3, 2 (a1) /* [__ __ __ B1] */ + + lbu t4, 3 (a1) /* [__ __ __ r2] */ + lbu t5, 4 (a1) /* [__ __ __ g2] */ + lbu t6, 5 (a1) /* [__ __ __ b2] */ + + lbu s1, 6 (a1) /* [__ __ __ R3] */ + lbu s2, 7 (a1) /* [__ __ __ G3] */ + lbu s3, 8 (a1) /* [__ __ __ B3] */ + + lbu s0, 9 (a1) /* [__ __ __ r4] */ + lbu v0, 10 (a1) /* [__ __ __ g4] */ + lbu v1, 11 (a1) /* [__ __ __ b4] */ + + append t1, t2, 8 /* [__ __ R1 G1] */ + append t4, t5, 8 /* [__ __ r2 g2] */ + append s1, s2, 8 /* [__ __ R3 G3] */ + append s0, v0, 8 /* [__ __ r4 g4] */ + append t1, t3, 8 /* [__ R1 G1 B1] */ + append t4, t6, 8 /* [__ r2 g2 b2] */ + append s1, s3, 8 /* [__ R3 G4 B3] */ + append s0, v1, 8 /* [__ r4 g4 b4] */ + or t1, t1, t7 /* [FF R1 G1 B1] */ + or t4, t4, t7 /* [FF r2 g2 b2] */ + or s1, s1, t7 /* [FF R3 G3 B3] */ + or s0, s0, t7 /* [FF r4 g4 b4] */ + + sw t1, 0 (a0) + sw t4, 4 (a0) + sw s1, 8 (a0) + sw s0, 12 (a0) + + addiu a1, a1, 12 /* src += 4*3 */ + bnez t0, 1b /* if batches: loop */ + addiu a0, a0, 16 /* dst += 4 */ + + RESTORE_REGS_FROM_STACK 8, s1, s2, s3, s0, v0, v1 + + /* handle remaining "tail" (a2) items */ +5: beqz a2, 0f + lui t0, 0xff00 /* [FF __ __ __] */ + +1: lbu t1, 0 (a1) /* [__ __ __ RR] */ + lbu t2, 1 (a1) /* [__ __ __ GG] */ + lbu t3, 2 (a1) /* [__ __ __ BB] */ + sll t1, t1, 16 /* [__ RR __ __] */ + sll t2, t2, 8 /* [__ __ GG __] */ + or t0, t0, t1 /* [FF RR __ __] */ + or t2, t2, t3 /* [__ __ GG BB] */ + addi a2, a2, -1 /* len-- */ + or t0, t0, t2 /* [FF RR GG BB] */ + addiu a1, a1, 3 /* src += 3 */ + sw t0, 0 (a0) + addiu a0, a0, 4 /* dst++ */ + bnez a2, 1b /* if tail: loop */ + lui t0, 0xff00 /* [FF __ __ __] */ + +0: jr ra + nop + +END(qt_convert_rgb888_to_rgb32_mips_dspr2_asm) diff --git a/src/gui/image/qimagereader.cpp b/src/gui/image/qimagereader.cpp index 091837b8b4..49370bb31c 100644 --- a/src/gui/image/qimagereader.cpp +++ b/src/gui/image/qimagereader.cpp @@ -125,7 +125,6 @@ #include <qimageiohandler.h> #include <qlist.h> #include <qrect.h> -#include <qset.h> #include <qsize.h> #include <qcolor.h> #include <qvariant.h> @@ -1444,11 +1443,11 @@ QByteArray QImageReader::imageFormat(QIODevice *device) #ifndef QT_NO_IMAGEFORMATPLUGIN void supportedImageHandlerFormats(QFactoryLoader *loader, QImageIOPlugin::Capability cap, - QSet<QByteArray> *result); + QList<QByteArray> *result); void supportedImageHandlerMimeTypes(QFactoryLoader *loader, QImageIOPlugin::Capability cap, - QSet<QByteArray> *result); + QList<QByteArray> *result); #endif /*! @@ -1481,7 +1480,7 @@ void supportedImageHandlerMimeTypes(QFactoryLoader *loader, QList<QByteArray> QImageReader::supportedImageFormats() { - QSet<QByteArray> formats; + QList<QByteArray> formats; for (int i = 0; i < _qt_NumFormats; ++i) formats << _qt_BuiltInFormats[i].extension; @@ -1489,12 +1488,9 @@ QList<QByteArray> QImageReader::supportedImageFormats() supportedImageHandlerFormats(loader(), QImageIOPlugin::CanRead, &formats); #endif // QT_NO_IMAGEFORMATPLUGIN - QList<QByteArray> sortedFormats; - for (QSet<QByteArray>::ConstIterator it = formats.constBegin(); it != formats.constEnd(); ++it) - sortedFormats << *it; - - std::sort(sortedFormats.begin(), sortedFormats.end()); - return sortedFormats; + std::sort(formats.begin(), formats.end()); + formats.erase(std::unique(formats.begin(), formats.end()), formats.end()); + return formats; } /*! @@ -1508,7 +1504,7 @@ QList<QByteArray> QImageReader::supportedImageFormats() QList<QByteArray> QImageReader::supportedMimeTypes() { - QSet<QByteArray> mimeTypes; + QList<QByteArray> mimeTypes; for (int i = 0; i < _qt_NumFormats; ++i) mimeTypes << _qt_BuiltInFormats[i].mimeType; @@ -1516,12 +1512,9 @@ QList<QByteArray> QImageReader::supportedMimeTypes() supportedImageHandlerMimeTypes(loader(), QImageIOPlugin::CanRead, &mimeTypes); #endif // QT_NO_IMAGEFORMATPLUGIN - QList<QByteArray> sortedMimeTypes; - for (QSet<QByteArray>::ConstIterator it = mimeTypes.constBegin(); it != mimeTypes.constEnd(); ++it) - sortedMimeTypes << *it; - - std::sort(sortedMimeTypes.begin(), sortedMimeTypes.end()); - return sortedMimeTypes; + std::sort(mimeTypes.begin(), mimeTypes.end()); + mimeTypes.erase(std::unique(mimeTypes.begin(), mimeTypes.end()), mimeTypes.end()); + return mimeTypes; } QT_END_NAMESPACE diff --git a/src/gui/image/qimagewriter.cpp b/src/gui/image/qimagewriter.cpp index c12dbb6544..7b8af90357 100644 --- a/src/gui/image/qimagewriter.cpp +++ b/src/gui/image/qimagewriter.cpp @@ -678,7 +678,7 @@ bool QImageWriter::supportsOption(QImageIOHandler::ImageOption option) const #ifndef QT_NO_IMAGEFORMATPLUGIN void supportedImageHandlerFormats(QFactoryLoader *loader, QImageIOPlugin::Capability cap, - QSet<QByteArray> *result) + QList<QByteArray> *result) { typedef QMultiMap<int, QString> PluginKeyMap; typedef PluginKeyMap::const_iterator PluginKeyMapConstIterator; @@ -687,6 +687,7 @@ void supportedImageHandlerFormats(QFactoryLoader *loader, const PluginKeyMapConstIterator cend = keyMap.constEnd(); int i = -1; QImageIOPlugin *plugin = 0; + result->reserve(result->size() + keyMap.size()); for (PluginKeyMapConstIterator it = keyMap.constBegin(); it != cend; ++it) { if (it.key() != i) { i = it.key(); @@ -694,13 +695,13 @@ void supportedImageHandlerFormats(QFactoryLoader *loader, } const QByteArray key = it.value().toLatin1(); if (plugin && (plugin->capabilities(0, key) & cap) != 0) - result->insert(key); + result->append(key); } } void supportedImageHandlerMimeTypes(QFactoryLoader *loader, QImageIOPlugin::Capability cap, - QSet<QByteArray> *result) + QList<QByteArray> *result) { QList<QJsonObject> metaDataList = loader->metaData(); @@ -713,7 +714,7 @@ void supportedImageHandlerMimeTypes(QFactoryLoader *loader, const int keyCount = keys.size(); for (int k = 0; k < keyCount; ++k) { if (plugin && (plugin->capabilities(0, keys.at(k).toString().toLatin1()) & cap) != 0) - result->insert(mimeTypes.at(k).toString().toLatin1()); + result->append(mimeTypes.at(k).toString().toLatin1()); } } } @@ -746,7 +747,7 @@ void supportedImageHandlerMimeTypes(QFactoryLoader *loader, */ QList<QByteArray> QImageWriter::supportedImageFormats() { - QSet<QByteArray> formats; + QList<QByteArray> formats; #ifndef QT_NO_IMAGEFORMAT_BMP formats << "bmp"; #endif @@ -770,12 +771,9 @@ QList<QByteArray> QImageWriter::supportedImageFormats() supportedImageHandlerFormats(loader(), QImageIOPlugin::CanWrite, &formats); #endif // QT_NO_IMAGEFORMATPLUGIN - QList<QByteArray> sortedFormats; - for (QSet<QByteArray>::ConstIterator it = formats.constBegin(); it != formats.constEnd(); ++it) - sortedFormats << *it; - - std::sort(sortedFormats.begin(), sortedFormats.end()); - return sortedFormats; + std::sort(formats.begin(), formats.end()); + formats.erase(std::unique(formats.begin(), formats.end()), formats.end()); + return formats; } /*! @@ -788,7 +786,7 @@ QList<QByteArray> QImageWriter::supportedImageFormats() */ QList<QByteArray> QImageWriter::supportedMimeTypes() { - QSet<QByteArray> mimeTypes; + QList<QByteArray> mimeTypes; #ifndef QT_NO_IMAGEFORMAT_BMP mimeTypes << "image/bmp"; #endif @@ -814,12 +812,9 @@ QList<QByteArray> QImageWriter::supportedMimeTypes() supportedImageHandlerMimeTypes(loader(), QImageIOPlugin::CanWrite, &mimeTypes); #endif // QT_NO_IMAGEFORMATPLUGIN - QList<QByteArray> sortedMimeTypes; - for (QSet<QByteArray>::ConstIterator it = mimeTypes.constBegin(); it != mimeTypes.constEnd(); ++it) - sortedMimeTypes << *it; - - std::sort(sortedMimeTypes.begin(), sortedMimeTypes.end()); - return sortedMimeTypes; + std::sort(mimeTypes.begin(), mimeTypes.end()); + mimeTypes.erase(std::unique(mimeTypes.begin(), mimeTypes.end()), mimeTypes.end()); + return mimeTypes; } QT_END_NAMESPACE diff --git a/src/gui/image/qjpeghandler.cpp b/src/gui/image/qjpeghandler.cpp index 5008b1982b..dfacf34097 100644 --- a/src/gui/image/qjpeghandler.cpp +++ b/src/gui/image/qjpeghandler.cpp @@ -856,6 +856,7 @@ bool QJpegHandlerPrivate::read(QImage *image) Q_GUI_EXPORT void QT_FASTCALL qt_convert_rgb888_to_rgb32_neon(quint32 *dst, const uchar *src, int len); Q_GUI_EXPORT void QT_FASTCALL qt_convert_rgb888_to_rgb32_ssse3(quint32 *dst, const uchar *src, int len); +extern "C" void qt_convert_rgb888_to_rgb32_mips_dspr2_asm(quint32 *dst, const uchar *src, int len); QJpegHandler::QJpegHandler() : d(new QJpegHandlerPrivate(this)) @@ -874,6 +875,9 @@ QJpegHandler::QJpegHandler() rgb888ToRgb32ConverterPtr = qt_convert_rgb888_to_rgb32_ssse3; } #endif // QT_COMPILER_SUPPORTS_SSSE3 +#if defined(QT_COMPILER_SUPPORTS_MIPS_DSPR2) + rgb888ToRgb32ConverterPtr = qt_convert_rgb888_to_rgb32_mips_dspr2_asm; +#endif // QT_COMPILER_SUPPORTS_DSPR2 } QJpegHandler::~QJpegHandler() diff --git a/src/gui/image/qpicture.cpp b/src/gui/image/qpicture.cpp index ec89b405b5..807746a26e 100644 --- a/src/gui/image/qpicture.cpp +++ b/src/gui/image/qpicture.cpp @@ -118,7 +118,7 @@ void qt_format_text(const QFont &fnt, const QRectF &_r, */ const char *qt_mfhdr_tag = "QPIC"; // header tag -static const quint16 mfhdr_maj = 11; // major version # +static const quint16 mfhdr_maj = QDataStream::Qt_DefaultCompiledVersion; // major version # static const quint16 mfhdr_min = 0; // minor version # /*! diff --git a/src/gui/opengl/opengl.pri b/src/gui/opengl/opengl.pri index cadba26797..f82401c973 100644 --- a/src/gui/opengl/opengl.pri +++ b/src/gui/opengl/opengl.pri @@ -2,7 +2,6 @@ contains(QT_CONFIG, opengl):CONFIG += opengl contains(QT_CONFIG, opengles2):CONFIG += opengles2 -contains(QT_CONFIG, egl):CONFIG += egl contains(QT_CONFIG, opengl)|contains(QT_CONFIG, opengles2) { diff --git a/src/gui/opengl/qopenglextensions_p.h b/src/gui/opengl/qopenglextensions_p.h index 265771ce1b..065cbb0e57 100644 --- a/src/gui/opengl/qopenglextensions_p.h +++ b/src/gui/opengl/qopenglextensions_p.h @@ -106,8 +106,6 @@ public: OpenGLExtensions openGLExtensions(); bool hasOpenGLExtension(QOpenGLExtensions::OpenGLExtension extension) const; - void initializeGLExtensions(); - GLvoid *glMapBuffer(GLenum target, GLenum access); GLboolean glUnmapBuffer(GLenum target); 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/qpainter.cpp b/src/gui/painting/qpainter.cpp index fe5fc051df..a3b1f07c69 100644 --- a/src/gui/painting/qpainter.cpp +++ b/src/gui/painting/qpainter.cpp @@ -6416,6 +6416,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 @@ -6443,6 +6444,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/text/qfont.cpp b/src/gui/text/qfont.cpp index cf40dd028d..1797905e93 100644 --- a/src/gui/text/qfont.cpp +++ b/src/gui/text/qfont.cpp @@ -2165,6 +2165,8 @@ QDataStream &operator<<(QDataStream &s, const QFont &font) s << font.d->request.family.toLatin1(); } else { s << font.d->request.family; + if (s.version() >= QDataStream::Qt_5_4) + s << font.d->request.styleName; } if (s.version() >= QDataStream::Qt_4_0) { @@ -2185,8 +2187,14 @@ QDataStream &operator<<(QDataStream &s, const QFont &font) } s << (quint8) font.d->request.styleHint; - if (s.version() >= QDataStream::Qt_3_1) - s << (quint8) font.d->request.styleStrategy; + if (s.version() >= QDataStream::Qt_3_1) { + // Continue writing 8 bits for versions < 5.4 so that we don't write too much, + // even though we need 16 to store styleStrategy, so there is some data loss. + if (s.version() >= QDataStream::Qt_5_4) + s << (quint16) font.d->request.styleStrategy; + else + s << (quint8) font.d->request.styleStrategy; + } s << (quint8) 0 << (quint8) font.d->request.weight << get_font_bits(s.version(), font.d.data()); @@ -2198,6 +2206,8 @@ QDataStream &operator<<(QDataStream &s, const QFont &font) s << font.d->letterSpacing.value(); s << font.d->wordSpacing.value(); } + if (s.version() >= QDataStream::Qt_5_4) + s << (quint8)font.d->request.hintingPreference; return s; } @@ -2215,7 +2225,8 @@ QDataStream &operator>>(QDataStream &s, QFont &font) font.d = new QFontPrivate; font.resolve_mask = QFont::AllPropertiesResolved; - quint8 styleHint, styleStrategy = QFont::PreferDefault, charSet, weight, bits; + quint8 styleHint, charSet, weight, bits; + quint16 styleStrategy = QFont::PreferDefault; if (s.version() == 1) { QByteArray fam; @@ -2223,6 +2234,8 @@ QDataStream &operator>>(QDataStream &s, QFont &font) font.d->request.family = QString::fromLatin1(fam); } else { s >> font.d->request.family; + if (s.version() >= QDataStream::Qt_5_4) + s >> font.d->request.styleName; } if (s.version() >= QDataStream::Qt_4_0) { @@ -2242,8 +2255,15 @@ QDataStream &operator>>(QDataStream &s, QFont &font) font.d->request.pixelSize = pixelSize; } s >> styleHint; - if (s.version() >= QDataStream::Qt_3_1) - s >> styleStrategy; + if (s.version() >= QDataStream::Qt_3_1) { + if (s.version() >= QDataStream::Qt_5_4) { + s >> styleStrategy; + } else { + quint8 tempStyleStrategy; + s >> tempStyleStrategy; + styleStrategy = tempStyleStrategy; + } + } s >> charSet; s >> weight; @@ -2273,6 +2293,11 @@ QDataStream &operator>>(QDataStream &s, QFont &font) s >> value; font.d->wordSpacing.setValue(value); } + if (s.version() >= QDataStream::Qt_5_4) { + quint8 value; + s >> value; + font.d->request.hintingPreference = QFont::HintingPreference(value); + } return s; } diff --git a/src/gui/text/qfont_p.h b/src/gui/text/qfont_p.h index 4d8712e76e..be0402b95a 100644 --- a/src/gui/text/qfont_p.h +++ b/src/gui/text/qfont_p.h @@ -92,7 +92,7 @@ struct QFontDef uint weight : 7; // 0-99 uint fixedPitch : 1; uint style : 2; - uint stretch : 12; // 0-400 + uint stretch : 12; // 0-4000 uint hintingPreference : 2; uint ignorePitch : 1; diff --git a/src/gui/util/qgridlayoutengine.cpp b/src/gui/util/qgridlayoutengine.cpp index 10b4a2ee35..7170477e84 100644 --- a/src/gui/util/qgridlayoutengine.cpp +++ b/src/gui/util/qgridlayoutengine.cpp @@ -983,9 +983,10 @@ void QGridLayoutEngine::invalidate() q_cachedEffectiveFirstRows[Ver] = -1; q_cachedEffectiveLastRows[Hor] = -1; q_cachedEffectiveLastRows[Ver] = -1; - q_totalBoxesValid = false; - q_sizeHintValid[Hor] = false; - q_sizeHintValid[Ver] = false; + + q_totalBoxCachedConstraints[Hor] = NotCached; + q_totalBoxCachedConstraints[Ver] = NotCached; + q_cachedSize = QSizeF(); q_cachedConstraintOrientation = UnknownConstraint; } @@ -1530,7 +1531,11 @@ void QGridLayoutEngine::ensureColumnAndRowData(QGridLayoutRowData *rowData, QGri const QAbstractLayoutStyleInfo *styleInfo) const { const int o = (orientation == Qt::Vertical ? Ver : Hor); - if (q_sizeHintValid[o] && !colPositions && !colSizes) { + const int cc = columnCount(orientation); + + const qreal constraint = (colPositions && colSizes && hasDynamicConstraint()) ? (colPositions[cc - 1] + colSizes[cc - 1]) : qreal(CachedWithNoConstraint); + qreal &cachedConstraint = q_totalBoxCachedConstraints[o]; + if (cachedConstraint == constraint) { if (totalBox != &q_totalBoxes[o]) *totalBox = q_totalBoxes[o]; return; @@ -1541,10 +1546,10 @@ void QGridLayoutEngine::ensureColumnAndRowData(QGridLayoutRowData *rowData, QGri rowData->distributeMultiCells(rowInfo); *totalBox = rowData->totalBox(0, rowCount(orientation)); - if (!colPositions && !colSizes) { + if (totalBox != &q_totalBoxes[o]) q_totalBoxes[o] = *totalBox; - q_sizeHintValid[o] = true; - } + + cachedConstraint = constraint; } /** @@ -1593,10 +1598,9 @@ Qt::Orientation QGridLayoutEngine::constraintOrientation() const void QGridLayoutEngine::ensureGeometries(const QSizeF &size, const QAbstractLayoutStyleInfo *styleInfo) const { - if (!styleInfo->hasChanged() && q_totalBoxesValid && q_cachedSize == size) + if (!styleInfo->hasChanged() && q_cachedSize == size) return; - q_totalBoxesValid = true; q_cachedSize = size; q_xx.resize(columnCount()); @@ -1606,7 +1610,7 @@ void QGridLayoutEngine::ensureGeometries(const QSizeF &size, q_descents.resize(rowCount()); if (constraintOrientation() != Qt::Horizontal) { - //We might have items whose width depends on their height + //We might have items whose height depends on their width (HFW) ensureColumnAndRowData(&q_columnData, &q_totalBoxes[Hor], NULL, NULL, Qt::Horizontal, styleInfo); //Calculate column widths and positions, and put results in q_xx.data() and q_widths.data() so that we can use this information as //constraints to find the row heights @@ -1617,7 +1621,7 @@ void QGridLayoutEngine::ensureGeometries(const QSizeF &size, q_rowData.calculateGeometries(0, rowCount(), size.height(), q_yy.data(), q_heights.data(), q_descents.data(), q_totalBoxes[Ver], q_infos[Ver]); } else { - //We have items whose height depends on their width + //We have items whose width depends on their height (WFH) ensureColumnAndRowData(&q_rowData, &q_totalBoxes[Ver], NULL, NULL, Qt::Vertical, styleInfo); //Calculate row heights and positions, and put results in q_yy.data() and q_heights.data() so that we can use this information as //constraints to find the column widths diff --git a/src/gui/util/qgridlayoutengine_p.h b/src/gui/util/qgridlayoutengine_p.h index 9650e7fffe..bbc94bd51f 100644 --- a/src/gui/util/qgridlayoutengine_p.h +++ b/src/gui/util/qgridlayoutengine_p.h @@ -450,15 +450,21 @@ private: mutable int q_cachedEffectiveLastRows[NOrientations]; mutable quint8 q_cachedConstraintOrientation : 3; + // this is useful to cache + mutable QGridLayoutBox q_totalBoxes[NOrientations]; + enum { + NotCached = -2, // Cache is empty. Happens when the engine is invalidated. + CachedWithNoConstraint = -1 // cache has a totalBox without any HFW/WFH constraints. + // >= 0 // cache has a totalBox with this specific constraint. + }; + mutable qreal q_totalBoxCachedConstraints[NOrientations]; // holds the constraint used for the cached totalBox + // Layout item input mutable QGridLayoutRowData q_columnData; mutable QGridLayoutRowData q_rowData; - mutable QGridLayoutBox q_totalBoxes[NOrientations]; // Output mutable QSizeF q_cachedSize; - mutable bool q_totalBoxesValid; - mutable bool q_sizeHintValid[NOrientations]; mutable QVector<qreal> q_xx; mutable QVector<qreal> q_yy; mutable QVector<qreal> q_widths; |