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

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

Issue 955303002: Web Animations: Remove AnimationPlayer discarding logic (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: don't actually delete unit test Created 5 years, 9 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
« no previous file with comments | « Source/core/animation/AnimationStack.h ('k') | Source/core/animation/AnimationStackTest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 WillBeHeapHashMap<CSSPropertyID, RefPtrWillBeMember<Interpolation> > AnimationSt ack::activeInterpolations(AnimationStack* animationStack, const WillBeHeapVector <RawPtrWillBeMember<InertAnimation> >* newAnimations, const WillBeHeapHashSet<Ra wPtrWillBeMember<const AnimationPlayer> >* suppressedAnimationPlayers, Animation ::Priority priority, double timelineCurrentTime) 83 WillBeHeapHashMap<CSSPropertyID, RefPtrWillBeMember<Interpolation> > AnimationSt ack::activeInterpolations(AnimationStack* animationStack, const WillBeHeapVector <RawPtrWillBeMember<InertAnimation> >* newAnimations, const WillBeHeapHashSet<Ra wPtrWillBeMember<const AnimationPlayer> >* suppressedAnimationPlayers, Animation ::Priority priority, double timelineCurrentTime)
84 { 84 {
85 // We don't exactly know when new animations will start, but timelineCurrent Time is a good estimate. 85 // We don't exactly know when new animations will start, but timelineCurrent Time is a good estimate.
86 86
87 WillBeHeapHashMap<CSSPropertyID, RefPtrWillBeMember<Interpolation> > result; 87 WillBeHeapHashMap<CSSPropertyID, RefPtrWillBeMember<Interpolation> > result;
88 88
89 if (animationStack) { 89 if (animationStack) {
90 WillBeHeapVector<OwnPtrWillBeMember<SampledEffect> >& effects = animatio nStack->m_effects; 90 WillBeHeapVector<OwnPtrWillBeMember<SampledEffect> >& effects = animatio nStack->m_effects;
91 // std::sort doesn't work with OwnPtrs 91 // std::sort doesn't work with OwnPtrs
92 nonCopyingSort(effects.begin(), effects.end(), compareEffects); 92 nonCopyingSort(effects.begin(), effects.end(), compareEffects);
93 animationStack->simplifyEffects();
94 for (const auto& effect : effects) { 93 for (const auto& effect : effects) {
95 if (effect->priority() != priority || (suppressedAnimationPlayers && effect->animation() && suppressedAnimationPlayers->contains(effect->animation() ->player()))) 94 if (effect->priority() != priority || (suppressedAnimationPlayers && effect->animation() && suppressedAnimationPlayers->contains(effect->animation() ->player())))
96 continue; 95 continue;
97 copyToActiveInterpolationMap(effect->interpolations(), result); 96 copyToActiveInterpolationMap(effect->interpolations(), result);
98 } 97 }
99 } 98 }
100 99
101 if (newAnimations) 100 if (newAnimations)
102 copyNewAnimationsToActiveInterpolationMap(*newAnimations, result); 101 copyNewAnimationsToActiveInterpolationMap(*newAnimations, result);
103 102
104 return result; 103 return result;
105 } 104 }
106 105
107 void AnimationStack::simplifyEffects()
108 {
109 // FIXME: This will need to be updated when we have 'add' keyframes.
110
111 BitArray<numCSSProperties> replacedProperties;
112 for (size_t i = m_effects.size(); i--; ) {
113 SampledEffect& effect = *m_effects[i];
114 effect.removeReplacedInterpolationsIfNeeded(replacedProperties);
115 if (!effect.canChange()) {
116 for (const auto& interpolation : effect.interpolations())
117 replacedProperties.set(toStyleInterpolation(interpolation.get()) ->id());
118 }
119 }
120
121 size_t dest = 0;
122 for (auto& effect : m_effects) {
123 if (!effect->interpolations().isEmpty()) {
124 m_effects[dest++].swap(effect);
125 continue;
126 }
127 if (effect->animation())
128 effect->animation()->notifySampledEffectRemovedFromAnimationStack();
129 }
130 m_effects.shrink(dest);
131 }
132
133 DEFINE_TRACE(AnimationStack) 106 DEFINE_TRACE(AnimationStack)
134 { 107 {
135 visitor->trace(m_effects); 108 visitor->trace(m_effects);
136 } 109 }
137 110
138 bool AnimationStack::getAnimatedBoundingBox(FloatBox& box, CSSPropertyID propert y) const 111 bool AnimationStack::getAnimatedBoundingBox(FloatBox& box, CSSPropertyID propert y) const
139 { 112 {
140 FloatBox originalBox(box); 113 FloatBox originalBox(box);
141 for (const auto& effect : m_effects) { 114 for (const auto& effect : m_effects) {
142 if (effect->animation() && effect->animation()->affects(property)) { 115 if (effect->animation() && effect->animation()->affects(property)) {
143 Animation* anim = effect->animation(); 116 Animation* anim = effect->animation();
144 if (!anim) 117 if (!anim)
145 continue; 118 continue;
146 const Timing& timing = anim->specifiedTiming(); 119 const Timing& timing = anim->specifiedTiming();
147 double startRange = 0; 120 double startRange = 0;
148 double endRange = 1; 121 double endRange = 1;
149 timing.timingFunction->range(&startRange, &endRange); 122 timing.timingFunction->range(&startRange, &endRange);
150 FloatBox expandingBox(originalBox); 123 FloatBox expandingBox(originalBox);
151 if (!CompositorAnimations::instance()->getAnimatedBoundingBox(expand ingBox, *anim->effect(), startRange, endRange)) 124 if (!CompositorAnimations::instance()->getAnimatedBoundingBox(expand ingBox, *anim->effect(), startRange, endRange))
152 return false; 125 return false;
153 box.expandTo(expandingBox); 126 box.expandTo(expandingBox);
154 } 127 }
155 } 128 }
156 return true; 129 return true;
157 } 130 }
158 131
159 } // namespace blink 132 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/animation/AnimationStack.h ('k') | Source/core/animation/AnimationStackTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698