From 35a9015deabb37e3fbf2de12f596a593fe40857a Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Fri, 8 Nov 2013 18:06:13 +0100 Subject: [PATCH] QmlProfiler: Draw time marks only in visible area The vertical Flickable element can get very large if certain categories are expanded. If the time marks have to fill the whole element the underlying buffers holding the pixmaps and/or OpenGL data may overflow. Task-number: QTCREATORBUG-10420 Change-Id: I45952e8237bb827a963e0e4e8deb060646c0c8f4 Reviewed-by: Ulf Hermann Reviewed-by: Kai Koehne --- src/plugins/qmlprofiler/qml/MainView.qml | 6 ++-- src/plugins/qmlprofiler/qml/TimeMarks.qml | 34 +++++++++++++++-------- 2 files changed, 26 insertions(+), 14 deletions(-) diff --git a/src/plugins/qmlprofiler/qml/MainView.qml b/src/plugins/qmlprofiler/qml/MainView.qml index e0d9f35661d..94701897cc5 100644 --- a/src/plugins/qmlprofiler/qml/MainView.qml +++ b/src/plugins/qmlprofiler/qml/MainView.qml @@ -349,10 +349,10 @@ Rectangle { // ***** child items TimeMarks { id: backgroundMarks - y: labels.y - height: flick.height + y: vertflick.contentY + height: vertflick.height + width: flick.width anchors.left: flick.left - anchors.right: flick.right } Flickable { diff --git a/src/plugins/qmlprofiler/qml/TimeMarks.qml b/src/plugins/qmlprofiler/qml/TimeMarks.qml index 401cc19a0de..f182d26a566 100644 --- a/src/plugins/qmlprofiler/qml/TimeMarks.qml +++ b/src/plugins/qmlprofiler/qml/TimeMarks.qml @@ -49,6 +49,10 @@ Canvas2D { requestRedraw(); } + onYChanged: { + requestRedraw(); + } + Connections { target: labels onHeightChanged: { requestRedraw(); } @@ -71,6 +75,8 @@ Canvas2D { timePerPixel = timePerBlock/pixelsPerBlock; + var lineStart = y < 0 ? -y : 0; + var lineEnd = Math.min(height, labels.height - y); ctxt.fillStyle = "#000000"; ctxt.font = "8px sans-serif"; @@ -78,16 +84,16 @@ Canvas2D { var x = Math.floor(ii*pixelsPerBlock - realStartPos); ctxt.strokeStyle = "#B0B0B0"; ctxt.beginPath(); - ctxt.moveTo(x, 0); - ctxt.lineTo(x, height); + ctxt.moveTo(x, lineStart); + ctxt.lineTo(x, lineEnd); ctxt.stroke(); ctxt.strokeStyle = "#CCCCCC"; for (var jj=1; jj < 5; jj++) { var xx = Math.floor(ii*pixelsPerBlock + jj*pixelsPerSection - realStartPos); ctxt.beginPath(); - ctxt.moveTo(xx, 0); - ctxt.lineTo(xx, height); + ctxt.moveTo(xx, lineStart); + ctxt.lineTo(xx, lineEnd); ctxt.stroke(); } } @@ -119,30 +125,36 @@ Canvas2D { function drawBackgroundBars( ctxt, region ) { var colorIndex = true; + // row background - for (var y=0; y < labels.height; y+= root.singleRowHeight) { + var backgroundOffset = y < 0 ? -y : -(y % (2 * root.singleRowHeight)); + for (var currentY= backgroundOffset; currentY < Math.min(height, labels.height - y); currentY += root.singleRowHeight) { ctxt.fillStyle = colorIndex ? "#f0f0f0" : "white"; ctxt.strokeStyle = colorIndex ? "#f0f0f0" : "white"; - ctxt.fillRect(0, y, width, root.singleRowHeight); + ctxt.fillRect(0, currentY, width, root.singleRowHeight); colorIndex = !colorIndex; } // separators var cumulatedHeight = 0; - for (var modelIndex = 0; modelIndex < qmlProfilerModelProxy.modelCount(); modelIndex++) { + for (var modelIndex = 0; modelIndex < qmlProfilerModelProxy.modelCount() && cumulatedHeight < y + height; modelIndex++) { for (var i=0; i labels.height - y) { + ctxt.fillStyle = "#f5f5f5"; + ctxt.fillRect(0, labels.height - y, width, Math.min(height - labels.height + y, labelsTail.height)); + } } }