forked from Blendman974/faceclaw
Add a performance tracing system (FrameTimings) and fix a big that would cause 6-second stalls
This commit is contained in:
1 parent
971b04f677
commit
630b511d32
11 files changed
+786
-72
No files matched your search
+15
-12
@@ -1,5 +1,6 @@
|
||||
import { G2_LENS_HEIGHT, G2_LENS_WIDTH, GrayImage } from "../graphics/image";
|
||||
import { BdfFont } from "../graphics/bdffont";
|
||||
import { spanCurrent } from "../native/frame-timings";
|
||||
import { type ConfigSettingString } from "./dashboard-settings";
|
||||
|
||||
export type DashboardInputEvent =
|
||||
@@ -79,18 +80,20 @@ export class LayerStack {
|
||||
private paintLayer(index: number): GrayImage {
|
||||
const layer = this.layers[index]!;
|
||||
let cachedBelow: GrayImage | null = null;
|
||||
return layer.paint(this.ctx, () => {
|
||||
if (cachedBelow) {
|
||||
return spanCurrent(`paint[${index}]:${layer.constructor.name}`, () =>
|
||||
layer.paint(this.ctx, () => {
|
||||
if (cachedBelow) {
|
||||
return cachedBelow;
|
||||
}
|
||||
if (index <= 0) {
|
||||
cachedBelow = new GrayImage(G2_LENS_WIDTH, G2_LENS_HEIGHT, 0);
|
||||
} else if (layer.paintOverBase) {
|
||||
cachedBelow = this.paintLayer(0);
|
||||
} else {
|
||||
cachedBelow = this.paintLayer(index - 1);
|
||||
}
|
||||
return cachedBelow;
|
||||
}
|
||||
if (index <= 0) {
|
||||
cachedBelow = new GrayImage(G2_LENS_WIDTH, G2_LENS_HEIGHT, 0);
|
||||
} else if (layer.paintOverBase) {
|
||||
cachedBelow = this.paintLayer(0);
|
||||
} else {
|
||||
cachedBelow = this.paintLayer(index - 1);
|
||||
}
|
||||
return cachedBelow;
|
||||
});
|
||||
}),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user