From bac12cfa2a70fd288f8883631d74e9da27bb37e8 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Mon, 11 Nov 2013 13:44:56 +0100 Subject: [PATCH] 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 --- src/plugins/qmlprofiler/qml/MainView.qml | 5 +++- src/plugins/qmlprofiler/timelinerenderer.cpp | 26 +++++++++----------- 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/src/plugins/qmlprofiler/qml/MainView.qml b/src/plugins/qmlprofiler/qml/MainView.qml index 94701897cc5..c80a56f5c5f 100644 --- a/src/plugins/qmlprofiler/qml/MainView.qml +++ b/src/plugins/qmlprofiler/qml/MainView.qml @@ -408,12 +408,15 @@ Rectangle { profilerModelProxy: qmlProfilerModelProxy x: flick.contentX + y: vertflick.contentY width: flick.width - height: parent.height + height: vertflick.height property real startX: 0 onEndTimeChanged: requestPaint() + onYChanged: requestPaint() + onHeightChanged: requestPaint() onStartXChanged: { var newStartTime = Math.round(startX * (endTime - startTime) / flick.width) + diff --git a/src/plugins/qmlprofiler/timelinerenderer.cpp b/src/plugins/qmlprofiler/timelinerenderer.cpp index 22f2a933896..ea3cc9d0e59 100644 --- a/src/plugins/qmlprofiler/timelinerenderer.cpp +++ b/src/plugins/qmlprofiler/timelinerenderer.cpp @@ -118,15 +118,14 @@ void TimelineRenderer::drawItemsToPainter(QPainter *p, int modelIndex, int fromI int modelRowStart = 0; for (int mi = 0; mi < modelIndex; mi++) modelRowStart += m_profilerModelProxy->rowCount(mi); - QRect window = p->window(); for (int i = fromIndex; i <= toIndex; i++) { int currentX, currentY, itemWidth, itemHeight; currentX = (m_profilerModelProxy->getStartTime(modelIndex, i) - m_startTime) * m_spacing; int rowNumber = m_profilerModelProxy->getEventRow(modelIndex, i); - currentY = (modelRowStart + rowNumber) * DefaultRowHeight; - if (currentY >= window.bottom()) + currentY = (modelRowStart + rowNumber) * DefaultRowHeight - y(); + if (currentY >= height()) continue; 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); currentY += DefaultRowHeight - itemHeight; - if (currentY + itemHeight < window.top()) + if (currentY + itemHeight < 0) continue; // normal events @@ -175,7 +174,9 @@ void TimelineRenderer::drawSelectionBoxes(QPainter *p, int modelIndex, int fromI continue; 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; if (itemWidth < 1) @@ -206,7 +207,6 @@ void TimelineRenderer::drawBindingLoopMarkers(QPainter *p, int modelIndex, int f QPen markerPen = QPen(QColor("orange"),2); QBrush shadowBrush = QBrush(QColor("grey")); QBrush markerBrush = QBrush(QColor("orange")); - QRect window = p->window(); p->save(); 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) + m_profilerModelProxy->getDuration(modelIndex, i)/2 - m_startTime) * m_spacing; - yfrom = getYPosition(modelIndex, i); - yfrom += DefaultRowHeight / 2; + yfrom = getYPosition(modelIndex, i) + DefaultRowHeight / 2 - y(); // to xto = (m_profilerModelProxy->getStartTime(modelIndex, destindex) + m_profilerModelProxy->getDuration(modelIndex, destindex)/2 - m_startTime) * m_spacing; - yto = getYPosition(modelIndex, destindex); - yto += DefaultRowHeight / 2; + yto = getYPosition(modelIndex, destindex) + DefaultRowHeight / 2 - y(); // radius int eventWidth = m_profilerModelProxy->getDuration(modelIndex, i) * m_spacing; @@ -235,8 +233,8 @@ void TimelineRenderer::drawBindingLoopMarkers(QPainter *p, int modelIndex, int f radius = 2; int shadowoffset = 2; - if ((yfrom + radius + shadowoffset < window.top() && yto + radius + shadowoffset < window.top()) || - (yfrom - radius >= window.bottom() && yto - radius >= window.bottom())) + if ((yfrom + radius + shadowoffset < 0 && yto + radius + shadowoffset < 0) || + (yfrom - radius >= height() && yto - radius >= height())) return; // shadow @@ -322,8 +320,8 @@ void TimelineRenderer::manageHovered(int mouseX, int mouseY) return; qint64 time = mouseX * (m_endTime - m_startTime) / width() + m_startTime; - int row = mouseY / DefaultRowHeight; - int modelIndex = modelFromPosition(mouseY); + int row = (mouseY + y()) / DefaultRowHeight; + int modelIndex = modelFromPosition(mouseY + y()); // already covered? nothing to do if (m_currentSelection.eventIndex != -1 &&