Limit screen updates to once every 30ms and only if needed.

This commit is contained in:
Sam El-Husseini
2017-07-12 12:26:14 +03:00
parent 8215e8446a
commit 5ea8048f0c
2 changed files with 10 additions and 1 deletions

View File

@ -284,6 +284,11 @@ namespace pxsim.visuals {
this.updateState();
this.attachEvents();
}
let board = this;
window.setInterval(function(){
board.updateScreen();
}, 30);
}
public getView(): SVGAndSize<SVGSVGElement> {
@ -459,6 +464,9 @@ namespace pxsim.visuals {
let state = this.board;
if (!state || !state.screenState) return;
if (!state.screenState.shouldUpdate) return;
state.screenState.shouldUpdate = false;
this.screenCanvasData = this.screenCanvasCtx.getImageData(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
Object.keys(state.screenState.points).forEach(xStr => {