forked from qt-creator/qt-creator
Timeline: Use some better number types
The scale parameters are converted to single precision float anyway as soon as we do something with them. We might as well change all the methods to be single precision, too. The min/max row values should really be 64bit as 32bit values are not enough to express memory usage. Change-Id: I2b058b112286eabb1c077f7e746c48b6b99cb416 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
@@ -381,7 +381,7 @@ TimelineRenderPass::State *TimelineItemsRenderPass::update(const TimelineAbstrac
|
|||||||
const TimelineRenderState *parentState,
|
const TimelineRenderState *parentState,
|
||||||
State *oldState, int indexFrom,
|
State *oldState, int indexFrom,
|
||||||
int indexTo, bool stateChanged,
|
int indexTo, bool stateChanged,
|
||||||
qreal spacing) const
|
float spacing) const
|
||||||
{
|
{
|
||||||
Q_UNUSED(stateChanged);
|
Q_UNUSED(stateChanged);
|
||||||
const TimelineModel *model = renderer->model();
|
const TimelineModel *model = renderer->model();
|
||||||
@@ -416,8 +416,8 @@ TimelineRenderPass::State *TimelineItemsRenderPass::update(const TimelineAbstrac
|
|||||||
state->expandedRow(row));
|
state->expandedRow(row));
|
||||||
rowNode->material.setScale(
|
rowNode->material.setScale(
|
||||||
QVector2D(spacing / parentState->scale(),
|
QVector2D(spacing / parentState->scale(),
|
||||||
static_cast<qreal>(model->expandedRowHeight(row))) /
|
static_cast<float>(model->expandedRowHeight(row))) /
|
||||||
static_cast<qreal>(TimelineModel::defaultRowHeight()));
|
static_cast<float>(TimelineModel::defaultRowHeight()));
|
||||||
rowNode->material.setSelectedItem(selectedItem);
|
rowNode->material.setSelectedItem(selectedItem);
|
||||||
rowNode->material.setSelectionColor(selectionColor);
|
rowNode->material.setSelectionColor(selectionColor);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -95,7 +95,7 @@ public:
|
|||||||
static const TimelineItemsRenderPass *instance();
|
static const TimelineItemsRenderPass *instance();
|
||||||
State *update(const TimelineAbstractRenderer *renderer, const TimelineRenderState *parentState,
|
State *update(const TimelineAbstractRenderer *renderer, const TimelineRenderState *parentState,
|
||||||
State *state, int firstIndex, int lastIndex, bool stateChanged,
|
State *state, int firstIndex, int lastIndex, bool stateChanged,
|
||||||
qreal spacing) const;
|
float spacing) const;
|
||||||
protected:
|
protected:
|
||||||
TimelineItemsRenderPass();
|
TimelineItemsRenderPass();
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -415,13 +415,13 @@ float TimelineModel::relativeHeight(int index) const
|
|||||||
return 1.0f;
|
return 1.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
int TimelineModel::rowMinValue(int rowNumber) const
|
qint64 TimelineModel::rowMinValue(int rowNumber) const
|
||||||
{
|
{
|
||||||
Q_UNUSED(rowNumber);
|
Q_UNUSED(rowNumber);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int TimelineModel::rowMaxValue(int rowNumber) const
|
qint64 TimelineModel::rowMaxValue(int rowNumber) const
|
||||||
{
|
{
|
||||||
Q_UNUSED(rowNumber);
|
Q_UNUSED(rowNumber);
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
@@ -102,8 +102,8 @@ public:
|
|||||||
Q_INVOKABLE virtual int typeId(int index) const;
|
Q_INVOKABLE virtual int typeId(int index) const;
|
||||||
Q_INVOKABLE virtual bool handlesTypeId(int typeId) const;
|
Q_INVOKABLE virtual bool handlesTypeId(int typeId) const;
|
||||||
Q_INVOKABLE virtual float relativeHeight(int index) const;
|
Q_INVOKABLE virtual float relativeHeight(int index) const;
|
||||||
Q_INVOKABLE virtual int rowMinValue(int rowNumber) const;
|
Q_INVOKABLE virtual qint64 rowMinValue(int rowNumber) const;
|
||||||
Q_INVOKABLE virtual int rowMaxValue(int rowNumber) const;
|
Q_INVOKABLE virtual qint64 rowMaxValue(int rowNumber) const;
|
||||||
|
|
||||||
Q_INVOKABLE int nextItemBySelectionId(int selectionId, qint64 time, int currentItem) const;
|
Q_INVOKABLE int nextItemBySelectionId(int selectionId, qint64 time, int currentItem) const;
|
||||||
Q_INVOKABLE int nextItemByTypeId(int typeId, qint64 time, int currentItem) const;
|
Q_INVOKABLE int nextItemByTypeId(int typeId, qint64 time, int currentItem) const;
|
||||||
|
|||||||
@@ -104,7 +104,7 @@ TimelineRenderPass::State *TimelineNotesRenderPass::update(const TimelineAbstrac
|
|||||||
const TimelineRenderState *parentState,
|
const TimelineRenderState *parentState,
|
||||||
State *oldState, int firstIndex,
|
State *oldState, int firstIndex,
|
||||||
int lastIndex, bool stateChanged,
|
int lastIndex, bool stateChanged,
|
||||||
qreal spacing) const
|
float spacing) const
|
||||||
{
|
{
|
||||||
Q_UNUSED(firstIndex);
|
Q_UNUSED(firstIndex);
|
||||||
Q_UNUSED(lastIndex);
|
Q_UNUSED(lastIndex);
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ public:
|
|||||||
|
|
||||||
State *update(const TimelineAbstractRenderer *renderer, const TimelineRenderState *parentState,
|
State *update(const TimelineAbstractRenderer *renderer, const TimelineRenderState *parentState,
|
||||||
State *oldState, int firstIndex, int lastIndex, bool stateChanged,
|
State *oldState, int firstIndex, int lastIndex, bool stateChanged,
|
||||||
qreal spacing) const;
|
float spacing) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
TimelineNotesRenderPass();
|
TimelineNotesRenderPass();
|
||||||
|
|||||||
@@ -63,8 +63,9 @@ QSGNode *TimelineOverviewRenderer::updatePaintNode(QSGNode *oldNode,
|
|||||||
1.0, d->renderPasses.size());
|
1.0, d->renderPasses.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
qreal xSpacing = width() / d->zoomer->traceDuration();
|
float xSpacing = static_cast<float>(width() / d->zoomer->traceDuration());
|
||||||
qreal ySpacing = height() / (d->model->collapsedRowCount() * TimelineModel::defaultRowHeight());
|
float ySpacing = static_cast<float>(
|
||||||
|
height() / (d->model->collapsedRowCount() * TimelineModel::defaultRowHeight()));
|
||||||
|
|
||||||
for (int i = 0; i < d->renderPasses.length(); ++i) {
|
for (int i = 0; i < d->renderPasses.length(); ++i) {
|
||||||
d->renderState->setPassState(i, d->renderPasses[i]->update(this, d->renderState,
|
d->renderState->setPassState(i, d->renderPasses[i]->update(this, d->renderState,
|
||||||
|
|||||||
@@ -120,7 +120,7 @@ QSGNode *TimelineRenderer::updatePaintNode(QSGNode *node, UpdatePaintNodeData *u
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
qreal spacing = width() / d->zoomer->windowDuration();
|
float spacing = static_cast<float>(width() / d->zoomer->windowDuration());
|
||||||
|
|
||||||
if (d->modelDirty) {
|
if (d->modelDirty) {
|
||||||
if (node)
|
if (node)
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ public:
|
|||||||
virtual State *update(const TimelineAbstractRenderer *renderer,
|
virtual State *update(const TimelineAbstractRenderer *renderer,
|
||||||
const TimelineRenderState *parentState,
|
const TimelineRenderState *parentState,
|
||||||
State *state, int indexFrom, int indexTo, bool stateChanged,
|
State *state, int indexFrom, int indexTo, bool stateChanged,
|
||||||
qreal spacing) const = 0;
|
float spacing) const = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Timeline
|
} // namespace Timeline
|
||||||
|
|||||||
@@ -28,7 +28,7 @@
|
|||||||
|
|
||||||
namespace Timeline {
|
namespace Timeline {
|
||||||
|
|
||||||
TimelineRenderState::TimelineRenderState(qint64 start, qint64 end, qreal scale, int numPasses) :
|
TimelineRenderState::TimelineRenderState(qint64 start, qint64 end, float scale, int numPasses) :
|
||||||
d_ptr(new TimelineRenderStatePrivate)
|
d_ptr(new TimelineRenderStatePrivate)
|
||||||
{
|
{
|
||||||
Q_D(TimelineRenderState);
|
Q_D(TimelineRenderState);
|
||||||
@@ -70,7 +70,7 @@ qint64 TimelineRenderState::end() const
|
|||||||
return d->end;
|
return d->end;
|
||||||
}
|
}
|
||||||
|
|
||||||
qreal TimelineRenderState::scale() const
|
float TimelineRenderState::scale() const
|
||||||
{
|
{
|
||||||
Q_D(const TimelineRenderState);
|
Q_D(const TimelineRenderState);
|
||||||
return d->scale;
|
return d->scale;
|
||||||
|
|||||||
@@ -33,12 +33,12 @@ namespace Timeline {
|
|||||||
|
|
||||||
class TIMELINE_EXPORT TimelineRenderState {
|
class TIMELINE_EXPORT TimelineRenderState {
|
||||||
public:
|
public:
|
||||||
TimelineRenderState(qint64 start, qint64 end, qreal scale, int numPasses);
|
TimelineRenderState(qint64 start, qint64 end, float scale, int numPasses);
|
||||||
~TimelineRenderState();
|
~TimelineRenderState();
|
||||||
|
|
||||||
qint64 start() const;
|
qint64 start() const;
|
||||||
qint64 end() const;
|
qint64 end() const;
|
||||||
qreal scale() const;
|
float scale() const;
|
||||||
|
|
||||||
TimelineRenderPass::State *passState(int i);
|
TimelineRenderPass::State *passState(int i);
|
||||||
const TimelineRenderPass::State *passState(int i) const;
|
const TimelineRenderPass::State *passState(int i) const;
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ public:
|
|||||||
qint64 start;
|
qint64 start;
|
||||||
qint64 end;
|
qint64 end;
|
||||||
|
|
||||||
qreal scale; // "native" scale, this stays the same through the life time of a state
|
float scale; // "native" scale, this stays the same through the life time of a state
|
||||||
|
|
||||||
QVector<TimelineRenderPass::State *> passes;
|
QVector<TimelineRenderPass::State *> passes;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ private:
|
|||||||
|
|
||||||
TimelineRenderPass::State *TimelineSelectionRenderPass::update(
|
TimelineRenderPass::State *TimelineSelectionRenderPass::update(
|
||||||
const TimelineAbstractRenderer *renderer, const TimelineRenderState *parentState,
|
const TimelineAbstractRenderer *renderer, const TimelineRenderState *parentState,
|
||||||
State *oldState, int firstIndex, int lastIndex, bool stateChanged, qreal spacing) const
|
State *oldState, int firstIndex, int lastIndex, bool stateChanged, float spacing) const
|
||||||
{
|
{
|
||||||
Q_UNUSED(stateChanged);
|
Q_UNUSED(stateChanged);
|
||||||
|
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ public:
|
|||||||
|
|
||||||
State *update(const TimelineAbstractRenderer *renderer, const TimelineRenderState *parentState,
|
State *update(const TimelineAbstractRenderer *renderer, const TimelineRenderState *parentState,
|
||||||
State *state, int firstIndex, int lastIndex, bool stateChanged,
|
State *state, int firstIndex, int lastIndex, bool stateChanged,
|
||||||
qreal spacing) const;
|
float spacing) const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
TimelineSelectionRenderPass();
|
TimelineSelectionRenderPass();
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ MemoryUsageModel::MemoryUsageModel(QmlProfilerModelManager *manager, QObject *pa
|
|||||||
announceFeatures(Constants::QML_JS_RANGE_FEATURES ^ (1 << ProfileCompiling));
|
announceFeatures(Constants::QML_JS_RANGE_FEATURES ^ (1 << ProfileCompiling));
|
||||||
}
|
}
|
||||||
|
|
||||||
int MemoryUsageModel::rowMaxValue(int rowNumber) const
|
qint64 MemoryUsageModel::rowMaxValue(int rowNumber) const
|
||||||
{
|
{
|
||||||
Q_UNUSED(rowNumber);
|
Q_UNUSED(rowNumber);
|
||||||
return m_maxSize;
|
return m_maxSize;
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ public:
|
|||||||
|
|
||||||
MemoryUsageModel(QmlProfilerModelManager *manager, QObject *parent = 0);
|
MemoryUsageModel(QmlProfilerModelManager *manager, QObject *parent = 0);
|
||||||
|
|
||||||
int rowMaxValue(int rowNumber) const override;
|
qint64 rowMaxValue(int rowNumber) const override;
|
||||||
|
|
||||||
int expandedRow(int index) const override;
|
int expandedRow(int index) const override;
|
||||||
int collapsedRow(int index) const override;
|
int collapsedRow(int index) const override;
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ PixmapCacheModel::PixmapCacheModel(QmlProfilerModelManager *manager, QObject *pa
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
int PixmapCacheModel::rowMaxValue(int rowNumber) const
|
qint64 PixmapCacheModel::rowMaxValue(int rowNumber) const
|
||||||
{
|
{
|
||||||
if (rowNumber == 1) {
|
if (rowNumber == 1) {
|
||||||
return m_maxCacheSize;
|
return m_maxCacheSize;
|
||||||
|
|||||||
@@ -96,7 +96,7 @@ public:
|
|||||||
|
|
||||||
PixmapCacheModel(QmlProfilerModelManager *manager, QObject *parent = 0);
|
PixmapCacheModel(QmlProfilerModelManager *manager, QObject *parent = 0);
|
||||||
|
|
||||||
int rowMaxValue(int rowNumber) const override;
|
qint64 rowMaxValue(int rowNumber) const override;
|
||||||
|
|
||||||
int expandedRow(int index) const override;
|
int expandedRow(int index) const override;
|
||||||
int collapsedRow(int index) const override;
|
int collapsedRow(int index) const override;
|
||||||
|
|||||||
@@ -109,7 +109,7 @@ int QmlProfilerAnimationsModel::rowFromThreadId(int threadId) const
|
|||||||
return (threadId == GuiThread || m_maxGuiThreadAnimations == 0) ? 1 : 2;
|
return (threadId == GuiThread || m_maxGuiThreadAnimations == 0) ? 1 : 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
int QmlProfilerAnimationsModel::rowMaxValue(int rowNumber) const
|
qint64 QmlProfilerAnimationsModel::rowMaxValue(int rowNumber) const
|
||||||
{
|
{
|
||||||
switch (rowNumber) {
|
switch (rowNumber) {
|
||||||
case 1:
|
case 1:
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ public:
|
|||||||
|
|
||||||
QmlProfilerAnimationsModel(QmlProfilerModelManager *manager, QObject *parent = 0);
|
QmlProfilerAnimationsModel(QmlProfilerModelManager *manager, QObject *parent = 0);
|
||||||
|
|
||||||
int rowMaxValue(int rowNumber) const override;
|
qint64 rowMaxValue(int rowNumber) const override;
|
||||||
|
|
||||||
int typeId(int index) const override;
|
int typeId(int index) const override;
|
||||||
Q_INVOKABLE int expandedRow(int index) const override;
|
Q_INVOKABLE int expandedRow(int index) const override;
|
||||||
|
|||||||
@@ -158,7 +158,7 @@ void updateNodes(const QmlProfilerRangeModel *model, int from, int to,
|
|||||||
Timeline::TimelineRenderPass::State *QmlProfilerBindingLoopsRenderPass::update(
|
Timeline::TimelineRenderPass::State *QmlProfilerBindingLoopsRenderPass::update(
|
||||||
const Timeline::TimelineAbstractRenderer *renderer,
|
const Timeline::TimelineAbstractRenderer *renderer,
|
||||||
const Timeline::TimelineRenderState *parentState, State *oldState,
|
const Timeline::TimelineRenderState *parentState, State *oldState,
|
||||||
int indexFrom, int indexTo, bool stateChanged, qreal spacing) const
|
int indexFrom, int indexTo, bool stateChanged, float spacing) const
|
||||||
{
|
{
|
||||||
Q_UNUSED(stateChanged);
|
Q_UNUSED(stateChanged);
|
||||||
Q_UNUSED(spacing);
|
Q_UNUSED(spacing);
|
||||||
@@ -244,7 +244,7 @@ void BindlingLoopsGeometry::allocate(QSGMaterial *material)
|
|||||||
|
|
||||||
void BindlingLoopsGeometry::addExpandedEvent(float itemCenter)
|
void BindlingLoopsGeometry::addExpandedEvent(float itemCenter)
|
||||||
{
|
{
|
||||||
float verticalCenter = Timeline::TimelineModel::defaultRowHeight() / 2.0;
|
float verticalCenter = Timeline::TimelineModel::defaultRowHeight() / 2.0f;
|
||||||
Point2DWithOffset *v = vertexData() + usedVertices;
|
Point2DWithOffset *v = vertexData() + usedVertices;
|
||||||
v[0].set(itemCenter, verticalCenter, -1.0f, currentY);
|
v[0].set(itemCenter, verticalCenter, -1.0f, currentY);
|
||||||
v[1].set(itemCenter, verticalCenter, +1.0f, currentY);
|
v[1].set(itemCenter, verticalCenter, +1.0f, currentY);
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ public:
|
|||||||
State *update(const Timeline::TimelineAbstractRenderer *renderer,
|
State *update(const Timeline::TimelineAbstractRenderer *renderer,
|
||||||
const Timeline::TimelineRenderState *parentState,
|
const Timeline::TimelineRenderState *parentState,
|
||||||
State *oldState, int indexFrom, int indexTo, bool stateChanged,
|
State *oldState, int indexFrom, int indexTo, bool stateChanged,
|
||||||
qreal spacing) const;
|
float spacing) const;
|
||||||
protected:
|
protected:
|
||||||
QmlProfilerBindingLoopsRenderPass();
|
QmlProfilerBindingLoopsRenderPass();
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ public:
|
|||||||
static bool s_dtorRan;
|
static bool s_dtorRan;
|
||||||
|
|
||||||
State *update(const TimelineAbstractRenderer *renderer, const TimelineRenderState *parentState,
|
State *update(const TimelineAbstractRenderer *renderer, const TimelineRenderState *parentState,
|
||||||
State *state, int indexFrom, int indexTo, bool stateChanged, qreal spacing) const;
|
State *state, int indexFrom, int indexTo, bool stateChanged, float spacing) const;
|
||||||
~DummyRenderPass();
|
~DummyRenderPass();
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -43,7 +43,7 @@ bool DummyRenderPass::s_dtorRan = false;
|
|||||||
TimelineRenderPass::State *DummyRenderPass::update(const TimelineAbstractRenderer *renderer,
|
TimelineRenderPass::State *DummyRenderPass::update(const TimelineAbstractRenderer *renderer,
|
||||||
const TimelineRenderState *parentState,
|
const TimelineRenderState *parentState,
|
||||||
State *state, int indexFrom, int indexTo,
|
State *state, int indexFrom, int indexTo,
|
||||||
bool stateChanged, qreal spacing) const
|
bool stateChanged, float spacing) const
|
||||||
{
|
{
|
||||||
Q_UNUSED(renderer);
|
Q_UNUSED(renderer);
|
||||||
Q_UNUSED(parentState);
|
Q_UNUSED(parentState);
|
||||||
|
|||||||
Reference in New Issue
Block a user