diff options
author | aa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-01-10 03:05:46 +0000 |
---|---|---|
committer | aa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-01-10 03:05:46 +0000 |
commit | 89adefdf3ebe499bee700670b6501ad3652adbe8 (patch) | |
tree | b1a8291fc3a00ec7dd33ba7273a9d28dfc5935ed /mojo/apps/js/main.js | |
parent | 2549d89cde93cc3d5d26a35d3da446b94e433a4c (diff) | |
download | chromium_src-89adefdf3ebe499bee700670b6501ad3652adbe8.zip chromium_src-89adefdf3ebe499bee700670b6501ad3652adbe8.tar.gz chromium_src-89adefdf3ebe499bee700670b6501ad3652adbe8.tar.bz2 |
Introduce a monotonic_clock module for Mojo.js.
Am having trouble coming up with a satisfactory way to test.
BUG=
Review URL: https://codereview.chromium.org/129633005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@244062 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'mojo/apps/js/main.js')
-rw-r--r-- | mojo/apps/js/main.js | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/mojo/apps/js/main.js b/mojo/apps/js/main.js index d5483f7..4f821a7 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() { |