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 12 matching lines...) Expand all Loading... | |
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
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 #include "core/animation/Interpolation.h" | 33 #include "core/animation/Interpolation.h" |
alancutter (OOO until 2018)
2014/03/26 01:23:03
Not sure why style never picked up on this but thi
Timothy Loh
2014/03/26 03:00:43
Done.
| |
34 | 34 |
35 #include "core/animation/css/CSSAnimations.h" | 35 #include "core/animation/css/CSSAnimations.h" |
36 | 36 |
37 namespace WebCore { | 37 namespace WebCore { |
38 | 38 |
39 namespace { | 39 namespace { |
40 | 40 |
41 void copyToActiveInterpolationMap(const Vector<RefPtr<WebCore::Interpolation> >& source, HashMap<CSSPropertyID, RefPtr<WebCore::Interpolation> >& target) | 41 void copyToActiveInterpolationMap(const Vector<RefPtr<WebCore::Interpolation> >& source, HashMap<CSSPropertyID, RefPtr<WebCore::Interpolation> >& target) |
42 { | 42 { |
43 for (Vector<RefPtr<WebCore::Interpolation> >::const_iterator iter = source.b egin(); iter != source.end(); ++iter) { | 43 for (Vector<RefPtr<WebCore::Interpolation> >::const_iterator iter = source.b egin(); iter != source.end(); ++iter) { |
44 RefPtr<WebCore::Interpolation> interpolation = *iter; | 44 RefPtr<WebCore::Interpolation> interpolation = *iter; |
45 WebCore::StyleInterpolation *styleInterpolation = toStyleInterpolation(i nterpolation.get()); | 45 WebCore::StyleInterpolation *styleInterpolation = toStyleInterpolation(i nterpolation.get()); |
46 target.set(styleInterpolation->id(), styleInterpolation); | 46 target.set(styleInterpolation->id(), styleInterpolation); |
47 } | 47 } |
48 } | 48 } |
49 | 49 |
50 bool compareAnimations(Animation* animation1, Animation* animation2) | |
51 { | |
52 ASSERT(animation1->player() && animation2->player()); | |
53 return AnimationPlayer::hasLowerPriority(animation1->player(), animation2->p layer()); | |
54 } | |
55 | |
56 void copyNewAnimationsToActiveInterpolationMap(const Vector<InertAnimation*>& ne wAnimations, HashMap<CSSPropertyID, RefPtr<Interpolation> >& result) | |
57 { | |
58 for (size_t i = 0; i < newAnimations.size(); ++i) { | |
59 OwnPtr<Vector<RefPtr<Interpolation> > > sample = newAnimations[i]->sampl e(); | |
60 if (sample) { | |
61 copyToActiveInterpolationMap(*sample, result); | |
62 } | |
63 } | |
64 } | |
65 | |
50 } // namespace | 66 } // namespace |
51 | 67 |
52 bool AnimationStack::affects(CSSPropertyID property) const | 68 bool AnimationStack::affects(CSSPropertyID property) const |
53 { | 69 { |
54 for (size_t i = 0; i < m_activeAnimations.size(); ++i) { | 70 for (size_t i = 0; i < m_activeAnimations.size(); ++i) { |
55 if (m_activeAnimations[i]->affects(property)) | 71 if (m_activeAnimations[i]->affects(property)) |
56 return true; | 72 return true; |
57 } | 73 } |
58 return false; | 74 return false; |
59 } | 75 } |
60 | 76 |
61 bool AnimationStack::hasActiveAnimationsOnCompositor(CSSPropertyID property) con st | 77 bool AnimationStack::hasActiveAnimationsOnCompositor(CSSPropertyID property) con st |
62 { | 78 { |
63 for (size_t i = 0; i < m_activeAnimations.size(); ++i) { | 79 for (size_t i = 0; i < m_activeAnimations.size(); ++i) { |
64 if (m_activeAnimations[i]->hasActiveAnimationsOnCompositor(property)) | 80 if (m_activeAnimations[i]->hasActiveAnimationsOnCompositor(property)) |
65 return true; | 81 return true; |
66 } | 82 } |
67 return false; | 83 return false; |
68 } | 84 } |
69 | 85 |
70 HashMap<CSSPropertyID, RefPtr<Interpolation> > AnimationStack::activeInterpolati ons(const AnimationStack* animationStack, const Vector<InertAnimation*>* newAnim ations, const HashSet<const AnimationPlayer*>* cancelledAnimationPlayers, Animat ion::Priority priority) | 86 HashMap<CSSPropertyID, RefPtr<Interpolation> > AnimationStack::activeInterpolati ons(AnimationStack* animationStack, const Vector<InertAnimation*>* newAnimations , const HashSet<const AnimationPlayer*>* cancelledAnimationPlayers, Animation::P riority priority, double timelineCurrentTime) |
71 { | 87 { |
88 // We don't exactly know when new animations will start, but timelineCurrent Time is a good estimate. | |
dstockwell
2014/03/26 01:32:21
We should probably track the start time for the pu
Timothy Loh
2014/03/26 03:00:43
Done.
| |
89 | |
72 HashMap<CSSPropertyID, RefPtr<Interpolation> > result; | 90 HashMap<CSSPropertyID, RefPtr<Interpolation> > result; |
73 | 91 |
74 if (animationStack) { | 92 if (animationStack) { |
75 const Vector<Animation*>& animations = animationStack->m_activeAnimation s; | 93 Vector<Animation*>& animations = animationStack->m_activeAnimations; |
94 std::sort(animations.begin(), animations.end(), compareAnimations); | |
76 for (size_t i = 0; i < animations.size(); ++i) { | 95 for (size_t i = 0; i < animations.size(); ++i) { |
77 Animation* animation = animations[i]; | 96 Animation* animation = animations[i]; |
78 if (animation->priority() != priority) | 97 if (animation->priority() != priority) |
79 continue; | 98 continue; |
80 if (cancelledAnimationPlayers && cancelledAnimationPlayers->contains (animation->player())) | 99 if (cancelledAnimationPlayers && cancelledAnimationPlayers->contains (animation->player())) |
81 continue; | 100 continue; |
101 if (animation->player()->startTime() > timelineCurrentTime && newAni mations) { | |
102 copyNewAnimationsToActiveInterpolationMap(*newAnimations, result ); | |
103 newAnimations = 0; | |
104 } | |
82 copyToActiveInterpolationMap(animation->activeInterpolations(), resu lt); | 105 copyToActiveInterpolationMap(animation->activeInterpolations(), resu lt); |
83 } | 106 } |
84 } | 107 } |
85 | 108 |
86 if (newAnimations) { | 109 if (newAnimations) |
87 for (size_t i = 0; i < newAnimations->size(); ++i) { | 110 copyNewAnimationsToActiveInterpolationMap(*newAnimations, result); |
88 OwnPtr<Vector<RefPtr<Interpolation> > > sample = newAnimations->at(i )->sample(); | |
89 if (sample) { | |
90 copyToActiveInterpolationMap(*sample, result); | |
91 } | |
92 } | |
93 } | |
94 | 111 |
95 return result; | 112 return result; |
96 } | 113 } |
97 | 114 |
98 } // namespace WebCore | 115 } // namespace WebCore |
OLD | NEW |