QmlProfiler: Draw Overview in multiple passes

If there are too many events it takes too long to draw the overview.
By drawing only part of the events in each paint callback and
scheduling multiple paints we can mitigate that. The result is that a
rough outline is visible immediately and the details are filled in bit
by bit.

Task-number: QTCREATORBUG-12341
Change-Id: Id94d914e2926be01cb1635fbd8814c4d2f57d23b
Reviewed-by: Kai Koehne <kai.koehne@digia.com>
This commit is contained in:
Ulf Hermann
2014-05-28 05:34:16 +02:00
parent ade2710725
commit a5863aba87
2 changed files with 43 additions and 27 deletions

View File

@@ -36,6 +36,10 @@ Canvas {
objectName: "Overview"
contextType: "2d"
property int eventsPerPass: 4096
property int increment: -1
property int offset: -1
// ***** properties
height: 50
property bool dataReady: false
@@ -43,10 +47,14 @@ Canvas {
property double endTime : 0
property bool recursionGuard: false
onWidthChanged: offset = -1
// ***** functions
function clear()
{
dataReady = false;
increment = -1;
offset = -1;
requestPaint();
}
@@ -88,23 +96,40 @@ Canvas {
Connections {
target: qmlProfilerModelProxy
onDataAvailable: {
dataReady = true;
requestPaint();
dataReady = true;
increment = Math.ceil(qmlProfilerModelProxy.count() / eventsPerPass);
offset = -1;
requestPaint();
}
}
Timer {
id: paintTimer
onTriggered: canvas.requestPaint();
}
// ***** slots
onPaint: {
if (context === null)
return; // canvas isn't ready
context.reset();
Plotter.qmlProfilerModelProxy = qmlProfilerModelProxy;
if (dataReady) {
Plotter.plot(canvas, context, region);
} else {
Plotter.drawGraph(canvas, context, region) //just draw the background
if (offset < 0) {
context.reset();
Plotter.drawGraph(canvas, context);
if (dataReady) {
Plotter.drawTimeBar(canvas, context);
offset = 0;
// Larger initial delay to avoid flickering on resize
paintTimer.interval = 1000;
paintTimer.start();
}
} else if (offset < increment) {
Plotter.drawData(canvas, context);
++offset;
paintTimer.interval = 1;
paintTimer.start();
}
}