Bug 1399714 - Iterate animation segments for setting start/end values and timing functions just once. r?boris draft
authorHiroyuki Ikezoe <hikezoe@mozilla.com>
Thu, 14 Sep 2017 12:59:06 +0900
changeset 664586 8a8428aa794a2de06fefebed90841f24a64a63f7
parent 664491 c15e2f280729b6503f9455cd4448ab2852eb5806
child 731481 4217498e4528c3021ebf2e69abeaf8eecbfb8cda
push id79735
push userhikezoe@mozilla.com
push dateThu, 14 Sep 2017 03:59:28 +0000
reviewersboris
bugs1399714
milestone57.0a1
Bug 1399714 - Iterate animation segments for setting start/end values and timing functions just once. r?boris MozReview-Commit-ID: 7ySuFcSi3cH
gfx/layers/AnimationHelper.cpp
--- a/gfx/layers/AnimationHelper.cpp
+++ b/gfx/layers/AnimationHelper.cpp
@@ -510,33 +510,29 @@ AnimationHelper::SetAnimations(Animation
 
     if (animation.baseStyle().type() != Animatable::Tnull_t) {
       aBaseAnimationStyle = ToStyleAnimationValue(animation.baseStyle());
     }
 
     AnimData* data = aAnimData.AppendElement();
     InfallibleTArray<Maybe<ComputedTimingFunction>>& functions =
       data->mFunctions;
+    InfallibleTArray<StyleAnimationValue>& startValues = data->mStartValues;
+    InfallibleTArray<StyleAnimationValue>& endValues = data->mEndValues;
+
     const InfallibleTArray<AnimationSegment>& segments = animation.segments();
-    for (uint32_t j = 0; j < segments.Length(); j++) {
-      TimingFunction tf = segments.ElementAt(j).sampleFn();
+    for (const AnimationSegment& segment : segments) {
+      startValues.AppendElement(ToStyleAnimationValue(segment.startState()));
+      endValues.AppendElement(ToStyleAnimationValue(segment.endState()));
 
+      TimingFunction tf = segment.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 (const AnimationSegment& segment : segments) {
-      startValues.AppendElement(ToStyleAnimationValue(segment.startState()));
-      endValues.AppendElement(ToStyleAnimationValue(segment.endState()));
-    }
   }
 }
 
 uint64_t
 AnimationHelper::GetNextCompositorAnimationsId()
 {
   static uint32_t sNextId = 0;
   ++sNextId;