mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2025-07-05 02:30:29 -04:00
Remove rAF usage and inline into _step (#318)
This commit is contained in:
parent
2f0ce7137c
commit
1dc4aaa2d7
3 changed files with 6 additions and 30 deletions
|
@ -231,9 +231,7 @@ window.onload = function() {
|
|||
|
||||
// Inform VM of animation frames.
|
||||
var animate = function() {
|
||||
stats.end();
|
||||
stats.begin();
|
||||
window.vm.animationFrame();
|
||||
stats.update();
|
||||
requestAnimationFrame(animate);
|
||||
};
|
||||
requestAnimationFrame(animate);
|
||||
|
|
|
@ -101,13 +101,6 @@ var Runtime = function () {
|
|||
*/
|
||||
this.compatibilityMode = false;
|
||||
|
||||
/**
|
||||
* How fast in ms "single stepping mode" should run, in ms.
|
||||
* Can be updated dynamically.
|
||||
* @type {!number}
|
||||
*/
|
||||
this.singleStepInterval = 1000 / 10;
|
||||
|
||||
/**
|
||||
* A reference to the current runtime stepping interval, set
|
||||
* by a `setInterval`.
|
||||
|
@ -534,6 +527,10 @@ Runtime.prototype._step = function () {
|
|||
this.redrawRequested = false;
|
||||
var inactiveThreads = this.sequencer.stepThreads();
|
||||
this._updateGlows(inactiveThreads);
|
||||
if (this.renderer) {
|
||||
// @todo: Only render when this.redrawRequested or clones rendered.
|
||||
this.renderer.draw();
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -729,24 +726,12 @@ Runtime.prototype.requestRedraw = function () {
|
|||
this.redrawRequested = true;
|
||||
};
|
||||
|
||||
/**
|
||||
* Handle an animation frame from the main thread.
|
||||
*/
|
||||
Runtime.prototype.animationFrame = function () {
|
||||
if (this.renderer) {
|
||||
// @todo: Only render when this.redrawRequested or clones rendered.
|
||||
this.renderer.draw();
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Set up timers to repeatedly step in a browser.
|
||||
*/
|
||||
Runtime.prototype.start = function () {
|
||||
var interval = Runtime.THREAD_STEP_INTERVAL;
|
||||
if (this.singleStepping) {
|
||||
interval = this.singleStepInterval;
|
||||
} else if (this.compatibilityMode) {
|
||||
if (this.compatibilityMode) {
|
||||
interval = Runtime.THREAD_STEP_INTERVAL_COMPATIBILITY;
|
||||
}
|
||||
this.currentStepTime = interval;
|
||||
|
|
|
@ -120,13 +120,6 @@ VirtualMachine.prototype.getPlaygroundData = function () {
|
|||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Handle an animation frame.
|
||||
*/
|
||||
VirtualMachine.prototype.animationFrame = function () {
|
||||
this.runtime.animationFrame();
|
||||
};
|
||||
|
||||
/**
|
||||
* Post I/O data to the virtual devices.
|
||||
* @param {?string} device Name of virtual I/O device.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue