Web Animations: Compositor timeOffset should not be scaled

This also seems to indicate that it's not yet possible to composite an
animation with a negative playback rate and infinite duration.

BUG=422432

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

git-svn-id: svn://svn.chromium.org/blink/trunk@183957 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent cdb7be43
<style>
div {
height: 100px;
width: 100px;
background: blue;
}
</style>
<p>
The four squares should make identical rotations at different rates without jumping.
<div id="target1"></div>
<div id="target2"></div>
<div id="target3"></div>
<div id="target4"></div>
<script>
var player1 = target1.animate([
{transform: 'none'},
{transform: 'rotate(90deg)'}
], {duration: 1000, iterations: 200000});
var player2 = target2.animate([
{transform: 'none', background: 'blue'},
{transform: 'rotate(90deg)', background: 'blue'}
], {duration: 1000, iterations: 200000});
var player3 = target3.animate([
{transform: 'none'},
{transform: 'rotate(90deg)'}
], {duration: 1000, iterations: Infinity});
var player4 = target4.animate([
{transform: 'none', background: 'blue'},
{transform: 'rotate(90deg)', background: 'blue'}
], {duration: 1000, iterations: Infinity});
setInterval(function() {
var playbackRate = (Math.random() - 0.5) * 5;
player1.playbackRate = playbackRate;
player2.playbackRate = playbackRate;
player3.playbackRate = playbackRate;
player4.playbackRate = playbackRate;
}, 100);
</script>
...@@ -37,6 +37,7 @@ ...@@ -37,6 +37,7 @@
#include "core/events/AnimationPlayerEvent.h" #include "core/events/AnimationPlayerEvent.h"
#include "core/frame/UseCounter.h" #include "core/frame/UseCounter.h"
#include "platform/TraceEvent.h" #include "platform/TraceEvent.h"
#include "wtf/MathExtras.h"
namespace blink { namespace blink {
...@@ -597,7 +598,7 @@ void AnimationPlayer::setOutdated() ...@@ -597,7 +598,7 @@ void AnimationPlayer::setOutdated()
bool AnimationPlayer::canStartAnimationOnCompositor() bool AnimationPlayer::canStartAnimationOnCompositor()
{ {
if (m_playbackRate == 0) if (m_playbackRate == 0 || (std::isinf(sourceEnd()) && m_playbackRate < 0))
return false; return false;
return m_timeline && m_content && m_content->isAnimation() && playing(); return m_timeline && m_content && m_content->isAnimation() && playing();
...@@ -612,6 +613,7 @@ bool AnimationPlayer::maybeStartAnimationOnCompositor() ...@@ -612,6 +613,7 @@ bool AnimationPlayer::maybeStartAnimationOnCompositor()
double timeOffset = 0; double timeOffset = 0;
if (std::isnan(startTime)) { if (std::isnan(startTime)) {
timeOffset = m_playbackRate < 0 ? sourceEnd() - currentTimeInternal() : currentTimeInternal(); timeOffset = m_playbackRate < 0 ? sourceEnd() - currentTimeInternal() : currentTimeInternal();
timeOffset = timeOffset / fabs(m_playbackRate);
} }
return toAnimation(m_content.get())->maybeStartAnimationOnCompositor(startTime, timeOffset, m_playbackRate); return toAnimation(m_content.get())->maybeStartAnimationOnCompositor(startTime, timeOffset, m_playbackRate);
} }
......
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