forked from qt-creator/qt-creator
Tracing/QmlProfiler/PerfProfiler/CtfVisualizer: Remove pre Qt 6.2 code
- Remove code for Qt below 6.2 from c++ sources and CMakeLists.txt - Remove Qml code from .qrc files - Qbs: Add qt.core.resource_data Groups for Qml code - Remove OpenGL shader .frag and .vert files - Remove Qml import version numbers Change-Id: I3bd1cd95381e66c98ee3af4259e89b0b1eff0709 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
This commit is contained in:
@@ -71,59 +71,48 @@ set(QMLPROFILER_CPP_SOURCES
|
||||
quick3dmodel.cpp quick3dmodel.h
|
||||
)
|
||||
|
||||
if(${Qt5_VERSION} VERSION_LESS "6.2.0")
|
||||
add_qtc_plugin(QmlProfiler
|
||||
DEPENDS QmlDebug QmlJS Tracing Qt5::QuickWidgets Utils
|
||||
PLUGIN_DEPENDS Core Debugger ProjectExplorer QtSupport TextEditor
|
||||
SOURCES
|
||||
${TEST_SOURCES}
|
||||
${QMLPROFILER_CPP_SOURCES}
|
||||
qml/qmlprofiler.qrc
|
||||
)
|
||||
else() # < Qt 6.2
|
||||
find_package(Qt6 COMPONENTS ShaderTools QUIET)
|
||||
find_package(Qt6 COMPONENTS ShaderTools QUIET)
|
||||
|
||||
add_qtc_plugin(QmlProfiler
|
||||
CONDITION TARGET Tracing AND TARGET Qt6::ShaderTools
|
||||
DEPENDS QmlDebug QmlJS Tracing Qt5::QuickWidgets
|
||||
PLUGIN_DEPENDS Core Debugger ProjectExplorer QtSupport TextEditor
|
||||
SOURCES
|
||||
${TEST_SOURCES}
|
||||
)
|
||||
add_qtc_plugin(QmlProfiler
|
||||
CONDITION TARGET Tracing AND TARGET Qt6::ShaderTools
|
||||
DEPENDS QmlDebug QmlJS Tracing Qt5::QuickWidgets
|
||||
PLUGIN_DEPENDS Core Debugger ProjectExplorer QtSupport TextEditor
|
||||
SOURCES
|
||||
${TEST_SOURCES}
|
||||
)
|
||||
|
||||
if (NOT TARGET QmlProfiler)
|
||||
return()
|
||||
endif()
|
||||
if (NOT TARGET QmlProfiler)
|
||||
return()
|
||||
endif()
|
||||
|
||||
set(QMLPROFILER_QML_FILES
|
||||
qml/QmlProfilerFlameGraphView.qml
|
||||
)
|
||||
set(QMLPROFILER_QML_FILES
|
||||
qml/QmlProfilerFlameGraphView.qml
|
||||
)
|
||||
|
||||
foreach(file IN LISTS QMLPROFILER_QML_FILES)
|
||||
get_filename_component(fileName "${file}" NAME)
|
||||
set_source_files_properties("${file}" PROPERTIES QT_RESOURCE_ALIAS "${fileName}")
|
||||
endforeach()
|
||||
foreach(file IN LISTS QMLPROFILER_QML_FILES)
|
||||
get_filename_component(fileName "${file}" NAME)
|
||||
set_source_files_properties("${file}" PROPERTIES QT_RESOURCE_ALIAS "${fileName}")
|
||||
endforeach()
|
||||
|
||||
qt_add_shaders(QmlProfiler "res_qmlprofilershaders"
|
||||
BATCHABLE
|
||||
PREFIX
|
||||
"/QtCreator/QmlProfiler"
|
||||
BASE
|
||||
"qml"
|
||||
FILES
|
||||
qml/bindingloops_qt6.frag
|
||||
qml/bindingloops_qt6.vert
|
||||
)
|
||||
qt_add_shaders(QmlProfiler "res_qmlprofilershaders"
|
||||
BATCHABLE
|
||||
PREFIX
|
||||
"/QtCreator/QmlProfiler"
|
||||
BASE
|
||||
"qml"
|
||||
FILES
|
||||
qml/bindingloops_qt6.frag
|
||||
qml/bindingloops_qt6.vert
|
||||
)
|
||||
|
||||
qt_add_qml_module(QmlProfiler
|
||||
URI "QtCreator.QmlProfiler"
|
||||
VERSION "1.0"
|
||||
NO_PLUGIN
|
||||
QML_FILES
|
||||
${QMLPROFILER_QML_FILES}
|
||||
RESOURCES
|
||||
${QMLPROFILER_QML_RESOURCES}
|
||||
SOURCES
|
||||
${QMLPROFILER_CPP_SOURCES}
|
||||
)
|
||||
endif() # < Qt 6.2
|
||||
qt_add_qml_module(QmlProfiler
|
||||
URI "QtCreator.QmlProfiler"
|
||||
VERSION "1.0"
|
||||
NO_PLUGIN
|
||||
QML_FILES
|
||||
${QMLPROFILER_QML_FILES}
|
||||
RESOURCES
|
||||
${QMLPROFILER_QML_RESOURCES}
|
||||
SOURCES
|
||||
${QMLPROFILER_CPP_SOURCES}
|
||||
)
|
||||
|
||||
@@ -55,10 +55,8 @@ struct FlameGraphData {
|
||||
class FlameGraphModel : public QAbstractItemModel
|
||||
{
|
||||
Q_OBJECT
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 2, 0)
|
||||
QML_NAMED_ELEMENT(QmlProfilerFlameGraphModel)
|
||||
QML_UNCREATABLE("use the context property")
|
||||
#endif // Qt >= 6.2
|
||||
public:
|
||||
enum Role {
|
||||
TypeIdRole = Qt::UserRole + 1, // Sort by data, not by displayed string
|
||||
|
||||
@@ -46,13 +46,6 @@ FlameGraphView::FlameGraphView(QmlProfilerModelManager *manager, QWidget *parent
|
||||
setObjectName("QmlProfiler.FlameGraph.Dock");
|
||||
setWindowTitle(tr("Flame Graph"));
|
||||
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6, 2, 0)
|
||||
qmlRegisterType<FlameGraph::FlameGraph>("QtCreator.Tracing", 1, 0, "FlameGraph");
|
||||
qmlRegisterUncreatableType<FlameGraphModel>("QtCreator.QmlProfiler", 1, 0,
|
||||
"QmlProfilerFlameGraphModel",
|
||||
QLatin1String("use the context property"));
|
||||
#endif // Qt < 6.2
|
||||
|
||||
Timeline::TimelineTheme::setupTheme(m_content->engine());
|
||||
|
||||
m_content->rootContext()->setContextProperty(QStringLiteral("flameGraphModel"), m_model);
|
||||
|
||||
@@ -72,12 +72,7 @@ QVariantList InputEventsModel::labels() const
|
||||
|
||||
QMetaEnum InputEventsModel::metaEnum(const char *name)
|
||||
{
|
||||
return
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
||||
staticQtMetaObject.enumerator(staticQtMetaObject.indexOfEnumerator(name));
|
||||
#else // < Qt 6
|
||||
Qt::staticMetaObject.enumerator(Qt::staticMetaObject.indexOfEnumerator(name));
|
||||
#endif // < Qt 6
|
||||
return Qt::staticMetaObject.enumerator(Qt::staticMetaObject.indexOfEnumerator(name));
|
||||
}
|
||||
|
||||
QVariantMap InputEventsModel::details(int index) const
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
import QtCreator.QmlProfiler 1.0
|
||||
import QtCreator.QmlProfiler
|
||||
import "../Tracing" // TODO: Turn into module import when possible
|
||||
|
||||
FlameGraphView {
|
||||
|
||||
@@ -1,31 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2016 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** 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 General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 3 as published by the Free Software
|
||||
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
||||
** 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-3.0.html.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
varying lowp vec4 color;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_FragColor = color;
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2016 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** 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 General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 3 as published by the Free Software
|
||||
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
||||
** 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-3.0.html.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
attribute vec4 vertexCoord;
|
||||
attribute vec2 postScaleOffset;
|
||||
|
||||
uniform mat4 matrix;
|
||||
uniform vec4 bindingLoopsColor;
|
||||
|
||||
varying vec4 color;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = matrix * vertexCoord;
|
||||
gl_Position.x += postScaleOffset.x * 0.005;
|
||||
gl_Position.y += postScaleOffset.y * 0.01;
|
||||
gl_Position.z -= 0.1;
|
||||
gl_Position.w = 1.0;
|
||||
color = bindingLoopsColor;
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
<RCC>
|
||||
<qresource prefix="/QtCreator/QmlProfiler">
|
||||
<file>bindingloops.vert</file>
|
||||
<file>bindingloops.frag</file>
|
||||
<file>QmlProfilerFlameGraphView.qml</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
@@ -65,9 +65,10 @@ QtcPlugin {
|
||||
}
|
||||
|
||||
Group {
|
||||
name: "QML"
|
||||
prefix: "qml/"
|
||||
files: ["qmlprofiler.qrc"]
|
||||
name: "Qml Files"
|
||||
Qt.core.resourcePrefix: "QtCreator/QmlProfiler/"
|
||||
fileTags: "qt.core.resource_data"
|
||||
files: "qml/**"
|
||||
}
|
||||
|
||||
Group {
|
||||
|
||||
@@ -34,11 +34,7 @@ namespace Internal {
|
||||
class BindingLoopMaterial : public QSGMaterial {
|
||||
public:
|
||||
QSGMaterialType *type() const override;
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
||||
QSGMaterialShader *createShader() const override;
|
||||
#else
|
||||
QSGMaterialShader *createShader(QSGRendererInterface::RenderMode) const override;
|
||||
#endif // < Qt 6
|
||||
BindingLoopMaterial();
|
||||
};
|
||||
|
||||
@@ -299,36 +295,14 @@ class BindingLoopMaterialShader : public QSGMaterialShader
|
||||
public:
|
||||
BindingLoopMaterialShader();
|
||||
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
||||
void updateState(const RenderState &state, QSGMaterial *newEffect,
|
||||
QSGMaterial *oldEffect) override;
|
||||
char const *const *attributeNames() const override;
|
||||
#else // < Qt 6
|
||||
bool updateUniformData(RenderState &state, QSGMaterial *, QSGMaterial *) override;
|
||||
#endif // < Qt 6
|
||||
|
||||
private:
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
||||
void initialize() override;
|
||||
|
||||
int m_matrix_id = 0;
|
||||
int m_z_range_id = 0;
|
||||
int m_color_id = 0;
|
||||
#endif // < Qt 6
|
||||
};
|
||||
|
||||
BindingLoopMaterialShader::BindingLoopMaterialShader()
|
||||
: QSGMaterialShader()
|
||||
{
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
||||
setShaderSourceFile(QOpenGLShader::Vertex,
|
||||
QStringLiteral(":/QtCreator/QmlProfiler/bindingloops.vert"));
|
||||
setShaderSourceFile(QOpenGLShader::Fragment,
|
||||
QStringLiteral(":/QtCreator/QmlProfiler/bindingloops.frag"));
|
||||
#else // < Qt 6
|
||||
setShaderFileName(VertexStage, ":/QtCreator/QmlProfiler/bindingloops_qt6.vert.qsb");
|
||||
setShaderFileName(FragmentStage, ":/QtCreator/QmlProfiler/bindingloops_qt6.frag.qsb");
|
||||
#endif // < Qt 6
|
||||
}
|
||||
|
||||
static QColor bindingLoopsColor()
|
||||
@@ -336,16 +310,6 @@ static QColor bindingLoopsColor()
|
||||
return Utils::creatorTheme()->color(Utils::Theme::Timeline_HighlightColor);
|
||||
}
|
||||
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
||||
void BindingLoopMaterialShader::updateState(const RenderState &state, QSGMaterial *, QSGMaterial *)
|
||||
{
|
||||
if (state.isMatrixDirty()) {
|
||||
program()->setUniformValue(m_matrix_id, state.combinedMatrix());
|
||||
program()->setUniformValue(m_z_range_id, GLfloat(1.0));
|
||||
program()->setUniformValue(m_color_id, bindingLoopsColor());
|
||||
}
|
||||
}
|
||||
#else // < Qt 6
|
||||
bool BindingLoopMaterialShader::updateUniformData(RenderState &state, QSGMaterial *, QSGMaterial *)
|
||||
{
|
||||
QByteArray *buf = state.uniformData();
|
||||
@@ -363,31 +327,15 @@ bool BindingLoopMaterialShader::updateUniformData(RenderState &state, QSGMateria
|
||||
|
||||
return true;
|
||||
}
|
||||
#endif // < Qt 6
|
||||
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
||||
char const *const *BindingLoopMaterialShader::attributeNames() const
|
||||
{
|
||||
static const char *const attr[] = {"vertexCoord", "postScaleOffset", nullptr};
|
||||
return attr;
|
||||
}
|
||||
|
||||
void BindingLoopMaterialShader::initialize()
|
||||
{
|
||||
m_matrix_id = program()->uniformLocation("matrix");
|
||||
m_z_range_id = program()->uniformLocation("_qt_zRange");
|
||||
m_color_id = program()->uniformLocation("bindingLoopsColor");
|
||||
}
|
||||
#endif // < Qt 6
|
||||
|
||||
BindingLoopMaterial::BindingLoopMaterial()
|
||||
{
|
||||
setFlag(QSGMaterial::Blending, false);
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 3, 0)
|
||||
setFlag(QSGMaterial::NoBatching, true);
|
||||
#elif QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
#else
|
||||
setFlag(QSGMaterial::CustomCompileStep, true);
|
||||
#endif // >= Qt 6.3/6.0
|
||||
#endif // >= Qt 6.3
|
||||
}
|
||||
|
||||
QSGMaterialType *BindingLoopMaterial::type() const
|
||||
@@ -396,11 +344,7 @@ QSGMaterialType *BindingLoopMaterial::type() const
|
||||
return &type;
|
||||
}
|
||||
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
||||
QSGMaterialShader *BindingLoopMaterial::createShader() const
|
||||
#else // < Qt 6
|
||||
QSGMaterialShader *BindingLoopMaterial::createShader(QSGRendererInterface::RenderMode) const
|
||||
#endif // < Qt 6
|
||||
{
|
||||
return new BindingLoopMaterialShader;
|
||||
}
|
||||
|
||||
@@ -123,15 +123,6 @@ QmlProfilerTraceView::QmlProfilerTraceView(QWidget *parent, QmlProfilerViewManag
|
||||
groupLayout->setContentsMargins(0, 0, 0, 0);
|
||||
groupLayout->setSpacing(0);
|
||||
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6, 2, 0)
|
||||
qmlRegisterType<Timeline::TimelineRenderer>("QtCreator.Tracing", 1, 0, "TimelineRenderer");
|
||||
qmlRegisterType<Timeline::TimelineOverviewRenderer>("QtCreator.Tracing", 1, 0,
|
||||
"TimelineOverviewRenderer");
|
||||
qmlRegisterAnonymousType<Timeline::TimelineZoomControl>("QtCreator.Tracing", 1);
|
||||
qmlRegisterAnonymousType<Timeline::TimelineModel>("QtCreator.Tracing", 1);
|
||||
qmlRegisterAnonymousType<Timeline::TimelineNotesModel>("QtCreator.Tracing", 1);
|
||||
#endif // Qt < 6.2
|
||||
|
||||
d->m_mainView = new QQuickWidget(this);
|
||||
d->m_mainView->setResizeMode(QQuickWidget::SizeRootObjectToView);
|
||||
d->m_mainView->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||
@@ -169,7 +160,6 @@ QmlProfilerTraceView::QmlProfilerTraceView(QWidget *parent, QmlProfilerViewManag
|
||||
setMinimumHeight(170);
|
||||
|
||||
Timeline::TimelineTheme::setupTheme(d->m_mainView->engine());
|
||||
Timeline::TimeFormatter::setupTimeFormatter();
|
||||
|
||||
d->m_mainView->rootContext()->setContextProperty(QLatin1String("timelineModelAggregator"),
|
||||
d->m_modelProxy);
|
||||
@@ -298,12 +288,9 @@ void QmlProfilerTraceView::showContextMenu(QPoint position)
|
||||
|
||||
bool QmlProfilerTraceView::isUsable() const
|
||||
{
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
||||
return d->m_mainView->quickWindow()->rendererInterface()->graphicsApi()
|
||||
== QSGRendererInterface::OpenGL;
|
||||
#else
|
||||
return QSGRendererInterface::isApiRhiBased(d->m_mainView->quickWindow()->rendererInterface()->graphicsApi());
|
||||
#endif
|
||||
const QSGRendererInterface::GraphicsApi api =
|
||||
d->m_mainView->quickWindow()->rendererInterface()->graphicsApi();
|
||||
return QSGRendererInterface::isApiRhiBased(api);
|
||||
}
|
||||
|
||||
bool QmlProfilerTraceView::isSuspended() const
|
||||
|
||||
@@ -119,18 +119,10 @@ void QmlProfilerBindingLoopsRenderPassTest::testUpdate()
|
||||
QCOMPARE(node->geometry()->vertexCount(), 7 * 18);
|
||||
QVERIFY(material2 != nullptr);
|
||||
QCOMPARE(material1->type(), material2->type());
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
||||
QSGMaterialShader *shader1 = material1->createShader();
|
||||
QVERIFY(shader1 != nullptr);
|
||||
QSGMaterialShader *shader2 = material2->createShader();
|
||||
QVERIFY(shader2 != nullptr);
|
||||
QCOMPARE(shader1->attributeNames(), shader2->attributeNames());
|
||||
#else // < Qt 6
|
||||
QSGMaterialShader *shader1 = material1->createShader(QSGRendererInterface::RenderMode2D);
|
||||
QVERIFY(shader1 != 0);
|
||||
QSGMaterialShader *shader2 = material2->createShader(QSGRendererInterface::RenderMode2D);
|
||||
QVERIFY(shader2 != 0);
|
||||
#endif // < Qt 6
|
||||
|
||||
delete shader1;
|
||||
delete shader2;
|
||||
|
||||
Reference in New Issue
Block a user