timeruler 绘制

This commit is contained in:
yhh
2020-08-25 19:04:12 +08:00
parent 0ab0728ddf
commit 1997b3f348
6 changed files with 72 additions and 8 deletions
+4 -1
View File
@@ -1091,6 +1091,7 @@ var es;
return __generator(this, function (_a) { return __generator(this, function (_a) {
switch (_a.label) { switch (_a.label) {
case 0: case 0:
this.startDebugUpdate();
es.Time.update(egret.getTimer()); es.Time.update(egret.getTimer());
if (!this._scene) return [3, 2]; if (!this._scene) return [3, 2];
for (i = this._globalManagers.length - 1; i >= 0; i--) { for (i = this._globalManagers.length - 1; i >= 0; i--) {
@@ -1113,7 +1114,9 @@ var es;
case 1: case 1:
_a.sent(); _a.sent();
_a.label = 2; _a.label = 2;
case 2: return [4, this.draw()]; case 2:
this.endDebugUpdate();
return [4, this.draw()];
case 3: case 3:
_a.sent(); _a.sent();
return [2]; return [2];
File diff suppressed because one or more lines are too long
+4 -1
View File
@@ -1091,6 +1091,7 @@ var es;
return __generator(this, function (_a) { return __generator(this, function (_a) {
switch (_a.label) { switch (_a.label) {
case 0: case 0:
this.startDebugUpdate();
es.Time.update(egret.getTimer()); es.Time.update(egret.getTimer());
if (!this._scene) return [3, 2]; if (!this._scene) return [3, 2];
for (i = this._globalManagers.length - 1; i >= 0; i--) { for (i = this._globalManagers.length - 1; i >= 0; i--) {
@@ -1113,7 +1114,9 @@ var es;
case 1: case 1:
_a.sent(); _a.sent();
_a.label = 2; _a.label = 2;
case 2: return [4, this.draw()]; case 2:
this.endDebugUpdate();
return [4, this.draw()];
case 3: case 3:
_a.sent(); _a.sent();
return [2]; return [2];
+1 -1
View File
File diff suppressed because one or more lines are too long
+2 -2
View File
@@ -182,7 +182,7 @@ module es {
} }
protected async update() { protected async update() {
// this.startDebugUpdate(); this.startDebugUpdate();
// 更新我们所有的系统管理器 // 更新我们所有的系统管理器
Time.update(egret.getTimer()); Time.update(egret.getTimer());
@@ -215,7 +215,7 @@ module es {
} }
} }
// this.endDebugUpdate(); this.endDebugUpdate();
await this.draw(); await this.draw();
} }
+60 -2
View File
@@ -23,7 +23,7 @@ module es {
/** 获取/设置计时器标尺宽度。 */ /** 获取/设置计时器标尺宽度。 */
public width: number; public width: number;
public enabled: true; public enabled: true;
/** */ /** 获取/设置日志显示或否 */
public showLog = false; public showLog = false;
private _frameKey = 'frame'; private _frameKey = 'frame';
private _logKey = 'log'; private _logKey = 'log';
@@ -54,6 +54,14 @@ module es {
private _updateCount: number; private _updateCount: number;
private _frameAdjust: number; private _frameAdjust: number;
/** 画透明背景 */
private _rectShape1: egret.Shape = new egret.Shape();
private _rectShape2: egret.Shape = new egret.Shape();
private _rectShape3: egret.Shape = new egret.Shape();
private _rectShape4: egret.Shape = new egret.Shape();
private _rectShape5: egret.Shape = new egret.Shape();
private _rectShape6: egret.Shape = new egret.Shape();
constructor() { constructor() {
this._logs = new Array<FrameLog>(2); this._logs = new Array<FrameLog>(2);
for (let i = 0; i < this._logs.length; ++i) for (let i = 0; i < this._logs.length; ++i)
@@ -290,7 +298,57 @@ module es {
let startY = position.y - (height - TimeRuler.barHeight); let startY = position.y - (height - TimeRuler.barHeight);
let y = startY; let y = startY;
// TODO: draw // 画透明背景
let rc = new Rectangle(position.x, y, width, height);
this._rectShape1.graphics.clear();
this._rectShape1.graphics.beginFill(0x000000, 128 / 255);
this._rectShape1.graphics.drawRect(rc.x, rc.y, rc.width, rc.height);
this._rectShape1.graphics.endFill();
// 为每条线画标记
rc.height = TimeRuler.barHeight;
this._rectShape2.graphics.clear();
for (let bar of this._prevLog.bars){
rc.y = y + TimeRuler.barPadding;
if (bar.markCount > 0){
for (let j = 0; j < bar.markCount; ++j){
let bt = bar.markers[j].beginTime;
let et = bar.markers[j].endTime;
let sx = Math.floor(position.x + bt * msToPs);
let ex = Math.floor(position.x + et * msToPs);
rc.x = sx;
rc.width = Math.max(ex - sx, 1);
this._rectShape2.graphics.beginFill(bar.markers[j].color);
this._rectShape2.graphics.drawRect(rc.x, rc.y, rc.width, rc.height);
this._rectShape2.graphics.endFill();
}
}
y += TimeRuler.barHeight + TimeRuler.barPadding;
}
// 画网格线
// 每个网格代表ms
rc = new Rectangle(position.x, startY, 1, height);
this._rectShape3.graphics.clear();
for (let t = 1; t < sampleSpan; t += 1){
rc.x = Math.floor(position.x + t * msToPs);
this._rectShape3.graphics.beginFill(0x808080);
this._rectShape3.graphics.drawRect(rc.x, rc.y, rc.width, rc.height);
this._rectShape3.graphics.endFill();
}
// 画frame grid
this._rectShape4.graphics.clear();
for (let i = 0; i <= this.sampleFrames; ++i){
rc.x = Math.floor(position.x + frameSpan * i * msToPs);
this._rectShape4.graphics.beginFill(0xFFFFFF);
this._rectShape4.graphics.drawRect(rc.x, rc.y, rc.width, rc.height);
this._rectShape4.graphics.endFill();
}
// TODO: 绘制字体
} }
private onGraphicsDeviceReset() { private onGraphicsDeviceReset() {