| OLD | NEW |
| 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 Loading... |
| 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 copyToActiveInterpolationsMap(const Vector<RefPtr<Interpolation>>& source,
ActiveInterpolationsMap& target) |
| 46 { | 47 { |
| 47 for (const auto& interpolation : source) { | 48 for (const auto& interpolation : source) { |
| 48 target.set(interpolation->property(), interpolation.get()); | 49 ActiveInterpolationsMap::AddResult entry = target.add(interpolation->pro
perty(), ActiveInterpolations(1)); |
| 50 ActiveInterpolations& activeInterpolations = entry.storedValue->value; |
| 51 if (!entry.isNewEntry |
| 52 && RuntimeEnabledFeatures::stackedCSSPropertyAnimationsEnabled() |
| 53 && interpolation->isInvalidatableStyleInterpolation() |
| 54 && toInvalidatableStyleInterpolation(*interpolation).dependsOnUnderl
yingValue()) { |
| 55 activeInterpolations.append(interpolation.get()); |
| 56 } else { |
| 57 activeInterpolations.at(0) = interpolation.get(); |
| 58 } |
| 49 } | 59 } |
| 50 } | 60 } |
| 51 | 61 |
| 52 bool compareEffects(const Member<SampledEffect>& effect1, const Member<SampledEf
fect>& effect2) | 62 bool compareEffects(const Member<SampledEffect>& effect1, const Member<SampledEf
fect>& effect2) |
| 53 { | 63 { |
| 54 ASSERT(effect1 && effect2); | 64 ASSERT(effect1 && effect2); |
| 55 return effect1->sequenceNumber() < effect2->sequenceNumber(); | 65 return effect1->sequenceNumber() < effect2->sequenceNumber(); |
| 56 } | 66 } |
| 57 | 67 |
| 58 void copyNewAnimationsToActiveInterpolationMap(const HeapVector<Member<InertEffe
ct>>& newAnimations, ActiveInterpolationMap& result) | 68 void copyNewAnimationsToActiveInterpolationsMap(const HeapVector<Member<InertEff
ect>>& newAnimations, ActiveInterpolationsMap& result) |
| 59 { | 69 { |
| 60 for (const auto& newAnimation : newAnimations) { | 70 for (const auto& newAnimation : newAnimations) { |
| 61 OwnPtr<Vector<RefPtr<Interpolation>>> sample; | 71 OwnPtr<Vector<RefPtr<Interpolation>>> sample; |
| 62 newAnimation->sample(sample); | 72 newAnimation->sample(sample); |
| 63 if (sample) | 73 if (sample) |
| 64 copyToActiveInterpolationMap(*sample, result); | 74 copyToActiveInterpolationsMap(*sample, result); |
| 65 } | 75 } |
| 66 } | 76 } |
| 67 | 77 |
| 68 } // namespace | 78 } // namespace |
| 69 | 79 |
| 70 AnimationStack::AnimationStack() | 80 AnimationStack::AnimationStack() |
| 71 { | 81 { |
| 72 } | 82 } |
| 73 | 83 |
| 74 bool AnimationStack::hasActiveAnimationsOnCompositor(CSSPropertyID property) con
st | 84 bool AnimationStack::hasActiveAnimationsOnCompositor(CSSPropertyID property) con
st |
| 75 { | 85 { |
| 76 for (const auto& sampledEffect : m_effects) { | 86 for (const auto& sampledEffect : m_effects) { |
| 77 // TODO(dstockwell): move the playing check into AnimationEffect and exp
ose both hasAnimations and hasActiveAnimations | 87 // 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)) | 88 if (sampledEffect->effect() && sampledEffect->effect()->animation()->pla
ying() && sampledEffect->effect()->hasActiveAnimationsOnCompositor(property)) |
| 79 return true; | 89 return true; |
| 80 } | 90 } |
| 81 return false; | 91 return false; |
| 82 } | 92 } |
| 83 | 93 |
| 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) | 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) |
| 85 { | 95 { |
| 86 // We don't exactly know when new animations will start, but timelineCurrent
Time is a good estimate. | 96 // We don't exactly know when new animations will start, but timelineCurrent
Time is a good estimate. |
| 87 | 97 |
| 88 ActiveInterpolationMap result; | 98 ActiveInterpolationsMap result; |
| 89 | 99 |
| 90 if (animationStack) { | 100 if (animationStack) { |
| 91 HeapVector<Member<SampledEffect>>& effects = animationStack->m_effects; | 101 HeapVector<Member<SampledEffect>>& effects = animationStack->m_effects; |
| 92 // std::sort doesn't work with OwnPtrs | 102 // std::sort doesn't work with OwnPtrs |
| 93 nonCopyingSort(effects.begin(), effects.end(), compareEffects); | 103 nonCopyingSort(effects.begin(), effects.end(), compareEffects); |
| 94 animationStack->removeClearedEffects(); | 104 animationStack->removeClearedEffects(); |
| 95 for (const auto& effect : effects) { | 105 for (const auto& effect : effects) { |
| 96 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()))) |
| 97 continue; | 107 continue; |
| 98 copyToActiveInterpolationMap(effect->interpolations(), result); | 108 copyToActiveInterpolationsMap(effect->interpolations(), result); |
| 99 } | 109 } |
| 100 } | 110 } |
| 101 | 111 |
| 102 if (newAnimations) | 112 if (newAnimations) |
| 103 copyNewAnimationsToActiveInterpolationMap(*newAnimations, result); | 113 copyNewAnimationsToActiveInterpolationsMap(*newAnimations, result); |
| 104 | 114 |
| 105 return result; | 115 return result; |
| 106 } | 116 } |
| 107 | 117 |
| 108 void AnimationStack::removeClearedEffects() | 118 void AnimationStack::removeClearedEffects() |
| 109 { | 119 { |
| 110 size_t dest = 0; | 120 size_t dest = 0; |
| 111 for (auto& effect : m_effects) { | 121 for (auto& effect : m_effects) { |
| 112 if (effect->effect()) | 122 if (effect->effect()) |
| 113 m_effects[dest++].swap(effect); | 123 m_effects[dest++].swap(effect); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 133 FloatBox expandingBox(originalBox); | 143 FloatBox expandingBox(originalBox); |
| 134 if (!CompositorAnimations::instance()->getAnimatedBoundingBox(expand
ingBox, *effect->model(), startRange, endRange)) | 144 if (!CompositorAnimations::instance()->getAnimatedBoundingBox(expand
ingBox, *effect->model(), startRange, endRange)) |
| 135 return false; | 145 return false; |
| 136 box.expandTo(expandingBox); | 146 box.expandTo(expandingBox); |
| 137 } | 147 } |
| 138 } | 148 } |
| 139 return true; | 149 return true; |
| 140 } | 150 } |
| 141 | 151 |
| 142 } // namespace blink | 152 } // namespace blink |
| OLD | NEW |