Bug 972199 part 1 - Make SampleAnimations filter out animations that are yet to start; r=nrc

When restoring the refresh driver after testing we can arrive at a situation
where a layer has an animation that has yet to start. However, calling
ElementAnimations::GetPositionInIteration with a negative value from the
compositor thread is an error.

This patch detects animations on the compositor thread that are yet-to-start and
skips them when sampling. It also moves the activeAnimations = true line up as
otherwise we would need special logic to wake up the compositor after the delay
has finished.
This commit is contained in:
Brian Birtles 2014-03-05 10:19:15 +09:00
parent 888a5613a3
commit 32a6b5d8fd

View File

@ -413,10 +413,26 @@ SampleAnimations(Layer* aLayer, TimeStamp aPoint)
Animation& animation = animations[i];
AnimData& animData = animationData[i];
activeAnimations = true;
TimeDuration elapsedDuration = aPoint - animation.startTime();
// Skip animations that are yet to start.
//
// Currently, this should only happen when the refresh driver is under test
// control and is made to produce a time in the past or is restored from
// test control causing it to jump backwards in time.
//
// Since activeAnimations is true, this could mean we keep compositing
// unnecessarily during the delay, but so long as this only happens while
// the refresh driver is under test control that should be ok.
if (elapsedDuration.ToSeconds() < 0) {
continue;
}
double numIterations = animation.numIterations() != -1 ?
animation.numIterations() : NS_IEEEPositiveInfinity();
double positionInIteration =
ElementAnimations::GetPositionInIteration(aPoint - animation.startTime(),
ElementAnimations::GetPositionInIteration(elapsedDuration,
animation.duration(),
numIterations,
animation.direction());
@ -437,8 +453,6 @@ SampleAnimations(Layer* aLayer, TimeStamp aPoint)
double portion = animData.mFunctions[segmentIndex]->GetValue(positionInSegment);
activeAnimations = true;
// interpolate the property
Animatable interpolatedValue;
SampleValue(portion, animation, animData.mStartValues[segmentIndex],