Bug 1454324 - Skip calculating animation value if animation's progress value hasn't been changed since the last composition and if there are no other animations on the same element. r=birtles,kats

Note that we have to calculate animation values if there is another animation
since the other animation might be 'accumulate' or 'add', or might have a
missing keyframe (i.e. the calculated animation values will be used in the
missing keyframe).

MozReview-Commit-ID: rQyS9nuVJi
This commit is contained in:
Hiroyuki Ikezoe
2018-04-24 09:27:54 +09:00
parent 2f2afbfec8
commit 302c271b0f
5 changed files with 150 additions and 48 deletions

View File

@@ -660,30 +660,58 @@ SampleAnimations(Layer* aLayer,
return;
}
isAnimating = true;
bool hasInEffectAnimations = false;
RefPtr<RawServoAnimationValue> animationValue =
layer->GetBaseAnimationStyle();
AnimationHelper::SampleAnimationForEachNode(aTime,
animations,
layer->GetAnimationData(),
animationValue,
hasInEffectAnimations);
if (hasInEffectAnimations) {
Animation& animation = animations.LastElement();
ApplyAnimatedValue(layer,
aStorage,
animation.property(),
animation.data(),
animationValue);
} else {
// Set non-animation values in the case there are no in-effect
// animations (i.e. all animations are in delay state or already
// finished with non-forward fill modes).
HostLayer* layerCompositor = layer->AsHostLayer();
layerCompositor->SetShadowBaseTransform(layer->GetBaseTransform());
layerCompositor->SetShadowTransformSetByAnimation(false);
layerCompositor->SetShadowOpacity(layer->GetOpacity());
layerCompositor->SetShadowOpacitySetByAnimation(false);
AnimationHelper::SampleResult sampleResult =
AnimationHelper::SampleAnimationForEachNode(aTime,
animations,
layer->GetAnimationData(),
animationValue);
switch (sampleResult) {
case AnimationHelper::SampleResult::Sampled: {
Animation& animation = animations.LastElement();
ApplyAnimatedValue(layer,
aStorage,
animation.property(),
animation.data(),
animationValue);
break;
}
case AnimationHelper::SampleResult::Skipped:
// We don't need to update animation values for this layer since
// the values haven't changed.
#ifdef DEBUG
// Sanity check that the animation value is surely unchanged.
switch (animations[0].property()) {
case eCSSProperty_opacity:
MOZ_ASSERT(FuzzyEqualsMultiplicative(
layer->AsHostLayer()->GetShadowOpacity(),
*(aStorage->GetAnimationOpacity(layer->GetCompositorAnimationsId()))));
break;
case eCSSProperty_transform: {
AnimatedValue* transform =
aStorage->GetAnimatedValue(layer->GetCompositorAnimationsId());
MOZ_ASSERT(
transform->mTransform.mTransformInDevSpace.FuzzyEqualsMultiplicative(
(layer->AsHostLayer()->GetShadowBaseTransform())));
break;
}
default:
MOZ_ASSERT_UNREACHABLE("Unsupported properties");
break;
}
#endif
break;
case AnimationHelper::SampleResult::None: {
HostLayer* layerCompositor = layer->AsHostLayer();
layerCompositor->SetShadowBaseTransform(layer->GetBaseTransform());
layerCompositor->SetShadowTransformSetByAnimation(false);
layerCompositor->SetShadowOpacity(layer->GetOpacity());
layerCompositor->SetShadowOpacitySetByAnimation(false);
break;
}
default:
break;
}
});