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

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: Created 5 years, 2 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 /* 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, double timelineCurrentTime) 96 ActiveInterpolationsMap AnimationStack::activeInterpolations(AnimationStack* ani mationStack, const HeapVector<Member<InertEffect>>* newAnimations, const HeapHas hSet<Member<const Animation>>* suppressedAnimations, KeyframeEffect::Priority pr iority, double timelineCurrentTime, PropertyHandleFilter propertyHandleFilter)
95 { 97 {
96 // We don't exactly know when new animations will start, but timelineCurrent Time is a good estimate. 98 // We don't exactly know when new animations will start, but timelineCurrent Time is a good estimate.
dstockwell 2015/10/21 01:00:39 Needs a rebase. Took me a while to figure out what
alancutter (OOO until 2018) 2015/10/21 04:22:16 Done.
97 99
98 ActiveInterpolationsMap result; 100 ActiveInterpolationsMap result;
99 101
100 if (animationStack) { 102 if (animationStack) {
101 HeapVector<Member<SampledEffect>>& effects = animationStack->m_effects; 103 HeapVector<Member<SampledEffect>>& effects = animationStack->m_effects;
102 // std::sort doesn't work with OwnPtrs 104 // std::sort doesn't work with OwnPtrs
103 nonCopyingSort(effects.begin(), effects.end(), compareEffects); 105 nonCopyingSort(effects.begin(), effects.end(), compareEffects);
104 animationStack->removeClearedEffects(); 106 animationStack->removeClearedEffects();
105 for (const auto& effect : effects) { 107 for (const auto& effect : effects) {
106 if (effect->priority() != priority || (suppressedAnimations && effec t->effect() && suppressedAnimations->contains(effect->effect()->animation()))) 108 if (effect->priority() != priority || (suppressedAnimations && effec t->effect() && suppressedAnimations->contains(effect->effect()->animation())))
107 continue; 109 continue;
108 copyToActiveInterpolationsMap(effect->interpolations(), result); 110 copyToActiveInterpolationsMap(effect->interpolations(), propertyHand leFilter, result);
109 } 111 }
110 } 112 }
111 113
112 if (newAnimations) 114 if (newAnimations)
113 copyNewAnimationsToActiveInterpolationsMap(*newAnimations, result); 115 copyNewAnimationsToActiveInterpolationsMap(*newAnimations, propertyHandl eFilter, result);
114 116
115 return result; 117 return result;
116 } 118 }
117 119
118 void AnimationStack::removeClearedEffects() 120 void AnimationStack::removeClearedEffects()
119 { 121 {
120 size_t dest = 0; 122 size_t dest = 0;
121 for (auto& effect : m_effects) { 123 for (auto& effect : m_effects) {
122 if (effect->effect()) 124 if (effect->effect())
123 m_effects[dest++].swap(effect); 125 m_effects[dest++].swap(effect);
(...skipping 19 matching lines...) Expand all
143 FloatBox expandingBox(originalBox); 145 FloatBox expandingBox(originalBox);
144 if (!CompositorAnimations::instance()->getAnimatedBoundingBox(expand ingBox, *effect->model(), startRange, endRange)) 146 if (!CompositorAnimations::instance()->getAnimatedBoundingBox(expand ingBox, *effect->model(), startRange, endRange))
145 return false; 147 return false;
146 box.expandTo(expandingBox); 148 box.expandTo(expandingBox);
147 } 149 }
148 } 150 }
149 return true; 151 return true;
150 } 152 }
151 153
152 } // namespace blink 154 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698