Animations: Make perf tests for web animations animate properly.

Web Animations uses ms for duration, while legacy keyframe animations uses sec
for duration. Currently, the given perf tests use sec, so animations are weird.

BUG=309981

Review URL: https://codereview.chromium.org/433423003

git-svn-id: svn://svn.chromium.org/blink/trunk@180150 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent f3940b74
...@@ -77,10 +77,9 @@ window.onload = function () { ...@@ -77,10 +77,9 @@ window.onload = function () {
for (var i = 0; i < maxParticles; i++) { for (var i = 0; i < maxParticles; i++) {
generateParticleKeyframes(i); generateParticleKeyframes(i);
var particle = new Particle(i); var particle = new Particle(i);
particle.start();
particles.push(particle); particles.push(particle);
} }
for (var i = 0; i < maxParticles; i++)
particles[i].start();
startTrackingFrameRate(); startTrackingFrameRate();
} }
...@@ -133,8 +132,6 @@ function generateParticleKeyframes(index) { ...@@ -133,8 +132,6 @@ function generateParticleKeyframes(index) {
} }
allParticleKeyframes[index].push(generateKeyframe(t, x, y)); allParticleKeyframes[index].push(generateKeyframe(t, x, y));
} }
return keyframes;
} }
function generateKeyframe(t, x, y) { function generateKeyframe(t, x, y) {
...@@ -151,7 +148,7 @@ function Particle(index) ...@@ -151,7 +148,7 @@ function Particle(index)
domNode.style.backgroundColor = colors[Math.floor(Math.random() * colors.length)]; domNode.style.backgroundColor = colors[Math.floor(Math.random() * colors.length)];
function start() { function start() {
var player = domNode.animate(allParticleKeyframes[index], {easing: "linear", iterations: Infinity, direction: "alternate", duration: animationDuration}); var player = domNode.animate(allParticleKeyframes[index], {easing: "linear", iterations: Infinity, direction: "alternate", duration: animationDuration * 1000});
} }
function destroy() function destroy()
......
...@@ -132,8 +132,6 @@ function generateParticleKeyframes(index) { ...@@ -132,8 +132,6 @@ function generateParticleKeyframes(index) {
} }
allParticleKeyframes[index].push(generateKeyframe(t, x, y)); allParticleKeyframes[index].push(generateKeyframe(t, x, y));
} }
return keyframes;
} }
function generateKeyframe(t, x, y) { function generateKeyframe(t, x, y) {
...@@ -150,7 +148,7 @@ function Particle(index) ...@@ -150,7 +148,7 @@ function Particle(index)
domNode.style.backgroundColor = colors[Math.floor(Math.random() * colors.length)]; domNode.style.backgroundColor = colors[Math.floor(Math.random() * colors.length)];
function start() { function start() {
var player = domNode.animate(allParticleKeyframes[index], {easing: "linear", iterations: Infinity, direction: "alternate", duration: animationDuration}); var player = domNode.animate(allParticleKeyframes[index], {easing: "linear", iterations: Infinity, direction: "alternate", duration: animationDuration * 1000});
player.pause(); player.pause();
this.player = player; this.player = player;
} }
...@@ -171,7 +169,7 @@ function advance(timestamp) ...@@ -171,7 +169,7 @@ function advance(timestamp)
if (start == null) if (start == null)
start = timestamp; start = timestamp;
for (var x in particles) { for (var x in particles) {
particles[x].player.currentTime = (timestamp - start) / 1000; particles[x].player.currentTime = timestamp - start;
} }
if (particles.length !== 0) if (particles.length !== 0)
requestAnimationFrame(advance); requestAnimationFrame(advance);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment