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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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(); |
93 for (const auto& effect : effects) { | 94 for (const auto& effect : effects) { |
94 if (effect->priority() != priority || (suppressedAnimationPlayers &&
effect->animation() && suppressedAnimationPlayers->contains(effect->animation()
->player()))) | 95 if (effect->priority() != priority || (suppressedAnimationPlayers &&
effect->animation() && suppressedAnimationPlayers->contains(effect->animation()
->player()))) |
95 continue; | 96 continue; |
96 copyToActiveInterpolationMap(effect->interpolations(), result); | 97 copyToActiveInterpolationMap(effect->interpolations(), result); |
97 } | 98 } |
98 } | 99 } |
99 | 100 |
100 if (newAnimations) | 101 if (newAnimations) |
101 copyNewAnimationsToActiveInterpolationMap(*newAnimations, result); | 102 copyNewAnimationsToActiveInterpolationMap(*newAnimations, result); |
102 | 103 |
103 return result; | 104 return result; |
104 } | 105 } |
105 | 106 |
| 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 |
106 DEFINE_TRACE(AnimationStack) | 133 DEFINE_TRACE(AnimationStack) |
107 { | 134 { |
108 visitor->trace(m_effects); | 135 visitor->trace(m_effects); |
109 } | 136 } |
110 | 137 |
111 bool AnimationStack::getAnimatedBoundingBox(FloatBox& box, CSSPropertyID propert
y) const | 138 bool AnimationStack::getAnimatedBoundingBox(FloatBox& box, CSSPropertyID propert
y) const |
112 { | 139 { |
113 FloatBox originalBox(box); | 140 FloatBox originalBox(box); |
114 for (const auto& effect : m_effects) { | 141 for (const auto& effect : m_effects) { |
115 if (effect->animation() && effect->animation()->affects(property)) { | 142 if (effect->animation() && effect->animation()->affects(property)) { |
116 Animation* anim = effect->animation(); | 143 Animation* anim = effect->animation(); |
117 if (!anim) | 144 if (!anim) |
118 continue; | 145 continue; |
119 const Timing& timing = anim->specifiedTiming(); | 146 const Timing& timing = anim->specifiedTiming(); |
120 double startRange = 0; | 147 double startRange = 0; |
121 double endRange = 1; | 148 double endRange = 1; |
122 timing.timingFunction->range(&startRange, &endRange); | 149 timing.timingFunction->range(&startRange, &endRange); |
123 FloatBox expandingBox(originalBox); | 150 FloatBox expandingBox(originalBox); |
124 if (!CompositorAnimations::instance()->getAnimatedBoundingBox(expand
ingBox, *anim->effect(), startRange, endRange)) | 151 if (!CompositorAnimations::instance()->getAnimatedBoundingBox(expand
ingBox, *anim->effect(), startRange, endRange)) |
125 return false; | 152 return false; |
126 box.expandTo(expandingBox); | 153 box.expandTo(expandingBox); |
127 } | 154 } |
128 } | 155 } |
129 return true; | 156 return true; |
130 } | 157 } |
131 | 158 |
132 } // namespace blink | 159 } // namespace blink |
OLD | NEW |