Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(591)

Unified Diff: mojo/apps/js/main.js

Issue 129633005: Introduce a monotonic_clock module for Mojo.js. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: blech Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « mojo/apps/js/bindings/monotonic_clock_unittests.js ('k') | mojo/apps/js/mojo_runner_delegate.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/apps/js/main.js
diff --git a/mojo/apps/js/main.js b/mojo/apps/js/main.js
index d5483f75112762112b3041d0af55438682240bfc..4f821a7eb77579e417760a3984637488a0631553 100644
--- a/mojo/apps/js/main.js
+++ b/mojo/apps/js/main.js
@@ -4,6 +4,7 @@
define([
'console',
+ 'monotonic_clock',
'timer',
'mojo/apps/js/bindings/connector',
'mojo/apps/js/bindings/core',
@@ -13,6 +14,7 @@ define([
'mojom/gles2',
'mojom/shell',
], function(console,
+ monotonicClock,
timer,
connector,
core,
@@ -313,7 +315,7 @@ define([
function GLES2ClientImpl(remote) {
this.remote_ = remote;
- this.lastTime_ = Date.now();
+ this.lastTime_ = monotonicClock.seconds();
this.angle_ = 45;
}
GLES2ClientImpl.prototype =
@@ -354,11 +356,11 @@ define([
};
GLES2ClientImpl.prototype.handleTimer = function() {
- var now = Date.now();
- var timeDelta = Date.now() - this.lastTime_;
+ var now = monotonicClock.seconds();
+ var secondsDelta = now - this.lastTime_;
this.lastTime_ = now;
- this.angle_ += this.getRotationForTimeDelgate(timeDelta);
+ this.angle_ += this.getRotationForTimeDelta(secondsDelta);
this.angle_ = this.angle_ % 360;
var aspect = this.width_ / this.height_;
@@ -377,8 +379,8 @@ define([
this.drawCube();
};
- GLES2ClientImpl.prototype.getRotationForTimeDelgate = function(timeDelta) {
- return timeDelta * .04;
+ GLES2ClientImpl.prototype.getRotationForTimeDelta = function(secondsDelta) {
+ return secondsDelta * 40;
};
GLES2ClientImpl.prototype.contextLost = function() {
« no previous file with comments | « mojo/apps/js/bindings/monotonic_clock_unittests.js ('k') | mojo/apps/js/mojo_runner_delegate.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698