QmlProfiler: Fix rounding error for items starting outside the screen

Change-Id: I132b7058de9e51f6a1d958594917fc926039a585
Task-number: QTCREATORBUG-12648
Reviewed-by: Kai Koehne <kai.koehne@digia.com>
This commit is contained in:
Ulf Hermann
2014-07-10 13:02:53 +02:00
parent 3a1f6f9ad7
commit 4f4251ba6d

View File

@@ -93,8 +93,12 @@ inline void TimelineRenderer::getItemXExtent(int modelIndex, int i, int &current
m_spacing, m_spacedDuration)));
} else {
currentX = -OutOfScreenMargin;
itemWidth = qMax(1.0, (qMin((m_profilerModelProxy->getDuration(modelIndex, i) + start) *
m_spacing + OutOfScreenMargin, m_spacedDuration)));
// Explicitly round the "start" part down, away from 0, to match the implicit rounding of
// currentX in the > 0 case. If we don't do that we get glitches where a pixel is added if
// the element starts outside the screen and subtracted if it starts inside the screen.
itemWidth = qMax(1.0, (qMin(m_profilerModelProxy->getDuration(modelIndex, i) * m_spacing +
floor(start * m_spacing) + OutOfScreenMargin,
m_spacedDuration)));
}
}