Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(23)

Side by Side Diff: third_party/WebKit/Source/core/animation/AnimationStackTest.cpp

Issue 1698093005: Discard SampledEffects on elements if they are redundant (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@_renameToSampledEffect
Patch Set: Rebased Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "core/animation/AnimationStack.h" 5 #include "core/animation/AnimationStack.h"
6 6
7 #include "core/animation/AnimationClock.h" 7 #include "core/animation/AnimationClock.h"
8 #include "core/animation/AnimationTimeline.h" 8 #include "core/animation/AnimationTimeline.h"
9 #include "core/animation/ElementAnimations.h" 9 #include "core/animation/ElementAnimations.h"
10 #include "core/animation/KeyframeEffectModel.h" 10 #include "core/animation/KeyframeEffectModel.h"
(...skipping 22 matching lines...) Expand all
33 animation->update(TimingUpdateOnDemand); 33 animation->update(TimingUpdateOnDemand);
34 return animation; 34 return animation;
35 } 35 }
36 36
37 void updateTimeline(double time) 37 void updateTimeline(double time)
38 { 38 {
39 document->animationClock().updateTime(document->timeline().zeroTime() + time); 39 document->animationClock().updateTime(document->timeline().zeroTime() + time);
40 timeline->serviceAnimations(TimingUpdateForAnimationFrame); 40 timeline->serviceAnimations(TimingUpdateForAnimationFrame);
41 } 41 }
42 42
43 size_t sampledEffectCount()
44 {
45 return element->ensureElementAnimations().animationStack().m_sampledEffe cts.size();
46 }
47
43 EffectModel* makeEffectModel(CSSPropertyID id, PassRefPtr<AnimatableValue> v alue) 48 EffectModel* makeEffectModel(CSSPropertyID id, PassRefPtr<AnimatableValue> v alue)
44 { 49 {
45 AnimatableValueKeyframeVector keyframes(2); 50 AnimatableValueKeyframeVector keyframes(2);
46 keyframes[0] = AnimatableValueKeyframe::create(); 51 keyframes[0] = AnimatableValueKeyframe::create();
47 keyframes[0]->setOffset(0.0); 52 keyframes[0]->setOffset(0.0);
48 keyframes[0]->setPropertyValue(id, value.get()); 53 keyframes[0]->setPropertyValue(id, value.get());
49 keyframes[1] = AnimatableValueKeyframe::create(); 54 keyframes[1] = AnimatableValueKeyframe::create();
50 keyframes[1]->setOffset(1.0); 55 keyframes[1]->setOffset(1.0);
51 keyframes[1]->setPropertyValue(id, value.get()); 56 keyframes[1]->setPropertyValue(id, value.get());
52 return AnimatableValueKeyframeEffectModel::create(keyframes); 57 return AnimatableValueKeyframeEffectModel::create(keyframes);
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 Animation* animation = play(makeKeyframeEffect(makeEffectModel(CSSPropertyFo ntSize, AnimatableDouble::create(1))), 10); 125 Animation* animation = play(makeKeyframeEffect(makeEffectModel(CSSPropertyFo ntSize, AnimatableDouble::create(1))), 10);
121 ActiveInterpolationsMap result = AnimationStack::activeInterpolations(&eleme nt->elementAnimations()->animationStack(), 0, 0, KeyframeEffect::DefaultPriority ); 126 ActiveInterpolationsMap result = AnimationStack::activeInterpolations(&eleme nt->elementAnimations()->animationStack(), 0, 0, KeyframeEffect::DefaultPriority );
122 EXPECT_EQ(1u, result.size()); 127 EXPECT_EQ(1u, result.size());
123 EXPECT_TRUE(interpolationValue(result, CSSPropertyFontSize)->equals(Animatab leDouble::create(1).get())); 128 EXPECT_TRUE(interpolationValue(result, CSSPropertyFontSize)->equals(Animatab leDouble::create(1).get()));
124 129
125 animation->setEffect(0); 130 animation->setEffect(0);
126 result = AnimationStack::activeInterpolations(&element->elementAnimations()- >animationStack(), 0, 0, KeyframeEffect::DefaultPriority); 131 result = AnimationStack::activeInterpolations(&element->elementAnimations()- >animationStack(), 0, 0, KeyframeEffect::DefaultPriority);
127 EXPECT_EQ(0u, result.size()); 132 EXPECT_EQ(0u, result.size());
128 } 133 }
129 134
135 TEST_F(AnimationAnimationStackTest, ForwardsFillDiscarding)
136 {
137 play(makeKeyframeEffect(makeEffectModel(CSSPropertyFontSize, AnimatableDoubl e::create(1))), 2);
138 play(makeKeyframeEffect(makeEffectModel(CSSPropertyFontSize, AnimatableDoubl e::create(2))), 6);
139 play(makeKeyframeEffect(makeEffectModel(CSSPropertyFontSize, AnimatableDoubl e::create(3))), 4);
140 document->compositorPendingAnimations().update();
141 ActiveInterpolationsMap interpolations;
142
143 updateTimeline(11);
144 Heap::collectAllGarbage();
145 interpolations = AnimationStack::activeInterpolations(&element->elementAnima tions()->animationStack(), nullptr, nullptr, KeyframeEffect::DefaultPriority);
146 EXPECT_EQ(1u, interpolations.size());
147 EXPECT_TRUE(interpolationValue(interpolations, CSSPropertyFontSize)->equals( AnimatableDouble::create(3).get()));
148 EXPECT_EQ(3u, sampledEffectCount());
149
150 updateTimeline(13);
151 Heap::collectAllGarbage();
152 interpolations = AnimationStack::activeInterpolations(&element->elementAnima tions()->animationStack(), nullptr, nullptr, KeyframeEffect::DefaultPriority);
153 EXPECT_EQ(1u, interpolations.size());
154 EXPECT_TRUE(interpolationValue(interpolations, CSSPropertyFontSize)->equals( AnimatableDouble::create(3).get()));
155 EXPECT_EQ(3u, sampledEffectCount());
156
157 updateTimeline(15);
158 Heap::collectAllGarbage();
159 interpolations = AnimationStack::activeInterpolations(&element->elementAnima tions()->animationStack(), nullptr, nullptr, KeyframeEffect::DefaultPriority);
160 EXPECT_EQ(1u, interpolations.size());
161 EXPECT_TRUE(interpolationValue(interpolations, CSSPropertyFontSize)->equals( AnimatableDouble::create(3).get()));
162 EXPECT_EQ(2u, sampledEffectCount());
163
164 updateTimeline(17);
165 Heap::collectAllGarbage();
166 interpolations = AnimationStack::activeInterpolations(&element->elementAnima tions()->animationStack(), nullptr, nullptr, KeyframeEffect::DefaultPriority);
167 EXPECT_EQ(1u, interpolations.size());
168 EXPECT_TRUE(interpolationValue(interpolations, CSSPropertyFontSize)->equals( AnimatableDouble::create(3).get()));
169 EXPECT_EQ(1u, sampledEffectCount());
170 }
171
130 } // namespace blink 172 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/animation/AnimationStack.cpp ('k') | third_party/WebKit/Source/core/animation/Interpolation.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698