diff options
55 files changed, 523 insertions, 374 deletions
diff --git a/src/imports/imports.pro b/src/imports/imports.pro index e9a93a0e83..ad33312891 100644 --- a/src/imports/imports.pro +++ b/src/imports/imports.pro @@ -20,9 +20,7 @@ qtHaveModule(quick) { window \ tableview - qtConfig(testlib): \ - SUBDIRS += testlib - + qtHaveModule(testlib): SUBDIRS += testlib qtConfig(systemsemaphore): SUBDIRS += sharedimage qtConfig(quick-particles): \ SUBDIRS += particles diff --git a/src/plugins/qmltooling/packetprotocol/packetprotocol.pro b/src/plugins/qmltooling/packetprotocol/packetprotocol.pro index 990d3169ad..a188b87a81 100644 --- a/src/plugins/qmltooling/packetprotocol/packetprotocol.pro +++ b/src/plugins/qmltooling/packetprotocol/packetprotocol.pro @@ -1,11 +1,11 @@ TARGET = QtPacketProtocol -QT = core-private qml-private +QT = core-private CONFIG += static internal_module HEADERS = \ qpacketprotocol_p.h \ qpacket_p.h \ - qqmldebugpacket_p.h + qversionedpacket_p.h SOURCES = \ qpacketprotocol.cpp \ diff --git a/src/plugins/qmltooling/packetprotocol/qqmldebugpacket_p.h b/src/plugins/qmltooling/packetprotocol/qversionedpacket_p.h index 9a0f8cd82d..635072adbc 100644 --- a/src/plugins/qmltooling/packetprotocol/qqmldebugpacket_p.h +++ b/src/plugins/qmltooling/packetprotocol/qversionedpacket_p.h @@ -37,14 +37,11 @@ ** ****************************************************************************/ -#ifndef QQMLDEBUGPACKET_P_H -#define QQMLDEBUGPACKET_P_H +#ifndef QVERSIONEDPACKET_P_H +#define QVERSIONEDPACKET_P_H #include "qpacket_p.h" -#include <QtCore/qbuffer.h> -#include <QtQml/private/qqmldebugconnector_p.h> - // // W A R N I N G // ------------- @@ -58,14 +55,15 @@ QT_BEGIN_NAMESPACE -// QPacket with a fixed data stream version, centrally set by QQmlDebugServer -class QQmlDebugPacket : public QPacket +// QPacket with a fixed data stream version, centrally set by some Connector +template<class Connector> +class QVersionedPacket : public QPacket { public: - QQmlDebugPacket() : QPacket(QQmlDebugConnector::dataStreamVersion()) {} - QQmlDebugPacket(const QByteArray &ba) : QPacket(QQmlDebugConnector::dataStreamVersion(), ba) {} + QVersionedPacket(const QByteArray &ba) : QPacket(Connector::dataStreamVersion(), ba) {} + QVersionedPacket() : QPacket(Connector::dataStreamVersion()) {} }; QT_END_NAMESPACE -#endif // QQMLDEBUGPACKET_P_H +#endif // QVERSIONEDPACKET_P_H diff --git a/src/plugins/qmltooling/qmldbg_debugger/qqmlenginedebugservice.cpp b/src/plugins/qmltooling/qmldbg_debugger/qqmlenginedebugservice.cpp index 236109d041..d008b86a78 100644 --- a/src/plugins/qmltooling/qmldbg_debugger/qqmlenginedebugservice.cpp +++ b/src/plugins/qmltooling/qmldbg_debugger/qqmlenginedebugservice.cpp @@ -56,10 +56,13 @@ #include <QtCore/qmetaobject.h> #include <QtCore/qfileinfo.h> #include <private/qmetaobject_p.h> -#include <private/qqmldebugpacket_p.h> +#include <private/qqmldebugconnector_p.h> +#include <private/qversionedpacket_p.h> QT_BEGIN_NAMESPACE +using QQmlDebugPacket = QVersionedPacket<QQmlDebugConnector>; + QQmlEngineDebugServiceImpl::QQmlEngineDebugServiceImpl(QObject *parent) : QQmlEngineDebugService(2, parent), m_watch(new QQmlWatcher(this)), m_statesDelegate(nullptr) { diff --git a/src/plugins/qmltooling/qmldbg_debugger/qv4debugservice.cpp b/src/plugins/qmltooling/qmldbg_debugger/qv4debugservice.cpp index 61209e08cb..32de8e9027 100644 --- a/src/plugins/qmltooling/qmldbg_debugger/qv4debugservice.cpp +++ b/src/plugins/qmltooling/qmldbg_debugger/qv4debugservice.cpp @@ -45,7 +45,7 @@ #include <private/qv4function_p.h> #include <private/qqmldebugconnector_p.h> #include <private/qv8engine_p.h> -#include <private/qqmldebugpacket_p.h> +#include <private/qversionedpacket_p.h> #include <QtCore/QJsonArray> #include <QtCore/QJsonDocument> @@ -70,6 +70,8 @@ QT_BEGIN_NAMESPACE class V8CommandHandler; class UnknownV8CommandHandler; +using QQmlDebugPacket = QVersionedPacket<QQmlDebugConnector>; + int QV4DebugServiceImpl::sequence = 0; class V8CommandHandler diff --git a/src/plugins/qmltooling/qmldbg_inspector/globalinspector.cpp b/src/plugins/qmltooling/qmldbg_inspector/globalinspector.cpp index 7ce83daed6..bac4e01df1 100644 --- a/src/plugins/qmltooling/qmldbg_inspector/globalinspector.cpp +++ b/src/plugins/qmltooling/qmldbg_inspector/globalinspector.cpp @@ -44,7 +44,8 @@ #include <private/qqmldebugserviceinterfaces_p.h> #include <private/qabstractanimation_p.h> #include <private/qqmlcomponent_p.h> -#include <private/qqmldebugpacket_p.h> +#include <private/qqmldebugconnector_p.h> +#include <private/qversionedpacket_p.h> #include <QtGui/qwindow.h> @@ -63,6 +64,8 @@ QT_BEGIN_NAMESPACE +using QQmlDebugPacket = QVersionedPacket<QQmlDebugConnector>; + const char REQUEST[] = "request"; const char RESPONSE[] = "response"; const char EVENT[] = "event"; diff --git a/src/plugins/qmltooling/qmldbg_messages/qdebugmessageservice.cpp b/src/plugins/qmltooling/qmldbg_messages/qdebugmessageservice.cpp index 2bf9210b37..4f6cb9364d 100644 --- a/src/plugins/qmltooling/qmldbg_messages/qdebugmessageservice.cpp +++ b/src/plugins/qmltooling/qmldbg_messages/qdebugmessageservice.cpp @@ -40,10 +40,12 @@ #include "qdebugmessageservice.h" #include <private/qqmldebugconnector_p.h> -#include <private/qqmldebugpacket_p.h> +#include <private/qversionedpacket_p.h> QT_BEGIN_NAMESPACE +using QQmlDebugPacket = QVersionedPacket<QQmlDebugConnector>; + void DebugMessageHandler(QtMsgType type, const QMessageLogContext &ctxt, const QString &buf) { diff --git a/src/plugins/qmltooling/qmldbg_native/qqmlnativedebugconnector.cpp b/src/plugins/qmltooling/qmldbg_native/qqmlnativedebugconnector.cpp index 93ac875e2d..bf73440a39 100644 --- a/src/plugins/qmltooling/qmldbg_native/qqmlnativedebugconnector.cpp +++ b/src/plugins/qmltooling/qmldbg_native/qqmlnativedebugconnector.cpp @@ -40,7 +40,7 @@ #include "qqmlnativedebugconnector.h" #include <private/qhooks_p.h> -#include <private/qqmldebugpacket_p.h> +#include <private/qversionedpacket_p.h> #include <QtQml/qjsengine.h> #include <QtCore/qdebug.h> diff --git a/src/plugins/qmltooling/qmldbg_nativedebugger/qqmlnativedebugservice.cpp b/src/plugins/qmltooling/qmldbg_nativedebugger/qqmlnativedebugservice.cpp index 6db82e9f52..92492d9305 100644 --- a/src/plugins/qmltooling/qmldbg_nativedebugger/qqmlnativedebugservice.cpp +++ b/src/plugins/qmltooling/qmldbg_nativedebugger/qqmlnativedebugservice.cpp @@ -49,7 +49,7 @@ #include <private/qv4objectiterator_p.h> #include <private/qv4identifier_p.h> #include <private/qv4runtime_p.h> -#include <private/qqmldebugpacket_p.h> +#include <private/qversionedpacket_p.h> #include <private/qqmldebugserviceinterfaces_p.h> #include <QtQml/qjsengine.h> @@ -65,6 +65,8 @@ QT_BEGIN_NAMESPACE +using QQmlDebugPacket = QVersionedPacket<QQmlDebugConnector>; + class BreakPoint { public: diff --git a/src/plugins/qmltooling/qmldbg_profiler/qqmlenginecontrolservice.cpp b/src/plugins/qmltooling/qmldbg_profiler/qqmlenginecontrolservice.cpp index 4eedb4bd51..f76add448f 100644 --- a/src/plugins/qmltooling/qmldbg_profiler/qqmlenginecontrolservice.cpp +++ b/src/plugins/qmltooling/qmldbg_profiler/qqmlenginecontrolservice.cpp @@ -38,11 +38,14 @@ ****************************************************************************/ #include "qqmlenginecontrolservice.h" -#include <private/qqmldebugpacket_p.h> +#include <private/qqmldebugconnector_p.h> +#include <private/qversionedpacket_p.h> #include <QJSEngine> QT_BEGIN_NAMESPACE +using QQmlDebugPacket = QVersionedPacket<QQmlDebugConnector>; + QQmlEngineControlServiceImpl::QQmlEngineControlServiceImpl(QObject *parent) : QQmlEngineControlService(1, parent) { diff --git a/src/plugins/qmltooling/qmldbg_profiler/qqmlprofileradapter.cpp b/src/plugins/qmltooling/qmldbg_profiler/qqmlprofileradapter.cpp index 551c06ecdd..a688e98b3f 100644 --- a/src/plugins/qmltooling/qmldbg_profiler/qqmlprofileradapter.cpp +++ b/src/plugins/qmltooling/qmldbg_profiler/qqmlprofileradapter.cpp @@ -38,8 +38,8 @@ ****************************************************************************/ #include "qqmlprofileradapter.h" +#include "qqmlprofilerservice.h" -#include <private/qqmldebugpacket_p.h> #include <private/qqmldebugserviceinterfaces_p.h> QT_BEGIN_NAMESPACE diff --git a/src/plugins/qmltooling/qmldbg_profiler/qqmlprofilerservice.cpp b/src/plugins/qmltooling/qmldbg_profiler/qqmlprofilerservice.cpp index 22c515adf9..462401a093 100644 --- a/src/plugins/qmltooling/qmldbg_profiler/qqmlprofilerservice.cpp +++ b/src/plugins/qmltooling/qmldbg_profiler/qqmlprofilerservice.cpp @@ -43,7 +43,6 @@ #include "qqmlprofilerservicefactory.h" #include <private/qjsengine_p.h> -#include <private/qqmldebugpacket_p.h> #include <private/qqmldebugpluginmanager_p.h> #include <QtCore/qurl.h> diff --git a/src/plugins/qmltooling/qmldbg_profiler/qqmlprofilerservice.h b/src/plugins/qmltooling/qmldbg_profiler/qqmlprofilerservice.h index ce0101f4d4..3791ab29ae 100644 --- a/src/plugins/qmltooling/qmldbg_profiler/qqmlprofilerservice.h +++ b/src/plugins/qmltooling/qmldbg_profiler/qqmlprofilerservice.h @@ -56,6 +56,8 @@ #include <private/qqmlprofilerdefinitions_p.h> #include <private/qqmlabstractprofileradapter_p.h> #include <private/qqmlboundsignal_p.h> +#include <private/qqmldebugconnector_p.h> +#include <private/qversionedpacket_p.h> #include <QtCore/qelapsedtimer.h> #include <QtCore/qmetaobject.h> @@ -70,6 +72,7 @@ QT_BEGIN_NAMESPACE class QUrl; +using QQmlDebugPacket = QVersionedPacket<QQmlDebugConnector>; class QQmlProfilerServiceImpl : public QQmlConfigurableDebugService<QQmlProfilerService>, diff --git a/src/plugins/qmltooling/qmldbg_profiler/qv4profileradapter.h b/src/plugins/qmltooling/qmldbg_profiler/qv4profileradapter.h index 49eaa8d2f6..c4ca38d9b0 100644 --- a/src/plugins/qmltooling/qmldbg_profiler/qv4profileradapter.h +++ b/src/plugins/qmltooling/qmldbg_profiler/qv4profileradapter.h @@ -51,9 +51,10 @@ // We mean it. // +#include "qqmlprofilerservice.h" + #include <private/qv4profiling_p.h> #include <private/qqmlabstractprofileradapter_p.h> -#include <private/qqmldebugpacket_p.h> #include <QStack> #include <QList> diff --git a/src/plugins/qmltooling/qmldbg_quickprofiler/qquickprofileradapter.cpp b/src/plugins/qmltooling/qmldbg_quickprofiler/qquickprofileradapter.cpp index 0879e22239..79a1c82411 100644 --- a/src/plugins/qmltooling/qmldbg_quickprofiler/qquickprofileradapter.cpp +++ b/src/plugins/qmltooling/qmldbg_quickprofiler/qquickprofileradapter.cpp @@ -40,12 +40,15 @@ #include "qquickprofileradapter.h" #include <QCoreApplication> -#include <private/qqmldebugpacket_p.h> +#include <private/qqmldebugconnector_p.h> +#include <private/qversionedpacket_p.h> #include <private/qqmldebugserviceinterfaces_p.h> #include <private/qquickprofiler_p.h> QT_BEGIN_NAMESPACE +using QQmlDebugPacket = QVersionedPacket<QQmlDebugConnector>; + QQuickProfilerAdapter::QQuickProfilerAdapter(QObject *parent) : QQmlAbstractProfilerAdapter(parent), next(0) { diff --git a/src/plugins/qmltooling/qmldbg_server/qqmldebugserver.cpp b/src/plugins/qmltooling/qmldbg_server/qqmldebugserver.cpp index 27b310a0ae..8293e88038 100644 --- a/src/plugins/qmltooling/qmldbg_server/qqmldebugserver.cpp +++ b/src/plugins/qmltooling/qmldbg_server/qqmldebugserver.cpp @@ -47,7 +47,7 @@ #include <private/qqmldebugpluginmanager_p.h> #include <private/qqmldebugserviceinterfaces_p.h> #include <private/qpacketprotocol_p.h> -#include <private/qqmldebugpacket_p.h> +#include <private/qversionedpacket_p.h> #include <QtCore/QAtomicInt> #include <QtCore/QDir> @@ -83,6 +83,7 @@ QT_BEGIN_NAMESPACE Q_QML_DEBUG_PLUGIN_LOADER(QQmlDebugServerConnection) const int protocolVersion = 1; +using QQmlDebugPacket = QVersionedPacket<QQmlDebugConnector>; class QQmlDebugServerImpl; class QQmlDebugServerThread : public QThread diff --git a/src/qml/debugger/qqmlprofilerdefinitions_p.h b/src/qml/debugger/qqmlprofilerdefinitions_p.h index f84a2c44e2..7b972c5d0d 100644 --- a/src/qml/debugger/qqmlprofilerdefinitions_p.h +++ b/src/qml/debugger/qqmlprofilerdefinitions_p.h @@ -96,11 +96,6 @@ struct QQmlProfilerDefinitions { MaximumRangeType }; - enum BindingType { - QmlBinding, - MaximumBindingType - }; - enum PixmapEventType { PixmapSizeKnown, PixmapReferenceCountChanged, @@ -129,8 +124,6 @@ struct QQmlProfilerDefinitions { NumGUIThreadFrameTypes = MaximumSceneGraphFrameType - NumRenderThreadFrameTypes }; - typedef QV4::Profiling::MemoryType MemoryType; - enum ProfileFeature { ProfileJavaScript, ProfileMemory, @@ -162,26 +155,6 @@ struct QQmlProfilerDefinitions { MaximumInputEventType }; - - static ProfileFeature featureFromRangeType(RangeType range) - { - switch (range) { - case Painting: - return ProfilePainting; - case Compiling: - return ProfileCompiling; - case Creating: - return ProfileCreating; - case Binding: - return ProfileBinding; - case HandlingSignal: - return ProfileHandlingSignal; - case Javascript: - return ProfileJavaScript; - default: - return MaximumProfileFeature; - } - } }; QT_END_NAMESPACE diff --git a/src/qmldebug/qmldebug.pro b/src/qmldebug/qmldebug.pro index 2539414d8f..2c1b71797d 100644 --- a/src/qmldebug/qmldebug.pro +++ b/src/qmldebug/qmldebug.pro @@ -1,5 +1,5 @@ TARGET = QtQmlDebug -QT = core-private network packetprotocol-private qml-private +QT = core-private network packetprotocol-private CONFIG += static internal_module load(qt_module) @@ -28,4 +28,5 @@ HEADERS += \ qqmlprofilereventlocation_p.h \ qqmlprofilereventreceiver_p.h \ qqmlprofilereventtype_p.h \ - qqmlprofilertypedevent_p.h + qqmlprofilertypedevent_p.h \ + qqmlprofilerclientdefinitions_p.h diff --git a/src/qmldebug/qqmlenginecontrolclient.cpp b/src/qmldebug/qqmlenginecontrolclient.cpp index 8d62fafb94..cdc724ef2f 100644 --- a/src/qmldebug/qqmlenginecontrolclient.cpp +++ b/src/qmldebug/qqmlenginecontrolclient.cpp @@ -41,7 +41,6 @@ #include "qqmlenginecontrolclient_p_p.h" #include "qqmldebugconnection_p.h" -#include <private/qqmldebugserviceinterfaces_p.h> #include <private/qpacket_p.h> QT_BEGIN_NAMESPACE @@ -142,7 +141,7 @@ void QQmlEngineControlClient::messageReceived(const QByteArray &data) } QQmlEngineControlClientPrivate::QQmlEngineControlClientPrivate(QQmlDebugConnection *connection) : - QQmlDebugClientPrivate(QQmlEngineControlService::s_key, connection) + QQmlDebugClientPrivate(QLatin1String("EngineControl"), connection) { } diff --git a/src/qmldebug/qqmlprofilerclient.cpp b/src/qmldebug/qqmlprofilerclient.cpp index 0f3cbb49ee..73db2ad94d 100644 --- a/src/qmldebug/qqmlprofilerclient.cpp +++ b/src/qmldebug/qqmlprofilerclient.cpp @@ -39,7 +39,6 @@ #include "qqmlprofilerclient_p_p.h" #include "qqmldebugconnection_p.h" -#include <private/qqmldebugserviceinterfaces_p.h> QT_BEGIN_NAMESPACE diff --git a/src/qmldebug/qqmlprofilerclient_p.h b/src/qmldebug/qqmlprofilerclient_p.h index 0c867525d2..89c117a8b5 100644 --- a/src/qmldebug/qqmlprofilerclient_p.h +++ b/src/qmldebug/qqmlprofilerclient_p.h @@ -43,8 +43,8 @@ #include "qqmldebugclient_p.h" #include "qqmlprofilereventlocation_p.h" #include "qqmlprofilereventreceiver_p.h" +#include "qqmlprofilerclientdefinitions_p.h" -#include <private/qqmlprofilerdefinitions_p.h> #include <private/qpacket_p.h> // @@ -61,7 +61,7 @@ QT_BEGIN_NAMESPACE class QQmlProfilerClientPrivate; -class QQmlProfilerClient : public QQmlDebugClient, public QQmlProfilerDefinitions +class QQmlProfilerClient : public QQmlDebugClient { Q_OBJECT Q_DECLARE_PRIVATE(QQmlProfilerClient) diff --git a/src/qmldebug/qqmlprofilerclient_p_p.h b/src/qmldebug/qqmlprofilerclient_p_p.h index 99fe47301b..df73209858 100644 --- a/src/qmldebug/qqmlprofilerclient_p_p.h +++ b/src/qmldebug/qqmlprofilerclient_p_p.h @@ -45,10 +45,10 @@ #include "qqmlenginecontrolclient_p.h" #include "qqmlprofilerclient_p.h" #include "qqmlprofilertypedevent_p.h" - -#include <private/qqmlprofilerdefinitions_p.h> +#include "qqmlprofilerclientdefinitions_p.h" #include <QtCore/qqueue.h> +#include <QtCore/qstack.h> // // W A R N I N G @@ -63,7 +63,7 @@ QT_BEGIN_NAMESPACE -class QQmlProfilerClientPrivate : public QQmlDebugClientPrivate, public QQmlProfilerDefinitions { +class QQmlProfilerClientPrivate : public QQmlDebugClientPrivate { Q_DECLARE_PUBLIC(QQmlProfilerClient) public: QQmlProfilerClientPrivate(QQmlDebugConnection *connection, diff --git a/src/qmldebug/qqmlprofilerclientdefinitions_p.h b/src/qmldebug/qqmlprofilerclientdefinitions_p.h new file mode 100644 index 0000000000..c8524574f6 --- /dev/null +++ b/src/qmldebug/qqmlprofilerclientdefinitions_p.h @@ -0,0 +1,152 @@ +/**************************************************************************** +** +** Copyright (C) 2018 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QQMLPROFILERCLIENTDEFINITIONS_P_H +#define QQMLPROFILERCLIENTDEFINITIONS_P_H + +#include <QtCore/qglobal.h> + +QT_BEGIN_NAMESPACE + +enum Message { + Event, + RangeStart, + RangeData, + RangeLocation, + RangeEnd, + Complete, // end of transmission + PixmapCacheEvent, + SceneGraphFrame, + MemoryAllocation, + DebugMessage, + + MaximumMessage +}; + +enum EventType { + FramePaint, + Mouse, + Key, + AnimationFrame, + EndTrace, + StartTrace, + + MaximumEventType +}; + +enum RangeType { + Painting, + Compiling, + Creating, + Binding, //running a binding + HandlingSignal, //running a signal handler + Javascript, + + MaximumRangeType +}; + +enum PixmapEventType { + PixmapSizeKnown, + PixmapReferenceCountChanged, + PixmapCacheCountChanged, + PixmapLoadingStarted, + PixmapLoadingFinished, + PixmapLoadingError, + + MaximumPixmapEventType +}; + +enum SceneGraphFrameType { + SceneGraphRendererFrame, // Render Thread + SceneGraphAdaptationLayerFrame, // Render Thread + SceneGraphContextFrame, // Render Thread + SceneGraphRenderLoopFrame, // Render Thread + SceneGraphTexturePrepare, // Render Thread + SceneGraphTextureDeletion, // Render Thread + SceneGraphPolishAndSync, // GUI Thread + SceneGraphWindowsRenderShow, // Unused + SceneGraphWindowsAnimations, // GUI Thread + SceneGraphPolishFrame, // GUI Thread + + MaximumSceneGraphFrameType, + NumRenderThreadFrameTypes = SceneGraphPolishAndSync, + NumGUIThreadFrameTypes = MaximumSceneGraphFrameType - NumRenderThreadFrameTypes +}; + +enum MemoryType { + HeapPage, + LargeItem, + SmallItem +}; + +enum ProfileFeature { + ProfileJavaScript, + ProfileMemory, + ProfilePixmapCache, + ProfileSceneGraph, + ProfileAnimations, + ProfilePainting, + ProfileCompiling, + ProfileCreating, + ProfileBinding, + ProfileHandlingSignal, + ProfileInputEvents, + ProfileDebugMessages, + + MaximumProfileFeature +}; + +enum InputEventType { + InputKeyPress, + InputKeyRelease, + InputKeyUnknown, + + InputMousePress, + InputMouseRelease, + InputMouseMove, + InputMouseDoubleClick, + InputMouseWheel, + InputMouseUnknown, + + MaximumInputEventType +}; + +QT_END_NAMESPACE + +#endif // QQMLPROFILERCLIENTDEFINITIONS_P_H diff --git a/src/qmldebug/qqmlprofilerevent_p.h b/src/qmldebug/qqmlprofilerevent_p.h index 49a0c9e347..1e205d8dbb 100644 --- a/src/qmldebug/qqmlprofilerevent_p.h +++ b/src/qmldebug/qqmlprofilerevent_p.h @@ -40,7 +40,7 @@ #ifndef QQMLPROFILEREVENT_P_H #define QQMLPROFILEREVENT_P_H -#include <private/qqmlprofilerdefinitions_p.h> +#include "qqmlprofilerclientdefinitions_p.h" #include <QtCore/qstring.h> #include <QtCore/qbytearray.h> @@ -63,7 +63,7 @@ QT_BEGIN_NAMESPACE -struct QQmlProfilerEvent : public QQmlProfilerDefinitions { +struct QQmlProfilerEvent { QQmlProfilerEvent() : m_timestamp(-1), m_typeIndex(-1), m_dataType(Inline8Bit), m_dataLength(0) {} diff --git a/src/qmldebug/qqmlprofilereventtype.cpp b/src/qmldebug/qqmlprofilereventtype.cpp index b0aad3fc5b..c92e914d74 100644 --- a/src/qmldebug/qqmlprofilereventtype.cpp +++ b/src/qmldebug/qqmlprofilereventtype.cpp @@ -38,6 +38,7 @@ ****************************************************************************/ #include "qqmlprofilereventtype_p.h" +#include "qqmlprofilerclientdefinitions_p.h" #include <QtCore/qdatastream.h> @@ -49,8 +50,8 @@ QDataStream &operator>>(QDataStream &stream, QQmlProfilerEventType &type) quint8 rangeType; stream >> type.m_displayName >> type.m_data >> type.m_location >> message >> rangeType >> type.m_detailType; - type.m_message = static_cast<QQmlProfilerDefinitions::Message>(message); - type.m_rangeType = static_cast<QQmlProfilerDefinitions::RangeType>(rangeType); + type.m_message = static_cast<Message>(message); + type.m_rangeType = static_cast<RangeType>(rangeType); return stream; } @@ -61,7 +62,7 @@ QDataStream &operator<<(QDataStream &stream, const QQmlProfilerEventType &type) << type.m_detailType; } -QQmlProfilerDefinitions::ProfileFeature QQmlProfilerEventType::feature() const +ProfileFeature QQmlProfilerEventType::feature() const { switch (m_message) { case Event: { @@ -84,7 +85,24 @@ QQmlProfilerDefinitions::ProfileFeature QQmlProfilerEventType::feature() const case DebugMessage: return ProfileDebugMessages; default: - return featureFromRangeType(m_rangeType); + break; + } + + switch (m_rangeType) { + case Painting: + return ProfilePainting; + case Compiling: + return ProfileCompiling; + case Creating: + return ProfileCreating; + case Binding: + return ProfileBinding; + case HandlingSignal: + return ProfileHandlingSignal; + case Javascript: + return ProfileJavaScript; + default: + return MaximumProfileFeature; } } diff --git a/src/qmldebug/qqmlprofilereventtype_p.h b/src/qmldebug/qqmlprofilereventtype_p.h index 7bd67f9ca8..7189df53ef 100644 --- a/src/qmldebug/qqmlprofilereventtype_p.h +++ b/src/qmldebug/qqmlprofilereventtype_p.h @@ -41,8 +41,7 @@ #define QQMLPROFILEREVENTTYPE_P_H #include "qqmlprofilereventlocation_p.h" - -#include <private/qqmlprofilerdefinitions_p.h> +#include "qqmlprofilerclientdefinitions_p.h" #include <QtCore/qstring.h> #include <QtCore/qmetatype.h> @@ -61,7 +60,7 @@ QT_BEGIN_NAMESPACE -class QQmlProfilerEventType : public QQmlProfilerDefinitions { +class QQmlProfilerEventType { public: QQmlProfilerEventType(Message message = MaximumMessage, RangeType rangeType = MaximumRangeType, int detailType = -1, diff --git a/src/qmldebug/qqmlprofilertypedevent.cpp b/src/qmldebug/qqmlprofilertypedevent.cpp index 9b00481e17..31a36bd052 100644 --- a/src/qmldebug/qqmlprofilertypedevent.cpp +++ b/src/qmldebug/qqmlprofilertypedevent.cpp @@ -38,6 +38,8 @@ ****************************************************************************/ #include "qqmlprofilertypedevent_p.h" +#include "qqmlprofilerclientdefinitions_p.h" + #include <QtCore/qvarlengtharray.h> QT_BEGIN_NAMESPACE @@ -50,15 +52,15 @@ QDataStream &operator>>(QDataStream &stream, QQmlProfilerTypedEvent &event) stream >> time >> messageType; - if (messageType < 0 || messageType > QQmlProfilerDefinitions::MaximumMessage) - messageType = QQmlProfilerDefinitions::MaximumMessage; + if (messageType < 0 || messageType > MaximumMessage) + messageType = MaximumMessage; - QQmlProfilerDefinitions::RangeType rangeType = QQmlProfilerDefinitions::MaximumRangeType; + RangeType rangeType = MaximumRangeType; if (!stream.atEnd()) { stream >> subtype; - rangeType = static_cast<QQmlProfilerDefinitions::RangeType>(subtype); - if (rangeType < 0 || rangeType > QQmlProfilerDefinitions::MaximumRangeType) - rangeType = QQmlProfilerDefinitions::MaximumRangeType; + rangeType = static_cast<RangeType>(subtype); + if (rangeType < 0 || rangeType > MaximumRangeType) + rangeType = MaximumRangeType; } else { subtype = -1; } @@ -68,13 +70,13 @@ QDataStream &operator>>(QDataStream &stream, QQmlProfilerTypedEvent &event) event.serverTypeId = 0; switch (messageType) { - case QQmlProfilerDefinitions::Event: { + case Event: { event.type = QQmlProfilerEventType( - static_cast<QQmlProfilerDefinitions::Message>(messageType), - QQmlProfilerDefinitions::MaximumRangeType, subtype); + static_cast<Message>(messageType), + MaximumRangeType, subtype); switch (subtype) { - case QQmlProfilerDefinitions::StartTrace: - case QQmlProfilerDefinitions::EndTrace: { + case StartTrace: + case EndTrace: { QVarLengthArray<qint32> engineIds; while (!stream.atEnd()) { qint32 id; @@ -84,7 +86,7 @@ QDataStream &operator>>(QDataStream &stream, QQmlProfilerTypedEvent &event) event.event.setNumbers<QVarLengthArray<qint32>, qint32>(engineIds); break; } - case QQmlProfilerDefinitions::AnimationFrame: { + case AnimationFrame: { qint32 frameRate, animationCount; qint32 threadId; stream >> frameRate >> animationCount; @@ -96,11 +98,9 @@ QDataStream &operator>>(QDataStream &stream, QQmlProfilerTypedEvent &event) event.event.setNumbers<qint32>({frameRate, animationCount, threadId}); break; } - case QQmlProfilerDefinitions::Mouse: - case QQmlProfilerDefinitions::Key: - int inputType = (subtype == QQmlProfilerDefinitions::Key - ? QQmlProfilerDefinitions::InputKeyUnknown - : QQmlProfilerDefinitions::InputMouseUnknown); + case Mouse: + case Key: + int inputType = (subtype == Key ? InputKeyUnknown : InputMouseUnknown); if (!stream.atEnd()) stream >> inputType; qint32 a = -1; @@ -116,13 +116,13 @@ QDataStream &operator>>(QDataStream &stream, QQmlProfilerTypedEvent &event) break; } - case QQmlProfilerDefinitions::Complete: { + case Complete: { event.type = QQmlProfilerEventType( - static_cast<QQmlProfilerDefinitions::Message>(messageType), - QQmlProfilerDefinitions::MaximumRangeType, subtype); + static_cast<Message>(messageType), + MaximumRangeType, subtype); break; } - case QQmlProfilerDefinitions::SceneGraphFrame: { + case SceneGraphFrame: { QVarLengthArray<qint64> params; qint64 param; @@ -132,41 +132,40 @@ QDataStream &operator>>(QDataStream &stream, QQmlProfilerTypedEvent &event) } event.type = QQmlProfilerEventType( - static_cast<QQmlProfilerDefinitions::Message>(messageType), - QQmlProfilerDefinitions::MaximumRangeType, subtype); + static_cast<Message>(messageType), + MaximumRangeType, subtype); event.event.setNumbers<QVarLengthArray<qint64>, qint64>(params); break; } - case QQmlProfilerDefinitions::PixmapCacheEvent: { + case PixmapCacheEvent: { qint32 width = 0, height = 0, refcount = 0; QString filename; stream >> filename; - if (subtype == QQmlProfilerDefinitions::PixmapReferenceCountChanged - || subtype == QQmlProfilerDefinitions::PixmapCacheCountChanged) { + if (subtype == PixmapReferenceCountChanged || subtype == PixmapCacheCountChanged) { stream >> refcount; - } else if (subtype == QQmlProfilerDefinitions::PixmapSizeKnown) { + } else if (subtype == PixmapSizeKnown) { stream >> width >> height; refcount = 1; } event.type = QQmlProfilerEventType( - static_cast<QQmlProfilerDefinitions::Message>(messageType), - QQmlProfilerDefinitions::MaximumRangeType, subtype, + static_cast<Message>(messageType), + MaximumRangeType, subtype, QQmlProfilerEventLocation(filename, 0, 0)); event.event.setNumbers<qint32>({width, height, refcount}); break; } - case QQmlProfilerDefinitions::MemoryAllocation: { + case MemoryAllocation: { qint64 delta; stream >> delta; event.type = QQmlProfilerEventType( - static_cast<QQmlProfilerDefinitions::Message>(messageType), - QQmlProfilerDefinitions::MaximumRangeType, subtype); + static_cast<Message>(messageType), + MaximumRangeType, subtype); event.event.setNumbers<qint64>({delta}); break; } - case QQmlProfilerDefinitions::RangeStart: { + case RangeStart: { if (!stream.atEnd()) { qint64 typeId; stream >> typeId; @@ -175,22 +174,22 @@ QDataStream &operator>>(QDataStream &stream, QQmlProfilerTypedEvent &event) // otherwise it's the old binding type of 4 bytes } - event.type = QQmlProfilerEventType(QQmlProfilerDefinitions::MaximumMessage, rangeType, -1); - event.event.setRangeStage(QQmlProfilerDefinitions::RangeStart); + event.type = QQmlProfilerEventType(MaximumMessage, rangeType, -1); + event.event.setRangeStage(RangeStart); break; } - case QQmlProfilerDefinitions::RangeData: { + case RangeData: { QString data; stream >> data; - event.type = QQmlProfilerEventType(QQmlProfilerDefinitions::MaximumMessage, rangeType, -1, + event.type = QQmlProfilerEventType(MaximumMessage, rangeType, -1, QQmlProfilerEventLocation(), data); - event.event.setRangeStage(QQmlProfilerDefinitions::RangeData); + event.event.setRangeStage(RangeData); if (!stream.atEnd()) stream >> event.serverTypeId; break; } - case QQmlProfilerDefinitions::RangeLocation: { + case RangeLocation: { QString filename; qint32 line = 0; qint32 column = 0; @@ -202,21 +201,21 @@ QDataStream &operator>>(QDataStream &stream, QQmlProfilerTypedEvent &event) stream >> event.serverTypeId; } - event.type = QQmlProfilerEventType(QQmlProfilerDefinitions::MaximumMessage, rangeType, -1, + event.type = QQmlProfilerEventType(MaximumMessage, rangeType, -1, QQmlProfilerEventLocation(filename, line, column)); - event.event.setRangeStage(QQmlProfilerDefinitions::RangeLocation); + event.event.setRangeStage(RangeLocation); break; } - case QQmlProfilerDefinitions::RangeEnd: { - event.type = QQmlProfilerEventType(QQmlProfilerDefinitions::MaximumMessage, rangeType, -1); - event.event.setRangeStage(QQmlProfilerDefinitions::RangeEnd); + case RangeEnd: { + event.type = QQmlProfilerEventType(MaximumMessage, rangeType, -1); + event.event.setRangeStage(RangeEnd); break; } default: event.event.setNumbers<char>({}); event.type = QQmlProfilerEventType( - static_cast<QQmlProfilerDefinitions::Message>(messageType), - QQmlProfilerDefinitions::MaximumRangeType, subtype); + static_cast<Message>(messageType), + MaximumRangeType, subtype); break; } diff --git a/src/quick/items/qquicklistview.cpp b/src/quick/items/qquicklistview.cpp index 33becd71ec..60f7efae12 100644 --- a/src/quick/items/qquicklistview.cpp +++ b/src/quick/items/qquicklistview.cpp @@ -538,8 +538,13 @@ FxViewItem *QQuickListViewPrivate::snapItemAt(qreal pos) qreal itemTop = item->position(); if (highlight && itemTop >= pos && item->endPosition() <= pos + highlight->size()) return item; - if (itemTop+item->size()/2 >= pos && itemTop-prevItemSize/2 < pos) + + // Middle of item and spacing (i.e. the middle of the distance between this item and the next + qreal halfwayToNextItem = itemTop + (item->size()+spacing) / 2; + qreal halfwayToPrevItem = itemTop - (prevItemSize+spacing) / 2; + if (halfwayToNextItem >= pos && halfwayToPrevItem < pos) snapItem = item; + prevItemSize = item->size(); } return snapItem; diff --git a/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp b/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp index ba71551302..afe3380494 100644 --- a/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp +++ b/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp @@ -775,9 +775,7 @@ Renderer::Renderer(QSGDefaultRenderContext *ctx) , m_currentClip(nullptr) , m_currentClipType(NoClip) , m_vertexUploadPool(256) -#ifdef QSG_SEPARATE_INDEX_BUFFER , m_indexUploadPool(64) -#endif , m_vao(nullptr) , m_visualizeMode(VisualizeNothing) { @@ -834,12 +832,11 @@ static void qsg_wipeBuffer(Buffer *buffer, QOpenGLFunctions *funcs) free(buffer->data); } -static void qsg_wipeBatch(Batch *batch, QOpenGLFunctions *funcs) +static void qsg_wipeBatch(Batch *batch, QOpenGLFunctions *funcs, bool separateIndexBuffer) { qsg_wipeBuffer(&batch->vbo, funcs); -#ifdef QSG_SEPARATE_INDEX_BUFFER - qsg_wipeBuffer(&batch->ibo, funcs); -#endif + if (separateIndexBuffer) + qsg_wipeBuffer(&batch->ibo, funcs); delete batch; } @@ -847,9 +844,13 @@ Renderer::~Renderer() { if (QOpenGLContext::currentContext()) { // Clean up batches and buffers - for (int i=0; i<m_opaqueBatches.size(); ++i) qsg_wipeBatch(m_opaqueBatches.at(i), this); - for (int i=0; i<m_alphaBatches.size(); ++i) qsg_wipeBatch(m_alphaBatches.at(i), this); - for (int i=0; i<m_batchPool.size(); ++i) qsg_wipeBatch(m_batchPool.at(i), this); + const bool separateIndexBuffer = m_context->separateIndexBuffer(); + for (int i = 0; i < m_opaqueBatches.size(); ++i) + qsg_wipeBatch(m_opaqueBatches.at(i), this, separateIndexBuffer); + for (int i = 0; i < m_alphaBatches.size(); ++i) + qsg_wipeBatch(m_alphaBatches.at(i), this, separateIndexBuffer); + for (int i = 0; i < m_batchPool.size(); ++i) + qsg_wipeBatch(m_batchPool.at(i), this, separateIndexBuffer); } for (Node *n : qAsConst(m_nodes)) @@ -889,13 +890,8 @@ void Renderer::map(Buffer *buffer, int byteSize, bool isIndexBuf) if (!m_context->hasBrokenIndexBufferObjects() && m_visualizeMode == VisualizeNothing) { // Common case, use a shared memory pool for uploading vertex data to avoid // excessive reevaluation - QDataBuffer<char> &pool = -#ifdef QSG_SEPARATE_INDEX_BUFFER - isIndexBuf ? m_indexUploadPool : m_vertexUploadPool; -#else - m_vertexUploadPool; - Q_UNUSED(isIndexBuf); -#endif + QDataBuffer<char> &pool = m_context->separateIndexBuffer() && isIndexBuf + ? m_indexUploadPool : m_vertexUploadPool; if (byteSize > pool.size()) pool.resize(byteSize); buffer->data = pool.data(); @@ -1864,11 +1860,11 @@ void Renderer::uploadBatch(Batch *b) ibufferSize = unmergedIndexSize; } -#ifdef QSG_SEPARATE_INDEX_BUFFER - map(&b->ibo, ibufferSize, true); -#else - bufferSize += ibufferSize; -#endif + const bool separateIndexBuffer = m_context->separateIndexBuffer(); + if (separateIndexBuffer) + map(&b->ibo, ibufferSize, true); + else + bufferSize += ibufferSize; map(&b->vbo, bufferSize); if (Q_UNLIKELY(debug_upload())) qDebug() << " - batch" << b << " first:" << b->first << " root:" @@ -1878,22 +1874,17 @@ void Renderer::uploadBatch(Batch *b) if (b->merged) { char *vertexData = b->vbo.data; char *zData = vertexData + b->vertexCount * g->sizeOfVertex(); -#ifdef QSG_SEPARATE_INDEX_BUFFER - char *indexData = b->ibo.data; -#else - char *indexData = zData + (m_useDepthBuffer ? b->vertexCount * sizeof(float) : 0); -#endif + char *indexData = separateIndexBuffer + ? b->ibo.data + : zData + (int(m_useDepthBuffer) * b->vertexCount * sizeof(float)); quint16 iOffset = 0; e = b->first; int verticesInSet = 0; int indicesInSet = 0; b->drawSets.reset(); -#ifdef QSG_SEPARATE_INDEX_BUFFER - int drawSetIndices = 0; -#else - int drawSetIndices = indexData - vertexData; -#endif + int drawSetIndices = separateIndexBuffer ? 0 : indexData - vertexData; + const auto indexBase = separateIndexBuffer ? b->ibo.data : b->vbo.data; b->drawSets << DrawSet(0, zData - vertexData, drawSetIndices); while (e) { verticesInSet += e->node->geometry()->vertexCount(); @@ -1903,11 +1894,7 @@ void Renderer::uploadBatch(Batch *b) b->drawSets.last().indices += 1 * sizeof(quint16); b->drawSets.last().indexCount -= 2; } -#ifdef QSG_SEPARATE_INDEX_BUFFER - drawSetIndices = indexData - b->ibo.data; -#else - drawSetIndices = indexData - b->vbo.data; -#endif + drawSetIndices = indexData - indexBase; b->drawSets << DrawSet(vertexData - b->vbo.data, zData - b->vbo.data, drawSetIndices); @@ -1927,11 +1914,8 @@ void Renderer::uploadBatch(Batch *b) } } else { char *vboData = b->vbo.data; -#ifdef QSG_SEPARATE_INDEX_BUFFER - char *iboData = b->ibo.data; -#else - char *iboData = vboData + b->vertexCount * g->sizeOfVertex(); -#endif + char *iboData = separateIndexBuffer ? b->ibo.data + : vboData + b->vertexCount * g->sizeOfVertex(); Element *e = b->first; while (e) { QSGGeometry *g = e->node->geometry(); @@ -1979,12 +1963,9 @@ void Renderer::uploadBatch(Batch *b) } if (!b->drawSets.isEmpty()) { - const quint16 *id = -# ifdef QSG_SEPARATE_INDEX_BUFFER - (const quint16 *) (b->ibo.data); -# else - (const quint16 *) (b->vbo.data + b->drawSets.at(0).indices); -# endif + const quint16 *id = (const quint16 *)(separateIndexBuffer + ? b->ibo.data + : b->vbo.data + b->drawSets.at(0).indices); { QDebug iDump = qDebug(); iDump << " -- Index Data, count:" << b->indexCount; @@ -2004,9 +1985,8 @@ void Renderer::uploadBatch(Batch *b) #endif // QT_NO_DEBUG_OUTPUT unmap(&b->vbo); -#ifdef QSG_SEPARATE_INDEX_BUFFER - unmap(&b->ibo, true); -#endif + if (separateIndexBuffer) + unmap(&b->ibo, true); if (Q_UNLIKELY(debug_upload())) qDebug() << " --- vertex/index buffers unmapped, batch upload completed..."; @@ -2299,11 +2279,7 @@ void Renderer::renderMergedBatch(const Batch *batch) glBindBuffer(GL_ARRAY_BUFFER, batch->vbo.id); char *indexBase = nullptr; -#ifdef QSG_SEPARATE_INDEX_BUFFER - const Buffer *indexBuf = &batch->ibo; -#else - const Buffer *indexBuf = &batch->vbo; -#endif + const Buffer *indexBuf = m_context->separateIndexBuffer() ? &batch->ibo : &batch->vbo; if (m_context->hasBrokenIndexBufferObjects()) { indexBase = indexBuf->data; glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); @@ -2395,11 +2371,8 @@ void Renderer::renderUnmergedBatch(const Batch *batch) glBindBuffer(GL_ARRAY_BUFFER, batch->vbo.id); char *indexBase = nullptr; -#ifdef QSG_SEPARATE_INDEX_BUFFER - const Buffer *indexBuf = &batch->ibo; -#else - const Buffer *indexBuf = &batch->vbo; -#endif + const auto separateIndexBuffer = m_context->separateIndexBuffer(); + const Buffer *indexBuf = separateIndexBuffer ? &batch->ibo : &batch->vbo; if (batch->indexCount) { if (m_context->hasBrokenIndexBufferObjects()) { indexBase = indexBuf->data; @@ -2428,11 +2401,9 @@ void Renderer::renderUnmergedBatch(const Batch *batch) } int vOffset = 0; -#ifdef QSG_SEPARATE_INDEX_BUFFER char *iOffset = indexBase; -#else - char *iOffset = indexBase + batch->vertexCount * gn->geometry()->sizeOfVertex(); -#endif + if (!separateIndexBuffer) + iOffset += batch->vertexCount * gn->geometry()->sizeOfVertex(); QMatrix4x4 rootMatrix = batch->root ? qsg_matrixForRoot(batch->root) : QMatrix4x4(); @@ -2735,17 +2706,13 @@ void Renderer::render() if (Q_UNLIKELY(debug_render())) timeSorting = timer.restart(); int largestVBO = 0; -#ifdef QSG_SEPARATE_INDEX_BUFFER int largestIBO = 0; -#endif if (Q_UNLIKELY(debug_upload())) qDebug("Uploading Opaque Batches:"); for (int i=0; i<m_opaqueBatches.size(); ++i) { Batch *b = m_opaqueBatches.at(i); largestVBO = qMax(b->vbo.size, largestVBO); -#ifdef QSG_SEPARATE_INDEX_BUFFER largestIBO = qMax(b->ibo.size, largestIBO); -#endif uploadBatch(b); } if (Q_UNLIKELY(debug_render())) timeUploadOpaque = timer.restart(); @@ -2756,18 +2723,14 @@ void Renderer::render() Batch *b = m_alphaBatches.at(i); uploadBatch(b); largestVBO = qMax(b->vbo.size, largestVBO); -#ifdef QSG_SEPARATE_INDEX_BUFFER largestIBO = qMax(b->ibo.size, largestIBO); -#endif } if (Q_UNLIKELY(debug_render())) timeUploadAlpha = timer.restart(); if (largestVBO * 2 < m_vertexUploadPool.size()) m_vertexUploadPool.resize(largestVBO * 2); -#ifdef QSG_SEPARATE_INDEX_BUFFER - if (largestIBO * 2 < m_indexUploadPool.size()) + if (m_context->separateIndexBuffer() && largestIBO * 2 < m_indexUploadPool.size()) m_indexUploadPool.resize(largestIBO * 2); -#endif renderBatches(); @@ -2978,14 +2941,12 @@ void Renderer::visualizeBatch(Batch *b) if (b->merged) { shader->setUniformValue(shader->matrix, matrix); + const auto &dataStart = m_context->separateIndexBuffer() ? b->ibo.data : b->vbo.data; for (int ds=0; ds<b->drawSets.size(); ++ds) { const DrawSet &set = b->drawSets.at(ds); glVertexAttribPointer(a.position, 2, a.type, false, g->sizeOfVertex(), (void *) (qintptr) (set.vertices)); -#ifdef QSG_SEPARATE_INDEX_BUFFER - glDrawElements(g->drawingMode(), set.indexCount, GL_UNSIGNED_SHORT, (void *) (qintptr) (b->ibo.data + set.indices)); -#else - glDrawElements(g->drawingMode(), set.indexCount, GL_UNSIGNED_SHORT, (void *) (qintptr) (b->vbo.data + set.indices)); -#endif + glDrawElements(g->drawingMode(), set.indexCount, GL_UNSIGNED_SHORT, + (void *)(qintptr)(dataStart + set.indices)); } } else { Element *e = b->first; diff --git a/src/quick/scenegraph/coreapi/qsgbatchrenderer_p.h b/src/quick/scenegraph/coreapi/qsgbatchrenderer_p.h index 918f3ce82c..12b48c1451 100644 --- a/src/quick/scenegraph/coreapi/qsgbatchrenderer_p.h +++ b/src/quick/scenegraph/coreapi/qsgbatchrenderer_p.h @@ -433,9 +433,7 @@ struct Batch mutable uint uploadedThisFrame : 1; // solely for debugging purposes Buffer vbo; -#ifdef QSG_SEPARATE_INDEX_BUFFER Buffer ibo; -#endif QDataBuffer<DrawSet> drawSets; }; @@ -738,9 +736,7 @@ private: ClipType m_currentClipType; QDataBuffer<char> m_vertexUploadPool; -#ifdef QSG_SEPARATE_INDEX_BUFFER QDataBuffer<char> m_indexUploadPool; -#endif // For minimal OpenGL core profile support QOpenGLVertexArrayObject *m_vao; @@ -760,10 +756,8 @@ Batch *Renderer::newBatch() m_batchPool.resize(size - 1); } else { b = new Batch(); - memset(&b->vbo, 0, sizeof(Buffer)); -#ifdef QSG_SEPARATE_INDEX_BUFFER - memset(&b->ibo, 0, sizeof(Buffer)); -#endif + Q_ASSERT(offsetof(Batch, ibo) == sizeof(Buffer) + offsetof(Batch, vbo)); + memset(&b->vbo, 0, sizeof(Buffer) * 2); // Clear VBO & IBO } b->init(); return b; diff --git a/src/quick/scenegraph/qsgdefaultrendercontext.cpp b/src/quick/scenegraph/qsgdefaultrendercontext.cpp index 7882496062..22e97a2dc9 100644 --- a/src/quick/scenegraph/qsgdefaultrendercontext.cpp +++ b/src/quick/scenegraph/qsgdefaultrendercontext.cpp @@ -39,6 +39,7 @@ #include "qsgdefaultrendercontext_p.h" +#include <QtGui/QGuiApplication> #include <QtGui/QOpenGLFramebufferObject> #include <QtQuick/private/qsgbatchrenderer_p.h> @@ -317,6 +318,17 @@ QSGDefaultRenderContext *QSGDefaultRenderContext::from(QOpenGLContext *context) return qobject_cast<QSGDefaultRenderContext *>(context->property(QSG_RENDERCONTEXT_PROPERTY).value<QObject *>()); } +bool QSGDefaultRenderContext::separateIndexBuffer() const +{ + // WebGL: A given WebGLBuffer object may only be bound to one of + // the ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target in its + // lifetime. An attempt to bind a buffer object to the other + // target will generate an INVALID_OPERATION error, and the + // current binding will remain untouched. + static const bool isWebGL = qGuiApp->platformName().compare(QLatin1String("webgl")) == 0; + return isWebGL; +} + QSGDistanceFieldGlyphCache *QSGDefaultRenderContext::distanceFieldGlyphCache(const QRawFont &font) { QString key = fontKey(font); diff --git a/src/quick/scenegraph/qsgdefaultrendercontext_p.h b/src/quick/scenegraph/qsgdefaultrendercontext_p.h index eb62586a94..57aa4b4c90 100644 --- a/src/quick/scenegraph/qsgdefaultrendercontext_p.h +++ b/src/quick/scenegraph/qsgdefaultrendercontext_p.h @@ -95,6 +95,7 @@ public: bool hasBrokenIndexBufferObjects() const { return m_brokenIBOs; } int maxTextureSize() const override { return m_maxTextureSize; } + bool separateIndexBuffer() const; protected: static QString fontKey(const QRawFont &font); @@ -106,8 +107,6 @@ protected: bool m_serializedRender; bool m_attachToGLContext; QSGAtlasTexture::Manager *m_atlasManager; - - }; QT_END_NAMESPACE diff --git a/src/quick/scenegraph/scenegraph.pri b/src/quick/scenegraph/scenegraph.pri index 4fa3e7b6bf..4f98638487 100644 --- a/src/quick/scenegraph/scenegraph.pri +++ b/src/quick/scenegraph/scenegraph.pri @@ -1,4 +1,3 @@ -# DEFINES += QSG_SEPARATE_INDEX_BUFFER # DEFINES += QSG_DISTANCEFIELD_CACHE_DEBUG # Core API diff --git a/tests/auto/qml/debugger/qdebugmessageservice/qdebugmessageservice.pro b/tests/auto/qml/debugger/qdebugmessageservice/qdebugmessageservice.pro index 9cf323ba36..3f2c0ca390 100644 --- a/tests/auto/qml/debugger/qdebugmessageservice/qdebugmessageservice.pro +++ b/tests/auto/qml/debugger/qdebugmessageservice/qdebugmessageservice.pro @@ -1,6 +1,6 @@ CONFIG += testcase TARGET = tst_qdebugmessageservice -QT += qml network testlib gui-private core-private +QT += network testlib gui-private core-private osx:CONFIG -= app_bundle SOURCES += tst_qdebugmessageservice.cpp diff --git a/tests/auto/qml/debugger/qpacketprotocol/qpacketprotocol.pro b/tests/auto/qml/debugger/qpacketprotocol/qpacketprotocol.pro index b1e3835844..dc0120cd87 100644 --- a/tests/auto/qml/debugger/qpacketprotocol/qpacketprotocol.pro +++ b/tests/auto/qml/debugger/qpacketprotocol/qpacketprotocol.pro @@ -6,4 +6,4 @@ SOURCES += tst_qpacketprotocol.cpp include(../shared/debugutil.pri) -QT += qml network testlib gui-private core-private +QT += network testlib gui-private core-private diff --git a/tests/auto/qml/debugger/qqmldebuglocal/tst_qqmldebuglocal.cpp b/tests/auto/qml/debugger/qqmldebuglocal/tst_qqmldebuglocal.cpp index 9f0501241d..5b3c0c5240 100644 --- a/tests/auto/qml/debugger/qqmldebuglocal/tst_qqmldebuglocal.cpp +++ b/tests/auto/qml/debugger/qqmldebuglocal/tst_qqmldebuglocal.cpp @@ -32,7 +32,6 @@ #include <private/qqmldebugconnector_p.h> #include <private/qqmldebugconnection_p.h> -#include <QtQml/qqmldebug.h> #include <QtQml/qqmlengine.h> #include <QtTest/qtest.h> diff --git a/tests/auto/qml/debugger/qqmlenginecontrol/qqmlenginecontrol.pro b/tests/auto/qml/debugger/qqmlenginecontrol/qqmlenginecontrol.pro index 73455bd903..36957628b2 100644 --- a/tests/auto/qml/debugger/qqmlenginecontrol/qqmlenginecontrol.pro +++ b/tests/auto/qml/debugger/qqmlenginecontrol/qqmlenginecontrol.pro @@ -8,7 +8,7 @@ include(../shared/debugutil.pri) TESTDATA = data/* -QT += core qml testlib gui-private core-private +QT += core testlib gui-private core-private OTHER_FILES += \ data/test.qml \ diff --git a/tests/auto/qml/debugger/qqmlenginedebuginspectorintegrationtest/qqmlenginedebuginspectorintegrationtest.pro b/tests/auto/qml/debugger/qqmlenginedebuginspectorintegrationtest/qqmlenginedebuginspectorintegrationtest.pro index 5f58e5ec7f..54244c6d16 100644 --- a/tests/auto/qml/debugger/qqmlenginedebuginspectorintegrationtest/qqmlenginedebuginspectorintegrationtest.pro +++ b/tests/auto/qml/debugger/qqmlenginedebuginspectorintegrationtest/qqmlenginedebuginspectorintegrationtest.pro @@ -1,7 +1,7 @@ CONFIG += testcase TARGET = tst_qqmlenginedebuginspectorintegration -QT += qml testlib gui-private core-private +QT += testlib gui-private core-private osx:CONFIG -= app_bundle SOURCES += tst_qqmlenginedebuginspectorintegration.cpp diff --git a/tests/auto/qml/debugger/qqmlenginedebugservice/qqmlenginedebugservice.pro b/tests/auto/qml/debugger/qqmlenginedebugservice/qqmlenginedebugservice.pro index 33ee023c06..ed4224446e 100644 --- a/tests/auto/qml/debugger/qqmlenginedebugservice/qqmlenginedebugservice.pro +++ b/tests/auto/qml/debugger/qqmlenginedebugservice/qqmlenginedebugservice.pro @@ -10,4 +10,4 @@ include(../shared/debugutil.pri) DEFINES += QT_QML_DEBUG_NO_WARNING -QT += core-private qml-private quick-private testlib gui-private +QT += quick qml-private testlib diff --git a/tests/auto/qml/debugger/qqmlinspector/qqmlinspector.pro b/tests/auto/qml/debugger/qqmlinspector/qqmlinspector.pro index fd07255ae5..3d4473c693 100644 --- a/tests/auto/qml/debugger/qqmlinspector/qqmlinspector.pro +++ b/tests/auto/qml/debugger/qqmlinspector/qqmlinspector.pro @@ -1,7 +1,7 @@ CONFIG += testcase TARGET = tst_qqmlinspector -QT += qml testlib gui-private core-private +QT += testlib gui-private core-private osx:CONFIG -= app_bundle SOURCES += tst_qqmlinspector.cpp diff --git a/tests/auto/qml/debugger/qqmlprofilerservice/qqmlprofilerservice.pro b/tests/auto/qml/debugger/qqmlprofilerservice/qqmlprofilerservice.pro index 7c78b5fcb3..2a685ed877 100644 --- a/tests/auto/qml/debugger/qqmlprofilerservice/qqmlprofilerservice.pro +++ b/tests/auto/qml/debugger/qqmlprofilerservice/qqmlprofilerservice.pro @@ -8,7 +8,7 @@ include(../shared/debugutil.pri) TESTDATA = data/* -QT += core qml testlib testlib-private gui-private core-private +QT += testlib gui-private OTHER_FILES += \ data/pixmapCacheTest.qml \ diff --git a/tests/auto/qml/debugger/qqmlprofilerservice/tst_qqmlprofilerservice.cpp b/tests/auto/qml/debugger/qqmlprofilerservice/tst_qqmlprofilerservice.cpp index 562804bc45..3cb315b355 100644 --- a/tests/auto/qml/debugger/qqmlprofilerservice/tst_qqmlprofilerservice.cpp +++ b/tests/auto/qml/debugger/qqmlprofilerservice/tst_qqmlprofilerservice.cpp @@ -34,13 +34,12 @@ #include <private/qqmldebugconnection_p.h> #include <QtTest/qtest.h> -#include <private/qtestresult_p.h> #include <QtCore/qlibraryinfo.h> #include <QtGui/private/qguiapplication_p.h> #include <QtGui/qpa/qplatformintegration.h> -class QQmlProfilerTestClient : public QQmlProfilerEventReceiver, public QQmlProfilerDefinitions +class QQmlProfilerTestClient : public QQmlProfilerEventReceiver { Q_OBJECT @@ -229,8 +228,8 @@ private: bool m_isComplete = false; // Don't use ({...}) here as MSVC will interpret that as the "QVector(int size)" ctor. - const QVector<qint64> m_rangeStart = (QVector<qint64>() << QQmlProfilerDefinitions::RangeStart); - const QVector<qint64> m_rangeEnd = (QVector<qint64>() << QQmlProfilerDefinitions::RangeEnd); + const QVector<qint64> m_rangeStart = (QVector<qint64>() << RangeStart); + const QVector<qint64> m_rangeEnd = (QVector<qint64>() << RangeEnd); }; #define VERIFY(type, position, expected, checks, numbers) \ @@ -247,7 +246,7 @@ QQmlDebugTest::ConnectResult tst_QQmlProfilerService::connect( // ### Still using qmlscene due to QTBUG-33377 return QQmlDebugTest::connect( QLibraryInfo::location(QLibraryInfo::BinariesPath) + "/qmlscene", - restrictServices ? QQmlDebuggingEnabler::profilerServices().join(',') : QString(), + restrictServices ? "CanvasFrameRate,EngineControl,DebugMessages" : QString(), testFile(file), block); } @@ -272,15 +271,11 @@ void tst_QQmlProfilerService::checkTraceReceived() QVector<qint64> numbers; // must start with "StartTrace" - QQmlProfilerEventType expected(QQmlProfilerDefinitions::Event, - QQmlProfilerDefinitions::MaximumRangeType, - QQmlProfilerDefinitions::StartTrace); + QQmlProfilerEventType expected(Event, MaximumRangeType, StartTrace); VERIFY(MessageListAsynchronous, 0, expected, CheckMessageType | CheckDetailType, numbers); // must end with "EndTrace" - expected = QQmlProfilerEventType(QQmlProfilerDefinitions::Event, - QQmlProfilerDefinitions::MaximumRangeType, - QQmlProfilerDefinitions::EndTrace); + expected = QQmlProfilerEventType(Event, MaximumRangeType, EndTrace); VERIFY(MessageListAsynchronous, m_client->asynchronousMessages.length() - 1, expected, CheckMessageType | CheckDetailType, numbers); } @@ -299,15 +294,15 @@ void tst_QQmlProfilerService::checkJsHeap() const qint64 amount = message.number<qint64>(0); const QQmlProfilerEventType &type = m_client->types.at(message.typeIndex()); switch (type.detailType()) { - case QV4::Profiling::HeapPage: + case HeapPage: allocated += amount; seen_alloc = true; break; - case QV4::Profiling::SmallItem: + case SmallItem: used += amount; seen_small = true; break; - case QV4::Profiling::LargeItem: + case LargeItem: allocated += amount; used += amount; seen_large = true; @@ -548,28 +543,27 @@ void tst_QQmlProfilerService::pixmapCacheData() checkTraceReceived(); checkJsHeap(); - auto createType = [](QQmlProfilerDefinitions::PixmapEventType type) { - return QQmlProfilerEventType(QQmlProfilerDefinitions::PixmapCacheEvent, - QQmlProfilerDefinitions::MaximumRangeType, type); + auto createType = [](PixmapEventType type) { + return QQmlProfilerEventType(PixmapCacheEvent, MaximumRangeType, type); }; QVector<qint64> numbers; // image starting to load - VERIFY(MessageListPixmap, 0, createType(QQmlProfilerDefinitions::PixmapLoadingStarted), + VERIFY(MessageListPixmap, 0, createType(PixmapLoadingStarted), CheckMessageType | CheckDetailType, numbers); // image size numbers = QVector<qint64>({2, 2, 1}); - VERIFY(MessageListPixmap, 1, createType(QQmlProfilerDefinitions::PixmapSizeKnown), + VERIFY(MessageListPixmap, 1, createType(PixmapSizeKnown), CheckMessageType | CheckDetailType | CheckNumbers, numbers); // image loaded - VERIFY(MessageListPixmap, 2, createType(QQmlProfilerDefinitions::PixmapLoadingFinished), + VERIFY(MessageListPixmap, 2, createType(PixmapLoadingFinished), CheckMessageType | CheckDetailType, numbers); // cache size - VERIFY(MessageListPixmap, 3, createType(QQmlProfilerDefinitions::PixmapCacheCountChanged), + VERIFY(MessageListPixmap, 3, createType(PixmapCacheCountChanged), CheckMessageType | CheckDetailType, numbers); } @@ -597,8 +591,8 @@ void tst_QQmlProfilerService::scenegraphData() if (QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::OpenGL)) { foreach (const QQmlProfilerEvent &msg, m_client->asynchronousMessages) { const QQmlProfilerEventType &type = m_client->types.at(msg.typeIndex()); - if (type.message() == QQmlProfilerDefinitions::SceneGraphFrame) { - if (type.detailType() == QQmlProfilerDefinitions::SceneGraphContextFrame) { + if (type.message() == SceneGraphFrame) { + if (type.detailType() == SceneGraphContextFrame) { contextFrameTime = msg.timestamp(); break; } @@ -610,7 +604,7 @@ void tst_QQmlProfilerService::scenegraphData() #endif foreach (const QQmlProfilerEvent &msg, m_client->asynchronousMessages) { const QQmlProfilerEventType &type = m_client->types.at(msg.typeIndex()); - if (type.detailType() == QQmlProfilerDefinitions::SceneGraphRendererFrame) { + if (type.detailType() == SceneGraphRendererFrame) { QVERIFY(msg.timestamp() >= contextFrameTime); renderFrameTime = msg.timestamp(); break; @@ -621,7 +615,7 @@ void tst_QQmlProfilerService::scenegraphData() foreach (const QQmlProfilerEvent &msg, m_client->asynchronousMessages) { const QQmlProfilerEventType &type = m_client->types.at(msg.typeIndex()); - if (type.detailType() == QQmlProfilerDefinitions::SceneGraphRenderLoopFrame) { + if (type.detailType() == SceneGraphRenderLoopFrame) { if (msg.timestamp() >= contextFrameTime) { // Make sure SceneGraphRenderLoopFrame is not between SceneGraphContextFrame and // SceneGraphRendererFrame. A SceneGraphRenderLoopFrame before everything else is @@ -664,8 +658,7 @@ void tst_QQmlProfilerService::signalSourceLocation() auto createType = [](int line, int column) { return QQmlProfilerEventType( - QQmlProfilerDefinitions::MaximumMessage, - QQmlProfilerDefinitions::HandlingSignal, -1, + MaximumMessage, HandlingSignal, -1, QQmlProfilerEventLocation(QLatin1String("signalSourceLocation.qml"), line, column)); }; @@ -684,23 +677,21 @@ void tst_QQmlProfilerService::javascript() checkTraceReceived(); checkJsHeap(); - VERIFY(MessageListJavaScript, 2, QQmlProfilerEventType(QQmlProfilerDefinitions::MaximumMessage, - QQmlProfilerDefinitions::Javascript), + VERIFY(MessageListJavaScript, 2, QQmlProfilerEventType(MaximumMessage, Javascript), CheckMessageType | CheckDetailType | CheckNumbers, m_rangeStart); VERIFY(MessageListJavaScript, 3, - QQmlProfilerEventType(QQmlProfilerDefinitions::MaximumMessage, - QQmlProfilerDefinitions::Javascript, -1, - QQmlProfilerEventLocation(QLatin1String("javascript.qml"), 4, 5)), + QQmlProfilerEventType( + MaximumMessage, Javascript, -1, + QQmlProfilerEventLocation(QLatin1String("javascript.qml"), 4, 5)), CheckType | CheckNumbers, m_rangeStart); VERIFY(MessageListJavaScript, 4, QQmlProfilerEventType( - QQmlProfilerDefinitions::MaximumMessage, QQmlProfilerDefinitions::Javascript, -1, + MaximumMessage, Javascript, -1, QQmlProfilerEventLocation(), QLatin1String("something")), CheckMessageType | CheckDetailType | CheckDataEndsWith | CheckNumbers, m_rangeStart); - VERIFY(MessageListJavaScript, 10, QQmlProfilerEventType(QQmlProfilerDefinitions::MaximumMessage, - QQmlProfilerDefinitions::Javascript), + VERIFY(MessageListJavaScript, 10, QQmlProfilerEventType(MaximumMessage, Javascript), CheckMessageType | CheckDetailType | CheckNumbers, m_rangeEnd); } @@ -726,8 +717,7 @@ void tst_QQmlProfilerService::translationBinding() checkTraceReceived(); checkJsHeap(); - const QQmlProfilerEventType type(QQmlProfilerDefinitions::MaximumMessage, - QQmlProfilerDefinitions::Binding); + const QQmlProfilerEventType type(MaximumMessage, Binding); VERIFY(MessageListQML, 4, type, CheckDetailType | CheckMessageType | CheckNumbers, m_rangeStart); @@ -746,7 +736,7 @@ void tst_QQmlProfilerService::memory() int smallItems = 0; for (auto message : m_client->jsHeapMessages) { const QQmlProfilerEventType &type = m_client->types[message.typeIndex()]; - if (type.detailType() == QV4::Profiling::SmallItem) + if (type.detailType() == SmallItem) ++smallItems; } @@ -756,8 +746,7 @@ void tst_QQmlProfilerService::memory() static bool hasCompileEvents(const QVector<QQmlProfilerEventType> &types) { for (const QQmlProfilerEventType &type : types) { - if (type.message() == QQmlProfilerDefinitions::MaximumMessage - && type.rangeType() == QQmlProfilerDefinitions::Compiling) + if (type.message() == MaximumMessage && type.rangeType() == Compiling) return true; } return false; @@ -776,29 +765,29 @@ void tst_QQmlProfilerService::compile() checkTraceReceived(); checkJsHeap(); - QQmlProfilerDefinitions::Message rangeStage = QQmlProfilerDefinitions::MaximumMessage; + Message rangeStage = MaximumMessage; for (auto message : m_client->qmlMessages) { const QQmlProfilerEventType &type = m_client->types[message.typeIndex()]; - if (type.rangeType() == QQmlProfilerDefinitions::Compiling) { + if (type.rangeType() == Compiling) { switch (rangeStage) { - case QQmlProfilerDefinitions::MaximumMessage: - QCOMPARE(message.rangeStage(), QQmlProfilerDefinitions::RangeStart); + case MaximumMessage: + QCOMPARE(message.rangeStage(), RangeStart); break; - case QQmlProfilerDefinitions::RangeStart: - QCOMPARE(message.rangeStage(), QQmlProfilerDefinitions::RangeEnd); + case RangeStart: + QCOMPARE(message.rangeStage(), RangeEnd); break; default: QFAIL("Wrong range stage"); } rangeStage = message.rangeStage(); - QCOMPARE(type.message(), QQmlProfilerDefinitions::MaximumMessage); + QCOMPARE(type.message(), MaximumMessage); QCOMPARE(type.location().filename(), testFileUrl("test.qml").toString()); QCOMPARE(type.location().line(), 0); QCOMPARE(type.location().column(), 0); } } - QCOMPARE(rangeStage, QQmlProfilerDefinitions::RangeEnd); + QCOMPARE(rangeStage, RangeEnd); } QTEST_MAIN(tst_QQmlProfilerService) diff --git a/tests/auto/qml/debugger/shared/debugutil.cpp b/tests/auto/qml/debugger/shared/debugutil.cpp index a6f7fa8724..46f504f6d3 100644 --- a/tests/auto/qml/debugger/shared/debugutil.cpp +++ b/tests/auto/qml/debugger/shared/debugutil.cpp @@ -31,8 +31,6 @@ #include <private/qqmldebugconnection_p.h> -#include <QtQml/qqmldebug.h> - #include <QtCore/qeventloop.h> #include <QtCore/qtimer.h> @@ -52,15 +50,23 @@ bool QQmlDebugTest::waitForSignal(QObject *receiver, const char *member, int tim QList<QQmlDebugClient *> QQmlDebugTest::createOtherClients(QQmlDebugConnection *connection) { QList<QQmlDebugClient *> ret; - foreach (const QString &service, QQmlDebuggingEnabler::debuggerServices()) { + + static const auto debuggerServices + = QStringList({"V8Debugger", "QmlDebugger", "DebugMessages"}); + static const auto inspectorServices + = QStringList({"QmlInspector"}); + static const auto profilerServices + = QStringList({"CanvasFrameRate", "EngineControl", "DebugMessages"}); + + for (const QString &service : debuggerServices) { if (!connection->client(service)) ret << new QQmlDebugClient(service, connection); } - foreach (const QString &service, QQmlDebuggingEnabler::inspectorServices()) { + for (const QString &service : inspectorServices) { if (!connection->client(service)) ret << new QQmlDebugClient(service, connection); } - foreach (const QString &service, QQmlDebuggingEnabler::profilerServices()) { + for (const QString &service : profilerServices) { if (!connection->client(service)) ret << new QQmlDebugClient(service, connection); } diff --git a/tests/auto/qml/ecmascripttests/test262 b/tests/auto/qml/ecmascripttests/test262 -Subproject 40b4f28e98c416a092e26aa17489bf94ccb8bf4 +Subproject e505c11eebe5a389a7d47a4bf570c66469740b0 diff --git a/tests/auto/qml/qqmlmoduleplugin/tst_qqmlmoduleplugin.cpp b/tests/auto/qml/qqmlmoduleplugin/tst_qqmlmoduleplugin.cpp index fac3ff15fd..97ca3fa1de 100644 --- a/tests/auto/qml/qqmlmoduleplugin/tst_qqmlmoduleplugin.cpp +++ b/tests/auto/qml/qqmlmoduleplugin/tst_qqmlmoduleplugin.cpp @@ -29,6 +29,7 @@ #include <qdir.h> #include <QtQml/qqmlengine.h> #include <QtQml/qqmlcomponent.h> +#include <QtQml/qqmlcontext.h> #include <QtQml/qqmlextensionplugin.h> #include <QtCore/qjsondocument.h> #include <QtCore/qjsonarray.h> @@ -332,6 +333,29 @@ void tst_qqmlmoduleplugin::remoteImportWithUnquotedUri() VERIFY_ERRORS(0); } +static QByteArray msgComponentError(const QQmlComponent &c, const QQmlEngine *engine /* = 0 */) +{ + QString result; + const QList<QQmlError> errors = c.errors(); + QTextStream str(&result); + str << "Component '" << c.url().toString() << "' has " << errors.size() << " errors: '"; + for (int i = 0; i < errors.size(); ++i) { + if (i) + str << ", '"; + str << errors.at(i).toString() << '\''; + } + if (!engine) { + if (QQmlContext *context = c.creationContext()) + engine = context->engine(); + } + if (engine) { + str << " Import paths: (" << engine->importPathList().join(QStringLiteral(", ")) + << ") Plugin paths: (" << engine->pluginPathList().join(QStringLiteral(", ")) + << ')'; + } + return result.toLocal8Bit(); +} + // QTBUG-17324 void tst_qqmlmoduleplugin::importsMixedQmlCppPlugin() @@ -345,7 +369,7 @@ void tst_qqmlmoduleplugin::importsMixedQmlCppPlugin() QQmlComponent component(&engine, testFileUrl(QStringLiteral("importsMixedQmlCppPlugin.qml"))); QObject *o = component.create(); - QVERIFY2(o != nullptr, QQmlDataTest::msgComponentError(component, &engine)); + QVERIFY2(o != nullptr, msgComponentError(component, &engine)); QCOMPARE(o->property("test").toBool(), true); delete o; } @@ -354,7 +378,7 @@ void tst_qqmlmoduleplugin::importsMixedQmlCppPlugin() QQmlComponent component(&engine, testFileUrl(QStringLiteral("importsMixedQmlCppPlugin.2.qml"))); QObject *o = component.create(); - QVERIFY2(o != nullptr, QQmlDataTest::msgComponentError(component, &engine)); + QVERIFY2(o != nullptr, msgComponentError(component, &engine)); QCOMPARE(o->property("test").toBool(), true); QCOMPARE(o->property("test2").toBool(), true); delete o; diff --git a/tests/auto/quick/pointerhandlers/multipointtoucharea_interop/tst_multipointtoucharea_interop.cpp b/tests/auto/quick/pointerhandlers/multipointtoucharea_interop/tst_multipointtoucharea_interop.cpp index 8d8c915e39..4b096f9c3a 100644 --- a/tests/auto/quick/pointerhandlers/multipointtoucharea_interop/tst_multipointtoucharea_interop.cpp +++ b/tests/auto/quick/pointerhandlers/multipointtoucharea_interop/tst_multipointtoucharea_interop.cpp @@ -211,7 +211,7 @@ void tst_MptaInterop::touchesThenPinch() pinchStoleGrab = i; } qCDebug(lcPointerTests) << "pinch started after" << pinchStoleGrab << "moves; ended with scale" << pinch->scale() << "rot" << pinch->rotation(); - QTRY_VERIFY(pinch->rotation() > 8); + QTRY_VERIFY(pinch->rotation() > 4); QVERIFY(pinch->scale() > 1); // Press one more point (pinkie finger) diff --git a/tests/auto/quick/qquicklistview/data/snapToItemWithSpacing.qml b/tests/auto/quick/qquicklistview/data/snapToItemWithSpacing.qml new file mode 100644 index 0000000000..50b5abb206 --- /dev/null +++ b/tests/auto/quick/qquicklistview/data/snapToItemWithSpacing.qml @@ -0,0 +1,18 @@ +import QtQuick 2.0 + +ListView { + width: 100 + height: 300 + snapMode: ListView.SnapToItem + spacing: 100 + model: 10 + delegate: Rectangle { + height: 100 + width: 100 + color: "blue" + Text { + anchors.centerIn: parent + text: index + } + } +} diff --git a/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp b/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp index 8bc5575e34..4d3a665255 100644 --- a/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp +++ b/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp @@ -176,6 +176,7 @@ private slots: void creationContext(); void snapToItem_data(); void snapToItem(); + void snapToItemWithSpacing_QTBUG_59852(); void snapOneItemResize_QTBUG_43555(); void snapOneItem_data(); void snapOneItem(); @@ -5197,6 +5198,31 @@ void tst_QQuickListView::snapToItem() releaseView(window); } +void tst_QQuickListView::snapToItemWithSpacing_QTBUG_59852() +{ + QQuickView *window = getView(); + + window->setSource(testFileUrl("snapToItemWithSpacing.qml")); + window->show(); + QVERIFY(QTest::qWaitForWindowExposed(window)); + + auto *listView = qobject_cast<QQuickListView*>(window->rootObject()); + QVERIFY(listView); + + QTRY_COMPARE(QQuickItemPrivate::get(listView)->polishScheduled, false); + + // each item in the list is 100 pixels tall, and the spacing is 100 + + listView->setContentY(110); // this is right below the first item + listView->returnToBounds(); + QCOMPARE(listView->contentY(), 200); // the position of the second item + + listView->setContentY(60); // this is right below the middle of the first item + listView->returnToBounds(); + QCOMPARE(listView->contentY(), 0); // it's farther to go to the next item, so snaps to the first + + releaseView(window); +} void tst_QQuickListView::snapOneItemResize_QTBUG_43555() { diff --git a/tests/auto/shared/util.cpp b/tests/auto/shared/util.cpp index 96beb51612..189398f0c2 100644 --- a/tests/auto/shared/util.cpp +++ b/tests/auto/shared/util.cpp @@ -28,11 +28,6 @@ #include "util.h" -#include <QtQml/QQmlComponent> -#include <QtQml/QQmlError> -#include <QtQml/QQmlContext> -#include <QtQml/QQmlEngine> -#include <QtCore/QTextStream> #include <QtCore/QDebug> #include <QtCore/QMutexLocker> @@ -72,31 +67,6 @@ QString QQmlDataTest::testFile(const QString &fileName) const return result; } -QByteArray QQmlDataTest::msgComponentError(const QQmlComponent &c, - const QQmlEngine *engine /* = 0 */) -{ - QString result; - const QList<QQmlError> errors = c.errors(); - QTextStream str(&result); - str << "Component '" << c.url().toString() << "' has " << errors.size() - << " errors: '"; - for (int i = 0; i < errors.size(); ++i) { - if (i) - str << ", '"; - str << errors.at(i).toString() << '\''; - - } - if (!engine) - if (QQmlContext *context = c.creationContext()) - engine = context->engine(); - if (engine) { - str << " Import paths: (" << engine->importPathList().join(QStringLiteral(", ")) - << ") Plugin paths: (" << engine->pluginPathList().join(QStringLiteral(", ")) - << ')'; - } - return result.toLocal8Bit(); -} - Q_GLOBAL_STATIC(QMutex, qQmlTestMessageHandlerMutex) QQmlTestMessageHandler *QQmlTestMessageHandler::m_instance = 0; diff --git a/tests/auto/shared/util.h b/tests/auto/shared/util.h index 33d7cbd1d0..6f3f0a06a8 100644 --- a/tests/auto/shared/util.h +++ b/tests/auto/shared/util.h @@ -35,9 +35,6 @@ #include <QtCore/QStringList> #include <QtTest/QTest> -QT_FORWARD_DECLARE_CLASS(QQmlComponent) -QT_FORWARD_DECLARE_CLASS(QQmlEngine) - /* Base class for tests with data that are located in a "data" subfolder. */ class QQmlDataTest : public QObject @@ -61,9 +58,6 @@ public: static inline QQmlDataTest *instance() { return m_instance; } - static QByteArray msgComponentError(const QQmlComponent &, - const QQmlEngine *engine = 0); - public slots: virtual void initTestCase(); diff --git a/tools/qmlprofiler/qmlprofiler.pro b/tools/qmlprofiler/qmlprofiler.pro index a2522e9267..28e316b23a 100644 --- a/tools/qmlprofiler/qmlprofiler.pro +++ b/tools/qmlprofiler/qmlprofiler.pro @@ -1,4 +1,4 @@ -QT = qml-private network core qmldebug-private +QT = network core qmldebug-private CONFIG += no_import_scan SOURCES += main.cpp \ diff --git a/tools/qmlprofiler/qmlprofilerapplication.cpp b/tools/qmlprofiler/qmlprofilerapplication.cpp index 64cd4ec87f..6732766b46 100644 --- a/tools/qmlprofiler/qmlprofilerapplication.cpp +++ b/tools/qmlprofiler/qmlprofilerapplication.cpp @@ -70,8 +70,7 @@ static const char *features[] = { "debugmessages" }; -Q_STATIC_ASSERT(sizeof(features) == - QQmlProfilerDefinitions::MaximumProfileFeature * sizeof(char *)); +Q_STATIC_ASSERT(sizeof(features) == MaximumProfileFeature * sizeof(char *)); QmlProfilerApplication::QmlProfilerApplication(int &argc, char **argv) : QCoreApplication(argc, argv), @@ -168,7 +167,7 @@ void QmlProfilerApplication::parseArguments() parser.addOption(record); QStringList featureList; - for (int i = 0; i < QQmlProfilerDefinitions::MaximumProfileFeature; ++i) + for (int i = 0; i < MaximumProfileFeature; ++i) featureList << QLatin1String(features[i]); QCommandLineOption include(QLatin1String("include"), diff --git a/tools/qmlprofiler/qmlprofilerclient.h b/tools/qmlprofiler/qmlprofilerclient.h index b4b4ad2b2f..7355688222 100644 --- a/tools/qmlprofiler/qmlprofilerclient.h +++ b/tools/qmlprofiler/qmlprofilerclient.h @@ -30,7 +30,7 @@ #define QMLPROFILERCLIENT_H #include <private/qqmlprofilerclient_p.h> -#include <private/qqmlprofilerdefinitions_p.h> +#include <private/qqmlprofilerclientdefinitions_p.h> #include <private/qqmlprofilereventlocation_p.h> class QmlProfilerData; diff --git a/tools/qmlprofiler/qmlprofilerdata.cpp b/tools/qmlprofiler/qmlprofilerdata.cpp index 32e03298da..d5662a0182 100644 --- a/tools/qmlprofiler/qmlprofilerdata.cpp +++ b/tools/qmlprofiler/qmlprofilerdata.cpp @@ -50,8 +50,7 @@ static const char *RANGE_TYPE_STRINGS[] = { "Javascript" }; -Q_STATIC_ASSERT(sizeof(RANGE_TYPE_STRINGS) == - QQmlProfilerDefinitions::MaximumRangeType * sizeof(const char *)); +Q_STATIC_ASSERT(sizeof(RANGE_TYPE_STRINGS) == MaximumRangeType * sizeof(const char *)); static const char *MESSAGE_STRINGS[] = { "Event", @@ -66,8 +65,7 @@ static const char *MESSAGE_STRINGS[] = { "DebugMessage" }; -Q_STATIC_ASSERT(sizeof(MESSAGE_STRINGS) == - QQmlProfilerDefinitions::MaximumMessage * sizeof(const char *)); +Q_STATIC_ASSERT(sizeof(MESSAGE_STRINGS) == MaximumMessage * sizeof(const char *)); ///////////////////////////////////////////////////////////////// class QmlProfilerDataPrivate @@ -113,7 +111,7 @@ void QmlProfilerData::clear() setState(Empty); } -QString QmlProfilerData::qmlRangeTypeAsString(QQmlProfilerDefinitions::RangeType type) +QString QmlProfilerData::qmlRangeTypeAsString(RangeType type) { if (type * sizeof(char *) < sizeof(RANGE_TYPE_STRINGS)) return QLatin1String(RANGE_TYPE_STRINGS[type]); @@ -121,7 +119,7 @@ QString QmlProfilerData::qmlRangeTypeAsString(QQmlProfilerDefinitions::RangeType return QString::number(type); } -QString QmlProfilerData::qmlMessageAsString(QQmlProfilerDefinitions::Message type) +QString QmlProfilerData::qmlMessageAsString(Message type) { if (type * sizeof(char *) < sizeof(MESSAGE_STRINGS)) return QLatin1String(MESSAGE_STRINGS[type]); @@ -178,13 +176,13 @@ void QmlProfilerData::addEventType(const QQmlProfilerEventType &type) QString displayName; switch (type.message()) { - case QQmlProfilerDefinitions::Event: { + case Event: { switch (type.detailType()) { - case QQmlProfilerDefinitions::Mouse: - case QQmlProfilerDefinitions::Key: + case Mouse: + case Key: displayName = QString::fromLatin1("Input:%1").arg(type.detailType()); break; - case QQmlProfilerDefinitions::AnimationFrame: + case AnimationFrame: displayName = QString::fromLatin1("AnimationFrame"); break; default: @@ -192,29 +190,29 @@ void QmlProfilerData::addEventType(const QQmlProfilerEventType &type) } break; } - case QQmlProfilerDefinitions::RangeStart: - case QQmlProfilerDefinitions::RangeData: - case QQmlProfilerDefinitions::RangeLocation: - case QQmlProfilerDefinitions::RangeEnd: - case QQmlProfilerDefinitions::Complete: + case RangeStart: + case RangeData: + case RangeLocation: + case RangeEnd: + case Complete: Q_UNREACHABLE(); break; - case QQmlProfilerDefinitions::PixmapCacheEvent: { + case PixmapCacheEvent: { const QString filePath = QUrl(type.location().filename()).path(); displayName = filePath.midRef(filePath.lastIndexOf(QLatin1Char('/')) + 1) + QLatin1Char(':') + QString::number(type.detailType()); break; } - case QQmlProfilerDefinitions::SceneGraphFrame: + case SceneGraphFrame: displayName = QString::fromLatin1("SceneGraph:%1").arg(type.detailType()); break; - case QQmlProfilerDefinitions::MemoryAllocation: + case MemoryAllocation: displayName = QString::fromLatin1("MemoryAllocation:%1").arg(type.detailType()); break; - case QQmlProfilerDefinitions::DebugMessage: + case DebugMessage: displayName = QString::fromLatin1("DebugMessage:%1").arg(type.detailType()); break; - case QQmlProfilerDefinitions::MaximumMessage: { + case MaximumMessage: { const QQmlProfilerEventLocation eventLocation = type.location(); // generate hash if (eventLocation.filename().isEmpty()) { @@ -241,21 +239,21 @@ void QmlProfilerData::computeQmlTime() for (const QQmlProfilerEvent &event : qAsConst(d->events)) { const QQmlProfilerEventType &type = d->eventTypes.at(event.typeIndex()); - if (type.message() != QQmlProfilerDefinitions::MaximumMessage) + if (type.message() != MaximumMessage) continue; switch (type.rangeType()) { - case QQmlProfilerDefinitions::Compiling: - case QQmlProfilerDefinitions::Creating: - case QQmlProfilerDefinitions::Binding: - case QQmlProfilerDefinitions::HandlingSignal: - case QQmlProfilerDefinitions::Javascript: + case Compiling: + case Creating: + case Binding: + case HandlingSignal: + case Javascript: switch (event.rangeStage()) { - case QQmlProfilerDefinitions::RangeStart: + case RangeStart: if (level++ == 0) level0Start = event.timestamp(); break; - case QQmlProfilerDefinitions::RangeEnd: + case RangeEnd: if (--level == 0) d->qmlMeasuredTime += event.timestamp() - level0Start; break; @@ -430,8 +428,7 @@ bool QmlProfilerData::save(const QString &filename) if (!eventData.displayName().isEmpty()) stream.writeTextElement("displayname", eventData.displayName()); - stream.writeTextElement("type", - eventData.rangeType() == QQmlProfilerDefinitions::MaximumRangeType + stream.writeTextElement("type", eventData.rangeType() == MaximumRangeType ? qmlMessageAsString(eventData.message()) : qmlRangeTypeAsString(eventData.rangeType())); @@ -444,25 +441,25 @@ bool QmlProfilerData::save(const QString &filename) stream.writeTextElement("column", location.column()); if (!eventData.data().isEmpty()) stream.writeTextElement("details", eventData.data()); - if (eventData.rangeType() == QQmlProfilerDefinitions::Binding) + if (eventData.rangeType() == Binding) stream.writeTextElement("bindingType", eventData.detailType()); - else if (eventData.message() == QQmlProfilerDefinitions::Event) { + else if (eventData.message() == Event) { switch (eventData.detailType()) { - case QQmlProfilerDefinitions::AnimationFrame: + case AnimationFrame: stream.writeTextElement("animationFrame", eventData.detailType()); break; - case QQmlProfilerDefinitions::Key: + case Key: stream.writeTextElement("keyEvent", eventData.detailType()); break; - case QQmlProfilerDefinitions::Mouse: + case Mouse: stream.writeTextElement("mouseEvent", eventData.detailType()); break; } - } else if (eventData.message() == QQmlProfilerDefinitions::PixmapCacheEvent) + } else if (eventData.message() == PixmapCacheEvent) stream.writeTextElement("cacheEventType", eventData.detailType()); - else if (eventData.message() == QQmlProfilerDefinitions::SceneGraphFrame) + else if (eventData.message() == SceneGraphFrame) stream.writeTextElement("sgEventType", eventData.detailType()); - else if (eventData.message() == QQmlProfilerDefinitions::MemoryAllocation) + else if (eventData.message() == MemoryAllocation) stream.writeTextElement("memoryEventType", eventData.detailType()); stream.writeEndElement(); } @@ -477,50 +474,49 @@ bool QmlProfilerData::save(const QString &filename) if (duration != 0) stream.writeAttribute("duration", duration); stream.writeAttribute("eventIndex", event.typeIndex()); - if (type.message() == QQmlProfilerDefinitions::Event) { - if (type.detailType() == QQmlProfilerDefinitions::AnimationFrame) { + if (type.message() == Event) { + if (type.detailType() == AnimationFrame) { // special: animation frame stream.writeAttribute("framerate", event, 0); stream.writeAttribute("animationcount", event, 1); stream.writeAttribute("thread", event, 2); - } else if (type.detailType() == QQmlProfilerDefinitions::Key || - type.detailType() == QQmlProfilerDefinitions::Mouse) { + } else if (type.detailType() == Key || type.detailType() == Mouse) { // numerical value here, to keep the format a bit more compact stream.writeAttribute("type", event, 0); stream.writeAttribute("data1", event, 1); stream.writeAttribute("data2", event, 2); } - } else if (type.message() == QQmlProfilerDefinitions::PixmapCacheEvent) { + } else if (type.message() == PixmapCacheEvent) { // special: pixmap cache event - if (type.detailType() == QQmlProfilerDefinitions::PixmapSizeKnown) { + if (type.detailType() == PixmapSizeKnown) { stream.writeAttribute("width", event, 0); stream.writeAttribute("height", event, 1); - } else if (type.detailType() == QQmlProfilerDefinitions::PixmapReferenceCountChanged - || type.detailType() == QQmlProfilerDefinitions::PixmapCacheCountChanged) { + } else if (type.detailType() == PixmapReferenceCountChanged + || type.detailType() == PixmapCacheCountChanged) { stream.writeAttribute("refCount", event, 1); } - } else if (type.message() == QQmlProfilerDefinitions::SceneGraphFrame) { + } else if (type.message() == SceneGraphFrame) { stream.writeAttribute("timing1", event, 0, false); stream.writeAttribute("timing2", event, 1, false); stream.writeAttribute("timing3", event, 2, false); stream.writeAttribute("timing4", event, 3, false); stream.writeAttribute("timing5", event, 4, false); - } else if (type.message() == QQmlProfilerDefinitions::MemoryAllocation) { + } else if (type.message() == MemoryAllocation) { stream.writeAttribute("amount", event, 0); } stream.writeEndElement(); }; QQueue<QQmlProfilerEvent> pointEvents; - QQueue<QQmlProfilerEvent> rangeStarts[QQmlProfilerDefinitions::MaximumRangeType]; - QStack<qint64> rangeEnds[QQmlProfilerDefinitions::MaximumRangeType]; + QQueue<QQmlProfilerEvent> rangeStarts[MaximumRangeType]; + QStack<qint64> rangeEnds[MaximumRangeType]; int level = 0; auto sendPending = [&]() { forever { - int minimum = QQmlProfilerDefinitions::MaximumRangeType; + int minimum = MaximumRangeType; qint64 minimumTime = std::numeric_limits<qint64>::max(); - for (int i = 0; i < QQmlProfilerDefinitions::MaximumRangeType; ++i) { + for (int i = 0; i < MaximumRangeType; ++i) { const QQueue<QQmlProfilerEvent> &starts = rangeStarts[i]; if (starts.isEmpty()) continue; @@ -529,7 +525,7 @@ bool QmlProfilerData::save(const QString &filename) minimum = i; } } - if (minimum == QQmlProfilerDefinitions::MaximumRangeType) + if (minimum == MaximumRangeType) break; while (!pointEvents.isEmpty() && pointEvents.front().timestamp() < minimumTime) @@ -543,15 +539,15 @@ bool QmlProfilerData::save(const QString &filename) for (const QQmlProfilerEvent &event : qAsConst(d->events)) { const QQmlProfilerEventType &type = d->eventTypes.at(event.typeIndex()); - if (type.rangeType() != QQmlProfilerDefinitions::MaximumRangeType) { + if (type.rangeType() != MaximumRangeType) { QQueue<QQmlProfilerEvent> &starts = rangeStarts[type.rangeType()]; switch (event.rangeStage()) { - case QQmlProfilerDefinitions::RangeStart: { + case RangeStart: { ++level; starts.enqueue(event); break; } - case QQmlProfilerDefinitions::RangeEnd: { + case RangeEnd: { QStack<qint64> &ends = rangeEnds[type.rangeType()]; if (starts.length() > ends.length()) { ends.push(event.timestamp()); @@ -571,7 +567,7 @@ bool QmlProfilerData::save(const QString &filename) } } - for (int i = 0; i < QQmlProfilerDefinitions::MaximumRangeType; ++i) { + for (int i = 0; i < MaximumRangeType; ++i) { while (rangeEnds[i].length() < rangeStarts[i].length()) { rangeEnds[i].push(d->traceEndTime); --level; diff --git a/tools/qmlprofiler/qmlprofilerdata.h b/tools/qmlprofiler/qmlprofilerdata.h index 2be0b73aee..16ebc37f28 100644 --- a/tools/qmlprofiler/qmlprofilerdata.h +++ b/tools/qmlprofiler/qmlprofilerdata.h @@ -29,7 +29,7 @@ #ifndef QMLPROFILERDATA_H #define QMLPROFILERDATA_H -#include <private/qqmlprofilerdefinitions_p.h> +#include <private/qqmlprofilerclientdefinitions_p.h> #include <private/qqmlprofilereventlocation_p.h> #include <private/qqmlprofilereventreceiver_p.h> @@ -55,8 +55,8 @@ public: void addEvent(const QQmlProfilerEvent &event) override; static QString getHashStringForQmlEvent(const QQmlProfilerEventLocation &location, int eventType); - static QString qmlRangeTypeAsString(QQmlProfilerDefinitions::RangeType type); - static QString qmlMessageAsString(QQmlProfilerDefinitions::Message type); + static QString qmlRangeTypeAsString(RangeType type); + static QString qmlMessageAsString(Message type); qint64 traceStartTime() const; qint64 traceEndTime() const; |