Skip to content

Commit 1ddb476

Browse files
committed
Rearrange draw checks in main render function to avoid unnecessary layouting
canvasSizeChanged can force the browser to do early layout calculations, so it should only be called if the other two checks return false.
1 parent 6e6f8cc commit 1ddb476

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

src/renderer/webgl/canvas-handler.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ var AbstractCanvasHandler = require("../renderer/canvas-handler.js");
22
var Options = require("../../utils/options.js");
33
var Util = require("../../utils/misc.js");
44

5-
var MAXFPS = 30;
6-
75
var OPTION_CONTINUOUS = "renderer-continuous";
86
Options.register(OPTION_CONTINUOUS, false);
97

@@ -49,11 +47,11 @@ GLCanvasHandler.prototype.initialize = function () {
4947
XML3D.updateXflowObserver();
5048
XML3D.flushDOMChanges();
5149

52-
if (that.canvasSizeChanged() || that.renderer.needsRedraw() || Options.getValue(OPTION_CONTINUOUS)) {
50+
if (that.renderer.needsRedraw() || Options.getValue(OPTION_CONTINUOUS) || that.canvasSizeChanged()) {
5351
that.draw();
5452
}
5553

56-
window.requestAnimationFrame(that.tick, MAXFPS);
54+
window.requestAnimationFrame(that.tick);
5755
};
5856

5957
// Block the right-click context menu on the canvas unless it's explicitly toggled

0 commit comments

Comments
 (0)