Tracing/QmlProfiler/CtfVisualizer/PerfProfiler: Compile with Qt 6

This makes the tracing lib, its tests and the three plugins which depend
on the lib compile with Qt 6.

The rectangles are not yet shown most likely because some OpenGL
specific code was #ifdef-ed for Qt 6. That code needs to be
reimplemented on top of the new Scenegraph API, using the RHI instead of
direct OpenGL in a follow-up patch.
An assertion failure in QQuickWidget::createFramebufferObject() needs to
be fixed as-well.

The code still builds and runs assertion free (and the autotests pass)
when built against Qt 5.

Task-number: QTCREATORBUG-20575
Change-Id: I47ebb477823de2f0d27329dac7c292a466cea1d7
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
This commit is contained in:
Alessandro Portale
2021-06-09 11:36:10 +02:00
parent 370410aca0
commit 43c5944571
17 changed files with 173 additions and 29 deletions

View File

@@ -5,7 +5,6 @@ if (WITH_TESTS)
endif()
add_qtc_library(Tracing
CONDITION Qt5_VERSION VERSION_LESS 6.0.0
FEATURE_INFO
DEPENDS Utils Qt5::Qml Qt5::Quick
PUBLIC_DEPENDS Qt5::Widgets

View File

@@ -29,8 +29,11 @@
#include <QString>
#include <QOpenGLContext>
#include <QOffscreenSurface>
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
#include <QSGEngine>
#include <QSGAbstractRenderer>
#endif // < Qt 6
namespace Timeline {
@@ -59,6 +62,7 @@ void runSceneGraphTest(QSGNode *node)
QVERIFY(context.makeCurrent(&surface));
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
QSGEngine engine;
QSGRootNode root;
root.appendChildNode(node);
@@ -74,6 +78,7 @@ void runSceneGraphTest(QSGNode *node)
// Unfortunately we cannot check the results of the rendering. But at least we know the shaders
// have not crashed here.
#endif // < Qt 6
context.doneCurrent();
}

View File

@@ -259,16 +259,16 @@ OpaqueColoredPoint2DWithSize *OpaqueColoredPoint2DWithSize::fromVertexData(QSGGe
const QSGGeometry::Attribute *attributes = geometry->attributes();
Q_ASSERT(attributes[0].position == 0);
Q_ASSERT(attributes[0].tupleSize == 2);
Q_ASSERT(attributes[0].type == GL_FLOAT);
Q_ASSERT(attributes[0].type == QSGGeometry::FloatType);
Q_ASSERT(attributes[1].position == 1);
Q_ASSERT(attributes[1].tupleSize == 2);
Q_ASSERT(attributes[1].type == GL_FLOAT);
Q_ASSERT(attributes[1].type == QSGGeometry::FloatType);
Q_ASSERT(attributes[2].position == 2);
Q_ASSERT(attributes[2].tupleSize == 1);
Q_ASSERT(attributes[2].type == GL_FLOAT);
Q_ASSERT(attributes[2].type == QSGGeometry::FloatType);
Q_ASSERT(attributes[3].position == 3);
Q_ASSERT(attributes[3].tupleSize == 4);
Q_ASSERT(attributes[3].type == GL_UNSIGNED_BYTE);
Q_ASSERT(attributes[3].type == QSGGeometry::UnsignedByteType);
Q_UNUSED(attributes)
return static_cast<OpaqueColoredPoint2DWithSize *>(geometry->vertexData());
}
@@ -358,10 +358,10 @@ static qint64 endTime(const TimelineModel *model, const TimelineRenderState *par
const QSGGeometry::AttributeSet &OpaqueColoredPoint2DWithSize::attributes()
{
static QSGGeometry::Attribute data[] = {
QSGGeometry::Attribute::create(0, 2, GL_FLOAT, true),
QSGGeometry::Attribute::create(1, 2, GL_FLOAT),
QSGGeometry::Attribute::create(2, 1, GL_FLOAT),
QSGGeometry::Attribute::create(3, 4, GL_UNSIGNED_BYTE)
QSGGeometry::Attribute::create(0, 2, QSGGeometry::FloatType, true),
QSGGeometry::Attribute::create(1, 2, QSGGeometry::FloatType),
QSGGeometry::Attribute::create(2, 1, QSGGeometry::FloatType),
QSGGeometry::Attribute::create(3, 4, QSGGeometry::UnsignedByteType)
};
static QSGGeometry::AttributeSet attrs = {
4,
@@ -436,12 +436,19 @@ class TimelineItemsMaterialShader : public QSGMaterialShader
public:
TimelineItemsMaterialShader();
#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 *newEffect,
QSGMaterial *oldEffect) override;
#endif // < Qt 6
private:
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
void initialize() override;
#endif // < Qt 6
int m_matrix_id;
int m_scale_id;
@@ -453,10 +460,16 @@ private:
TimelineItemsMaterialShader::TimelineItemsMaterialShader()
: QSGMaterialShader()
{
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
setShaderSourceFile(QOpenGLShader::Vertex, QStringLiteral(":/tracing/timelineitems.vert"));
setShaderSourceFile(QOpenGLShader::Fragment, QStringLiteral(":/tracing/timelineitems.frag"));
#else // < Qt 6
setShaderFileName(VertexStage, ":/tracing/timelineitems.vert");
setShaderFileName(FragmentStage, ":/tracing/timelineitems.frag");
#endif // < Qt 6
}
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
void TimelineItemsMaterialShader::updateState(const RenderState &state, QSGMaterial *newMaterial,
QSGMaterial *)
{
@@ -469,7 +482,19 @@ void TimelineItemsMaterialShader::updateState(const RenderState &state, QSGMater
program()->setUniformValue(m_z_range_id, GLfloat(1.0));
}
}
#else // < Qt 6
bool TimelineItemsMaterialShader::updateUniformData(RenderState &state,
QSGMaterial *newMaterial, QSGMaterial *)
{
// TODO: Make this work
if (state.isMatrixDirty()) {
TimelineItemsMaterial *material = static_cast<TimelineItemsMaterial *>(newMaterial);
}
return state.isMatrixDirty();
}
#endif // < Qt 6
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
char const *const *TimelineItemsMaterialShader::attributeNames() const
{
static const char *const attr[] = {"vertexCoord", "rectSize", "selectionId", "vertexColor", nullptr};
@@ -484,7 +509,7 @@ void TimelineItemsMaterialShader::initialize()
m_selected_item_id = program()->uniformLocation("selectedItem");
m_z_range_id = program()->uniformLocation("_qt_zRange");
}
#endif // < Qt 6
TimelineItemsMaterial::TimelineItemsMaterial() : m_selectedItem(-1)
{
@@ -527,10 +552,19 @@ QSGMaterialType *TimelineItemsMaterial::type() const
return &type;
}
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
QSGMaterialShader *TimelineItemsMaterial::createShader() const
{
return new TimelineItemsMaterialShader;
}
#else // < Qt 6
QSGMaterialShader *TimelineItemsMaterial::createShader(
QSGRendererInterface::RenderMode renderMode) const
{
Q_UNUSED(renderMode);
return new TimelineItemsMaterialShader;
}
#endif // < Qt 6
TimelineItemsRenderPassState::TimelineItemsRenderPassState(const TimelineModel *model) :
m_indexFrom(std::numeric_limits<int>::max()), m_indexTo(-1)

View File

@@ -45,7 +45,11 @@ public:
void setSelectionColor(QColor selectionColor);
QSGMaterialType *type() const override;
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
QSGMaterialShader *createShader() const override;
#else
QSGMaterialShader *createShader(QSGRendererInterface::RenderMode renderMode) const override;
#endif // < Qt 6
private:
QVector2D m_scale;

View File

@@ -40,7 +40,11 @@ class NotesMaterial : public QSGMaterial
{
public:
QSGMaterialType *type() const final;
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
QSGMaterialShader *createShader() const final;
#else // < Qt 6
QSGMaterialShader *createShader(QSGRendererInterface::RenderMode renderMode) const final;
#endif // < Qt 6
};
struct NotesGeometry
@@ -79,8 +83,8 @@ private:
const QSGGeometry::AttributeSet &NotesGeometry::point2DWithDistanceFromTop()
{
static QSGGeometry::Attribute data[] = {
QSGGeometry::Attribute::create(0, 2, GL_FLOAT, true),
QSGGeometry::Attribute::create(1, 1, GL_FLOAT),
QSGGeometry::Attribute::create(0, 2, QSGGeometry::FloatType, true),
QSGGeometry::Attribute::create(1, 1, QSGGeometry::FloatType),
};
static QSGGeometry::AttributeSet attrs = {
2,
@@ -197,7 +201,7 @@ QSGGeometry *NotesGeometry::createGeometry(QVector<int> &ids, const TimelineMode
QSGGeometry *geometry = new QSGGeometry(point2DWithDistanceFromTop(),
ids.count() * 2);
Q_ASSERT(geometry->vertexData());
geometry->setDrawingMode(GL_LINES);
geometry->setDrawingMode(QSGGeometry::DrawLines);
geometry->setLineWidth(3);
Point2DWithDistanceFromTop *v =
static_cast<Point2DWithDistanceFromTop *>(geometry->vertexData());
@@ -220,12 +224,19 @@ class NotesMaterialShader : public QSGMaterialShader
public:
NotesMaterialShader();
#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 *newMaterial, QSGMaterial *oldMaterial) override;
#endif // < Qt 6
private:
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
void initialize() override;
#endif // < Qt 6
int m_matrix_id;
int m_z_range_id;
@@ -235,10 +246,16 @@ private:
NotesMaterialShader::NotesMaterialShader()
: QSGMaterialShader()
{
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
setShaderSourceFile(QOpenGLShader::Vertex, QStringLiteral(":/tracing/notes.vert"));
setShaderSourceFile(QOpenGLShader::Fragment, QStringLiteral(":/tracing/notes.frag"));
#else // < Qt 6
setShaderFileName(VertexStage, ":/tracing/notes.vert");
setShaderFileName(FragmentStage, ":/tracing/notes.frag");
#endif // < Qt 6
}
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
void NotesMaterialShader::updateState(const RenderState &state, QSGMaterial *, QSGMaterial *)
{
if (state.isMatrixDirty()) {
@@ -250,7 +267,16 @@ void NotesMaterialShader::updateState(const RenderState &state, QSGMaterial *, Q
program()->setUniformValue(m_color_id, notesColor);
}
}
#else // < Qt 6
bool NotesMaterialShader::updateUniformData(QSGMaterialShader::RenderState &state, QSGMaterial *, QSGMaterial *)
{
if (state.isMatrixDirty()) {
}
return state.isMatrixDirty();
}
#endif // < Qt 6
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
char const *const *NotesMaterialShader::attributeNames() const
{
static const char *const attr[] = {"vertexCoord", "distanceFromTop", nullptr};
@@ -263,6 +289,7 @@ void NotesMaterialShader::initialize()
m_z_range_id = program()->uniformLocation("_qt_zRange");
m_color_id = program()->uniformLocation("notesColor");
}
#endif // < Qt 6
QSGMaterialType *NotesMaterial::type() const
{
@@ -270,10 +297,18 @@ QSGMaterialType *NotesMaterial::type() const
return &type;
}
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
QSGMaterialShader *NotesMaterial::createShader() const
{
return new NotesMaterialShader;
}
#else // < Qt 6
QSGMaterialShader *NotesMaterial::createShader(QSGRendererInterface::RenderMode renderMode) const
{
Q_UNUSED(renderMode);
return new NotesMaterialShader;
}
#endif // < Qt 6
void Point2DWithDistanceFromTop::set(float nx, float ny, float nd)
{

View File

@@ -37,7 +37,7 @@ QSGGeometryNode *createSelectionNode(QSGMaterial *material)
selectionNode->setFlag(QSGNode::OwnsMaterial, false);
QSGGeometry *geometry = new QSGGeometry(OpaqueColoredPoint2DWithSize::attributes(), 4);
Q_ASSERT(geometry->vertexData());
geometry->setDrawingMode(GL_TRIANGLE_STRIP);
geometry->setDrawingMode(QSGGeometry::DrawTriangleStrip);
OpaqueColoredPoint2DWithSize *v = OpaqueColoredPoint2DWithSize::fromVertexData(geometry);
for (int i = 0; i < 4; ++i)
v[i].set(0, 0, 0, 0, 0, 0, 0, 0, 0);

View File

@@ -250,7 +250,7 @@ qint64 CtfTimelineModel::newStackEvent(const json &event, qint64 normalizedTime,
int selectionId)
{
int nestingLevel = m_openEventIds.size();
m_maxStackSize = std::max(m_maxStackSize, m_openEventIds.size() + 1);
m_maxStackSize = std::max(qsizetype(m_maxStackSize), qsizetype(m_openEventIds.size() + 1));
int index = 0;
qint64 duration = -1;
if (eventPhase == CtfEventTypeBegin) {

View File

@@ -31,6 +31,7 @@
#include <tracing/traceevent.h>
#include <utils/qtcassert.h>
#include <QVariant>
#include <QVector>
#include <QDataStream>

View File

@@ -72,7 +72,12 @@ QVariantList InputEventsModel::labels() const
QMetaEnum InputEventsModel::metaEnum(const char *name)
{
return staticQtMetaObject.enumerator(staticQtMetaObject.indexOfEnumerator(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
}
QVariantMap InputEventsModel::details(int index) const

View File

@@ -34,7 +34,11 @@ 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 renderMode) const override;
#endif // < Qt 6
BindingLoopMaterial();
};
@@ -196,8 +200,8 @@ Timeline::TimelineRenderPass::State *QmlProfilerBindingLoopsRenderPass::update(
const QSGGeometry::AttributeSet &BindlingLoopsGeometry::point2DWithOffset()
{
static QSGGeometry::Attribute data[] = {
QSGGeometry::Attribute::create(0, 2, GL_FLOAT, true),
QSGGeometry::Attribute::create(1, 2, GL_FLOAT),
QSGGeometry::Attribute::create(0, 2, QSGGeometry::FloatType, true),
QSGGeometry::Attribute::create(1, 2, QSGGeometry::FloatType),
};
static QSGGeometry::AttributeSet attrs = {
2,
@@ -215,10 +219,10 @@ Point2DWithOffset *BindlingLoopsGeometry::vertexData()
const QSGGeometry::Attribute *attributes = geometry->attributes();
Q_ASSERT(attributes[0].position == 0);
Q_ASSERT(attributes[0].tupleSize == 2);
Q_ASSERT(attributes[0].type == GL_FLOAT);
Q_ASSERT(attributes[0].type == QSGGeometry::FloatType);
Q_ASSERT(attributes[1].position == 1);
Q_ASSERT(attributes[1].tupleSize == 2);
Q_ASSERT(attributes[1].type == GL_FLOAT);
Q_ASSERT(attributes[1].type == QSGGeometry::FloatType);
Q_UNUSED(attributes)
return static_cast<Point2DWithOffset *>(geometry->vertexData());
}
@@ -290,12 +294,19 @@ 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 *newEffect,
QSGMaterial *oldEffect) override;
#endif // < Qt 6
private:
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
void initialize() override;
#endif // < Qt 6
int m_matrix_id = 0;
int m_z_range_id = 0;
@@ -305,10 +316,16 @@ private:
BindingLoopMaterialShader::BindingLoopMaterialShader()
: QSGMaterialShader()
{
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
setShaderSourceFile(QOpenGLShader::Vertex, QStringLiteral(":/qmlprofiler/bindingloops.vert"));
setShaderSourceFile(QOpenGLShader::Fragment, QStringLiteral(":/qmlprofiler/bindingloops.frag"));
#else // < Qt 6
setShaderFileName(VertexStage, ":/qmlprofiler/bindingloops.vert");
setShaderFileName(FragmentStage, ":/qmlprofiler/bindingloops.frag");
#endif // < Qt 6
}
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
void BindingLoopMaterialShader::updateState(const RenderState &state, QSGMaterial *, QSGMaterial *)
{
if (state.isMatrixDirty()) {
@@ -319,7 +336,19 @@ void BindingLoopMaterialShader::updateState(const RenderState &state, QSGMateria
Utils::creatorTheme()->color(Utils::Theme::Timeline_HighlightColor));
}
}
#else // < Qt 6
bool BindingLoopMaterialShader::updateUniformData(RenderState &state,
QSGMaterial *newMaterial, QSGMaterial *)
{
// TODO: Make this work
if (state.isMatrixDirty()) {
BindingLoopMaterial *material = static_cast<BindingLoopMaterial *>(newMaterial);
}
return state.isMatrixDirty();
}
#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};
@@ -332,7 +361,7 @@ void BindingLoopMaterialShader::initialize()
m_z_range_id = program()->uniformLocation("_qt_zRange");
m_color_id = program()->uniformLocation("bindingLoopsColor");
}
#endif // < Qt 6
BindingLoopMaterial::BindingLoopMaterial()
{
@@ -345,10 +374,19 @@ QSGMaterialType *BindingLoopMaterial::type() const
return &type;
}
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
QSGMaterialShader *BindingLoopMaterial::createShader() const
{
return new BindingLoopMaterialShader;
}
#else // < Qt 6
QSGMaterialShader *BindingLoopMaterial::createShader(
QSGRendererInterface::RenderMode renderMode) const
{
Q_UNUSED(renderMode);
return new BindingLoopMaterialShader;
}
#endif // < Qt 6
void Point2DWithOffset::set(float nx, float ny, float nx2, float ny2)
{

View File

@@ -152,7 +152,7 @@ void QmlProfilerTraceFile::loadQtd(QIODevice *device)
while (validVersion && !stream.atEnd() && !stream.hasError() && !isCanceled()) {
QXmlStreamReader::TokenType token = stream.readNext();
const QStringRef elementName = stream.name();
const QStringView elementName = stream.name();
switch (token) {
case QXmlStreamReader::StartDocument : continue;
case QXmlStreamReader::StartElement : {
@@ -327,7 +327,7 @@ void QmlProfilerTraceFile::loadEventTypes(QXmlStreamReader &stream)
while (!stream.atEnd() && !stream.hasError() && !isCanceled()) {
QXmlStreamReader::TokenType token = stream.readNext();
const QStringRef elementName = stream.name();
const QStringView elementName = stream.name();
switch (token) {
case QXmlStreamReader::StartElement: {
@@ -503,7 +503,7 @@ void QmlProfilerTraceFile::loadEvents(QXmlStreamReader &stream)
while (!stream.atEnd() && !stream.hasError() && !isCanceled()) {
QXmlStreamReader::TokenType token = stream.readNext();
const QStringRef elementName = stream.name();
const QStringView elementName = stream.name();
switch (token) {
case QXmlStreamReader::StartElement: {
@@ -588,7 +588,7 @@ void QmlProfilerTraceFile::loadNotes(QXmlStreamReader &stream)
while (!stream.atEnd() && !stream.hasError() && !isCanceled()) {
QXmlStreamReader::TokenType token = stream.readNext();
const QStringRef elementName = stream.name();
const QStringView elementName = stream.name();
switch (token) {
case QXmlStreamReader::StartElement: {

View File

@@ -119,11 +119,18 @@ 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;

View File

@@ -100,7 +100,9 @@ public:
{
for (int i = 0; i < d->colors.count(); ++i) {
d->colors[i] = QPair<QColor, QString>(
QColor::fromRgb(qrand() % 256, qrand() % 256, qrand() % 256),
QColor::fromRgb(QRandomGenerator::global()->bounded(256),
QRandomGenerator::global()->bounded(256),
QRandomGenerator::global()->bounded(256)),
QString::number(i));
}
}

View File

@@ -111,11 +111,18 @@ void tst_TimelineItemsRenderPass::update()
QCOMPARE(node->geometry()->vertexCount(), 30);
QVERIFY(material2 != 0);
QCOMPARE(material1->type(), material2->type());
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
QSGMaterialShader *shader1 = material1->createShader();
QVERIFY(shader1 != 0);
QSGMaterialShader *shader2 = material2->createShader();
QVERIFY(shader2 != 0);
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;

View File

@@ -121,11 +121,18 @@ void tst_TimelineNotesRenderPass::update()
QCOMPARE(node->geometry()->vertexCount(), 2);
QVERIFY(material2 != 0);
QCOMPARE(material1->type(), material2->type());
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
QSGMaterialShader *shader1 = material1->createShader();
QVERIFY(shader1 != 0);
QSGMaterialShader *shader2 = material2->createShader();
QVERIFY(shader2 != 0);
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;

View File

@@ -95,6 +95,7 @@ void tst_TimelineRenderer::testMouseEvents(DummyRenderer *renderer, int x, int y
QHoverEvent hover(QMouseEvent::HoverMove, QPointF(x, y), QPointF(x - 1, y));
renderer->hoverMoveEvent(&hover);
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
event = QMouseEvent(QMouseEvent::MouseButtonPress, QPointF(x, y), Qt::LeftButton,
Qt::LeftButton, Qt::NoModifier);
renderer->mousePressEvent(&event);
@@ -102,8 +103,7 @@ void tst_TimelineRenderer::testMouseEvents(DummyRenderer *renderer, int x, int y
event = QMouseEvent(QMouseEvent::MouseButtonRelease, QPointF(x, y), Qt::LeftButton,
Qt::LeftButton, Qt::NoModifier);
renderer->mouseReleaseEvent(&event);
#endif // < Qt 6
}
void tst_TimelineRenderer::mouseEvents()

View File

@@ -84,7 +84,7 @@ void compareSelectionNode(QSGNode *node, const QRectF &rect, int selectionId)
QSGGeometryNode *geometryNode = static_cast<QSGGeometryNode *>(node);
QSGGeometry *geometry = geometryNode->geometry();
QCOMPARE(geometry->vertexCount(), 4);
QCOMPARE(geometry->drawingMode(), (GLenum)GL_TRIANGLE_STRIP);
QCOMPARE(geometry->drawingMode(), QSGGeometry::DrawTriangleStrip);
OpaqueColoredPoint2DWithSize *data =
static_cast<OpaqueColoredPoint2DWithSize *>(geometry->vertexData());
float *lowerLeft = reinterpret_cast<float *>(data);