| 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 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 } | 94 } |
| 95 | 95 |
| 96 ActiveInterpolationsMap AnimationStack::activeInterpolations(AnimationStack* ani
mationStack, const HeapVector<Member<const InertEffect>>* newAnimations, const H
eapHashSet<Member<const Animation>>* suppressedAnimations, KeyframeEffect::Prior
ity priority, PropertyHandleFilter propertyHandleFilter) | 96 ActiveInterpolationsMap AnimationStack::activeInterpolations(AnimationStack* ani
mationStack, const HeapVector<Member<const InertEffect>>* newAnimations, const H
eapHashSet<Member<const Animation>>* suppressedAnimations, KeyframeEffect::Prior
ity priority, PropertyHandleFilter propertyHandleFilter) |
| 97 { | 97 { |
| 98 ActiveInterpolationsMap result; | 98 ActiveInterpolationsMap result; |
| 99 | 99 |
| 100 if (animationStack) { | 100 if (animationStack) { |
| 101 HeapVector<Member<SampledEffect>>& sampledEffects = animationStack->m_sa
mpledEffects; | 101 HeapVector<Member<SampledEffect>>& sampledEffects = animationStack->m_sa
mpledEffects; |
| 102 // std::sort doesn't work with OwnPtrs | 102 // std::sort doesn't work with OwnPtrs |
| 103 nonCopyingSort(sampledEffects.begin(), sampledEffects.end(), compareSamp
ledEffects); | 103 nonCopyingSort(sampledEffects.begin(), sampledEffects.end(), compareSamp
ledEffects); |
| 104 animationStack->removeClearedSampledEffects(); | 104 animationStack->removeRedundantSampledEffects(); |
| 105 for (const auto& sampledEffect : sampledEffects) { | 105 for (const auto& sampledEffect : sampledEffects) { |
| 106 if (sampledEffect->priority() != priority || (suppressedAnimations &
& sampledEffect->effect() && suppressedAnimations->contains(sampledEffect->effec
t()->animation()))) | 106 if (sampledEffect->priority() != priority || (suppressedAnimations &
& sampledEffect->effect() && suppressedAnimations->contains(sampledEffect->effec
t()->animation()))) |
| 107 continue; | 107 continue; |
| 108 copyToActiveInterpolationsMap(sampledEffect->interpolations(), prope
rtyHandleFilter, result); | 108 copyToActiveInterpolationsMap(sampledEffect->interpolations(), prope
rtyHandleFilter, result); |
| 109 } | 109 } |
| 110 } | 110 } |
| 111 | 111 |
| 112 if (newAnimations) | 112 if (newAnimations) |
| 113 copyNewAnimationsToActiveInterpolationsMap(*newAnimations, propertyHandl
eFilter, result); | 113 copyNewAnimationsToActiveInterpolationsMap(*newAnimations, propertyHandl
eFilter, result); |
| 114 | 114 |
| 115 return result; | 115 return result; |
| 116 } | 116 } |
| 117 | 117 |
| 118 void AnimationStack::removeClearedSampledEffects() | 118 void AnimationStack::removeRedundantSampledEffects() |
| 119 { | 119 { |
| 120 size_t dest = 0; | 120 HashSet<PropertyHandle> replacedProperties; |
| 121 for (size_t i = m_sampledEffects.size(); i--;) { |
| 122 SampledEffect& sampledEffect = *m_sampledEffects[i]; |
| 123 if (sampledEffect.willNeverChange()) { |
| 124 sampledEffect.removeReplacedInterpolations(replacedProperties); |
| 125 sampledEffect.updateReplacedProperties(replacedProperties); |
| 126 } |
| 127 } |
| 128 |
| 129 size_t newSize = 0; |
| 121 for (auto& sampledEffect : m_sampledEffects) { | 130 for (auto& sampledEffect : m_sampledEffects) { |
| 122 if (sampledEffect->effect()) | 131 if (!sampledEffect->interpolations().isEmpty()) |
| 123 m_sampledEffects[dest++].swap(sampledEffect); | 132 m_sampledEffects[newSize++].swap(sampledEffect); |
| 133 else if (sampledEffect->effect()) |
| 134 sampledEffect->effect()->notifySampledEffectRemovedFromAnimationStac
k(); |
| 124 } | 135 } |
| 125 m_sampledEffects.shrink(dest); | 136 m_sampledEffects.shrink(newSize); |
| 126 } | 137 } |
| 127 | 138 |
| 128 DEFINE_TRACE(AnimationStack) | 139 DEFINE_TRACE(AnimationStack) |
| 129 { | 140 { |
| 130 visitor->trace(m_sampledEffects); | 141 visitor->trace(m_sampledEffects); |
| 131 } | 142 } |
| 132 | 143 |
| 133 bool AnimationStack::getAnimatedBoundingBox(FloatBox& box, CSSPropertyID propert
y) const | 144 bool AnimationStack::getAnimatedBoundingBox(FloatBox& box, CSSPropertyID propert
y) const |
| 134 { | 145 { |
| 135 FloatBox originalBox(box); | 146 FloatBox originalBox(box); |
| 136 for (const auto& sampledEffect : m_sampledEffects) { | 147 for (const auto& sampledEffect : m_sampledEffects) { |
| 137 if (sampledEffect->effect() && sampledEffect->effect()->affects(Property
Handle(property))) { | 148 if (sampledEffect->effect() && sampledEffect->effect()->affects(Property
Handle(property))) { |
| 138 KeyframeEffect* effect = sampledEffect->effect(); | 149 KeyframeEffect* effect = sampledEffect->effect(); |
| 139 const Timing& timing = effect->specifiedTiming(); | 150 const Timing& timing = effect->specifiedTiming(); |
| 140 double startRange = 0; | 151 double startRange = 0; |
| 141 double endRange = 1; | 152 double endRange = 1; |
| 142 timing.timingFunction->range(&startRange, &endRange); | 153 timing.timingFunction->range(&startRange, &endRange); |
| 143 FloatBox expandingBox(originalBox); | 154 FloatBox expandingBox(originalBox); |
| 144 if (!CompositorAnimations::instance()->getAnimatedBoundingBox(expand
ingBox, *effect->model(), startRange, endRange)) | 155 if (!CompositorAnimations::instance()->getAnimatedBoundingBox(expand
ingBox, *effect->model(), startRange, endRange)) |
| 145 return false; | 156 return false; |
| 146 box.expandTo(expandingBox); | 157 box.expandTo(expandingBox); |
| 147 } | 158 } |
| 148 } | 159 } |
| 149 return true; | 160 return true; |
| 150 } | 161 } |
| 151 | 162 |
| 152 } // namespace blink | 163 } // namespace blink |
| OLD | NEW |