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

Side by Side Diff: Source/core/animation/AnimationStack.cpp

Issue 1329843002: Support per property CSS Animation stacks (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fix TODO Created 5 years, 3 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 | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 14 matching lines...) Expand all
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 #include "config.h" 31 #include "config.h"
32 #include "core/animation/AnimationStack.h" 32 #include "core/animation/AnimationStack.h"
33 33
34 #include "core/animation/CompositorAnimations.h" 34 #include "core/animation/CompositorAnimations.h"
35 #include "core/animation/StyleInterpolation.h" 35 #include "core/animation/InvalidatableStyleInterpolation.h"
36 #include "core/animation/css/CSSAnimations.h" 36 #include "core/animation/css/CSSAnimations.h"
37 #include "platform/RuntimeEnabledFeatures.h"
37 #include "wtf/BitArray.h" 38 #include "wtf/BitArray.h"
38 #include "wtf/NonCopyingSort.h" 39 #include "wtf/NonCopyingSort.h"
39 #include <algorithm> 40 #include <algorithm>
40 41
41 namespace blink { 42 namespace blink {
42 43
43 namespace { 44 namespace {
44 45
45 void copyToActiveInterpolationMap(const Vector<RefPtr<Interpolation>>& source, A ctiveInterpolationMap& target) 46 void copyToActiveInterpolationMap(const Vector<RefPtr<Interpolation>>& source, A ctiveInterpolationsMap& target)
dstockwell 2015/09/07 03:11:36 copyToActiveInterpolation*s*Map?
alancutter (OOO until 2018) 2015/09/07 03:36:46 Done.
46 { 47 {
47 for (const auto& interpolation : source) { 48 for (const auto& interpolation : source) {
48 target.set(interpolation->property(), interpolation.get()); 49 ActiveInterpolationsMap::iterator entry = target.find(interpolation->pro perty());
50 if (entry == target.end()) {
51 // Python version of this line: target[interpolation.property] = [in terpolation]
52 target.set(interpolation->property(), ActiveInterpolations(1)).store dValue->value.at(0) = interpolation.get();
dstockwell 2015/09/07 03:11:36 is there a way to avoid the second hash here?
alancutter (OOO until 2018) 2015/09/07 03:36:46 Done.
53 } else if (RuntimeEnabledFeatures::stackedCSSPropertyAnimationsEnabled()
54 && interpolation->isInvalidatableStyleInterpolation()
55 && toInvalidatableStyleInterpolation(*interpolation).dependsOnUnderl yingValue()) {
dstockwell 2015/09/07 03:11:36 Why is dependonunderlying part of invalidatablesty
alancutter (OOO until 2018) 2015/09/07 03:36:46 Correct, InvalidatableStyleInterpolation will even
56 entry->value.append(interpolation.get());
57 } else {
58 entry->value.at(0) = interpolation.get();
59 }
49 } 60 }
50 } 61 }
51 62
52 bool compareEffects(const Member<SampledEffect>& effect1, const Member<SampledEf fect>& effect2) 63 bool compareEffects(const Member<SampledEffect>& effect1, const Member<SampledEf fect>& effect2)
53 { 64 {
54 ASSERT(effect1 && effect2); 65 ASSERT(effect1 && effect2);
55 return effect1->sequenceNumber() < effect2->sequenceNumber(); 66 return effect1->sequenceNumber() < effect2->sequenceNumber();
56 } 67 }
57 68
58 void copyNewAnimationsToActiveInterpolationMap(const HeapVector<Member<InertEffe ct>>& newAnimations, ActiveInterpolationMap& result) 69 void copyNewAnimationsToActiveInterpolationMap(const HeapVector<Member<InertEffe ct>>& newAnimations, ActiveInterpolationsMap& result)
59 { 70 {
60 for (const auto& newAnimation : newAnimations) { 71 for (const auto& newAnimation : newAnimations) {
61 OwnPtr<Vector<RefPtr<Interpolation>>> sample; 72 OwnPtr<Vector<RefPtr<Interpolation>>> sample;
62 newAnimation->sample(sample); 73 newAnimation->sample(sample);
63 if (sample) 74 if (sample)
64 copyToActiveInterpolationMap(*sample, result); 75 copyToActiveInterpolationMap(*sample, result);
65 } 76 }
66 } 77 }
67 78
68 } // namespace 79 } // namespace
69 80
70 AnimationStack::AnimationStack() 81 AnimationStack::AnimationStack()
71 { 82 {
72 } 83 }
73 84
74 bool AnimationStack::hasActiveAnimationsOnCompositor(CSSPropertyID property) con st 85 bool AnimationStack::hasActiveAnimationsOnCompositor(CSSPropertyID property) con st
75 { 86 {
76 for (const auto& sampledEffect : m_effects) { 87 for (const auto& sampledEffect : m_effects) {
77 // TODO(dstockwell): move the playing check into AnimationEffect and exp ose both hasAnimations and hasActiveAnimations 88 // TODO(dstockwell): move the playing check into AnimationEffect and exp ose both hasAnimations and hasActiveAnimations
78 if (sampledEffect->effect() && sampledEffect->effect()->animation()->pla ying() && sampledEffect->effect()->hasActiveAnimationsOnCompositor(property)) 89 if (sampledEffect->effect() && sampledEffect->effect()->animation()->pla ying() && sampledEffect->effect()->hasActiveAnimationsOnCompositor(property))
79 return true; 90 return true;
80 } 91 }
81 return false; 92 return false;
82 } 93 }
83 94
84 ActiveInterpolationMap AnimationStack::activeInterpolations(AnimationStack* anim ationStack, const HeapVector<Member<InertEffect>>* newAnimations, const HeapHash Set<Member<const Animation>>* suppressedAnimations, KeyframeEffect::Priority pri ority, double timelineCurrentTime) 95 ActiveInterpolationsMap AnimationStack::activeInterpolations(AnimationStack* ani mationStack, const HeapVector<Member<InertEffect>>* newAnimations, const HeapHas hSet<Member<const Animation>>* suppressedAnimations, KeyframeEffect::Priority pr iority, double timelineCurrentTime)
85 { 96 {
86 // We don't exactly know when new animations will start, but timelineCurrent Time is a good estimate. 97 // We don't exactly know when new animations will start, but timelineCurrent Time is a good estimate.
87 98
88 ActiveInterpolationMap result; 99 ActiveInterpolationsMap result;
89 100
90 if (animationStack) { 101 if (animationStack) {
91 HeapVector<Member<SampledEffect>>& effects = animationStack->m_effects; 102 HeapVector<Member<SampledEffect>>& effects = animationStack->m_effects;
92 // std::sort doesn't work with OwnPtrs 103 // std::sort doesn't work with OwnPtrs
93 nonCopyingSort(effects.begin(), effects.end(), compareEffects); 104 nonCopyingSort(effects.begin(), effects.end(), compareEffects);
94 animationStack->removeClearedEffects(); 105 animationStack->removeClearedEffects();
95 for (const auto& effect : effects) { 106 for (const auto& effect : effects) {
96 if (effect->priority() != priority || (suppressedAnimations && effec t->effect() && suppressedAnimations->contains(effect->effect()->animation()))) 107 if (effect->priority() != priority || (suppressedAnimations && effec t->effect() && suppressedAnimations->contains(effect->effect()->animation())))
97 continue; 108 continue;
98 copyToActiveInterpolationMap(effect->interpolations(), result); 109 copyToActiveInterpolationMap(effect->interpolations(), result);
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 FloatBox expandingBox(originalBox); 144 FloatBox expandingBox(originalBox);
134 if (!CompositorAnimations::instance()->getAnimatedBoundingBox(expand ingBox, *effect->model(), startRange, endRange)) 145 if (!CompositorAnimations::instance()->getAnimatedBoundingBox(expand ingBox, *effect->model(), startRange, endRange))
135 return false; 146 return false;
136 box.expandTo(expandingBox); 147 box.expandTo(expandingBox);
137 } 148 }
138 } 149 }
139 return true; 150 return true;
140 } 151 }
141 152
142 } // namespace blink 153 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698