diff options
author | Liang Qi <liang.qi@qt.io> | 2018-02-06 12:38:51 +0100 |
---|---|---|
committer | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2018-02-10 15:55:52 +0100 |
commit | 32b506d1db1f8cee748a27b548ba8208f2928058 (patch) | |
tree | 2d5b23baafe22ccc3518719f8f5d19bb846b2b61 /src/gui | |
parent | 2cb1db64370989fffeec313c196fe573c479e6aa (diff) | |
parent | c0948d508e7179e2e23c893ba6152c40400de060 (diff) |
Merge remote-tracking branch 'origin/dev' into 5.11
Conflicts:
src/corelib/tools/qvarlengtharray.qdoc
src/corelib/tools/qvector.qdoc
Resolved documentation changes in favor of 017569f702b6dd0,
which keeps the move overloads along with its const-ref sibling.
Change-Id: I0835b0b3211a418e5e50defc4cf315f0964fab79
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/gui.pro | 3 | ||||
-rw-r--r-- | src/gui/itemmodels/qstandarditemmodel.cpp | 33 | ||||
-rw-r--r-- | src/gui/itemmodels/qstandarditemmodel.h | 1 | ||||
-rw-r--r-- | src/gui/itemmodels/qstandarditemmodel_p.h | 2 | ||||
-rw-r--r-- | src/gui/kernel/qevent.cpp | 19 | ||||
-rw-r--r-- | src/gui/kernel/qguiapplication.cpp | 10 | ||||
-rw-r--r-- | src/gui/kernel/qplatformintegration.cpp | 2 | ||||
-rw-r--r-- | src/gui/kernel/qplatformintegration.h | 1 | ||||
-rw-r--r-- | src/gui/kernel/qplatformtheme.cpp | 2 | ||||
-rw-r--r-- | src/gui/kernel/qplatformtheme.h | 3 | ||||
-rw-r--r-- | src/gui/kernel/qstylehints.cpp | 36 | ||||
-rw-r--r-- | src/gui/kernel/qstylehints.h | 4 | ||||
-rw-r--r-- | src/gui/painting/qdrawhelper.cpp | 112 | ||||
-rw-r--r-- | src/gui/painting/qdrawhelper_avx2.cpp | 4 | ||||
-rw-r--r-- | src/gui/painting/qdrawhelper_p.h | 18 | ||||
-rw-r--r-- | src/gui/qtgui.tracepoints | 8 | ||||
-rw-r--r-- | src/gui/text/qfontdatabase.cpp | 10 |
17 files changed, 190 insertions, 78 deletions
diff --git a/src/gui/gui.pro b/src/gui/gui.pro index f8cec00b82..759d6f3cbf 100644 --- a/src/gui/gui.pro +++ b/src/gui/gui.pro @@ -95,3 +95,6 @@ qtConfig(angle) { qtConfig(egl): CMAKE_EGL_INCDIRS = $$cmakePortablePaths($$QMAKE_INCDIR_EGL) QMAKE_DYNAMIC_LIST_FILE = $$PWD/QtGui.dynlist + +TRACEPOINT_PROVIDER = $$PWD/qtgui.tracepoints +CONFIG += qt_tracepoints diff --git a/src/gui/itemmodels/qstandarditemmodel.cpp b/src/gui/itemmodels/qstandarditemmodel.cpp index 519995e82a..d1e0604caf 100644 --- a/src/gui/itemmodels/qstandarditemmodel.cpp +++ b/src/gui/itemmodels/qstandarditemmodel.cpp @@ -278,8 +278,24 @@ void QStandardItemPrivate::setItemData(const QMap<int, QVariant> &roles) if (newValues != values) { values.swap(newValues); - if (model) - model->d_func()->itemChanged(q); + if (model) { + QVector<int> roleKeys; + roleKeys.reserve(roles.size() + 1); + bool hasEditRole = false; + bool hasDisplayRole = false; + for (auto it = roles.keyBegin(); it != roles.keyEnd(); ++it) { + roleKeys.push_back(*it); + if (*it == Qt::EditRole) + hasEditRole = true; + else if (*it == Qt::DisplayRole) + hasDisplayRole = true; + } + if (hasEditRole && !hasDisplayRole) + roleKeys.push_back(Qt::DisplayRole); + else if (!hasEditRole && hasDisplayRole) + roleKeys.push_back(Qt::EditRole); + model->d_func()->itemChanged(q, roleKeys); + } } } @@ -554,7 +570,7 @@ bool QStandardItemPrivate::insertColumns(int column, int count, const QList<QSta /*! \internal */ -void QStandardItemModelPrivate::itemChanged(QStandardItem *item) +void QStandardItemModelPrivate::itemChanged(QStandardItem *item, const QVector<int> &roles) { Q_Q(QStandardItemModel); Q_ASSERT(item); @@ -570,8 +586,8 @@ void QStandardItemModelPrivate::itemChanged(QStandardItem *item) } } else { // Normal item - QModelIndex index = q->indexFromItem(item); - emit q->dataChanged(index, index); + const QModelIndex index = q->indexFromItem(item); + emit q->dataChanged(index, index, roles); } } @@ -885,6 +901,9 @@ void QStandardItem::setData(const QVariant &value, int role) { Q_D(QStandardItem); role = (role == Qt::EditRole) ? Qt::DisplayRole : role; + const QVector<int> roles((role == Qt::DisplayRole) ? + QVector<int>({Qt::DisplayRole, Qt::EditRole}) : + QVector<int>({role})); QVector<QStandardItemData>::iterator it; for (it = d->values.begin(); it != d->values.end(); ++it) { if ((*it).role == role) { @@ -896,13 +915,13 @@ void QStandardItem::setData(const QVariant &value, int role) d->values.erase(it); } if (d->model) - d->model->d_func()->itemChanged(this); + d->model->d_func()->itemChanged(this, roles); return; } } d->values.append(QStandardItemData(role, value)); if (d->model) - d->model->d_func()->itemChanged(this); + d->model->d_func()->itemChanged(this, roles); } /*! diff --git a/src/gui/itemmodels/qstandarditemmodel.h b/src/gui/itemmodels/qstandarditemmodel.h index c54e7b27d9..d8f06b629a 100644 --- a/src/gui/itemmodels/qstandarditemmodel.h +++ b/src/gui/itemmodels/qstandarditemmodel.h @@ -419,6 +419,7 @@ public: bool dropMimeData (const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) override; Q_SIGNALS: + // ### Qt 6: add changed roles void itemChanged(QStandardItem *item); protected: diff --git a/src/gui/itemmodels/qstandarditemmodel_p.h b/src/gui/itemmodels/qstandarditemmodel_p.h index caee3ea34c..bd28ec3029 100644 --- a/src/gui/itemmodels/qstandarditemmodel_p.h +++ b/src/gui/itemmodels/qstandarditemmodel_p.h @@ -200,7 +200,7 @@ public: } void sort(QStandardItem *parent, int column, Qt::SortOrder order); - void itemChanged(QStandardItem *item); + void itemChanged(QStandardItem *item, const QVector<int> &roles = QVector<int>()); void rowsAboutToBeInserted(QStandardItem *parent, int start, int end); void columnsAboutToBeInserted(QStandardItem *parent, int start, int end); void rowsAboutToBeRemoved(QStandardItem *parent, int start, int end); diff --git a/src/gui/kernel/qevent.cpp b/src/gui/kernel/qevent.cpp index be8ce1a011..50d9bbb2cc 100644 --- a/src/gui/kernel/qevent.cpp +++ b/src/gui/kernel/qevent.cpp @@ -3761,14 +3761,25 @@ static inline void formatInputMethodEvent(QDebug d, const QInputMethodEvent *e) static inline void formatInputMethodQueryEvent(QDebug d, const QInputMethodQueryEvent *e) { + QDebugStateSaver saver(d); + d.noquote(); const Qt::InputMethodQueries queries = e->queries(); d << "QInputMethodQueryEvent(queries=" << showbase << hex << int(queries) << noshowbase << dec << ", {"; - for (unsigned mask = 1; mask <= Qt::ImTextAfterCursor; mask<<=1) { + for (unsigned mask = 1; mask <= Qt::ImInputItemClipRectangle; mask<<=1) { if (queries & mask) { - const QVariant value = e->value(static_cast<Qt::InputMethodQuery>(mask)); - if (value.isValid()) - d << '[' << showbase << hex << mask << noshowbase << dec << '=' << value << "],"; + const Qt::InputMethodQuery query = static_cast<Qt::InputMethodQuery>(mask); + const QVariant value = e->value(query); + if (value.isValid()) { + d << '['; + QtDebugUtils::formatQEnum(d, query); + d << '='; + if (query == Qt::ImHints) + QtDebugUtils::formatQFlags(d, Qt::InputMethodHints(value.toInt())); + else + d << value.toString(); + d << "],"; + } } } d << "})"; diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp index 5f4a1a0236..055347500b 100644 --- a/src/gui/kernel/qguiapplication.cpp +++ b/src/gui/kernel/qguiapplication.cpp @@ -111,6 +111,8 @@ # include <QtCore/QLibraryInfo> #endif // Q_OS_WIN +#include <qtgui_tracepoints_p.h> + #include <ctype.h> QT_BEGIN_NAMESPACE @@ -1360,6 +1362,8 @@ void QGuiApplicationPrivate::eventDispatcherReady() void QGuiApplicationPrivate::init() { + Q_TRACE(qguiapplicationprivate_init_entry); + #if defined(Q_OS_MACOS) QMacAutoReleasePool pool; #endif @@ -1522,6 +1526,8 @@ void QGuiApplicationPrivate::init() if (!QGuiApplicationPrivate::displayName) QObject::connect(q, &QGuiApplication::applicationNameChanged, q, &QGuiApplication::applicationDisplayNameChanged); + + Q_TRACE(qguiapplicationprivate_init_exit); } extern void qt_cleanupFontDatabase(); @@ -1756,6 +1762,8 @@ bool QGuiApplicationPrivate::processNativeEvent(QWindow *window, const QByteArra void QGuiApplicationPrivate::processWindowSystemEvent(QWindowSystemInterfacePrivate::WindowSystemEvent *e) { + Q_TRACE(qguiapplicationprivate_processwsevents_entry, e->type); + switch(e->type) { case QWindowSystemInterfacePrivate::Mouse: QGuiApplicationPrivate::processMouseEvent(static_cast<QWindowSystemInterfacePrivate::MouseEvent *>(e)); @@ -1864,6 +1872,8 @@ void QGuiApplicationPrivate::processWindowSystemEvent(QWindowSystemInterfacePriv qWarning() << "Unknown user input event type:" << e->type; break; } + + Q_TRACE(qguiapplicationprivate_processwsevents_exit, e->type); } /*! \internal diff --git a/src/gui/kernel/qplatformintegration.cpp b/src/gui/kernel/qplatformintegration.cpp index 151151de23..448d670209 100644 --- a/src/gui/kernel/qplatformintegration.cpp +++ b/src/gui/kernel/qplatformintegration.cpp @@ -418,6 +418,8 @@ QVariant QPlatformIntegration::styleHint(StyleHint hint) const return QPlatformTheme::defaultThemeHint(QPlatformTheme::UiEffects); case WheelScrollLines: return QPlatformTheme::defaultThemeHint(QPlatformTheme::WheelScrollLines); + case MouseQuickSelectionThreshold: + return QPlatformTheme::defaultThemeHint(QPlatformTheme::MouseQuickSelectionThreshold); } return 0; diff --git a/src/gui/kernel/qplatformintegration.h b/src/gui/kernel/qplatformintegration.h index a7d9a87502..37884e1f78 100644 --- a/src/gui/kernel/qplatformintegration.h +++ b/src/gui/kernel/qplatformintegration.h @@ -164,6 +164,7 @@ public: UiEffects, WheelScrollLines, ShowShortcutsInContextMenus, + MouseQuickSelectionThreshold }; virtual QVariant styleHint(StyleHint hint) const; diff --git a/src/gui/kernel/qplatformtheme.cpp b/src/gui/kernel/qplatformtheme.cpp index 1856952805..277d976dde 100644 --- a/src/gui/kernel/qplatformtheme.cpp +++ b/src/gui/kernel/qplatformtheme.cpp @@ -559,6 +559,8 @@ QVariant QPlatformTheme::defaultThemeHint(ThemeHint hint) dist = defaultThemeHint(MouseDoubleClickDistance).toInt(&ok) * 2; return QVariant(ok ? dist : 10); } + case MouseQuickSelectionThreshold: + return QVariant(10); } return QVariant(); } diff --git a/src/gui/kernel/qplatformtheme.h b/src/gui/kernel/qplatformtheme.h index 87873d446f..1d6049a98d 100644 --- a/src/gui/kernel/qplatformtheme.h +++ b/src/gui/kernel/qplatformtheme.h @@ -117,7 +117,8 @@ public: WheelScrollLines, TouchDoubleTapDistance, ShowShortcutsInContextMenus, - IconFallbackSearchPaths + IconFallbackSearchPaths, + MouseQuickSelectionThreshold }; enum DialogType { diff --git a/src/gui/kernel/qstylehints.cpp b/src/gui/kernel/qstylehints.cpp index 0850228ee5..b2d968c046 100644 --- a/src/gui/kernel/qstylehints.cpp +++ b/src/gui/kernel/qstylehints.cpp @@ -79,6 +79,7 @@ public: , m_tabFocusBehavior(-1) , m_uiEffects(-1) , m_wheelScrollLines(-1) + , m_mouseQuickSelectionThreshold(-1) {} int m_mouseDoubleClickInterval; @@ -90,6 +91,7 @@ public: int m_tabFocusBehavior; int m_uiEffects; int m_wheelScrollLines; + int m_mouseQuickSelectionThreshold; }; /*! @@ -537,4 +539,38 @@ void QStyleHints::setWheelScrollLines(int scrollLines) emit wheelScrollLinesChanged(scrollLines); } +/*! + Sets the mouse quick selection threshold. + \internal + \sa mouseQuickSelectionThreshold() + \since 5.11 +*/ +void QStyleHints::setMouseQuickSelectionThreshold(int threshold) +{ + Q_D(QStyleHints); + if (d->m_mouseQuickSelectionThreshold == threshold) + return; + d->m_mouseQuickSelectionThreshold = threshold; + emit mouseDoubleClickIntervalChanged(threshold); +} + +/*! + \property QStyleHints::mouseQuickSelectionThreshold + \brief Quick selection mouse threshold in QLineEdit. + + This property defines how much the mouse cursor should be moved along the y axis + to trigger a quick selection during a normal QLineEdit text selection. + + If the property value is less than or equal to 0, the quick selection feature is disabled. + + \since 5.11 +*/ +int QStyleHints::mouseQuickSelectionThreshold() const +{ + Q_D(const QStyleHints); + if (d->m_mouseQuickSelectionThreshold >= 0) + return d->m_mouseQuickSelectionThreshold; + return themeableHint(QPlatformTheme::MouseQuickSelectionThreshold, QPlatformIntegration::MouseQuickSelectionThreshold).toInt(); +} + QT_END_NAMESPACE diff --git a/src/gui/kernel/qstylehints.h b/src/gui/kernel/qstylehints.h index 2c2e048b15..7b0683e9b1 100644 --- a/src/gui/kernel/qstylehints.h +++ b/src/gui/kernel/qstylehints.h @@ -73,6 +73,7 @@ class Q_GUI_EXPORT QStyleHints : public QObject Q_PROPERTY(bool singleClickActivation READ singleClickActivation STORED false CONSTANT FINAL) Q_PROPERTY(bool useHoverEffects READ useHoverEffects WRITE setUseHoverEffects NOTIFY useHoverEffectsChanged FINAL) Q_PROPERTY(int wheelScrollLines READ wheelScrollLines NOTIFY wheelScrollLinesChanged FINAL) + Q_PROPERTY(int mouseQuickSelectionThreshold READ mouseQuickSelectionThreshold WRITE setMouseQuickSelectionThreshold NOTIFY mouseQuickSelectionThresholdChanged FINAL) public: void setMouseDoubleClickInterval(int mouseDoubleClickInterval); @@ -104,6 +105,8 @@ public: void setUseHoverEffects(bool useHoverEffects); int wheelScrollLines() const; void setWheelScrollLines(int scrollLines); + void setMouseQuickSelectionThreshold(int threshold); + int mouseQuickSelectionThreshold() const; Q_SIGNALS: void cursorFlashTimeChanged(int cursorFlashTime); @@ -115,6 +118,7 @@ Q_SIGNALS: void tabFocusBehaviorChanged(Qt::TabFocusBehavior tabFocusBehavior); void useHoverEffectsChanged(bool useHoverEffects); void wheelScrollLinesChanged(int scrollLines); + void mouseQuickSelectionThresholdChanged(int threshold); private: friend class QGuiApplication; diff --git a/src/gui/painting/qdrawhelper.cpp b/src/gui/painting/qdrawhelper.cpp index 6ddfcdfaf4..23c8e42ded 100644 --- a/src/gui/painting/qdrawhelper.cpp +++ b/src/gui/painting/qdrawhelper.cpp @@ -174,29 +174,31 @@ template<QImage::Format Format> static const uint *QT_FASTCALL convertToRGB32(uint *buffer, const uint *src, int count, const QVector<QRgb> *, QDitherInfo *) { - Q_CONSTEXPR uint redMask = ((1 << redWidth<Format>()) - 1); - Q_CONSTEXPR uint greenMask = ((1 << greenWidth<Format>()) - 1); - Q_CONSTEXPR uint blueMask = ((1 << blueWidth<Format>()) - 1); + auto conversion = [](uint s) { + // MSVC needs these constexpr defined in here otherwise it will create a capture. + Q_CONSTEXPR uint redMask = ((1 << redWidth<Format>()) - 1); + Q_CONSTEXPR uint greenMask = ((1 << greenWidth<Format>()) - 1); + Q_CONSTEXPR uint blueMask = ((1 << blueWidth<Format>()) - 1); - Q_CONSTEXPR uchar redLeftShift = 8 - redWidth<Format>(); - Q_CONSTEXPR uchar greenLeftShift = 8 - greenWidth<Format>(); - Q_CONSTEXPR uchar blueLeftShift = 8 - blueWidth<Format>(); + Q_CONSTEXPR uchar redLeftShift = 8 - redWidth<Format>(); + Q_CONSTEXPR uchar greenLeftShift = 8 - greenWidth<Format>(); + Q_CONSTEXPR uchar blueLeftShift = 8 - blueWidth<Format>(); - Q_CONSTEXPR uchar redRightShift = 2 * redWidth<Format>() - 8; - Q_CONSTEXPR uchar greenRightShift = 2 * greenWidth<Format>() - 8; - Q_CONSTEXPR uchar blueRightShift = 2 * blueWidth<Format>() - 8; + Q_CONSTEXPR uchar redRightShift = 2 * redWidth<Format>() - 8; + Q_CONSTEXPR uchar greenRightShift = 2 * greenWidth<Format>() - 8; + Q_CONSTEXPR uchar blueRightShift = 2 * blueWidth<Format>() - 8; - for (int i = 0; i < count; ++i) { - uint red = (src[i] >> redShift<Format>()) & redMask; - uint green = (src[i] >> greenShift<Format>()) & greenMask; - uint blue = (src[i] >> blueShift<Format>()) & blueMask; + uint red = (s >> redShift<Format>()) & redMask; + uint green = (s >> greenShift<Format>()) & greenMask; + uint blue = (s >> blueShift<Format>()) & blueMask; red = ((red << redLeftShift) | (red >> redRightShift)) << 16; green = ((green << greenLeftShift) | (green >> greenRightShift)) << 8; blue = (blue << blueLeftShift) | (blue >> blueRightShift); - buffer[i] = 0xff000000 | red | green | blue; - } + return 0xff000000 | red | green | blue; + }; + UNALIASED_CONVERSION_LOOP(buffer, src, count, conversion); return buffer; } @@ -348,21 +350,21 @@ static const uint *QT_FASTCALL convertRGBFromARGB32PM(uint *buffer, const uint * // RGB32 -> RGB888 is not a precision loss. if (!dither || (rWidth == 8 && gWidth == 8 && bWidth == 8)) { - Q_CONSTEXPR uint rMask = (1 << rWidth) - 1; - Q_CONSTEXPR uint gMask = (1 << gWidth) - 1; - Q_CONSTEXPR uint bMask = (1 << bWidth) - 1; + auto conversion = [](uint s) { + const uint c = fromRGB ? s : qUnpremultiply(s); + Q_CONSTEXPR uint rMask = (1 << redWidth<Format>()) - 1; + Q_CONSTEXPR uint gMask = (1 << greenWidth<Format>()) - 1; + Q_CONSTEXPR uint bMask = (1 << blueWidth<Format>()) - 1; + Q_CONSTEXPR uchar rRightShift = 24 - redWidth<Format>(); + Q_CONSTEXPR uchar gRightShift = 16 - greenWidth<Format>(); + Q_CONSTEXPR uchar bRightShift = 8 - blueWidth<Format>(); - Q_CONSTEXPR uchar rRightShift = 24 - rWidth; - Q_CONSTEXPR uchar gRightShift = 16 - gWidth; - Q_CONSTEXPR uchar bRightShift = 8 - bWidth; - - for (int i = 0; i < count; ++i) { - const uint c = fromRGB ? src[i] : qUnpremultiply(src[i]); const uint r = ((c >> rRightShift) & rMask) << redShift<Format>(); const uint g = ((c >> gRightShift) & gMask) << greenShift<Format>(); const uint b = ((c >> bRightShift) & bMask) << blueShift<Format>(); - buffer[i] = r | g | b; - } + return r | g | b; + }; + UNALIASED_CONVERSION_LOOP(buffer, src, count, conversion); } else { // We do ordered dither by using a rounding conversion, but instead of // adding half of input precision, we add the adjusted result from the @@ -394,32 +396,32 @@ template<QImage::Format Format, bool fromRGB> static const uint *QT_FASTCALL convertARGBPMFromARGB32PM(uint *buffer, const uint *src, int count, const QVector<QRgb> *, QDitherInfo *dither) { - Q_CONSTEXPR uchar aWidth = alphaWidth<Format>(); - Q_CONSTEXPR uchar rWidth = redWidth<Format>(); - Q_CONSTEXPR uchar gWidth = greenWidth<Format>(); - Q_CONSTEXPR uchar bWidth = blueWidth<Format>(); - if (!dither) { - Q_CONSTEXPR uint aMask = (1 << aWidth) - 1; - Q_CONSTEXPR uint rMask = (1 << rWidth) - 1; - Q_CONSTEXPR uint gMask = (1 << gWidth) - 1; - Q_CONSTEXPR uint bMask = (1 << bWidth) - 1; - - Q_CONSTEXPR uchar aRightShift = 32 - aWidth; - Q_CONSTEXPR uchar rRightShift = 24 - rWidth; - Q_CONSTEXPR uchar gRightShift = 16 - gWidth; - Q_CONSTEXPR uchar bRightShift = 8 - bWidth; - - Q_CONSTEXPR uint aOpaque = aMask << alphaShift<Format>(); - for (int i = 0; i < count; ++i) { - const uint c = src[i]; + auto conversion = [](uint c) { + Q_CONSTEXPR uint aMask = (1 << alphaWidth<Format>()) - 1; + Q_CONSTEXPR uint rMask = (1 << redWidth<Format>()) - 1; + Q_CONSTEXPR uint gMask = (1 << greenWidth<Format>()) - 1; + Q_CONSTEXPR uint bMask = (1 << blueWidth<Format>()) - 1; + + Q_CONSTEXPR uchar aRightShift = 32 - alphaWidth<Format>(); + Q_CONSTEXPR uchar rRightShift = 24 - redWidth<Format>(); + Q_CONSTEXPR uchar gRightShift = 16 - greenWidth<Format>(); + Q_CONSTEXPR uchar bRightShift = 8 - blueWidth<Format>(); + + Q_CONSTEXPR uint aOpaque = aMask << alphaShift<Format>(); const uint a = fromRGB ? aOpaque : (((c >> aRightShift) & aMask) << alphaShift<Format>()); const uint r = ((c >> rRightShift) & rMask) << redShift<Format>(); const uint g = ((c >> gRightShift) & gMask) << greenShift<Format>(); const uint b = ((c >> bRightShift) & bMask) << blueShift<Format>(); - buffer[i] = a | r | g | b; - } + return a | r | g | b; + }; + UNALIASED_CONVERSION_LOOP(buffer, src, count, conversion); } else { + Q_CONSTEXPR uchar aWidth = alphaWidth<Format>(); + Q_CONSTEXPR uchar rWidth = redWidth<Format>(); + Q_CONSTEXPR uchar gWidth = greenWidth<Format>(); + Q_CONSTEXPR uchar bWidth = blueWidth<Format>(); + const uint *bayer_line = qt_bayer_matrix[dither->y & 15]; for (int i = 0; i < count; ++i) { const uint c = src[i]; @@ -514,8 +516,7 @@ static const uint *QT_FASTCALL convertARGB32ToARGB32PM(uint *buffer, const uint static const uint *QT_FASTCALL convertRGBA8888PMToARGB32PM(uint *buffer, const uint *src, int count, const QVector<QRgb> *, QDitherInfo *) { - for (int i = 0; i < count; ++i) - buffer[i] = RGBA2ARGB(src[i]); + UNALIASED_CONVERSION_LOOP(buffer, src, count, RGBA2ARGB); return buffer; } @@ -568,8 +569,7 @@ static const uint *QT_FASTCALL convertARGB32FromARGB32PM(uint *buffer, const uin static const uint *QT_FASTCALL convertRGBA8888PMFromARGB32PM(uint *buffer, const uint *src, int count, const QVector<QRgb> *, QDitherInfo *) { - for (int i = 0; i < count; ++i) - buffer[i] = ARGB2RGBA(src[i]); + UNALIASED_CONVERSION_LOOP(buffer, src, count, ARGB2RGBA); return buffer; } @@ -695,8 +695,7 @@ static const uint *QT_FASTCALL convertRGBA8888FromARGB32PM(uint *buffer, const u static const uint *QT_FASTCALL convertRGBXFromRGB32(uint *buffer, const uint *src, int count, const QVector<QRgb> *, QDitherInfo *) { - for (int i = 0; i < count; ++i) - buffer[i] = ARGB2RGBA(0xff000000 | src[i]); + UNALIASED_CONVERSION_LOOP(buffer, src, count, [](uint c) { return ARGB2RGBA(0xff000000 | c); }); return buffer; } @@ -713,8 +712,7 @@ static const uint *QT_FASTCALL convertA2RGB30PMToARGB32PM(uint *buffer, const ui const QVector<QRgb> *, QDitherInfo *dither) { if (!dither) { - for (int i = 0; i < count; ++i) - buffer[i] = qConvertA2rgb30ToArgb32<PixelOrder>(src[i]); + UNALIASED_CONVERSION_LOOP(buffer, src, count, qConvertA2rgb30ToArgb32<PixelOrder>); } else { for (int i = 0; i < count; ++i) { const uint c = src[i]; @@ -796,8 +794,7 @@ template<QtPixelOrder PixelOrder> static const uint *QT_FASTCALL convertA2RGB30PMFromARGB32PM(uint *buffer, const uint *src, int count, const QVector<QRgb> *, QDitherInfo *) { - for (int i = 0; i < count; ++i) - buffer[i] = qConvertArgb32ToA2rgb30<PixelOrder>(src[i]); + UNALIASED_CONVERSION_LOOP(buffer, src, count, qConvertArgb32ToA2rgb30<PixelOrder>); return buffer; } @@ -814,8 +811,7 @@ template<QtPixelOrder PixelOrder> static const uint *QT_FASTCALL convertRGB30FromARGB32PM(uint *buffer, const uint *src, int count, const QVector<QRgb> *, QDitherInfo *) { - for (int i = 0; i < count; ++i) - buffer[i] = qConvertRgb32ToRgb30<PixelOrder>(qUnpremultiply(src[i])); + UNALIASED_CONVERSION_LOOP(buffer, src, count, qConvertRgb32ToRgb30<PixelOrder>); return buffer; } diff --git a/src/gui/painting/qdrawhelper_avx2.cpp b/src/gui/painting/qdrawhelper_avx2.cpp index cf89f408b5..3a70524a9d 100644 --- a/src/gui/painting/qdrawhelper_avx2.cpp +++ b/src/gui/painting/qdrawhelper_avx2.cpp @@ -427,7 +427,7 @@ void QT_FASTCALL comp_func_Source_rgb64_avx2(QRgba64 *dst, const QRgba64 *src, i ::memcpy(dst, src, length * sizeof(QRgba64)); } else { const uint ca = const_alpha | (const_alpha << 8); // adjust to [0-65535] - const uint cia = 65535 - const_alpha; + const uint cia = 65535 - ca; int x = 0; @@ -493,7 +493,7 @@ void QT_FASTCALL comp_func_solid_SourceOver_rgb64_avx2(QRgba64 *destPixels, int if (const_alpha != 255) color = multiplyAlpha255(color, const_alpha); - const uint minusAlphaOfColor = ~ushort(color.alpha()); + const uint minusAlphaOfColor = 65535 - color.alpha(); int x = 0; quint64 *dst = (quint64 *) destPixels; const __m256i colorVector = _mm256_set1_epi64x(color); diff --git a/src/gui/painting/qdrawhelper_p.h b/src/gui/painting/qdrawhelper_p.h index 4c2fe87355..ebf215a3eb 100644 --- a/src/gui/painting/qdrawhelper_p.h +++ b/src/gui/painting/qdrawhelper_p.h @@ -1104,22 +1104,30 @@ inline int qBlue565(quint16 rgb) { return (b << 3) | (b >> 2); } +// We manually unalias the variables to make sure the compiler +// fully optimizes both aliased and unaliased cases. +#define UNALIASED_CONVERSION_LOOP(buffer, src, count, conversion) \ + if (src == buffer) { \ + for (int i = 0; i < count; ++i) \ + buffer[i] = conversion(buffer[i]); \ + } else { \ + for (int i = 0; i < count; ++i) \ + buffer[i] = conversion(src[i]); \ + } + static Q_ALWAYS_INLINE const uint *qt_convertARGB32ToARGB32PM(uint *buffer, const uint *src, int count) { - for (int i = 0; i < count; ++i) - buffer[i] = qPremultiply(src[i]); + UNALIASED_CONVERSION_LOOP(buffer, src, count, qPremultiply); return buffer; } static Q_ALWAYS_INLINE const uint *qt_convertRGBA8888ToARGB32PM(uint *buffer, const uint *src, int count) { - for (int i = 0; i < count; ++i) - buffer[i] = qPremultiply(RGBA2ARGB(src[i])); + UNALIASED_CONVERSION_LOOP(buffer, src, count, [](uint s) { return qPremultiply(RGBA2ARGB(s));}); return buffer; } - const uint qt_bayer_matrix[16][16] = { { 0x1, 0xc0, 0x30, 0xf0, 0xc, 0xcc, 0x3c, 0xfc, 0x3, 0xc3, 0x33, 0xf3, 0xf, 0xcf, 0x3f, 0xff}, diff --git a/src/gui/qtgui.tracepoints b/src/gui/qtgui.tracepoints new file mode 100644 index 0000000000..aa8a8ede57 --- /dev/null +++ b/src/gui/qtgui.tracepoints @@ -0,0 +1,8 @@ +qfontdatabase_addapplicationfont(const QString &filename) +qfontdatabase_load(const QString &family, int pointSize) +qfontdatabase_loadengine(const QString &family, int pointSize) +qfontdatabaseprivate_addappfont(const QString &fileName) +qguiapplicationprivate_init_entry() +qguiapplicationprivate_init_exit() +qguiapplicationprivate_processwsevents_entry(int type) +qguiapplicationprivate_processwsevents_exit(int type) diff --git a/src/gui/text/qfontdatabase.cpp b/src/gui/text/qfontdatabase.cpp index 4be2197c68..404a722e29 100644 --- a/src/gui/text/qfontdatabase.cpp +++ b/src/gui/text/qfontdatabase.cpp @@ -74,6 +74,7 @@ # define FM_DEBUG if (false) qDebug #endif +#include <qtgui_tracepoints_p.h> QT_BEGIN_NAMESPACE @@ -1009,6 +1010,8 @@ QFontEngine *loadEngine(int script, const QFontDef &request, QFontEngine *engine = loadSingleEngine(script, request, family, foundry, style, size); if (engine && !(request.styleStrategy & QFont::NoFontMerging) && !engine->symbol) { + Q_TRACE(qfontdatabase_loadengine, request.family, request.pointSize); + QPlatformFontDatabase *pfdb = QGuiApplicationPrivate::platformIntegration()->fontDatabase(); QFontEngineMulti *pfMultiEngine = pfdb->fontEngineMulti(engine, QChar::Script(script)); if (!request.fallBackFamilies.isEmpty()) { @@ -2439,6 +2442,8 @@ int QFontDatabasePrivate::addAppFont(const QByteArray &fontData, const QString & font.data = fontData; font.fileName = fileName; + Q_TRACE(qfontdatabaseprivate_addappfont, fileName); + int i; for (i = 0; i < applicationFonts.count(); ++i) if (applicationFonts.at(i).families.isEmpty()) @@ -2494,6 +2499,9 @@ int QFontDatabase::addApplicationFont(const QString &fileName) QFile f(fileName); if (!f.open(QIODevice::ReadOnly)) return -1; + + Q_TRACE(qfontdatabase_addapplicationfont, fileName); + data = f.readAll(); } QMutexLocker locker(fontDatabaseMutex()); @@ -2792,6 +2800,8 @@ void QFontDatabase::load(const QFontPrivate *d, int script) QFontEngine *fe = nullptr; + Q_TRACE(qfontdatabase_load, req.family, req.pointSize); + req.fallBackFamilies = fallBackFamilies; if (!req.fallBackFamilies.isEmpty()) req.family = req.fallBackFamilies.takeFirst(); |