Bug 1175751 - Apply playback rate to compositor animations. r=bbirtles

This commit is contained in:
Hiroyuki Ikezoe
2015-07-06 19:05:00 +02:00
parent 153895959a
commit 69ab73575e
6 changed files with 89 additions and 1 deletions

View File

@@ -441,7 +441,8 @@ SampleAnimations(Layer* aLayer, TimeStamp aPoint)
MOZ_ASSERT(!animation.startTime().IsNull(),
"Failed to resolve start time of pending animations");
TimeDuration elapsedDuration = aPoint - animation.startTime();
TimeDuration elapsedDuration =
(aPoint - animation.startTime()).MultDouble(animation.playbackRate());
// Skip animations that are yet to start.
//
// Currently, this should only happen when the refresh driver is under test

View File

@@ -198,6 +198,7 @@ struct Animation {
int32_t direction;
nsCSSProperty property;
AnimationData data;
float playbackRate;
};
// Change a layer's attributes

View File

@@ -385,6 +385,7 @@ AddAnimationForProperty(nsIFrame* aFrame, const AnimationProperty& aProperty,
animation->iterationCount() = timing.mIterationCount;
animation->direction() = timing.mDirection;
animation->property() = aProperty.mProperty;
animation->playbackRate() = aAnimation->PlaybackRate();
animation->data() = aData;
for (uint32_t segIdx = 0; segIdx < aProperty.mSegments.Length(); segIdx++) {

View File

@@ -0,0 +1,55 @@
<!DOCTYPE html>
<html>
<head>
<script type="application/javascript"
src="/tests/SimpleTest/paint_listener.js"></script>
<script type="application/javascript" src="animation_utils.js"></script>
<style type="text/css">
@keyframes anim {
0% { transform: translate(0px) }
100% { transform: translate(100px) }
}
.target {
/* The animation target needs geometry in order to qualify for OMTA */
width: 100px;
height: 100px;
background-color: white;
}
</style>
<script>
var ok = opener.ok.bind(opener);
var is = opener.is.bind(opener);
var todo = opener.todo.bind(opener);
function finish() {
var o = opener;
self.close();
o.SimpleTest.finish();
}
</script>
</head>
<body>
<div id="display"></div>
<script type="application/javascript">
"use strict";
runOMTATest(function() {
runAllAsyncAnimTests().then(function() {
finish();
});
}, finish, opener.SpecialPowers);
addAsyncAnimTest(function *() {
var [ div, cs ] = new_div("animation: anim 10s 1 linear forwards");
var animation = div.getAnimations()[0];
animation.playbackRate = 10;
advance_clock(300);
yield waitForPaints();
omta_is(div, "transform", { tx: 30 }, RunningOn.Compositor,
"at 300ms");
done_div();
});
</script>
</body>
</html>

View File

@@ -42,6 +42,8 @@ skip-if = toolkit == 'android'
skip-if = (buildapp == 'b2g' && toolkit != 'gonk') # bug 1041017
[test_animations_pausing.html]
support-files = file_animations_pausing.html
[test_animations_playbackrate.html]
support-files = file_animations_playbackrate.html
[test_any_dynamic.html]
[test_at_rule_parse_serialize.html]
[test_bug73586.html]

View File

@@ -0,0 +1,28 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=1175751
-->
<head>
<title>Test for Animation.playbackRate on compositor animations (Bug 1175751)</title>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1175751">Mozilla Bug 1175751</a>
<div id="display"></div>
<pre id="test">
<script type="application/javascript">
"use strict";
SimpleTest.waitForExplicitFinish();
SpecialPowers.pushPrefEnv(
{ "set": [[ "dom.animations-api.core.enabled", true]] },
function() {
window.open("file_animations_playbackrate.html");
});
</script>
</pre>
</body>
</html>