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 "sky/engine/config.h" | 31 #include "sky/engine/config.h" |
32 #include "sky/engine/core/animation/AnimationStack.h" | 32 #include "sky/engine/core/animation/AnimationStack.h" |
33 | 33 |
34 #include <algorithm> | 34 #include <algorithm> |
35 #include "sky/engine/core/animation/CompositorAnimations.h" | |
36 #include "sky/engine/core/animation/StyleInterpolation.h" | 35 #include "sky/engine/core/animation/StyleInterpolation.h" |
37 #include "sky/engine/core/animation/css/CSSAnimations.h" | 36 #include "sky/engine/core/animation/css/CSSAnimations.h" |
38 #include "sky/engine/wtf/BitArray.h" | 37 #include "sky/engine/wtf/BitArray.h" |
39 #include "sky/engine/wtf/NonCopyingSort.h" | 38 #include "sky/engine/wtf/NonCopyingSort.h" |
40 | 39 |
41 namespace blink { | 40 namespace blink { |
42 | 41 |
43 namespace { | 42 namespace { |
44 | 43 |
45 void copyToActiveInterpolationMap(const Vector<RefPtr<blink::Interpolation> >& s
ource, HashMap<CSSPropertyID, RefPtr<blink::Interpolation> >& target) | 44 void copyToActiveInterpolationMap(const Vector<RefPtr<blink::Interpolation> >& s
ource, HashMap<CSSPropertyID, RefPtr<blink::Interpolation> >& target) |
(...skipping 19 matching lines...) Expand all Loading... |
65 } | 64 } |
66 } | 65 } |
67 } | 66 } |
68 | 67 |
69 } // namespace | 68 } // namespace |
70 | 69 |
71 AnimationStack::AnimationStack() | 70 AnimationStack::AnimationStack() |
72 { | 71 { |
73 } | 72 } |
74 | 73 |
75 bool AnimationStack::affects(CSSPropertyID property) const | |
76 { | |
77 for (size_t i = 0; i < m_effects.size(); ++i) { | |
78 if (m_effects[i]->animation() && m_effects[i]->animation()->affects(prop
erty)) | |
79 return true; | |
80 } | |
81 return false; | |
82 } | |
83 | |
84 bool AnimationStack::hasActiveAnimationsOnCompositor(CSSPropertyID property) con
st | |
85 { | |
86 for (size_t i = 0; i < m_effects.size(); ++i) { | |
87 if (m_effects[i]->animation() && m_effects[i]->animation()->hasActiveAni
mationsOnCompositor(property)) | |
88 return true; | |
89 } | |
90 return false; | |
91 } | |
92 | |
93 HashMap<CSSPropertyID, RefPtr<Interpolation> > AnimationStack::activeInterpolati
ons(AnimationStack* animationStack, const Vector<RawPtr<InertAnimation> >* newAn
imations, const HashSet<RawPtr<const AnimationPlayer> >* cancelledAnimationPlaye
rs, Animation::Priority priority, double timelineCurrentTime) | 74 HashMap<CSSPropertyID, RefPtr<Interpolation> > AnimationStack::activeInterpolati
ons(AnimationStack* animationStack, const Vector<RawPtr<InertAnimation> >* newAn
imations, const HashSet<RawPtr<const AnimationPlayer> >* cancelledAnimationPlaye
rs, Animation::Priority priority, double timelineCurrentTime) |
94 { | 75 { |
95 // We don't exactly know when new animations will start, but timelineCurrent
Time is a good estimate. | 76 // We don't exactly know when new animations will start, but timelineCurrent
Time is a good estimate. |
96 | 77 |
97 HashMap<CSSPropertyID, RefPtr<Interpolation> > result; | 78 HashMap<CSSPropertyID, RefPtr<Interpolation> > result; |
98 | 79 |
99 if (animationStack) { | 80 if (animationStack) { |
100 Vector<OwnPtr<SampledEffect> >& effects = animationStack->m_effects; | 81 Vector<OwnPtr<SampledEffect> >& effects = animationStack->m_effects; |
101 // std::sort doesn't work with OwnPtrs | 82 // std::sort doesn't work with OwnPtrs |
102 nonCopyingSort(effects.begin(), effects.end(), compareEffects); | 83 nonCopyingSort(effects.begin(), effects.end(), compareEffects); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 if (!m_effects[i]->interpolations().isEmpty()) { | 115 if (!m_effects[i]->interpolations().isEmpty()) { |
135 m_effects[dest++].swap(m_effects[i]); | 116 m_effects[dest++].swap(m_effects[i]); |
136 continue; | 117 continue; |
137 } | 118 } |
138 if (m_effects[i]->animation()) | 119 if (m_effects[i]->animation()) |
139 m_effects[i]->animation()->notifySampledEffectRemovedFromAnimationSt
ack(); | 120 m_effects[i]->animation()->notifySampledEffectRemovedFromAnimationSt
ack(); |
140 } | 121 } |
141 m_effects.shrink(dest); | 122 m_effects.shrink(dest); |
142 } | 123 } |
143 | 124 |
144 bool AnimationStack::getAnimatedBoundingBox(FloatBox& box, CSSPropertyID propert
y) const | |
145 { | |
146 FloatBox originalBox(box); | |
147 for (size_t i = 0; i < m_effects.size(); ++i) { | |
148 if (m_effects[i]->animation() && m_effects[i]->animation()->affects(prop
erty)) { | |
149 Animation* anim = m_effects[i]->animation(); | |
150 if (!anim) | |
151 continue; | |
152 const Timing& timing = anim->specifiedTiming(); | |
153 double startRange = 0; | |
154 double endRange = 1; | |
155 timing.timingFunction->range(&startRange, &endRange); | |
156 FloatBox expandingBox(originalBox); | |
157 if (!CompositorAnimations::instance()->getAnimatedBoundingBox(expand
ingBox, *anim->effect(), startRange, endRange)) | |
158 return false; | |
159 box.expandTo(expandingBox); | |
160 } | |
161 } | |
162 return true; | |
163 } | |
164 | |
165 } // namespace blink | 125 } // namespace blink |
OLD | NEW |