diff --git a/src/libs/tracing/timelineitemsrenderpass.cpp b/src/libs/tracing/timelineitemsrenderpass.cpp index 9911382240a..344810d81d4 100644 --- a/src/libs/tracing/timelineitemsrenderpass.cpp +++ b/src/libs/tracing/timelineitemsrenderpass.cpp @@ -357,14 +357,22 @@ static qint64 endTime(const TimelineModel *model, const TimelineRenderState *par const QSGGeometry::AttributeSet &OpaqueColoredPoint2DWithSize::attributes() { - static QSGGeometry::Attribute data[] = { - 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 const QSGGeometry::Attribute data[] = { + // vec4 vertexCoord + QSGGeometry::Attribute::createWithAttributeType(0, 2, QSGGeometry::FloatType, + QSGGeometry::PositionAttribute), + // vec2 rectSize + QSGGeometry::Attribute::createWithAttributeType(1, 2, QSGGeometry::FloatType, + QSGGeometry::UnknownAttribute), + // float selectionId + QSGGeometry::Attribute::createWithAttributeType(2, 1, QSGGeometry::FloatType, + QSGGeometry::UnknownAttribute), + // vec4 vertexColor + QSGGeometry::Attribute::createWithAttributeType(3, 4, QSGGeometry::UnsignedByteType, + QSGGeometry::ColorAttribute), }; - static QSGGeometry::AttributeSet attrs = { - 4, + static const QSGGeometry::AttributeSet attrs = { + sizeof(data) / sizeof(data[0]), sizeof(OpaqueColoredPoint2DWithSize), data }; @@ -448,13 +456,13 @@ public: private: #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) void initialize() override; -#endif // < Qt 6 int m_matrix_id; int m_scale_id; int m_selection_color_id; int m_selected_item_id; int m_z_range_id; +#endif // < Qt 6 }; TimelineItemsMaterialShader::TimelineItemsMaterialShader() @@ -556,17 +564,12 @@ QSGMaterialType *TimelineItemsMaterial::type() const #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 +QSGMaterialShader *TimelineItemsMaterial::createShader(QSGRendererInterface::RenderMode) const +#endif // < Qt 6 { - Q_UNUSED(renderMode); return new TimelineItemsMaterialShader; } -#endif // < Qt 6 TimelineItemsRenderPassState::TimelineItemsRenderPassState(const TimelineModel *model) : m_indexFrom(std::numeric_limits::max()), m_indexTo(-1) diff --git a/src/libs/tracing/timelineitemsrenderpass.h b/src/libs/tracing/timelineitemsrenderpass.h index 807f0ed5518..9d52be9ac71 100644 --- a/src/libs/tracing/timelineitemsrenderpass.h +++ b/src/libs/tracing/timelineitemsrenderpass.h @@ -48,7 +48,7 @@ public: #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) QSGMaterialShader *createShader() const override; #else - QSGMaterialShader *createShader(QSGRendererInterface::RenderMode renderMode) const override; + QSGMaterialShader *createShader(QSGRendererInterface::RenderMode) const override; #endif // < Qt 6 private: @@ -83,8 +83,10 @@ public: static OpaqueColoredPoint2DWithSize *fromVertexData(QSGGeometry *geometry); private: - float x, y, w, h, id; - unsigned char r, g, b, a; + float x, y; // vec4 vertexCoord + float w, h; // vec2 rectSize + float id; // float selectionId + unsigned char r, g, b, a; // vec4 vertexColor void setCommon(const OpaqueColoredPoint2DWithSize *master); void setLeft(const OpaqueColoredPoint2DWithSize *master); diff --git a/src/libs/tracing/timelinenotesrenderpass.cpp b/src/libs/tracing/timelinenotesrenderpass.cpp index 90a10ca4602..e71366e74eb 100644 --- a/src/libs/tracing/timelinenotesrenderpass.cpp +++ b/src/libs/tracing/timelinenotesrenderpass.cpp @@ -32,7 +32,8 @@ namespace Timeline { struct Point2DWithDistanceFromTop { - float x, y, d; + float x, y; // vec4 vertexCoord + float d; // float distanceFromTop void set(float nx, float ny, float nd); }; @@ -43,7 +44,7 @@ public: #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) QSGMaterialShader *createShader() const final; #else // < Qt 6 - QSGMaterialShader *createShader(QSGRendererInterface::RenderMode renderMode) const final; + QSGMaterialShader *createShader(QSGRendererInterface::RenderMode) const final; #endif // < Qt 6 }; @@ -82,12 +83,16 @@ private: const QSGGeometry::AttributeSet &NotesGeometry::point2DWithDistanceFromTop() { - static QSGGeometry::Attribute data[] = { - QSGGeometry::Attribute::create(0, 2, QSGGeometry::FloatType, true), - QSGGeometry::Attribute::create(1, 1, QSGGeometry::FloatType), + static const QSGGeometry::Attribute data[] = { + // vec4 vertexCoord + QSGGeometry::Attribute::createWithAttributeType(0, 2, QSGGeometry::FloatType, + QSGGeometry::PositionAttribute), + // float distanceFromTop + QSGGeometry::Attribute::createWithAttributeType(1, 1, QSGGeometry::FloatType, + QSGGeometry::UnknownAttribute), }; - static QSGGeometry::AttributeSet attrs = { - 2, + static const QSGGeometry::AttributeSet attrs = { + sizeof(data) / sizeof(data[0]), sizeof(Point2DWithDistanceFromTop), data }; @@ -229,18 +234,17 @@ public: QSGMaterial *oldEffect) override; char const *const *attributeNames() const override; #else // < Qt 6 - bool updateUniformData(RenderState &state, - QSGMaterial *newMaterial, QSGMaterial *oldMaterial) override; + bool updateUniformData(RenderState &state, QSGMaterial *, QSGMaterial *) 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; int m_color_id; +#endif // < Qt 6 }; NotesMaterialShader::NotesMaterialShader() @@ -255,20 +259,24 @@ NotesMaterialShader::NotesMaterialShader() #endif // < Qt 6 } +static QColor notesColor() +{ + return Utils::creatorTheme() + ? Utils::creatorTheme()->color(Utils::Theme::Timeline_HighlightColor) + : QColor(255, 165, 0); +} + #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) void NotesMaterialShader::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)); - const QColor notesColor = Utils::creatorTheme() - ? Utils::creatorTheme()->color(Utils::Theme::Timeline_HighlightColor) - : QColor(255, 165, 0); - program()->setUniformValue(m_color_id, notesColor); + program()->setUniformValue(m_color_id, notesColor()); } } #else // < Qt 6 -bool NotesMaterialShader::updateUniformData(QSGMaterialShader::RenderState &state, QSGMaterial *, QSGMaterial *) +bool NotesMaterialShader::updateUniformData(RenderState &state, QSGMaterial *, QSGMaterial *) { if (state.isMatrixDirty()) { } @@ -299,16 +307,12 @@ QSGMaterialType *NotesMaterial::type() const #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 +QSGMaterialShader *NotesMaterial::createShader(QSGRendererInterface::RenderMode) const +#endif // < Qt 6 { - Q_UNUSED(renderMode); return new NotesMaterialShader; } -#endif // < Qt 6 void Point2DWithDistanceFromTop::set(float nx, float ny, float nd) { diff --git a/src/plugins/qmlprofiler/qmlprofilerbindingloopsrenderpass.cpp b/src/plugins/qmlprofiler/qmlprofilerbindingloopsrenderpass.cpp index e9f056f5693..2d2f11fe110 100644 --- a/src/plugins/qmlprofiler/qmlprofilerbindingloopsrenderpass.cpp +++ b/src/plugins/qmlprofiler/qmlprofilerbindingloopsrenderpass.cpp @@ -37,7 +37,7 @@ public: #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) QSGMaterialShader *createShader() const override; #else - QSGMaterialShader *createShader(QSGRendererInterface::RenderMode renderMode) const override; + QSGMaterialShader *createShader(QSGRendererInterface::RenderMode) const override; #endif // < Qt 6 BindingLoopMaterial(); }; @@ -66,7 +66,8 @@ private: }; struct Point2DWithOffset { - float x, y, x2, y2; + float x, y; // vec4 vertexCoord + float x2, y2; // vec2 postScaleOffset void set(float nx, float ny, float nx2, float ny2); }; @@ -199,12 +200,16 @@ Timeline::TimelineRenderPass::State *QmlProfilerBindingLoopsRenderPass::update( const QSGGeometry::AttributeSet &BindlingLoopsGeometry::point2DWithOffset() { - static QSGGeometry::Attribute data[] = { - QSGGeometry::Attribute::create(0, 2, QSGGeometry::FloatType, true), - QSGGeometry::Attribute::create(1, 2, QSGGeometry::FloatType), + static const QSGGeometry::Attribute data[] = { + // vec4 vertexCoord + QSGGeometry::Attribute::createWithAttributeType(0, 2, QSGGeometry::FloatType, + QSGGeometry::PositionAttribute), + // vec2 postScaleOffset + QSGGeometry::Attribute::createWithAttributeType(1, 2, QSGGeometry::FloatType, + QSGGeometry::UnknownAttribute), }; - static QSGGeometry::AttributeSet attrs = { - 2, + static const QSGGeometry::AttributeSet attrs = { + sizeof(data) / sizeof(data[0]), sizeof(Point2DWithOffset), data }; @@ -299,18 +304,17 @@ public: QSGMaterial *oldEffect) override; char const *const *attributeNames() const override; #else // < Qt 6 - bool updateUniformData(RenderState &state, QSGMaterial *newEffect, - QSGMaterial *oldEffect) override; + bool updateUniformData(RenderState &state, QSGMaterial *, QSGMaterial *) 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; int m_color_id = 0; +#endif // < Qt 6 }; BindingLoopMaterialShader::BindingLoopMaterialShader() @@ -327,25 +331,24 @@ BindingLoopMaterialShader::BindingLoopMaterialShader() #endif // < Qt 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, - Utils::creatorTheme()->color(Utils::Theme::Timeline_HighlightColor)); + program()->setUniformValue(m_color_id, bindingLoopsColor()); } } #else // < Qt 6 -bool BindingLoopMaterialShader::updateUniformData(RenderState &state, - QSGMaterial *newMaterial, QSGMaterial *) +bool BindingLoopMaterialShader::updateUniformData(RenderState &state, QSGMaterial *, QSGMaterial *) { // TODO: Make this work - if (state.isMatrixDirty()) { - BindingLoopMaterial *material = static_cast(newMaterial); - } return state.isMatrixDirty(); } #endif // < Qt 6 @@ -378,17 +381,12 @@ QSGMaterialType *BindingLoopMaterial::type() const #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 +QSGMaterialShader *BindingLoopMaterial::createShader(QSGRendererInterface::RenderMode) const +#endif // < Qt 6 { - Q_UNUSED(renderMode); return new BindingLoopMaterialShader; } -#endif // < Qt 6 void Point2DWithOffset::set(float nx, float ny, float nx2, float ny2) {