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

@@ -32,16 +32,16 @@
var qmlProfilerModelProxy = 0;
//draw background of the graph
function drawGraph(canvas, ctxt, region)
function drawGraph(canvas, ctxt)
{
ctxt.fillStyle = "#eaeaea";
ctxt.fillRect(0, 0, canvas.width, canvas.height);
}
//draw the actual data to be graphed
function drawData(canvas, ctxt, region)
function drawData(canvas, ctxt)
{
if ((!qmlProfilerModelProxy) || qmlProfilerModelProxy.count() == 0)
if ((!qmlProfilerModelProxy) || qmlProfilerModelProxy.count() === 0)
return;
var width = canvas.width;
@@ -54,17 +54,15 @@ function drawData(canvas, ctxt, region)
var spacing = width / qmlProfilerModelProxy.traceDuration();
var modelRowStart = 0;
for (var modelIndex = 0; modelIndex < qmlProfilerModelProxy.modelCount(); modelIndex++) {
for (var ii = 0; ii < qmlProfilerModelProxy.count(modelIndex); ++ii) {
for (var modelIndex = 0; modelIndex < qmlProfilerModelProxy.modelCount(); ++modelIndex) {
for (var ii = canvas.offset; ii < qmlProfilerModelProxy.count(modelIndex);
ii += canvas.increment) {
var xx = (qmlProfilerModelProxy.getStartTime(modelIndex,ii) -
qmlProfilerModelProxy.traceStartTime()) * spacing;
if (xx > region.x + region.width)
continue;
var eventWidth = qmlProfilerModelProxy.getDuration(modelIndex,ii) * spacing;
if (xx + eventWidth < region.x)
continue;
if (eventWidth < 1)
eventWidth = 1;
@@ -88,8 +86,9 @@ function drawData(canvas, ctxt, region)
ctxt.lineWidth = 2;
var radius = 1;
modelRowStart = 0;
for (modelIndex = 0; modelIndex < qmlProfilerModelProxy.modelCount(); modelIndex++) {
for (ii = 0; ii < qmlProfilerModelProxy.count(modelIndex); ++ii) {
for (modelIndex = 0; modelIndex < qmlProfilerModelProxy.modelCount(); modelIndex += 10) {
for (ii = canvas.offset; ii < qmlProfilerModelProxy.count(modelIndex);
ii += canvas.increment) {
if (qmlProfilerModelProxy.getBindingLoopDest(modelIndex,ii) >= 0) {
var xcenter = Math.round(qmlProfilerModelProxy.getStartTime(modelIndex,ii) +
qmlProfilerModelProxy.getDuration(modelIndex,ii) -
@@ -107,7 +106,7 @@ function drawData(canvas, ctxt, region)
}
function drawTimeBar(canvas, ctxt, region)
function drawTimeBar(canvas, ctxt)
{
if (!qmlProfilerModelProxy)
return;
@@ -172,11 +171,3 @@ function prettyPrintTime( t )
t = Math.floor(t - m*60);
return m+"m"+t+"s";
}
function plot(canvas, ctxt, region)
{
drawGraph(canvas, ctxt, region);
drawData(canvas, ctxt, region);
drawTimeBar(canvas, ctxt, region);
}