forked from qt-creator/qt-creator
QmlProfiler: Remove custom canvas implementation
The canvas integrated in QtQuick does the same thing. We can remove a lot of code like this. Change-Id: I6425ae4e1b542107defd9d76fa5755712a0f8613 Reviewed-by: Ulf Hermann <ulf.hermann@digia.com> Reviewed-by: Christian Stenger <christian.stenger@digia.com> Reviewed-by: Kai Koehne <kai.koehne@digia.com>
This commit is contained in:
@@ -30,9 +30,10 @@
|
||||
import QtQuick 2.1
|
||||
import Monitor 1.0
|
||||
|
||||
Canvas2D {
|
||||
Canvas {
|
||||
id: timeDisplay
|
||||
objectName: "TimeDisplay"
|
||||
contextType: "2d"
|
||||
|
||||
property real startTime : 0
|
||||
property real endTime : 0
|
||||
@@ -43,13 +44,13 @@ Canvas2D {
|
||||
onRangeChanged: {
|
||||
startTime = zoomControl.startTime();
|
||||
endTime = zoomControl.endTime();
|
||||
requestRedraw();
|
||||
requestPaint();
|
||||
}
|
||||
}
|
||||
|
||||
onDrawRegion: {
|
||||
ctxt.fillStyle = "white";
|
||||
ctxt.fillRect(0, 0, width, height);
|
||||
onPaint: {
|
||||
context.fillStyle = "white";
|
||||
context.fillRect(0, 0, width, height);
|
||||
|
||||
var totalTime = endTime - startTime;
|
||||
var spacing = width / totalTime;
|
||||
@@ -67,50 +68,50 @@ Canvas2D {
|
||||
|
||||
var initialColor = Math.floor(realStartTime/timePerBlock) % 2;
|
||||
|
||||
ctxt.fillStyle = "#000000";
|
||||
ctxt.font = "8px sans-serif";
|
||||
context.fillStyle = "#000000";
|
||||
context.font = "8px sans-serif";
|
||||
for (var ii = 0; ii < blockCount+1; ii++) {
|
||||
var x = Math.floor(ii*pixelsPerBlock - realStartPos);
|
||||
|
||||
ctxt.fillStyle = (ii+initialColor)%2 ? "#E6E6E6":"white";
|
||||
ctxt.fillRect(x, 0, pixelsPerBlock, height);
|
||||
context.fillStyle = (ii+initialColor)%2 ? "#E6E6E6":"white";
|
||||
context.fillRect(x, 0, pixelsPerBlock, height);
|
||||
|
||||
ctxt.strokeStyle = "#B0B0B0";
|
||||
ctxt.beginPath();
|
||||
ctxt.moveTo(x, 0);
|
||||
ctxt.lineTo(x, height);
|
||||
ctxt.stroke();
|
||||
context.strokeStyle = "#B0B0B0";
|
||||
context.beginPath();
|
||||
context.moveTo(x, 0);
|
||||
context.lineTo(x, height);
|
||||
context.stroke();
|
||||
|
||||
ctxt.fillStyle = "#000000";
|
||||
ctxt.fillText(prettyPrintTime(ii*timePerBlock + realStartTime), x + 5, height/2 + 5);
|
||||
context.fillStyle = "#000000";
|
||||
context.fillText(prettyPrintTime(ii*timePerBlock + realStartTime), x + 5, height/2 + 5);
|
||||
}
|
||||
|
||||
ctxt.strokeStyle = "#525252";
|
||||
ctxt.beginPath();
|
||||
ctxt.moveTo(0, height-1);
|
||||
ctxt.lineTo(width, height-1);
|
||||
ctxt.stroke();
|
||||
context.strokeStyle = "#525252";
|
||||
context.beginPath();
|
||||
context.moveTo(0, height-1);
|
||||
context.lineTo(width, height-1);
|
||||
context.stroke();
|
||||
|
||||
// gradient borders
|
||||
var gradientDark = "rgba(0, 0, 0, 0.53125)";
|
||||
var gradientClear = "rgba(0, 0, 0, 0)";
|
||||
var grad = ctxt.createLinearGradient(0, 0, 0, 6);
|
||||
var grad = context.createLinearGradient(0, 0, 0, 6);
|
||||
grad.addColorStop(0,gradientDark);
|
||||
grad.addColorStop(1,gradientClear);
|
||||
ctxt.fillStyle = grad;
|
||||
ctxt.fillRect(0, 0, width, 6);
|
||||
context.fillStyle = grad;
|
||||
context.fillRect(0, 0, width, 6);
|
||||
|
||||
grad = ctxt.createLinearGradient(0, 0, 6, 0);
|
||||
grad = context.createLinearGradient(0, 0, 6, 0);
|
||||
grad.addColorStop(0,gradientDark);
|
||||
grad.addColorStop(1,gradientClear);
|
||||
ctxt.fillStyle = grad;
|
||||
ctxt.fillRect(0, 0, 6, height);
|
||||
context.fillStyle = grad;
|
||||
context.fillRect(0, 0, 6, height);
|
||||
|
||||
grad = ctxt.createLinearGradient(width, 0, width-6, 0);
|
||||
grad = context.createLinearGradient(width, 0, width-6, 0);
|
||||
grad.addColorStop(0,gradientDark);
|
||||
grad.addColorStop(1,gradientClear);
|
||||
ctxt.fillStyle = grad;
|
||||
ctxt.fillRect(width-6, 0, 6, height);
|
||||
context.fillStyle = grad;
|
||||
context.fillRect(width-6, 0, 6, height);
|
||||
}
|
||||
|
||||
function prettyPrintTime( t )
|
||||
|
||||
Reference in New Issue
Block a user