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:
Ulf Hermann
2018-01-11 13:31:58 +01:00
parent a4c318d5e1
commit 77e28efad6
23 changed files with 33 additions and 32 deletions

View File

@@ -381,7 +381,7 @@ TimelineRenderPass::State *TimelineItemsRenderPass::update(const TimelineAbstrac
const TimelineRenderState *parentState,
State *oldState, int indexFrom,
int indexTo, bool stateChanged,
qreal spacing) const
float spacing) const
{
Q_UNUSED(stateChanged);
const TimelineModel *model = renderer->model();
@@ -416,8 +416,8 @@ TimelineRenderPass::State *TimelineItemsRenderPass::update(const TimelineAbstrac
state->expandedRow(row));
rowNode->material.setScale(
QVector2D(spacing / parentState->scale(),
static_cast<qreal>(model->expandedRowHeight(row))) /
static_cast<qreal>(TimelineModel::defaultRowHeight()));
static_cast<float>(model->expandedRowHeight(row))) /
static_cast<float>(TimelineModel::defaultRowHeight()));
rowNode->material.setSelectedItem(selectedItem);
rowNode->material.setSelectionColor(selectionColor);
}

View File

@@ -95,7 +95,7 @@ public:
static const TimelineItemsRenderPass *instance();
State *update(const TimelineAbstractRenderer *renderer, const TimelineRenderState *parentState,
State *state, int firstIndex, int lastIndex, bool stateChanged,
qreal spacing) const;
float spacing) const;
protected:
TimelineItemsRenderPass();
};

View File

@@ -415,13 +415,13 @@ float TimelineModel::relativeHeight(int index) const
return 1.0f;
}
int TimelineModel::rowMinValue(int rowNumber) const
qint64 TimelineModel::rowMinValue(int rowNumber) const
{
Q_UNUSED(rowNumber);
return 0;
}
int TimelineModel::rowMaxValue(int rowNumber) const
qint64 TimelineModel::rowMaxValue(int rowNumber) const
{
Q_UNUSED(rowNumber);
return 0;

View File

@@ -102,8 +102,8 @@ public:
Q_INVOKABLE virtual int typeId(int index) const;
Q_INVOKABLE virtual bool handlesTypeId(int typeId) const;
Q_INVOKABLE virtual float relativeHeight(int index) const;
Q_INVOKABLE virtual int rowMinValue(int rowNumber) const;
Q_INVOKABLE virtual int rowMaxValue(int rowNumber) const;
Q_INVOKABLE virtual qint64 rowMinValue(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 nextItemByTypeId(int typeId, qint64 time, int currentItem) const;

View File

@@ -104,7 +104,7 @@ TimelineRenderPass::State *TimelineNotesRenderPass::update(const TimelineAbstrac
const TimelineRenderState *parentState,
State *oldState, int firstIndex,
int lastIndex, bool stateChanged,
qreal spacing) const
float spacing) const
{
Q_UNUSED(firstIndex);
Q_UNUSED(lastIndex);

View File

@@ -37,7 +37,7 @@ public:
State *update(const TimelineAbstractRenderer *renderer, const TimelineRenderState *parentState,
State *oldState, int firstIndex, int lastIndex, bool stateChanged,
qreal spacing) const;
float spacing) const;
private:
TimelineNotesRenderPass();

View File

@@ -63,8 +63,9 @@ QSGNode *TimelineOverviewRenderer::updatePaintNode(QSGNode *oldNode,
1.0, d->renderPasses.size());
}
qreal xSpacing = width() / d->zoomer->traceDuration();
qreal ySpacing = height() / (d->model->collapsedRowCount() * TimelineModel::defaultRowHeight());
float xSpacing = static_cast<float>(width() / d->zoomer->traceDuration());
float ySpacing = static_cast<float>(
height() / (d->model->collapsedRowCount() * TimelineModel::defaultRowHeight()));
for (int i = 0; i < d->renderPasses.length(); ++i) {
d->renderState->setPassState(i, d->renderPasses[i]->update(this, d->renderState,

View File

@@ -120,7 +120,7 @@ QSGNode *TimelineRenderer::updatePaintNode(QSGNode *node, UpdatePaintNodeData *u
return 0;
}
qreal spacing = width() / d->zoomer->windowDuration();
float spacing = static_cast<float>(width() / d->zoomer->windowDuration());
if (d->modelDirty) {
if (node)

View File

@@ -49,7 +49,7 @@ public:
virtual State *update(const TimelineAbstractRenderer *renderer,
const TimelineRenderState *parentState,
State *state, int indexFrom, int indexTo, bool stateChanged,
qreal spacing) const = 0;
float spacing) const = 0;
};
} // namespace Timeline

View File

@@ -28,7 +28,7 @@
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)
{
Q_D(TimelineRenderState);
@@ -70,7 +70,7 @@ qint64 TimelineRenderState::end() const
return d->end;
}
qreal TimelineRenderState::scale() const
float TimelineRenderState::scale() const
{
Q_D(const TimelineRenderState);
return d->scale;

View File

@@ -33,12 +33,12 @@ namespace Timeline {
class TIMELINE_EXPORT TimelineRenderState {
public:
TimelineRenderState(qint64 start, qint64 end, qreal scale, int numPasses);
TimelineRenderState(qint64 start, qint64 end, float scale, int numPasses);
~TimelineRenderState();
qint64 start() const;
qint64 end() const;
qreal scale() const;
float scale() const;
TimelineRenderPass::State *passState(int i);
const TimelineRenderPass::State *passState(int i) const;

View File

@@ -39,7 +39,7 @@ public:
qint64 start;
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;
};

View File

@@ -64,7 +64,7 @@ private:
TimelineRenderPass::State *TimelineSelectionRenderPass::update(
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);

View File

@@ -38,7 +38,7 @@ public:
State *update(const TimelineAbstractRenderer *renderer, const TimelineRenderState *parentState,
State *state, int firstIndex, int lastIndex, bool stateChanged,
qreal spacing) const;
float spacing) const;
protected:
TimelineSelectionRenderPass();

View File

@@ -39,7 +39,7 @@ MemoryUsageModel::MemoryUsageModel(QmlProfilerModelManager *manager, QObject *pa
announceFeatures(Constants::QML_JS_RANGE_FEATURES ^ (1 << ProfileCompiling));
}
int MemoryUsageModel::rowMaxValue(int rowNumber) const
qint64 MemoryUsageModel::rowMaxValue(int rowNumber) const
{
Q_UNUSED(rowNumber);
return m_maxSize;

View File

@@ -53,7 +53,7 @@ public:
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 collapsedRow(int index) const override;

View File

@@ -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) {
return m_maxCacheSize;

View File

@@ -96,7 +96,7 @@ public:
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 collapsedRow(int index) const override;

View File

@@ -109,7 +109,7 @@ int QmlProfilerAnimationsModel::rowFromThreadId(int threadId) const
return (threadId == GuiThread || m_maxGuiThreadAnimations == 0) ? 1 : 2;
}
int QmlProfilerAnimationsModel::rowMaxValue(int rowNumber) const
qint64 QmlProfilerAnimationsModel::rowMaxValue(int rowNumber) const
{
switch (rowNumber) {
case 1:

View File

@@ -51,7 +51,7 @@ public:
QmlProfilerAnimationsModel(QmlProfilerModelManager *manager, QObject *parent = 0);
int rowMaxValue(int rowNumber) const override;
qint64 rowMaxValue(int rowNumber) const override;
int typeId(int index) const override;
Q_INVOKABLE int expandedRow(int index) const override;

View File

@@ -158,7 +158,7 @@ void updateNodes(const QmlProfilerRangeModel *model, int from, int to,
Timeline::TimelineRenderPass::State *QmlProfilerBindingLoopsRenderPass::update(
const Timeline::TimelineAbstractRenderer *renderer,
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(spacing);
@@ -244,7 +244,7 @@ void BindlingLoopsGeometry::allocate(QSGMaterial *material)
void BindlingLoopsGeometry::addExpandedEvent(float itemCenter)
{
float verticalCenter = Timeline::TimelineModel::defaultRowHeight() / 2.0;
float verticalCenter = Timeline::TimelineModel::defaultRowHeight() / 2.0f;
Point2DWithOffset *v = vertexData() + usedVertices;
v[0].set(itemCenter, verticalCenter, -1.0f, currentY);
v[1].set(itemCenter, verticalCenter, +1.0f, currentY);

View File

@@ -43,7 +43,7 @@ public:
State *update(const Timeline::TimelineAbstractRenderer *renderer,
const Timeline::TimelineRenderState *parentState,
State *oldState, int indexFrom, int indexTo, bool stateChanged,
qreal spacing) const;
float spacing) const;
protected:
QmlProfilerBindingLoopsRenderPass();
};

View File

@@ -34,7 +34,7 @@ public:
static bool s_dtorRan;
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();
};
@@ -43,7 +43,7 @@ bool DummyRenderPass::s_dtorRan = false;
TimelineRenderPass::State *DummyRenderPass::update(const TimelineAbstractRenderer *renderer,
const TimelineRenderState *parentState,
State *state, int indexFrom, int indexTo,
bool stateChanged, qreal spacing) const
bool stateChanged, float spacing) const
{
Q_UNUSED(renderer);
Q_UNUSED(parentState);