Bug 1311196 - Part 3: Adjust fill mode to fill forwards for all animations on the compositor. r?birtles
MozReview-Commit-ID: DsIrWoxci0X
--- a/gfx/layers/Layers.cpp
+++ b/gfx/layers/Layers.cpp
@@ -426,35 +426,49 @@ CreateCSSValueList(const InfallibleTArra
void
Layer::SetAnimations(const AnimationArray& aAnimations)
{
MOZ_LAYERS_LOG_IF_SHADOWABLE(this, ("Layer::Mutated(%p) SetAnimations", this));
mAnimations = aAnimations;
mAnimationData.Clear();
for (uint32_t i = 0; i < mAnimations.Length(); i++) {
+ Animation& animation = mAnimations[i];
+ // Adjust fill mode to fill forwards so that if the main thread is delayed
+ // in clearing this animation we don't introduce flicker by jumping back to
+ // the old underlying value
+ switch (static_cast<dom::FillMode>(animation.fillMode())) {
+ case dom::FillMode::None:
+ animation.fillMode() = static_cast<uint8_t>(dom::FillMode::Forwards);
+ break;
+ case dom::FillMode::Backwards:
+ animation.fillMode() = static_cast<uint8_t>(dom::FillMode::Both);
+ break;
+ default:
+ break;
+ }
+
AnimData* data = mAnimationData.AppendElement();
InfallibleTArray<Maybe<ComputedTimingFunction>>& functions =
data->mFunctions;
- const InfallibleTArray<AnimationSegment>& segments =
- mAnimations.ElementAt(i).segments();
+ const InfallibleTArray<AnimationSegment>& segments = animation.segments();
for (uint32_t j = 0; j < segments.Length(); j++) {
TimingFunction tf = segments.ElementAt(j).sampleFn();
Maybe<ComputedTimingFunction> ctf =
AnimationUtils::TimingFunctionToComputedTimingFunction(tf);
functions.AppendElement(ctf);
}
// Precompute the StyleAnimationValues that we need if this is a transform
// animation.
InfallibleTArray<StyleAnimationValue>& startValues = data->mStartValues;
InfallibleTArray<StyleAnimationValue>& endValues = data->mEndValues;
- for (uint32_t j = 0; j < mAnimations[i].segments().Length(); j++) {
- const AnimationSegment& segment = mAnimations[i].segments()[j];
+ for (uint32_t j = 0; j < segments.Length(); j++) {
+ const AnimationSegment& segment = segments[j];
StyleAnimationValue* startValue = startValues.AppendElement();
StyleAnimationValue* endValue = endValues.AppendElement();
if (segment.endState().type() == Animatable::TArrayOfTransformFunction) {
const InfallibleTArray<TransformFunction>& startFunctions =
segment.startState().get_ArrayOfTransformFunction();
startValue->SetTransformValue(CreateCSSValueList(startFunctions));
const InfallibleTArray<TransformFunction>& endFunctions =
--- a/layout/base/nsDisplayList.cpp
+++ b/layout/base/nsDisplayList.cpp
@@ -426,17 +426,17 @@ AddAnimationForProperty(nsIFrame* aFrame
ToTimeStamp(startTime.Value());
animation->initialCurrentTime() = aAnimation->GetCurrentTime().Value()
- timing.mDelay;
animation->delay() = timing.mDelay;
animation->duration() = computedTiming.mDuration;
animation->iterations() = computedTiming.mIterations;
animation->iterationStart() = computedTiming.mIterationStart;
animation->direction() = static_cast<uint8_t>(timing.mDirection);
- animation->fillMode() = static_cast<uint8_t>(timing.mFill);
+ animation->fillMode() = static_cast<uint8_t>(computedTiming.mFill);
animation->property() = aProperty.mProperty;
animation->playbackRate() = aAnimation->PlaybackRate();
animation->data() = aData;
animation->easingFunction() = ToTimingFunction(timing.mFunction);
animation->iterationComposite() =
static_cast<uint8_t>(aAnimation->GetEffect()->
AsKeyframeEffect()->IterationComposite());