QmlProfiler: Restrict rendering of timeline to visible area

The timeline can cover a large vertical space. The introduction of
the Flickable element to navigate that space has reverted the effect
of commit 5eb057c7e. This change restores the performance
improvements and avoids overflows in the underlying buffers.

Change-Id: I86ddd66652ee0a26c81619682a883622072b0f87
Reviewed-by: Kai Koehne <kai.koehne@digia.com>
This commit is contained in:
Ulf Hermann
2013-11-11 13:44:56 +01:00
parent bfe55bc818
commit bac12cfa2a
2 changed files with 16 additions and 15 deletions

View File

@@ -408,12 +408,15 @@ Rectangle {
profilerModelProxy: qmlProfilerModelProxy profilerModelProxy: qmlProfilerModelProxy
x: flick.contentX x: flick.contentX
y: vertflick.contentY
width: flick.width width: flick.width
height: parent.height height: vertflick.height
property real startX: 0 property real startX: 0
onEndTimeChanged: requestPaint() onEndTimeChanged: requestPaint()
onYChanged: requestPaint()
onHeightChanged: requestPaint()
onStartXChanged: { onStartXChanged: {
var newStartTime = Math.round(startX * (endTime - startTime) / flick.width) + var newStartTime = Math.round(startX * (endTime - startTime) / flick.width) +

View File

@@ -118,15 +118,14 @@ void TimelineRenderer::drawItemsToPainter(QPainter *p, int modelIndex, int fromI
int modelRowStart = 0; int modelRowStart = 0;
for (int mi = 0; mi < modelIndex; mi++) for (int mi = 0; mi < modelIndex; mi++)
modelRowStart += m_profilerModelProxy->rowCount(mi); modelRowStart += m_profilerModelProxy->rowCount(mi);
QRect window = p->window();
for (int i = fromIndex; i <= toIndex; i++) { for (int i = fromIndex; i <= toIndex; i++) {
int currentX, currentY, itemWidth, itemHeight; int currentX, currentY, itemWidth, itemHeight;
currentX = (m_profilerModelProxy->getStartTime(modelIndex, i) - m_startTime) * m_spacing; currentX = (m_profilerModelProxy->getStartTime(modelIndex, i) - m_startTime) * m_spacing;
int rowNumber = m_profilerModelProxy->getEventRow(modelIndex, i); int rowNumber = m_profilerModelProxy->getEventRow(modelIndex, i);
currentY = (modelRowStart + rowNumber) * DefaultRowHeight; currentY = (modelRowStart + rowNumber) * DefaultRowHeight - y();
if (currentY >= window.bottom()) if (currentY >= height())
continue; continue;
itemWidth = m_profilerModelProxy->getDuration(modelIndex, i) * m_spacing; itemWidth = m_profilerModelProxy->getDuration(modelIndex, i) * m_spacing;
@@ -135,7 +134,7 @@ void TimelineRenderer::drawItemsToPainter(QPainter *p, int modelIndex, int fromI
itemHeight = DefaultRowHeight * m_profilerModelProxy->getHeight(modelIndex, i); itemHeight = DefaultRowHeight * m_profilerModelProxy->getHeight(modelIndex, i);
currentY += DefaultRowHeight - itemHeight; currentY += DefaultRowHeight - itemHeight;
if (currentY + itemHeight < window.top()) if (currentY + itemHeight < 0)
continue; continue;
// normal events // normal events
@@ -175,7 +174,9 @@ void TimelineRenderer::drawSelectionBoxes(QPainter *p, int modelIndex, int fromI
continue; continue;
currentX = (m_profilerModelProxy->getStartTime(modelIndex, i) - m_startTime) * m_spacing; currentX = (m_profilerModelProxy->getStartTime(modelIndex, i) - m_startTime) * m_spacing;
currentY = (modelRowStart + m_profilerModelProxy->getEventRow(modelIndex, i)) * DefaultRowHeight; currentY = (modelRowStart + m_profilerModelProxy->getEventRow(modelIndex, i)) * DefaultRowHeight - y();
if (currentY + DefaultRowHeight < 0 || height() < currentY)
continue;
itemWidth = m_profilerModelProxy->getDuration(modelIndex, i) * m_spacing; itemWidth = m_profilerModelProxy->getDuration(modelIndex, i) * m_spacing;
if (itemWidth < 1) if (itemWidth < 1)
@@ -206,7 +207,6 @@ void TimelineRenderer::drawBindingLoopMarkers(QPainter *p, int modelIndex, int f
QPen markerPen = QPen(QColor("orange"),2); QPen markerPen = QPen(QColor("orange"),2);
QBrush shadowBrush = QBrush(QColor("grey")); QBrush shadowBrush = QBrush(QColor("grey"));
QBrush markerBrush = QBrush(QColor("orange")); QBrush markerBrush = QBrush(QColor("orange"));
QRect window = p->window();
p->save(); p->save();
for (int i = fromIndex; i <= toIndex; i++) { for (int i = fromIndex; i <= toIndex; i++) {
@@ -216,15 +216,13 @@ void TimelineRenderer::drawBindingLoopMarkers(QPainter *p, int modelIndex, int f
xfrom = (m_profilerModelProxy->getStartTime(modelIndex, i) + xfrom = (m_profilerModelProxy->getStartTime(modelIndex, i) +
m_profilerModelProxy->getDuration(modelIndex, i)/2 - m_profilerModelProxy->getDuration(modelIndex, i)/2 -
m_startTime) * m_spacing; m_startTime) * m_spacing;
yfrom = getYPosition(modelIndex, i); yfrom = getYPosition(modelIndex, i) + DefaultRowHeight / 2 - y();
yfrom += DefaultRowHeight / 2;
// to // to
xto = (m_profilerModelProxy->getStartTime(modelIndex, destindex) + xto = (m_profilerModelProxy->getStartTime(modelIndex, destindex) +
m_profilerModelProxy->getDuration(modelIndex, destindex)/2 - m_profilerModelProxy->getDuration(modelIndex, destindex)/2 -
m_startTime) * m_spacing; m_startTime) * m_spacing;
yto = getYPosition(modelIndex, destindex); yto = getYPosition(modelIndex, destindex) + DefaultRowHeight / 2 - y();
yto += DefaultRowHeight / 2;
// radius // radius
int eventWidth = m_profilerModelProxy->getDuration(modelIndex, i) * m_spacing; int eventWidth = m_profilerModelProxy->getDuration(modelIndex, i) * m_spacing;
@@ -235,8 +233,8 @@ void TimelineRenderer::drawBindingLoopMarkers(QPainter *p, int modelIndex, int f
radius = 2; radius = 2;
int shadowoffset = 2; int shadowoffset = 2;
if ((yfrom + radius + shadowoffset < window.top() && yto + radius + shadowoffset < window.top()) || if ((yfrom + radius + shadowoffset < 0 && yto + radius + shadowoffset < 0) ||
(yfrom - radius >= window.bottom() && yto - radius >= window.bottom())) (yfrom - radius >= height() && yto - radius >= height()))
return; return;
// shadow // shadow
@@ -322,8 +320,8 @@ void TimelineRenderer::manageHovered(int mouseX, int mouseY)
return; return;
qint64 time = mouseX * (m_endTime - m_startTime) / width() + m_startTime; qint64 time = mouseX * (m_endTime - m_startTime) / width() + m_startTime;
int row = mouseY / DefaultRowHeight; int row = (mouseY + y()) / DefaultRowHeight;
int modelIndex = modelFromPosition(mouseY); int modelIndex = modelFromPosition(mouseY + y());
// already covered? nothing to do // already covered? nothing to do
if (m_currentSelection.eventIndex != -1 && if (m_currentSelection.eventIndex != -1 &&