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

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

Issue 1412423004: Web Animations: Move property handle filtering into AnimationStack building (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@_svgAdditiveApplication
Patch Set: Rebased Created 5 years, 1 month 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 /* 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 25 matching lines...) Expand all
36 #include "core/animation/css/CSSAnimations.h" 36 #include "core/animation/css/CSSAnimations.h"
37 #include "platform/RuntimeEnabledFeatures.h" 37 #include "platform/RuntimeEnabledFeatures.h"
38 #include "wtf/BitArray.h" 38 #include "wtf/BitArray.h"
39 #include "wtf/NonCopyingSort.h" 39 #include "wtf/NonCopyingSort.h"
40 #include <algorithm> 40 #include <algorithm>
41 41
42 namespace blink { 42 namespace blink {
43 43
44 namespace { 44 namespace {
45 45
46 void copyToActiveInterpolationsMap(const Vector<RefPtr<Interpolation>>& source, ActiveInterpolationsMap& target) 46 void copyToActiveInterpolationsMap(const Vector<RefPtr<Interpolation>>& source, AnimationStack::PropertyHandleFilter propertyHandleFilter, ActiveInterpolationsM ap& target)
47 { 47 {
48 for (const auto& interpolation : source) { 48 for (const auto& interpolation : source) {
49 if (propertyHandleFilter && !propertyHandleFilter(interpolation->propert y()))
50 continue;
49 ActiveInterpolationsMap::AddResult entry = target.add(interpolation->pro perty(), ActiveInterpolations(1)); 51 ActiveInterpolationsMap::AddResult entry = target.add(interpolation->pro perty(), ActiveInterpolations(1));
50 ActiveInterpolations& activeInterpolations = entry.storedValue->value; 52 ActiveInterpolations& activeInterpolations = entry.storedValue->value;
51 if (!entry.isNewEntry 53 if (!entry.isNewEntry
52 && RuntimeEnabledFeatures::stackedCSSPropertyAnimationsEnabled() 54 && RuntimeEnabledFeatures::stackedCSSPropertyAnimationsEnabled()
53 && interpolation->isInvalidatableInterpolation() 55 && interpolation->isInvalidatableInterpolation()
54 && toInvalidatableInterpolation(*interpolation).dependsOnUnderlyingV alue()) { 56 && toInvalidatableInterpolation(*interpolation).dependsOnUnderlyingV alue()) {
55 activeInterpolations.append(interpolation.get()); 57 activeInterpolations.append(interpolation.get());
56 } else { 58 } else {
57 activeInterpolations.at(0) = interpolation.get(); 59 activeInterpolations.at(0) = interpolation.get();
58 } 60 }
59 } 61 }
60 } 62 }
61 63
62 bool compareEffects(const Member<SampledEffect>& effect1, const Member<SampledEf fect>& effect2) 64 bool compareEffects(const Member<SampledEffect>& effect1, const Member<SampledEf fect>& effect2)
63 { 65 {
64 ASSERT(effect1 && effect2); 66 ASSERT(effect1 && effect2);
65 return effect1->sequenceNumber() < effect2->sequenceNumber(); 67 return effect1->sequenceNumber() < effect2->sequenceNumber();
66 } 68 }
67 69
68 void copyNewAnimationsToActiveInterpolationsMap(const HeapVector<Member<InertEff ect>>& newAnimations, ActiveInterpolationsMap& result) 70 void copyNewAnimationsToActiveInterpolationsMap(const HeapVector<Member<InertEff ect>>& newAnimations, AnimationStack::PropertyHandleFilter propertyHandleFilter, ActiveInterpolationsMap& result)
69 { 71 {
70 for (const auto& newAnimation : newAnimations) { 72 for (const auto& newAnimation : newAnimations) {
71 Vector<RefPtr<Interpolation>> sample; 73 Vector<RefPtr<Interpolation>> sample;
72 newAnimation->sample(sample); 74 newAnimation->sample(sample);
73 if (!sample.isEmpty()) 75 if (!sample.isEmpty())
74 copyToActiveInterpolationsMap(sample, result); 76 copyToActiveInterpolationsMap(sample, propertyHandleFilter, result);
75 } 77 }
76 } 78 }
77 79
78 } // namespace 80 } // namespace
79 81
80 AnimationStack::AnimationStack() 82 AnimationStack::AnimationStack()
81 { 83 {
82 } 84 }
83 85
84 bool AnimationStack::hasActiveAnimationsOnCompositor(CSSPropertyID property) con st 86 bool AnimationStack::hasActiveAnimationsOnCompositor(CSSPropertyID property) con st
85 { 87 {
86 for (const auto& sampledEffect : m_effects) { 88 for (const auto& sampledEffect : m_effects) {
87 // TODO(dstockwell): move the playing check into AnimationEffect and exp ose both hasAnimations and hasActiveAnimations 89 // TODO(dstockwell): move the playing check into AnimationEffect and exp ose both hasAnimations and hasActiveAnimations
88 if (sampledEffect->effect() && sampledEffect->effect()->animation()->pla ying() && sampledEffect->effect()->hasActiveAnimationsOnCompositor(property)) 90 if (sampledEffect->effect() && sampledEffect->effect()->animation()->pla ying() && sampledEffect->effect()->hasActiveAnimationsOnCompositor(property))
89 return true; 91 return true;
90 } 92 }
91 return false; 93 return false;
92 } 94 }
93 95
94 ActiveInterpolationsMap AnimationStack::activeInterpolations(AnimationStack* ani mationStack, const HeapVector<Member<InertEffect>>* newAnimations, const HeapHas hSet<Member<const Animation>>* suppressedAnimations, KeyframeEffect::Priority pr iority) 96 ActiveInterpolationsMap AnimationStack::activeInterpolations(AnimationStack* ani mationStack, const HeapVector<Member<InertEffect>>* newAnimations, const HeapHas hSet<Member<const Animation>>* suppressedAnimations, KeyframeEffect::Priority pr iority, PropertyHandleFilter propertyHandleFilter)
95 { 97 {
96 ActiveInterpolationsMap result; 98 ActiveInterpolationsMap result;
97 99
98 if (animationStack) { 100 if (animationStack) {
99 HeapVector<Member<SampledEffect>>& effects = animationStack->m_effects; 101 HeapVector<Member<SampledEffect>>& effects = animationStack->m_effects;
100 // std::sort doesn't work with OwnPtrs 102 // std::sort doesn't work with OwnPtrs
101 nonCopyingSort(effects.begin(), effects.end(), compareEffects); 103 nonCopyingSort(effects.begin(), effects.end(), compareEffects);
102 animationStack->removeClearedEffects(); 104 animationStack->removeClearedEffects();
103 for (const auto& effect : effects) { 105 for (const auto& effect : effects) {
104 if (effect->priority() != priority || (suppressedAnimations && effec t->effect() && suppressedAnimations->contains(effect->effect()->animation()))) 106 if (effect->priority() != priority || (suppressedAnimations && effec t->effect() && suppressedAnimations->contains(effect->effect()->animation())))
105 continue; 107 continue;
106 copyToActiveInterpolationsMap(effect->interpolations(), result); 108 copyToActiveInterpolationsMap(effect->interpolations(), propertyHand leFilter, result);
107 } 109 }
108 } 110 }
109 111
110 if (newAnimations) 112 if (newAnimations)
111 copyNewAnimationsToActiveInterpolationsMap(*newAnimations, result); 113 copyNewAnimationsToActiveInterpolationsMap(*newAnimations, propertyHandl eFilter, result);
112 114
113 return result; 115 return result;
114 } 116 }
115 117
116 void AnimationStack::removeClearedEffects() 118 void AnimationStack::removeClearedEffects()
117 { 119 {
118 size_t dest = 0; 120 size_t dest = 0;
119 for (auto& effect : m_effects) { 121 for (auto& effect : m_effects) {
120 if (effect->effect()) 122 if (effect->effect())
121 m_effects[dest++].swap(effect); 123 m_effects[dest++].swap(effect);
(...skipping 19 matching lines...) Expand all
141 FloatBox expandingBox(originalBox); 143 FloatBox expandingBox(originalBox);
142 if (!CompositorAnimations::instance()->getAnimatedBoundingBox(expand ingBox, *effect->model(), startRange, endRange)) 144 if (!CompositorAnimations::instance()->getAnimatedBoundingBox(expand ingBox, *effect->model(), startRange, endRange))
143 return false; 145 return false;
144 box.expandTo(expandingBox); 146 box.expandTo(expandingBox);
145 } 147 }
146 } 148 }
147 return true; 149 return true;
148 } 150 }
149 151
150 } // namespace blink 152 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698