Bug 1345017 - Discard the unchanged animated value during sample animations, r?kats
MozReview-Commit-ID: 1CEcqBp7zS4
--- a/gfx/layers/AnimationHelper.cpp
+++ b/gfx/layers/AnimationHelper.cpp
@@ -493,16 +493,17 @@ AnimationHelper::SampleAnimations(Compos
{
MOZ_ASSERT(aStorage);
// Do nothing if there are no compositor animations
if (!aStorage->AnimationsCount()) {
return;
}
+ nsTArray<uint64_t> unchangedAnimations;
//Sample the animations in CompositorAnimationStorage
for (auto iter = aStorage->ConstAnimationsTableIter();
!iter.Done(); iter.Next()) {
bool hasInEffectAnimations = false;
AnimationArray* animations = iter.UserData();
StyleAnimationValue animationValue;
InfallibleTArray<AnimData> animationData;
AnimationHelper::SetAnimations(*animations,
@@ -517,18 +518,23 @@ AnimationHelper::SampleAnimations(Compos
if (!hasInEffectAnimations) {
continue;
}
// Store the AnimatedValue
Animation& animation = animations->LastElement();
switch (animation.property()) {
case eCSSProperty_opacity: {
- aStorage->SetAnimatedValue(iter.Key(),
- animationValue.GetFloatValue());
+ auto lastValue = aStorage->GetAnimatedValue(iter.Key());
+ if (lastValue && lastValue->mOpacity == animationValue.GetFloatValue()) {
+ unchangedAnimations.AppendElement(iter.Key());
+ } else {
+ aStorage->SetAnimatedValue(iter.Key(),
+ animationValue.GetFloatValue());
+ }
break;
}
case eCSSProperty_transform: {
nsCSSValueSharedList* list = animationValue.GetCSSValueSharedListValue();
const TransformData& transformData = animation.data().get_TransformData();
nsPoint origin = transformData.origin();
// we expect all our transform data to arrive in device pixels
gfx::Point3D transformOrigin = transformData.transformOrigin();
@@ -550,22 +556,31 @@ AnimationHelper::SampleAnimations(Compos
// nsLayoutUtils::PostTranslate(transform, origin,
// transformData.appUnitsPerDevPixel(),
// true);
// }
// if (ContainerLayer* c = aLayer->AsContainerLayer()) {
// transform.PostScale(c->GetInheritedXScale(), c->GetInheritedYScale(), 1);
// }
-
- aStorage->SetAnimatedValue(iter.Key(),
- Move(transform), Move(frameTransform),
- transformData);
+ auto lastValue = aStorage->GetAnimatedValue(iter.Key());
+ if (lastValue &&
+ lastValue->mTransform.mTransformInDevSpace == transform) {
+ unchangedAnimations.AppendElement(iter.Key());
+ } else {
+ aStorage->SetAnimatedValue(iter.Key(), Move(transform),
+ Move(frameTransform), transformData);
+ }
break;
}
default:
MOZ_ASSERT_UNREACHABLE("Unhandled animated property");
}
}
+
+ // Clean up the unchanged animations
+ for (const uint64_t& key : unchangedAnimations) {
+ aStorage->ClearById(key);
+ }
}
} // namespace layers
} // namespace mozilla