diff options
Diffstat (limited to 'src/gui')
30 files changed, 280 insertions, 144 deletions
diff --git a/src/gui/accessible/linux/qspi_struct_marshallers.cpp b/src/gui/accessible/linux/qspi_struct_marshallers.cpp index 241bad502e3..5e171244cd0 100644 --- a/src/gui/accessible/linux/qspi_struct_marshallers.cpp +++ b/src/gui/accessible/linux/qspi_struct_marshallers.cpp @@ -28,7 +28,6 @@ QT_IMPL_METATYPE_EXTERN(QSpiRelationArray) QT_IMPL_METATYPE_EXTERN(QSpiTextRange) QT_IMPL_METATYPE_EXTERN(QSpiTextRangeList) QT_IMPL_METATYPE_EXTERN(QSpiAttributeSet) -QT_IMPL_METATYPE_EXTERN(QSpiAppUpdate) QT_IMPL_METATYPE_EXTERN(QSpiDeviceEvent) QT_IMPL_METATYPE_EXTERN(QSpiMatchRule) @@ -134,23 +133,6 @@ const QDBusArgument &operator>>(const QDBusArgument &argument, QSpiEventListener return argument; } -/* QSpiAppUpdate */ -/*---------------------------------------------------------------------------*/ - -QDBusArgument &operator<<(QDBusArgument &argument, const QSpiAppUpdate &update) { - argument.beginStructure(); - argument << update.type << update.address; - argument.endStructure(); - return argument; -} - -const QDBusArgument &operator>>(const QDBusArgument &argument, QSpiAppUpdate &update) { - argument.beginStructure(); - argument >> update.type >> update.address; - argument.endStructure(); - return argument; -} - /* QSpiRelationArrayEntry */ /*---------------------------------------------------------------------------*/ @@ -245,7 +227,6 @@ void qSpiInitializeStructTypes() qDBusRegisterMetaType<QSpiEventListenerArray>(); qDBusRegisterMetaType<QSpiDeviceEvent>(); qDBusRegisterMetaType<QSpiMatchRule>(); - qDBusRegisterMetaType<QSpiAppUpdate>(); qDBusRegisterMetaType<QSpiRelationArrayEntry>(); qDBusRegisterMetaType<QSpiRelationArray>(); } diff --git a/src/gui/accessible/linux/qspi_struct_marshallers_p.h b/src/gui/accessible/linux/qspi_struct_marshallers_p.h index fe2d52fb4c2..4c446a97040 100644 --- a/src/gui/accessible/linux/qspi_struct_marshallers_p.h +++ b/src/gui/accessible/linux/qspi_struct_marshallers_p.h @@ -106,21 +106,6 @@ Q_DECLARE_TYPEINFO(QSpiTextRange, Q_RELOCATABLE_TYPE); typedef QList<QSpiTextRange> QSpiTextRangeList; typedef QMap <QString, QString> QSpiAttributeSet; -enum QSpiAppUpdateType { - QSPI_APP_UPDATE_ADDED = 0, - QSPI_APP_UPDATE_REMOVED = 1 -}; -Q_DECLARE_TYPEINFO(QSpiAppUpdateType, Q_PRIMITIVE_TYPE); - -struct QSpiAppUpdate { - int type; /* Is an application added or removed */ - QString address; /* D-Bus address of application added or removed */ -}; -Q_DECLARE_TYPEINFO(QSpiAppUpdate, Q_RELOCATABLE_TYPE); - -QDBusArgument &operator<<(QDBusArgument &argument, const QSpiAppUpdate &update); -const QDBusArgument &operator>>(const QDBusArgument &argument, QSpiAppUpdate &update); - struct QSpiDeviceEvent { unsigned int type; int id; @@ -171,7 +156,6 @@ QT_DECL_METATYPE_EXTERN(QSpiRelationArray, /* not exported */) QT_DECL_METATYPE_EXTERN(QSpiTextRange, /* not exported */) QT_DECL_METATYPE_EXTERN(QSpiTextRangeList, /* not exported */) QT_DECL_METATYPE_EXTERN(QSpiAttributeSet, /* not exported */) -QT_DECL_METATYPE_EXTERN(QSpiAppUpdate, /* not exported */) QT_DECL_METATYPE_EXTERN(QSpiDeviceEvent, /* not exported */) QT_DECL_METATYPE_EXTERN(QSpiMatchRule, /* not exported */) diff --git a/src/gui/accessible/qaccessible_base.h b/src/gui/accessible/qaccessible_base.h index 3881c6346a0..04efeddf06f 100644 --- a/src/gui/accessible/qaccessible_base.h +++ b/src/gui/accessible/qaccessible_base.h @@ -175,11 +175,15 @@ public: // quint64 alertMedium : 1; // quint64 alertHigh : 1; + Q_DECL_UNUSED_MEMBER quint64 qt_reserved : 27; + State() { std::memset(this, 0, sizeof(State)); } friend inline bool operator==(const QAccessible::State &first, const QAccessible::State &second) { + static_assert(std::has_unique_object_representations_v<State>, + "memcmp() cannot be used on types with padding"); return std::memcmp(&first, &second, sizeof(QAccessible::State)) == 0; } }; diff --git a/src/gui/accessible/qaccessiblecache.cpp b/src/gui/accessible/qaccessiblecache.cpp index a8255e04c02..311b53aeaa3 100644 --- a/src/gui/accessible/qaccessiblecache.cpp +++ b/src/gui/accessible/qaccessiblecache.cpp @@ -4,6 +4,7 @@ #include "qaccessiblecache_p.h" #include <QtCore/qdebug.h> #include <QtCore/qloggingcategory.h> +#include <private/qguiapplication_p.h> #if QT_CONFIG(accessibility) @@ -176,10 +177,28 @@ void QAccessibleCache::sendObjectDestroyedEvent(QObject *obj) void QAccessibleCache::deleteInterface(QAccessible::Id id, QObject *obj) { - QAccessibleInterface *iface = idToInterface.take(id); + const auto it = idToInterface.find(id); + if (it == idToInterface.end()) // the interface may be deleted already + return; + + QAccessibleInterface *iface = *it; qCDebug(lcAccessibilityCache) << "delete - id:" << id << " iface:" << iface; - if (!iface) // the interface may be deleted already + if (!iface) { + idToInterface.erase(it); return; + } + + // QObjects sends this from their destructor, but + // the object less interfaces calls deleteInterface + // directly + if (!obj && !iface->object()) { + if (QGuiApplicationPrivate::is_app_running && !QGuiApplicationPrivate::is_app_closing && QAccessible::isActive()) { + QAccessibleObjectDestroyedEvent event(id); + QAccessible::updateAccessibility(&event); + } + } + + idToInterface.erase(it); interfaceToId.take(iface); if (!obj) obj = iface->object(); diff --git a/src/gui/image/qabstractfileiconprovider.cpp b/src/gui/image/qabstractfileiconprovider.cpp index 78777ec115a..ad646a6b89a 100644 --- a/src/gui/image/qabstractfileiconprovider.cpp +++ b/src/gui/image/qabstractfileiconprovider.cpp @@ -288,3 +288,5 @@ QString QAbstractFileIconProvider::type(const QFileInfo &info) const } QT_END_NAMESPACE + +#include "moc_qabstractfileiconprovider.cpp" diff --git a/src/gui/kernel/qguiapplication_p.h b/src/gui/kernel/qguiapplication_p.h index cb4702b5f7e..633ae7895ba 100644 --- a/src/gui/kernel/qguiapplication_p.h +++ b/src/gui/kernel/qguiapplication_p.h @@ -228,8 +228,8 @@ public: // to use single-point precision. friend constexpr bool operator==(const QLastCursorPosition &p1, const QPointF &p2) noexcept { - return qFuzzyCompare(float(p1.x()), float(p2.x())) - && qFuzzyCompare(float(p1.y()), float(p2.y())); + return QtPrivate::fuzzyCompare(float(p1.x()), float(p2.x())) + && QtPrivate::fuzzyCompare(float(p1.y()), float(p2.y())); } friend constexpr bool operator!=(const QLastCursorPosition &p1, const QPointF &p2) noexcept { diff --git a/src/gui/kernel/qsurface.cpp b/src/gui/kernel/qsurface.cpp index e2bafa73988..f361ec86c2d 100644 --- a/src/gui/kernel/qsurface.cpp +++ b/src/gui/kernel/qsurface.cpp @@ -68,7 +68,10 @@ QT_IMPL_METATYPE_EXTERN_TAGGED(QSurface*, QSurface_ptr) bool QSurface::supportsOpenGL() const { - return surfaceType() == OpenGLSurface; + static bool openGLOnRasterSurfaceSupported = + QGuiApplicationPrivate::instance()->platformIntegration()->hasCapability(QPlatformIntegration::OpenGLOnRasterSurface); + return surfaceType() == OpenGLSurface + || (surfaceType() == RasterSurface && openGLOnRasterSurfaceSupported); } /*! diff --git a/src/gui/math3d/qmatrix4x4.cpp b/src/gui/math3d/qmatrix4x4.cpp index f6a06fd47ca..ec6e696ba00 100644 --- a/src/gui/math3d/qmatrix4x4.cpp +++ b/src/gui/math3d/qmatrix4x4.cpp @@ -294,6 +294,7 @@ double QMatrix4x4::determinant() const if ((flagBits & ~(Translation | Rotation2D | Rotation)) == Identity) return 1.0; + Q_DECL_UNINITIALIZED double mm[4][4]; copyToDoubles(m, mm); if (flagBits < Rotation2D) @@ -355,8 +356,10 @@ QMatrix4x4 QMatrix4x4::inverted(bool *invertible) const *invertible = true; return orthonormalInverse(); } else if (flagBits < Perspective) { + Q_DECL_UNINITIALIZED QMatrix4x4 inv(Qt::Uninitialized); + Q_DECL_UNINITIALIZED double mm[4][4]; copyToDoubles(m, mm); @@ -391,8 +394,10 @@ QMatrix4x4 QMatrix4x4::inverted(bool *invertible) const return inv; } + Q_DECL_UNINITIALIZED QMatrix4x4 inv(Qt::Uninitialized); + Q_DECL_UNINITIALIZED double mm[4][4]; copyToDoubles(m, mm); @@ -465,6 +470,7 @@ QMatrix3x3 QMatrix4x4::normalMatrix() const return inv; } + Q_DECL_UNINITIALIZED double mm[4][4]; copyToDoubles(m, mm); double det = matrixDet3(mm, 0, 1, 2, 0, 1, 2); @@ -493,6 +499,7 @@ QMatrix3x3 QMatrix4x4::normalMatrix() const */ QMatrix4x4 QMatrix4x4::transposed() const { + Q_DECL_UNINITIALIZED QMatrix4x4 result(Qt::Uninitialized); for (int row = 0; row < 4; ++row) { for (int col = 0; col < 4; ++col) { @@ -709,6 +716,7 @@ QMatrix4x4& QMatrix4x4::operator/=(float divisor) */ QMatrix4x4 operator/(const QMatrix4x4& matrix, float divisor) { + Q_DECL_UNINITIALIZED QMatrix4x4 m(Qt::Uninitialized); m.m[0][0] = matrix.m[0][0] / divisor; m.m[0][1] = matrix.m[0][1] / divisor; @@ -738,22 +746,22 @@ QMatrix4x4 operator/(const QMatrix4x4& matrix, float divisor) */ bool qFuzzyCompare(const QMatrix4x4& m1, const QMatrix4x4& m2) noexcept { - return qFuzzyCompare(m1.m[0][0], m2.m[0][0]) && - qFuzzyCompare(m1.m[0][1], m2.m[0][1]) && - qFuzzyCompare(m1.m[0][2], m2.m[0][2]) && - qFuzzyCompare(m1.m[0][3], m2.m[0][3]) && - qFuzzyCompare(m1.m[1][0], m2.m[1][0]) && - qFuzzyCompare(m1.m[1][1], m2.m[1][1]) && - qFuzzyCompare(m1.m[1][2], m2.m[1][2]) && - qFuzzyCompare(m1.m[1][3], m2.m[1][3]) && - qFuzzyCompare(m1.m[2][0], m2.m[2][0]) && - qFuzzyCompare(m1.m[2][1], m2.m[2][1]) && - qFuzzyCompare(m1.m[2][2], m2.m[2][2]) && - qFuzzyCompare(m1.m[2][3], m2.m[2][3]) && - qFuzzyCompare(m1.m[3][0], m2.m[3][0]) && - qFuzzyCompare(m1.m[3][1], m2.m[3][1]) && - qFuzzyCompare(m1.m[3][2], m2.m[3][2]) && - qFuzzyCompare(m1.m[3][3], m2.m[3][3]); + return QtPrivate::fuzzyCompare(m1.m[0][0], m2.m[0][0]) + && QtPrivate::fuzzyCompare(m1.m[0][1], m2.m[0][1]) + && QtPrivate::fuzzyCompare(m1.m[0][2], m2.m[0][2]) + && QtPrivate::fuzzyCompare(m1.m[0][3], m2.m[0][3]) + && QtPrivate::fuzzyCompare(m1.m[1][0], m2.m[1][0]) + && QtPrivate::fuzzyCompare(m1.m[1][1], m2.m[1][1]) + && QtPrivate::fuzzyCompare(m1.m[1][2], m2.m[1][2]) + && QtPrivate::fuzzyCompare(m1.m[1][3], m2.m[1][3]) + && QtPrivate::fuzzyCompare(m1.m[2][0], m2.m[2][0]) + && QtPrivate::fuzzyCompare(m1.m[2][1], m2.m[2][1]) + && QtPrivate::fuzzyCompare(m1.m[2][2], m2.m[2][2]) + && QtPrivate::fuzzyCompare(m1.m[2][3], m2.m[2][3]) + && QtPrivate::fuzzyCompare(m1.m[3][0], m2.m[3][0]) + && QtPrivate::fuzzyCompare(m1.m[3][1], m2.m[3][1]) + && QtPrivate::fuzzyCompare(m1.m[3][2], m2.m[3][2]) + && QtPrivate::fuzzyCompare(m1.m[3][3], m2.m[3][3]); } @@ -1141,6 +1149,7 @@ void QMatrix4x4::rotate(float angle, float x, float y, float z) z = float(double(z) / len); } float ic = 1.0f - c; + Q_DECL_UNINITIALIZED QMatrix4x4 rot(Qt::Uninitialized); rot.m[0][0] = x * x * ic + c; rot.m[1][0] = x * y * ic - z * s; @@ -1244,6 +1253,7 @@ void QMatrix4x4::projectedRotate(float angle, float x, float y, float z, float d z = float(double(z) / len); } const float ic = 1.0f - c; + Q_DECL_UNINITIALIZED QMatrix4x4 rot(Qt::Uninitialized); rot.m[0][0] = x * x * ic + c; rot.m[1][0] = x * y * ic - z * s; @@ -1306,6 +1316,7 @@ void QMatrix4x4::rotate(const QQuaternion& quaternion) // Algorithm from: // http://www.j3d.org/matrix_faq/matrfaq_latest.html#Q54 + Q_DECL_UNINITIALIZED QMatrix4x4 m(Qt::Uninitialized); const float f2x = quaternion.x() + quaternion.x(); @@ -1393,6 +1404,7 @@ void QMatrix4x4::ortho(float left, float right, float bottom, float top, float n const float width = right - left; const float invheight = top - bottom; const float clip = farPlane - nearPlane; + Q_DECL_UNINITIALIZED QMatrix4x4 m(Qt::Uninitialized); m.m[0][0] = 2.0f / width; m.m[1][0] = 0.0f; @@ -1431,6 +1443,7 @@ void QMatrix4x4::frustum(float left, float right, float bottom, float top, float return; // Construct the projection. + Q_DECL_UNINITIALIZED QMatrix4x4 m(Qt::Uninitialized); const float width = right - left; const float invheight = top - bottom; @@ -1474,6 +1487,7 @@ void QMatrix4x4::perspective(float verticalAngle, float aspectRatio, float nearP return; // Construct the projection. + Q_DECL_UNINITIALIZED QMatrix4x4 m(Qt::Uninitialized); const float radians = qDegreesToRadians(verticalAngle / 2.0f); const float sine = std::sin(radians); @@ -1524,6 +1538,7 @@ void QMatrix4x4::lookAt(const QVector3D& eye, const QVector3D& center, const QVe QVector3D side = QVector3D::crossProduct(forward, up).normalized(); QVector3D upVector = QVector3D::crossProduct(side, forward); + Q_DECL_UNINITIALIZED QMatrix4x4 m(Qt::Uninitialized); m.m[0][0] = side.x(); m.m[1][0] = side.y(); @@ -1573,6 +1588,7 @@ void QMatrix4x4::viewport(float left, float bottom, float width, float height, f const float w2 = width / 2.0f; const float h2 = height / 2.0f; + Q_DECL_UNINITIALIZED QMatrix4x4 m(Qt::Uninitialized); m.m[0][0] = w2; m.m[1][0] = 0.0f; @@ -1871,6 +1887,7 @@ QRectF QMatrix4x4::mapRect(const QRectF& rect) const // of just rotations and translations. QMatrix4x4 QMatrix4x4::orthonormalInverse() const { + Q_DECL_UNINITIALIZED QMatrix4x4 result(Qt::Uninitialized); result.m[0][0] = m[0][0]; @@ -1943,6 +1960,7 @@ void QMatrix4x4::optimize() flagBits &= ~Scale; } else { // If the columns are orthonormal and form a right-handed system, then there is no scale. + Q_DECL_UNINITIALIZED double mm[4][4]; copyToDoubles(m, mm); double det = matrixDet2(mm, 0, 1, 0, 1); @@ -1957,6 +1975,7 @@ void QMatrix4x4::optimize() } } else { // If the columns are orthonormal and form a right-handed system, then there is no scale. + Q_DECL_UNINITIALIZED double mm[4][4]; copyToDoubles(m, mm); double det = matrixDet3(mm, 0, 1, 2, 0, 1, 2); diff --git a/src/gui/math3d/qmatrix4x4.h b/src/gui/math3d/qmatrix4x4.h index 2ba274d4517..2a801905ce0 100644 --- a/src/gui/math3d/qmatrix4x4.h +++ b/src/gui/math3d/qmatrix4x4.h @@ -564,6 +564,7 @@ inline bool QMatrix4x4::operator!=(const QMatrix4x4& other) const inline QMatrix4x4 operator+(const QMatrix4x4& m1, const QMatrix4x4& m2) { + Q_DECL_UNINITIALIZED QMatrix4x4 m(Qt::Uninitialized); m.m[0][0] = m1.m[0][0] + m2.m[0][0]; m.m[0][1] = m1.m[0][1] + m2.m[0][1]; @@ -586,6 +587,7 @@ inline QMatrix4x4 operator+(const QMatrix4x4& m1, const QMatrix4x4& m2) inline QMatrix4x4 operator-(const QMatrix4x4& m1, const QMatrix4x4& m2) { + Q_DECL_UNINITIALIZED QMatrix4x4 m(Qt::Uninitialized); m.m[0][0] = m1.m[0][0] - m2.m[0][0]; m.m[0][1] = m1.m[0][1] - m2.m[0][1]; @@ -608,21 +610,34 @@ inline QMatrix4x4 operator-(const QMatrix4x4& m1, const QMatrix4x4& m2) inline QMatrix4x4 operator*(const QMatrix4x4& m1, const QMatrix4x4& m2) { + Q_DECL_UNINITIALIZED + QMatrix4x4 m(Qt::Uninitialized); QMatrix4x4::Flags flagBits = m1.flagBits | m2.flagBits; if (flagBits.toInt() < QMatrix4x4::Rotation2D) { - QMatrix4x4 m = m1; - m.m[3][0] += m.m[0][0] * m2.m[3][0]; - m.m[3][1] += m.m[1][1] * m2.m[3][1]; - m.m[3][2] += m.m[2][2] * m2.m[3][2]; - - m.m[0][0] *= m2.m[0][0]; - m.m[1][1] *= m2.m[1][1]; - m.m[2][2] *= m2.m[2][2]; + // Scale | Translation + m.m[0][0] = m1.m[0][0] * m2.m[0][0]; + m.m[0][1] = 0.0f; + m.m[0][2] = 0.0f; + m.m[0][3] = 0.0f; + + m.m[1][0] = 0.0f; + m.m[1][1] = m1.m[1][1] * m2.m[1][1]; + m.m[1][2] = 0.0f; + m.m[1][3] = 0.0f; + + m.m[2][0] = 0.0f; + m.m[2][1] = 0.0f; + m.m[2][2] = m1.m[2][2] * m2.m[2][2]; + m.m[2][3] = 0.0f; + + m.m[3][0] = m1.m[3][0] + m1.m[0][0] * m2.m[3][0]; + m.m[3][1] = m1.m[3][1] + m1.m[1][1] * m2.m[3][1]; + m.m[3][2] = m1.m[3][2] + m1.m[2][2] * m2.m[3][2]; + m.m[3][3] = 1.0f; m.flagBits = flagBits; return m; } - QMatrix4x4 m(Qt::Uninitialized); m.m[0][0] = m1.m[0][0] * m2.m[0][0] + m1.m[1][0] * m2.m[0][1] + m1.m[2][0] * m2.m[0][2] @@ -843,6 +858,7 @@ inline QPointF operator*(const QMatrix4x4& matrix, const QPointF& point) inline QMatrix4x4 operator-(const QMatrix4x4& matrix) { + Q_DECL_UNINITIALIZED QMatrix4x4 m(Qt::Uninitialized); m.m[0][0] = -matrix.m[0][0]; m.m[0][1] = -matrix.m[0][1]; @@ -865,6 +881,7 @@ inline QMatrix4x4 operator-(const QMatrix4x4& matrix) inline QMatrix4x4 operator*(float factor, const QMatrix4x4& matrix) { + Q_DECL_UNINITIALIZED QMatrix4x4 m(Qt::Uninitialized); m.m[0][0] = matrix.m[0][0] * factor; m.m[0][1] = matrix.m[0][1] * factor; @@ -887,6 +904,7 @@ inline QMatrix4x4 operator*(float factor, const QMatrix4x4& matrix) inline QMatrix4x4 operator*(const QMatrix4x4& matrix, float factor) { + Q_DECL_UNINITIALIZED QMatrix4x4 m(Qt::Uninitialized); m.m[0][0] = matrix.m[0][0] * factor; m.m[0][1] = matrix.m[0][1] * factor; diff --git a/src/gui/math3d/qquaternion.cpp b/src/gui/math3d/qquaternion.cpp index a675f59eb1f..57587322ea5 100644 --- a/src/gui/math3d/qquaternion.cpp +++ b/src/gui/math3d/qquaternion.cpp @@ -409,7 +409,7 @@ QQuaternion QQuaternion::fromAxisAndAngle (float x, float y, float z, float angle) { float length = qHypot(x, y, z); - if (!qFuzzyCompare(length, 1.0f) && !qFuzzyIsNull(length)) { + if (!qFuzzyIsNull(length) && !qFuzzyCompare(length, 1.0f)) { x /= length; y /= length; z /= length; diff --git a/src/gui/math3d/qquaternion.h b/src/gui/math3d/qquaternion.h index a7b1d432df7..c92e7177199 100644 --- a/src/gui/math3d/qquaternion.h +++ b/src/gui/math3d/qquaternion.h @@ -305,10 +305,10 @@ constexpr QQuaternion operator/(const QQuaternion &quaternion, float divisor) constexpr bool qFuzzyCompare(const QQuaternion &q1, const QQuaternion &q2) noexcept { - return qFuzzyCompare(q1.wp, q2.wp) && - qFuzzyCompare(q1.xp, q2.xp) && - qFuzzyCompare(q1.yp, q2.yp) && - qFuzzyCompare(q1.zp, q2.zp); + return QtPrivate::fuzzyCompare(q1.wp, q2.wp) + && QtPrivate::fuzzyCompare(q1.xp, q2.xp) + && QtPrivate::fuzzyCompare(q1.yp, q2.yp) + && QtPrivate::fuzzyCompare(q1.zp, q2.zp); } #if QT_GUI_INLINE_IMPL_SINCE(6, 11) diff --git a/src/gui/math3d/qvectornd.cpp b/src/gui/math3d/qvectornd.cpp index dcd7bdbcf80..ee070b2b5be 100644 --- a/src/gui/math3d/qvectornd.cpp +++ b/src/gui/math3d/qvectornd.cpp @@ -375,7 +375,8 @@ QT_BEGIN_NAMESPACE */ bool qFuzzyCompare(QVector2D v1, QVector2D v2) noexcept { - return qFuzzyCompare(v1.v[0], v2.v[0]) && qFuzzyCompare(v1.v[1], v2.v[1]); + return QtPrivate::fuzzyCompare(v1.v[0], v2.v[0]) + && QtPrivate::fuzzyCompare(v1.v[1], v2.v[1]); } #ifndef QT_NO_VECTOR3D @@ -467,7 +468,6 @@ QDataStream &operator>>(QDataStream &stream, QVector2D &vector) float x, y; stream >> x; stream >> y; - Q_ASSERT(qIsFinite(x) && qIsFinite(y)); vector.setX(x); vector.setY(y); return stream; @@ -980,9 +980,9 @@ QVector3D QVector3D::unproject(const QMatrix4x4 &modelView, const QMatrix4x4 &pr */ bool qFuzzyCompare(QVector3D v1, QVector3D v2) noexcept { - return qFuzzyCompare(v1.v[0], v2.v[0]) && - qFuzzyCompare(v1.v[1], v2.v[1]) && - qFuzzyCompare(v1.v[2], v2.v[2]); + return QtPrivate::fuzzyCompare(v1.v[0], v2.v[0]) + && QtPrivate::fuzzyCompare(v1.v[1], v2.v[1]) + && QtPrivate::fuzzyCompare(v1.v[2], v2.v[2]); } #ifndef QT_NO_VECTOR2D @@ -1098,7 +1098,6 @@ QDataStream &operator>>(QDataStream &stream, QVector3D &vector) stream >> x; stream >> y; stream >> z; - Q_ASSERT(qIsFinite(x) && qIsFinite(y) && qIsFinite(z)); vector.setX(x); vector.setY(y); vector.setZ(z); @@ -1503,10 +1502,10 @@ QDataStream &operator>>(QDataStream &stream, QVector3D &vector) */ bool qFuzzyCompare(QVector4D v1, QVector4D v2) noexcept { - return qFuzzyCompare(v1.v[0], v2.v[0]) && - qFuzzyCompare(v1.v[1], v2.v[1]) && - qFuzzyCompare(v1.v[2], v2.v[2]) && - qFuzzyCompare(v1.v[3], v2.v[3]); + return QtPrivate::fuzzyCompare(v1.v[0], v2.v[0]) + && QtPrivate::fuzzyCompare(v1.v[1], v2.v[1]) + && QtPrivate::fuzzyCompare(v1.v[2], v2.v[2]) + && QtPrivate::fuzzyCompare(v1.v[3], v2.v[3]); } #ifndef QT_NO_VECTOR2D @@ -1627,7 +1626,6 @@ QDataStream &operator>>(QDataStream &stream, QVector4D &vector) stream >> y; stream >> z; stream >> w; - Q_ASSERT(qIsFinite(x) && qIsFinite(y) && qIsFinite(z) && qIsFinite(w)); vector.setX(x); vector.setY(y); vector.setZ(z); diff --git a/src/gui/opengl/platform/egl/qeglplatformcontext.cpp b/src/gui/opengl/platform/egl/qeglplatformcontext.cpp index e56504833d1..350968b87d4 100644 --- a/src/gui/opengl/platform/egl/qeglplatformcontext.cpp +++ b/src/gui/opengl/platform/egl/qeglplatformcontext.cpp @@ -104,6 +104,14 @@ QT_BEGIN_NAMESPACE #define GL_LOSE_CONTEXT_ON_RESET 0x8252 #endif +// Constants from GL_EXT_robustness. +#ifndef GL_RESET_NOTIFICATION_STRATEGY_EXT +#define GL_RESET_NOTIFICATION_STRATEGY_EXT 0x8256 +#endif +#ifndef GL_LOSE_CONTEXT_ON_RESET_EXT +#define GL_LOSE_CONTEXT_ON_RESET_EXT 0x8252 +#endif + // Constants from EGL_NV_robustness_video_memory_purge #ifndef EGL_GENERATE_RESET_ON_VIDEO_MEMORY_PURGE_NV #define EGL_GENERATE_RESET_ON_VIDEO_MEMORY_PURGE_NV 0x334C @@ -452,11 +460,16 @@ void QEGLPlatformContext::updateFormatFromGL() } } } - if (hasExtension("GL_ARB_robustness")) { + if (m_format.renderableType() == QSurfaceFormat::OpenGL && hasExtension("GL_ARB_robustness")) { GLint value = 0; glGetIntegerv(GL_RESET_NOTIFICATION_STRATEGY, &value); if (value == GL_LOSE_CONTEXT_ON_RESET) m_format.setOption(QSurfaceFormat::ResetNotification); + } else if (m_format.renderableType() == QSurfaceFormat::OpenGLES && hasExtension("GL_EXT_robustness")) { + GLint value = 0; + glGetIntegerv(GL_RESET_NOTIFICATION_STRATEGY_EXT, &value); + if (value == GL_LOSE_CONTEXT_ON_RESET_EXT) + m_format.setOption(QSurfaceFormat::ResetNotification); } } runGLChecks(); diff --git a/src/gui/painting/qdrawhelper.cpp b/src/gui/painting/qdrawhelper.cpp index 04433c7703a..697ede42d92 100644 --- a/src/gui/painting/qdrawhelper.cpp +++ b/src/gui/painting/qdrawhelper.cpp @@ -930,7 +930,7 @@ static inline bool canUseFastMatrixPath(const qreal cx, const qreal cy, const qs minc = std::min(minc, std::min(fx, fy)); maxc = std::max(maxc, std::max(fx, fy)); - return minc >= std::numeric_limits<int>::min() && maxc <= std::numeric_limits<int>::max(); + return minc >= std::numeric_limits<int>::min() && maxc <= qreal(std::numeric_limits<int>::max()); } template<TextureBlendType blendType, QPixelLayout::BPP bpp, typename T> @@ -5179,7 +5179,7 @@ static inline bool calculate_fixed_gradient_factors(int count, const QT_FT_Span const int gss = GRADIENT_STOPTABLE_SIZE - 1; qreal ryinc = linear.dy * data->m22 * gss * FIXPT_SIZE; qreal roff = (linear.dy * (data->m22 * qreal(0.5) + data->dy) + linear.off) * gss * FIXPT_SIZE; - const int limit = std::numeric_limits<int>::max() - FIXPT_SIZE; + const qreal limit = qreal(std::numeric_limits<int>::max() - FIXPT_SIZE); if (count && (std::fabs(ryinc) < limit) && (std::fabs(roff) < limit) && (std::fabs(ryinc * spans->y + roff) < limit) && (std::fabs(ryinc * (spans + count - 1)->y + roff) < limit)) { diff --git a/src/gui/painting/qpagelayout.cpp b/src/gui/painting/qpagelayout.cpp index e6f346dcdf2..17fb6491b75 100644 --- a/src/gui/painting/qpagelayout.cpp +++ b/src/gui/painting/qpagelayout.cpp @@ -606,7 +606,7 @@ bool QPageLayout::setLeftMargin(qreal leftMargin, OutOfBoundsPolicy outOfBoundsP if (d->m_mode == StandardMode && outOfBoundsPolicy == OutOfBoundsPolicy::Clamp) leftMargin = qBound(d->m_minMargins.left(), leftMargin, d->m_maxMargins.left()); - if (qFuzzyCompare(leftMargin, d->m_margins.left())) + if (QtPrivate::fuzzyCompare(leftMargin, d->m_margins.left())) return true; if (d->m_mode == FullPageMode @@ -637,7 +637,7 @@ bool QPageLayout::setRightMargin(qreal rightMargin, OutOfBoundsPolicy outOfBound if (d->m_mode == StandardMode && outOfBoundsPolicy == OutOfBoundsPolicy::Clamp) rightMargin = qBound(d->m_minMargins.right(), rightMargin, d->m_maxMargins.right()); - if (qFuzzyCompare(rightMargin, d->m_margins.right())) + if (QtPrivate::fuzzyCompare(rightMargin, d->m_margins.right())) return true; if (d->m_mode == FullPageMode @@ -668,7 +668,7 @@ bool QPageLayout::setTopMargin(qreal topMargin, OutOfBoundsPolicy outOfBoundsPol if (d->m_mode == StandardMode && outOfBoundsPolicy == OutOfBoundsPolicy::Clamp) topMargin = qBound(d->m_minMargins.top(), topMargin, d->m_maxMargins.top()); - if (qFuzzyCompare(topMargin, d->m_margins.top())) + if (QtPrivate::fuzzyCompare(topMargin, d->m_margins.top())) return true; if (d->m_mode == FullPageMode @@ -699,7 +699,7 @@ bool QPageLayout::setBottomMargin(qreal bottomMargin, OutOfBoundsPolicy outOfBou if (d->m_mode == StandardMode && outOfBoundsPolicy == OutOfBoundsPolicy::Clamp) bottomMargin = qBound(d->m_minMargins.bottom(), bottomMargin, d->m_maxMargins.bottom()); - if (qFuzzyCompare(bottomMargin, d->m_margins.bottom())) + if (QtPrivate::fuzzyCompare(bottomMargin, d->m_margins.bottom())) return true; if (d->m_mode == FullPageMode diff --git a/src/gui/painting/qpaintengine_raster.cpp b/src/gui/painting/qpaintengine_raster.cpp index 74321705ff5..047be5f1c3d 100644 --- a/src/gui/painting/qpaintengine_raster.cpp +++ b/src/gui/painting/qpaintengine_raster.cpp @@ -2952,9 +2952,9 @@ inline bool QRasterPaintEnginePrivate::isUnclipped(const QRectF &rect, int penWidth) const { const QRectF norm = rect.normalized(); - if (norm.left() <= INT_MIN || norm.top() <= INT_MIN - || norm.right() > INT_MAX || norm.bottom() > INT_MAX - || norm.width() > INT_MAX || norm.height() > INT_MAX) + if (norm.left() <= qreal(INT_MIN) || norm.top() <= qreal(INT_MIN) + || norm.right() > qreal(INT_MAX) || norm.bottom() > qreal(INT_MAX) + || norm.width() > qreal(INT_MAX) || norm.height() > qreal(INT_MAX)) return false; return isUnclipped(norm.toAlignedRect(), penWidth); } diff --git a/src/gui/rhi/qrhimetal.mm b/src/gui/rhi/qrhimetal.mm index 7fa05f69232..0d4ce909daa 100644 --- a/src/gui/rhi/qrhimetal.mm +++ b/src/gui/rhi/qrhimetal.mm @@ -26,6 +26,8 @@ #include <Metal/Metal.h> +#include <utility> // for std::pair + QT_BEGIN_NAMESPACE /* @@ -1674,12 +1676,12 @@ void QRhiMetal::setShaderResources(QRhiCommandBuffer *cb, QRhiShaderResourceBind if (needsBufferSizeBuffer) { QMetalBuffer *bufD = nullptr; - QVarLengthArray<QPair<QMetalShader *, QRhiShaderResourceBinding::StageFlag>, 4> shaders; + QVarLengthArray<std::pair<QMetalShader *, QRhiShaderResourceBinding::StageFlag>, 4> shaders; if (compPsD) { bufD = compPsD->d->bufferSizeBuffer; Q_ASSERT(compPsD->d->cs.nativeShaderInfo.extraBufferBindings.contains(QShaderPrivate::MslBufferSizeBufferBinding)); - shaders.append(qMakePair(&compPsD->d->cs, QRhiShaderResourceBinding::StageFlag::ComputeStage)); + shaders.append({&compPsD->d->cs, QRhiShaderResourceBinding::StageFlag::ComputeStage}); } else { bufD = gfxPsD->d->bufferSizeBuffer; if (gfxPsD->d->tess.enabled) { @@ -1706,24 +1708,24 @@ void QRhiMetal::setShaderResources(QRhiCommandBuffer *cb, QRhiShaderResourceBind == gfxPsD->d->tess.compVs[2].nativeShaderInfo.extraBufferBindings[QShaderPrivate::MslBufferSizeBufferBinding]); if (gfxPsD->d->tess.compVs[0].nativeShaderInfo.extraBufferBindings.contains(QShaderPrivate::MslBufferSizeBufferBinding)) - shaders.append(qMakePair(&gfxPsD->d->tess.compVs[0], QRhiShaderResourceBinding::StageFlag::VertexStage)); + shaders.append({&gfxPsD->d->tess.compVs[0], QRhiShaderResourceBinding::StageFlag::VertexStage}); if (gfxPsD->d->tess.compTesc.nativeShaderInfo.extraBufferBindings.contains(QShaderPrivate::MslBufferSizeBufferBinding)) - shaders.append(qMakePair(&gfxPsD->d->tess.compTesc, QRhiShaderResourceBinding::StageFlag::TessellationControlStage)); + shaders.append({&gfxPsD->d->tess.compTesc, QRhiShaderResourceBinding::StageFlag::TessellationControlStage}); if (gfxPsD->d->tess.vertTese.nativeShaderInfo.extraBufferBindings.contains(QShaderPrivate::MslBufferSizeBufferBinding)) - shaders.append(qMakePair(&gfxPsD->d->tess.vertTese, QRhiShaderResourceBinding::StageFlag::TessellationEvaluationStage)); + shaders.append({&gfxPsD->d->tess.vertTese, QRhiShaderResourceBinding::StageFlag::TessellationEvaluationStage}); } else { if (gfxPsD->d->vs.nativeShaderInfo.extraBufferBindings.contains(QShaderPrivate::MslBufferSizeBufferBinding)) - shaders.append(qMakePair(&gfxPsD->d->vs, QRhiShaderResourceBinding::StageFlag::VertexStage)); + shaders.append({&gfxPsD->d->vs, QRhiShaderResourceBinding::StageFlag::VertexStage}); } if (gfxPsD->d->fs.nativeShaderInfo.extraBufferBindings.contains(QShaderPrivate::MslBufferSizeBufferBinding)) - shaders.append(qMakePair(&gfxPsD->d->fs, QRhiShaderResourceBinding::StageFlag::FragmentStage)); + shaders.append({&gfxPsD->d->fs, QRhiShaderResourceBinding::StageFlag::FragmentStage}); } quint32 offset = 0; - for (const QPair<QMetalShader *, QRhiShaderResourceBinding::StageFlag> &shader : shaders) { + for (const auto &shader : shaders) { const int binding = shader.first->nativeShaderInfo.extraBufferBindings[QShaderPrivate::MslBufferSizeBufferBinding]; @@ -6030,7 +6032,7 @@ bool QMetalGraphicsPipeline::create() for (QMetalShader *shader : shaders) { if (shader->nativeShaderInfo.extraBufferBindings.contains(QShaderPrivate::MslBufferSizeBufferBinding)) { const int binding = shader->nativeShaderInfo.extraBufferBindings[QShaderPrivate::MslBufferSizeBufferBinding]; - shader->nativeResourceBindingMap[binding] = qMakePair(binding, -1); + shader->nativeResourceBindingMap[binding] = {binding, -1}; int maxNativeBinding = 0; for (const QShaderDescription::StorageBlock &block : shader->desc.storageBlocks()) maxNativeBinding = qMax(maxNativeBinding, shader->nativeResourceBindingMap[block.binding].first); @@ -6148,7 +6150,7 @@ bool QMetalComputePipeline::create() // SPIRV-Cross buffer size buffers if (d->cs.nativeShaderInfo.extraBufferBindings.contains(QShaderPrivate::MslBufferSizeBufferBinding)) { const int binding = d->cs.nativeShaderInfo.extraBufferBindings[QShaderPrivate::MslBufferSizeBufferBinding]; - d->cs.nativeResourceBindingMap[binding] = qMakePair(binding, -1); + d->cs.nativeResourceBindingMap[binding] = {binding, -1}; } if (rhiD->d->shaderCache.count() >= QRhiMetal::MAX_SHADER_CACHE_ENTRIES) { diff --git a/src/gui/rhi/qrhivulkan.cpp b/src/gui/rhi/qrhivulkan.cpp index 33e35ba6694..202e28263c2 100644 --- a/src/gui/rhi/qrhivulkan.cpp +++ b/src/gui/rhi/qrhivulkan.cpp @@ -682,6 +682,12 @@ bool QRhiVulkan::create(QRhi::Flags flags) if (devExts.contains("VK_KHR_fragment_shading_rate")) addToChain(&physDevFeaturesChainable, &fragmentShadingRateFeatures); #endif +#ifdef VK_EXT_device_fault + VkPhysicalDeviceFaultFeaturesEXT deviceFaultFeatures = {}; + deviceFaultFeatures.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FAULT_FEATURES_EXT; + if (devExts.contains(VK_EXT_DEVICE_FAULT_EXTENSION_NAME)) + addToChain(&physDevFeaturesChainable, &deviceFaultFeatures); +#endif #endif // Vulkan >=1.2 headers at build time, >=1.2 implementation at run time @@ -825,6 +831,13 @@ bool QRhiVulkan::create(QRhi::Flags flags) requestedDevExts.append(VK_KHR_FRAGMENT_SHADING_RATE_EXTENSION_NAME); #endif +#ifdef VK_EXT_device_fault + if (devExts.contains(VK_EXT_DEVICE_FAULT_EXTENSION_NAME)) { + requestedDevExts.append(VK_EXT_DEVICE_FAULT_EXTENSION_NAME); + caps.deviceFault = true; + } +#endif + for (const QByteArray &ext : requestedDeviceExtensions) { if (!ext.isEmpty() && !requestedDevExts.contains(ext)) { if (devExts.contains(ext)) { @@ -910,6 +923,7 @@ bool QRhiVulkan::create(QRhi::Flags flags) // Here we have no way to tell if the extensions got enabled or not. // Pretend it's all there and supported. If getProcAddress fails, we'll // handle that gracefully. + caps.deviceFault = true; caps.vertexAttribDivisor = true; caps.renderPass2KHR = true; caps.depthStencilResolveKHR = true; @@ -1126,6 +1140,12 @@ bool QRhiVulkan::create(QRhi::Flags flags) } #endif +#ifdef VK_EXT_device_fault + if (caps.deviceFault) { + vkGetDeviceFaultInfoEXT = reinterpret_cast<PFN_vkGetDeviceFaultInfoEXT>(f->vkGetDeviceProcAddr(dev, "vkGetDeviceFaultInfoEXT")); + } +#endif + deviceLost = false; nativeHandlesStruct.physDev = physDev; @@ -2643,6 +2663,7 @@ QRhi::FrameOpResult QRhiVulkan::beginFrame(QRhiSwapChain *swapChain, QRhi::Begin } else { if (err == VK_ERROR_DEVICE_LOST) { qWarning("Device loss detected in vkAcquireNextImageKHR()"); + printExtraErrorInfo(err); deviceLost = true; return QRhi::FrameOpDeviceLost; } @@ -2803,6 +2824,7 @@ QRhi::FrameOpResult QRhiVulkan::endFrame(QRhiSwapChain *swapChain, QRhi::EndFram } else if (err != VK_SUBOPTIMAL_KHR) { if (err == VK_ERROR_DEVICE_LOST) { qWarning("Device loss detected in vkQueuePresentKHR()"); + printExtraErrorInfo(err); deviceLost = true; return QRhi::FrameOpDeviceLost; } @@ -2862,6 +2884,7 @@ QRhi::FrameOpResult QRhiVulkan::startPrimaryCommandBuffer(VkCommandBuffer *cb) if (err != VK_SUCCESS) { if (err == VK_ERROR_DEVICE_LOST) { qWarning("Device loss detected in vkAllocateCommandBuffers()"); + printExtraErrorInfo(err); deviceLost = true; return QRhi::FrameOpDeviceLost; } @@ -2877,6 +2900,7 @@ QRhi::FrameOpResult QRhiVulkan::startPrimaryCommandBuffer(VkCommandBuffer *cb) if (err != VK_SUCCESS) { if (err == VK_ERROR_DEVICE_LOST) { qWarning("Device loss detected in vkBeginCommandBuffer()"); + printExtraErrorInfo(err); deviceLost = true; return QRhi::FrameOpDeviceLost; } @@ -2894,6 +2918,7 @@ QRhi::FrameOpResult QRhiVulkan::endAndSubmitPrimaryCommandBuffer(VkCommandBuffer if (err != VK_SUCCESS) { if (err == VK_ERROR_DEVICE_LOST) { qWarning("Device loss detected in vkEndCommandBuffer()"); + printExtraErrorInfo(err); deviceLost = true; return QRhi::FrameOpDeviceLost; } @@ -2930,6 +2955,7 @@ QRhi::FrameOpResult QRhiVulkan::endAndSubmitPrimaryCommandBuffer(VkCommandBuffer if (err != VK_SUCCESS) { if (err == VK_ERROR_DEVICE_LOST) { qWarning("Device loss detected in vkQueueSubmit()"); + printExtraErrorInfo(err); deviceLost = true; return QRhi::FrameOpDeviceLost; } @@ -2951,6 +2977,7 @@ QRhi::FrameOpResult QRhiVulkan::waitCommandCompletion(int frameSlot) if (err != VK_SUCCESS) { if (err == VK_ERROR_DEVICE_LOST) { qWarning("Device loss detected in vkWaitForFences()"); + printExtraErrorInfo(err); deviceLost = true; return QRhi::FrameOpDeviceLost; } @@ -4079,10 +4106,87 @@ void QRhiVulkan::prepareUploadSubres(QVkTexture *texD, int layer, int level, void QRhiVulkan::printExtraErrorInfo(VkResult err) { + if (err == VK_ERROR_DEVICE_LOST) + printDeviceLossErrorInfo(); if (err == VK_ERROR_OUT_OF_DEVICE_MEMORY) qWarning() << "Out of device memory, current allocator statistics are" << statistics(); } +void QRhiVulkan::printDeviceLossErrorInfo() const +{ +#ifdef VK_EXT_device_fault + if (!dev || !caps.deviceFault || !vkGetDeviceFaultInfoEXT) + return; + + VkDeviceFaultCountsEXT faultCounts{}; + faultCounts.sType = VK_STRUCTURE_TYPE_DEVICE_FAULT_COUNTS_EXT; + faultCounts.pNext = nullptr; + + VkResult result = vkGetDeviceFaultInfoEXT(dev, &faultCounts, nullptr); + if (result != VK_SUCCESS && result != VK_INCOMPLETE) { + qWarning("vkGetDeviceFaultInfoEXT failed with %d", result); + return; + } + faultCounts.vendorBinarySize = 0; + + QVarLengthArray<VkDeviceFaultAddressInfoEXT> addressInfos; + addressInfos.resize(faultCounts.addressInfoCount); + + QVarLengthArray<VkDeviceFaultVendorInfoEXT> vendorInfos; + vendorInfos.resize(faultCounts.vendorInfoCount); + + VkDeviceFaultInfoEXT info{}; + info.sType = VK_STRUCTURE_TYPE_DEVICE_FAULT_INFO_EXT; + info.pNext = nullptr; + info.pAddressInfos = addressInfos.isEmpty() ? nullptr : addressInfos.data(); + info.pVendorInfos = vendorInfos.isEmpty() ? nullptr : vendorInfos.data(); + info.pVendorBinaryData = nullptr; + + result = vkGetDeviceFaultInfoEXT(dev, &faultCounts, &info); + if (result != VK_SUCCESS && result != VK_INCOMPLETE) { + qWarning("vkGetDeviceFaultInfoEXT failed with %d", result); + return; + } + + const char *desc = info.description[0] ? info.description : "n/a"; + qWarning("VK_ERROR_DEVICE_LOST (VK_EXT_device_fault): %u address infos, %u vendor infos, %llu bytes vendor binary: %s", + faultCounts.addressInfoCount, + faultCounts.vendorInfoCount, + (unsigned long long)faultCounts.vendorBinarySize, + desc); + + for (uint32_t i = 0; i < faultCounts.addressInfoCount; ++i) { + const auto &a = addressInfos[i]; + auto addressTypeString = [](const VkDeviceFaultAddressTypeEXT type) { + switch (type) { + case VK_DEVICE_FAULT_ADDRESS_TYPE_NONE_EXT: return "NONE"; + case VK_DEVICE_FAULT_ADDRESS_TYPE_READ_INVALID_EXT: return "READ_INVALID"; + case VK_DEVICE_FAULT_ADDRESS_TYPE_WRITE_INVALID_EXT: return "WRITE_INVALID"; + case VK_DEVICE_FAULT_ADDRESS_TYPE_EXECUTE_INVALID_EXT: return "EXECUTE_INVALID"; + case VK_DEVICE_FAULT_ADDRESS_TYPE_INSTRUCTION_POINTER_UNKNOWN_EXT: return "INSTRUCTION_POINTER_UNKNOWN"; + case VK_DEVICE_FAULT_ADDRESS_TYPE_INSTRUCTION_POINTER_INVALID_EXT: return "INSTRUCTION_POINTER_INVALID"; + case VK_DEVICE_FAULT_ADDRESS_TYPE_INSTRUCTION_POINTER_FAULT_EXT: return "INSTRUCTION_POINTER_FAULT"; + default: return "UNKNOWN"; + }; + }; + qWarning(" AddressInfo[%02u]: type=%s addr=0x%llx precision=%llu", + i, + addressTypeString(a.addressType), + (unsigned long long)a.reportedAddress, + (unsigned long long)a.addressPrecision); + } + + for (uint32_t i = 0; i < faultCounts.vendorInfoCount; ++i) { + const auto &v = vendorInfos[i]; + qWarning(" VendorInfo[%02u]: code=%llu data=%llu desc=%s", + i, + (unsigned long long)v.vendorFaultCode, + (unsigned long long)v.vendorFaultData, + v.description); + } +#endif // VK_EXT_device_fault +} + void QRhiVulkan::enqueueResourceUpdates(QVkCommandBuffer *cbD, QRhiResourceUpdateBatch *resourceUpdates) { QRhiResourceUpdateBatchPrivate *ud = QRhiResourceUpdateBatchPrivate::get(resourceUpdates); diff --git a/src/gui/rhi/qrhivulkan_p.h b/src/gui/rhi/qrhivulkan_p.h index 21044545ad2..eb07d8be448 100644 --- a/src/gui/rhi/qrhivulkan_p.h +++ b/src/gui/rhi/qrhivulkan_p.h @@ -882,6 +882,7 @@ public: void ensureCommandPoolForNewFrame(); double elapsedSecondsFromTimestamp(quint64 timestamp[2], bool *ok); void printExtraErrorInfo(VkResult err); + void printDeviceLossErrorInfo() const; QVulkanInstance *inst = nullptr; QWindow *maybeWindow = nullptr; @@ -942,11 +943,16 @@ public: PFN_vkCreateRenderPass2KHR vkCreateRenderPass2KHR = nullptr; #endif +#ifdef VK_EXT_device_fault + PFN_vkGetDeviceFaultInfoEXT vkGetDeviceFaultInfoEXT = nullptr; +#endif + struct { bool compute = false; bool depthClamp = false; bool wideLines = false; bool debugUtils = false; + bool deviceFault = false; bool vertexAttribDivisor = false; bool texture3DSliceAs2D = false; bool tessellation = false; diff --git a/src/gui/text/freetype/qfontengine_ft.cpp b/src/gui/text/freetype/qfontengine_ft.cpp index 63d9c2893dc..e331a4cc815 100644 --- a/src/gui/text/freetype/qfontengine_ft.cpp +++ b/src/gui/text/freetype/qfontengine_ft.cpp @@ -1225,7 +1225,7 @@ static inline QTransform FTAffineToQTransform(const FT_Affine23 &matrix) } bool QFontEngineFT::traverseColr1(FT_OpaquePaint opaquePaint, - QSet<QPair<FT_Byte *, FT_Bool> > *loops, + QSet<std::pair<FT_Byte *, FT_Bool> > *loops, QColor foregroundColor, FT_Color *palette, ushort paletteCount, @@ -1233,7 +1233,7 @@ bool QFontEngineFT::traverseColr1(FT_OpaquePaint opaquePaint, { FT_Face face = freetype->face; - auto key = qMakePair(opaquePaint.p, opaquePaint.insert_root_transform); + auto key = std::pair{opaquePaint.p, opaquePaint.insert_root_transform}; if (loops->contains(key)) { qCWarning(lcColrv1) << "Cycle detected in COLRv1 graph"; return false; @@ -1680,7 +1680,7 @@ QFontEngineFT::Glyph *QFontEngineFT::loadColrv1Glyph(QGlyphSet *set, // Do a pass over the graph to find the bounds QColrPaintGraphRenderer boundingRectCalculator; boundingRectCalculator.beginCalculateBoundingBox(); - QSet<QPair<FT_Byte *, FT_Bool> > loops; + QSet<std::pair<FT_Byte *, FT_Bool> > loops; if (traverseColr1(opaquePaint, &loops, QColor{}, @@ -1735,7 +1735,7 @@ QFontEngineFT::Glyph *QFontEngineFT::loadColrv1Glyph(QGlyphSet *set, originalXform); // Render - QSet<QPair<FT_Byte *, FT_Bool> > loops; + QSet<std::pair<FT_Byte *, FT_Bool> > loops; if (!traverseColr1(opaquePaint, &loops, foregroundColor, diff --git a/src/gui/text/freetype/qfontengine_ft_p.h b/src/gui/text/freetype/qfontengine_ft_p.h index fc07693ef6a..13cd1bf2bfa 100644 --- a/src/gui/text/freetype/qfontengine_ft_p.h +++ b/src/gui/text/freetype/qfontengine_ft_p.h @@ -34,6 +34,8 @@ #include <string.h> #include <qpainterpath.h> +#include <utility> // for std::pair + QT_BEGIN_NAMESPACE class QFontEngineFTRawFont; @@ -333,7 +335,7 @@ private: bool fetchMetricsOnly) const; bool traverseColr1(FT_OpaquePaint paint, - QSet<QPair<FT_Byte *, FT_Bool> > *loops, + QSet<std::pair<FT_Byte *, FT_Bool> > *loops, QColor foregroundColor, FT_Color *palette, ushort paletteCount, diff --git a/src/gui/text/qcolrpaintgraphrenderer.cpp b/src/gui/text/qcolrpaintgraphrenderer.cpp index 9041e804753..bc439021eb1 100644 --- a/src/gui/text/qcolrpaintgraphrenderer.cpp +++ b/src/gui/text/qcolrpaintgraphrenderer.cpp @@ -180,7 +180,7 @@ void QColrPaintGraphRenderer::setConicalGradient(QPointF center, adaptedStops.reserve(gradientStops.size()); for (const QGradientStop &gradientStop : gradientStops) - adaptedStops.append(qMakePair(gradientStop.first * multiplier, gradientStop.second)); + adaptedStops.append({gradientStop.first * multiplier, gradientStop.second}); conicalGradient.setStops(adaptedStops); conicalGradient.setCoordinateMode(QGradient::LogicalMode); diff --git a/src/gui/text/qfont.cpp b/src/gui/text/qfont.cpp index c144820fa24..ba49d538c2c 100644 --- a/src/gui/text/qfont.cpp +++ b/src/gui/text/qfont.cpp @@ -31,6 +31,7 @@ #include <QtCore/QMutexLocker> #include <QtCore/QMutex> +#include <algorithm> #include <array> // #define QFONTCACHE_DEBUG @@ -1853,35 +1854,13 @@ bool QFont::operator<(const QFont &f) const int f2attrs = (d->underline << 3) + (d->overline << 2) + (d->strikeOut<<1) + d->kerning; if (f1attrs != f2attrs) return f1attrs < f2attrs; - if (d->features.size() != f.d->features.size()) - return f.d->features.size() < d->features.size(); - - { - auto it = d->features.constBegin(); - auto jt = f.d->features.constBegin(); - for (; it != d->features.constEnd(); ++it, ++jt) { - if (it.key() != jt.key()) - return jt.key() < it.key(); - if (it.value() != jt.value()) - return jt.value() < it.value(); - } - } - - if (r1.variableAxisValues.size() != r2.variableAxisValues.size()) - return r1.variableAxisValues.size() < r2.variableAxisValues.size(); - - { - auto it = r1.variableAxisValues.constBegin(); - auto jt = r2.variableAxisValues.constBegin(); - for (; it != r1.variableAxisValues.constEnd(); ++it, ++jt) { - if (it.key() != jt.key()) - return jt.key() < it.key(); - if (it.value() != jt.value()) - return jt.value() < it.value(); - } + if (d->features != f.d->features) { + return std::lexicographical_compare(f.d->features.keyValueBegin(), f.d->features.keyValueEnd(), + d->features.keyValueBegin(), d->features.keyValueEnd()); } - return false; + return std::lexicographical_compare(r1.variableAxisValues.keyValueBegin(), r1.variableAxisValues.keyValueEnd(), + r2.variableAxisValues.keyValueBegin(), r2.variableAxisValues.keyValueEnd()); } diff --git a/src/gui/text/qfontengine.cpp b/src/gui/text/qfontengine.cpp index 0ad45b1f280..d41296291f6 100644 --- a/src/gui/text/qfontengine.cpp +++ b/src/gui/text/qfontengine.cpp @@ -402,7 +402,7 @@ bool QFontEngine::processHheaTable() const const qreal unitsPerEm = emSquareSize().toReal(); // Bail out if values are too large for QFixed - const auto limitForQFixed = std::numeric_limits<int>::max() / (fontDef.pixelSize * 64); + const auto limitForQFixed = qreal(std::numeric_limits<int>::max() / 64) / fontDef.pixelSize; if (ascent > limitForQFixed || descent > limitForQFixed || leading > limitForQFixed) return false; m_ascent = QFixed::fromReal(ascent * fontDef.pixelSize / unitsPerEm); @@ -470,7 +470,7 @@ bool QFontEngine::processOS2Table() const if (typoAscent == 0 && typoDescent == 0) return false; // Bail out if values are too large for QFixed - const auto limitForQFixed = std::numeric_limits<int>::max() / (fontDef.pixelSize * 64); + const auto limitForQFixed = qreal(std::numeric_limits<int>::max() / 64) / fontDef.pixelSize; if (typoAscent > limitForQFixed || typoDescent > limitForQFixed || typoLineGap > limitForQFixed) return false; @@ -481,7 +481,7 @@ bool QFontEngine::processOS2Table() const // Some fonts may have invalid OS/2 data. We detect this and bail out. if (winAscent == 0 && winDescent == 0) return false; - const auto limitForQFixed = std::numeric_limits<int>::max() / (fontDef.pixelSize * 64); + const auto limitForQFixed = qreal(std::numeric_limits<int>::max() / 64) / fontDef.pixelSize; if (winAscent > limitForQFixed || winDescent > limitForQFixed) return false; m_ascent = QFixed::fromReal(winAscent * fontDef.pixelSize / unitsPerEm); diff --git a/src/gui/text/qrawfont.cpp b/src/gui/text/qrawfont.cpp index 7acc3c5218c..5bd9799ca7d 100644 --- a/src/gui/text/qrawfont.cpp +++ b/src/gui/text/qrawfont.cpp @@ -224,7 +224,7 @@ void QRawFont::loadFromData(const QByteArray &fontData, \since 6.11 */ -int QRawFont::glyphCount() const +quint32 QRawFont::glyphCount() const { return d->isValid() ? d->fontEngine->glyphCount() : 0; } diff --git a/src/gui/text/qrawfont.h b/src/gui/text/qrawfont.h index f13f04ebe37..a1522aa8048 100644 --- a/src/gui/text/qrawfont.h +++ b/src/gui/text/qrawfont.h @@ -55,7 +55,7 @@ public: inline bool operator!=(const QRawFont &other) const { return !operator==(other); } - int glyphCount() const; + quint32 glyphCount() const; QString familyName() const; QString styleName() const; diff --git a/src/gui/text/qtextdocument.cpp b/src/gui/text/qtextdocument.cpp index eb0f6c3710c..4f01d09fed1 100644 --- a/src/gui/text/qtextdocument.cpp +++ b/src/gui/text/qtextdocument.cpp @@ -1976,7 +1976,7 @@ void QTextDocument::print(QPagedPaintDevice *printer) const return; bool documentPaginated = d->pageSize.isValid() && !d->pageSize.isNull() - && d->pageSize.height() != INT_MAX; + && d->pageSize.height() != qreal(INT_MAX); // ### set page size to paginated size? QMarginsF m = printer->pageLayout().margins(QPageLayout::Millimeter); diff --git a/src/gui/text/qtextengine.cpp b/src/gui/text/qtextengine.cpp index ede5409b112..41d2d417133 100644 --- a/src/gui/text/qtextengine.cpp +++ b/src/gui/text/qtextengine.cpp @@ -1746,7 +1746,7 @@ int QTextEngine::shapeTextWithHarfbuzzNG(const QScriptItem &si, const ushort *st // fix up clusters so that the cluster indices will be monotonic // and thus we never return out-of-order indices - while (last_cluster++ < cluster && str_pos < item_length) + for (uint j = last_cluster; j < cluster && str_pos < item_length; ++j) log_clusters[str_pos++] = last_glyph_pos; last_glyph_pos = i + glyphs_shaped; last_cluster = cluster; diff --git a/src/gui/text/windows/qwindowsfontdatabasebase.cpp b/src/gui/text/windows/qwindowsfontdatabasebase.cpp index 990f20fa447..055e616dbb2 100644 --- a/src/gui/text/windows/qwindowsfontdatabasebase.cpp +++ b/src/gui/text/windows/qwindowsfontdatabasebase.cpp @@ -18,6 +18,8 @@ # include "qwindowsfontenginedirectwrite_p.h" #endif +#include <utility> // for std::pair + QT_BEGIN_NAMESPACE using namespace Qt::StringLiterals; @@ -363,7 +365,7 @@ namespace { inline void addKey(const QByteArray &fontData, const QString &filename) { if (!m_fontDatas.contains(fontData.data())) - m_fontDatas.insert(fontData.data(), qMakePair(fontData, filename)); + m_fontDatas.insert(fontData.data(), {fontData, filename}); } HRESULT STDMETHODCALLTYPE GetFilePathLengthFromKey(void const* fontFileReferenceKey, @@ -433,7 +435,7 @@ namespace { private: ULONG m_referenceCount; - QHash<const void *, QPair<QByteArray, QString> > m_fontDatas; + QHash<const void *, std::pair<QByteArray, QString> > m_fontDatas; }; HRESULT STDMETHODCALLTYPE DirectWriteFontFileLoader::QueryInterface(const IID &iid, diff --git a/src/gui/text/windows/qwindowsfontenginedirectwrite.cpp b/src/gui/text/windows/qwindowsfontenginedirectwrite.cpp index 3e10cdad44f..2f0ce3449d9 100644 --- a/src/gui/text/windows/qwindowsfontenginedirectwrite.cpp +++ b/src/gui/text/windows/qwindowsfontenginedirectwrite.cpp @@ -1074,7 +1074,7 @@ bool QWindowsFontEngineDirectWrite::traverseColr1(IDWritePaintReader *paintReade for (int i = 0; i < stopCount; ++i) { const D2D1_GRADIENT_STOP &stop = stops[i]; QColor color = QColor::fromRgbF(stop.color.r, stop.color.g, stop.color.b, stop.color.a); - ret.append(qMakePair(stop.position, color)); + ret.append({stop.position, color}); } return ret; |
