QmlProfiler: Convert the render pass state into a pure interface

Like that we don't have to expose any private members and we don't have
to care about QSGNodes we'll never create in a render pass.

Change-Id: I4e71da24c85de8f8f73d58fc2e76dc5e82ee31ae
Reviewed-by: Kai Koehne <kai.koehne@theqtcompany.com>
This commit is contained in:
Ulf Hermann
2014-12-09 12:44:23 +01:00
parent 35204e1147
commit 2b143cf810
7 changed files with 108 additions and 54 deletions

View File

@@ -45,6 +45,12 @@ struct BindingLoopsRenderPassState : public Timeline::TimelineRenderPass::State
BindingLoopMaterial material;
int indexFrom;
int indexTo;
QVector<QSGNode *> m_expandedRows;
const QVector<QSGNode *> &expandedRows() const { return m_expandedRows; }
QSGNode *m_collapsedOverlay;
QSGNode *collapsedOverlay() const { return m_collapsedOverlay; }
};
struct Point2DWithOffset {
@@ -106,13 +112,13 @@ void updateNodes(const QmlProfilerRangeModel *model, int from, int to,
BindlingLoopsGeometry &row = expandedPerRow[i];
if (row.usedVertices > 0) {
row.allocate(&state->material);
state->expandedRows[i]->appendChildNode(row.node);
state->m_expandedRows[i]->appendChildNode(row.node);
}
}
if (collapsed.usedVertices > 0) {
collapsed.allocate(&state->material);
state->collapsedOverlay->appendChildNode(collapsed.node);
state->m_collapsedOverlay->appendChildNode(collapsed.node);
}
int rowHeight = Timeline::TimelineModel::defaultRowHeight();
@@ -150,25 +156,23 @@ Timeline::TimelineRenderPass::State *QmlProfilerBindingLoopsRenderPass::update(
Q_UNUSED(stateChanged);
Q_UNUSED(spacing);
BindingLoopsRenderPassState *state;
if (oldState == 0)
state = new BindingLoopsRenderPassState;
else
state = static_cast<BindingLoopsRenderPassState *>(oldState);
const QmlProfilerRangeModel *model = qobject_cast<const QmlProfilerRangeModel *>(
renderer->model());
BindingLoopsRenderPassState *state;
if (oldState == 0) {
state = new BindingLoopsRenderPassState;
state->m_expandedRows.reserve(model->expandedRowCount());
for (int i = 0; i < model->expandedRowCount(); ++i)
state->m_expandedRows << new QSGNode;
state->m_collapsedOverlay = new QSGNode;
} else {
state = static_cast<BindingLoopsRenderPassState *>(oldState);
}
if (!model)
return state;
if (state->expandedRows.isEmpty()) {
state->expandedRows.reserve(model->expandedRowCount());
for (int i = 0; i < model->expandedRowCount(); ++i)
state->expandedRows << new QSGNode;
}
if (state->collapsedOverlay == 0)
state->collapsedOverlay = new QSGNode;
if (indexFrom < 0 || indexTo > model->count())
return state;