From dcb14c4bc0c362471a83ae5909081efb46756910 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Wed, 2 Jul 2014 11:06:56 +0200 Subject: [PATCH] Boost small paint events a little when no scale is shown Like this you can see if the frame rate is low, even if there aren't many animations. Change-Id: Ib9c759278d4c5e7e4bff94737e2ced87791f2e4b Task-number: QTCREATORBUG-12589 Reviewed-by: Kai Koehne --- .../qmlprofiler/abstracttimelinemodel.cpp | 2 -- .../qmlprofiler/abstracttimelinemodel.h | 2 ++ .../qmlprofilerpainteventsmodelproxy.cpp | 21 +++++++++++++++---- 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/src/plugins/qmlprofiler/abstracttimelinemodel.cpp b/src/plugins/qmlprofiler/abstracttimelinemodel.cpp index ff5da4485c0..17ea48be0f5 100644 --- a/src/plugins/qmlprofiler/abstracttimelinemodel.cpp +++ b/src/plugins/qmlprofiler/abstracttimelinemodel.cpp @@ -32,8 +32,6 @@ namespace QmlProfiler { -static const int DefaultRowHeight = 30; - AbstractTimelineModel::AbstractTimelineModel(AbstractTimelineModelPrivate *dd, const QString &name, const QString &label, QmlDebug::Message message, QmlDebug::RangeType rangeType, QObject *parent) : diff --git a/src/plugins/qmlprofiler/abstracttimelinemodel.h b/src/plugins/qmlprofiler/abstracttimelinemodel.h index ea0486970a6..2d612e16a59 100644 --- a/src/plugins/qmlprofiler/abstracttimelinemodel.h +++ b/src/plugins/qmlprofiler/abstracttimelinemodel.h @@ -101,6 +101,8 @@ signals: void rowHeightChanged(); protected: + static const int DefaultRowHeight = 30; + enum BoxColorProperties { EventHueMultiplier = 25, FractionHueMultiplier = 96, diff --git a/src/plugins/qmlprofiler/qmlprofilerpainteventsmodelproxy.cpp b/src/plugins/qmlprofiler/qmlprofilerpainteventsmodelproxy.cpp index 233a3d7c2d5..37a3d4c6f1f 100644 --- a/src/plugins/qmlprofiler/qmlprofilerpainteventsmodelproxy.cpp +++ b/src/plugins/qmlprofiler/qmlprofilerpainteventsmodelproxy.cpp @@ -55,6 +55,7 @@ public: int maxGuiThreadAnimations; int maxRenderThreadAnimations; bool seenForeignPaintEvent; + int rowFromThreadId(QmlDebug::AnimationThread threadId) const; private: Q_DECLARE_PUBLIC(PaintEventsModelProxy) @@ -160,11 +161,16 @@ int PaintEventsModelProxy::rowCount() const return (d->maxGuiThreadAnimations == 0 || d->maxRenderThreadAnimations == 0) ? 2 : 3; } +int PaintEventsModelProxy::PaintEventsModelProxyPrivate::rowFromThreadId( + QmlDebug::AnimationThread threadId) const +{ + return (threadId == QmlDebug::GuiThread || maxGuiThreadAnimations == 0) ? 1 : 2; +} + int PaintEventsModelProxy::getEventRow(int index) const { Q_D(const PaintEventsModelProxy); - QmlDebug::AnimationThread threadId = d->range(index).threadId; - return (threadId == QmlDebug::GuiThread || d->maxGuiThreadAnimations == 0) ? 1 : 2; + return d->rowFromThreadId(d->range(index).threadId); } int PaintEventsModelProxy::rowMaxValue(int rowNumber) const @@ -202,8 +208,15 @@ float PaintEventsModelProxy::getHeight(int index) const { Q_D(const PaintEventsModelProxy); const PaintEventsModelProxyPrivate::Range &range = d->range(index); - return (float)range.animationcount / (float)(range.threadId == QmlDebug::GuiThread ? - d->maxGuiThreadAnimations : d->maxRenderThreadAnimations); + + // Add some height to the events if we're far from the scale threshold of 2 * DefaultRowHeight. + // Like that you can see the smaller events more easily. + int scaleThreshold = 2 * DefaultRowHeight - rowHeight(d->rowFromThreadId(range.threadId)); + float boost = scaleThreshold > 0 ? (0.15 * scaleThreshold / DefaultRowHeight) : 0; + + return boost + (1.0 - boost) * (float)range.animationcount / + (float)(range.threadId == QmlDebug::GuiThread ? d->maxGuiThreadAnimations : + d->maxRenderThreadAnimations); } const QVariantList PaintEventsModelProxy::getLabels() const