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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 } | 55 } |
56 } | 56 } |
57 | 57 |
58 bool CompositorPendingAnimations::update(bool startOnCompositor) | 58 bool CompositorPendingAnimations::update(bool startOnCompositor) |
59 { | 59 { |
60 WillBeHeapVector<RawPtrWillBeMember<AnimationPlayer>> waitingForStartTime; | 60 WillBeHeapVector<RawPtrWillBeMember<AnimationPlayer>> waitingForStartTime; |
61 bool startedSynchronizedOnCompositor = false; | 61 bool startedSynchronizedOnCompositor = false; |
62 | 62 |
63 WillBeHeapVector<RefPtrWillBeMember<AnimationPlayer> > players; | 63 WillBeHeapVector<RefPtrWillBeMember<AnimationPlayer> > players; |
64 players.swap(m_pending); | 64 players.swap(m_pending); |
| 65 int compositorGroup = ++m_compositorGroup; |
| 66 if (compositorGroup == 0) { |
| 67 // Wrap around, skipping 0. |
| 68 compositorGroup = ++m_compositorGroup; |
| 69 } |
65 | 70 |
66 for (size_t i = 0; i < players.size(); ++i) { | 71 for (size_t i = 0; i < players.size(); ++i) { |
67 AnimationPlayer& player = *players[i].get(); | 72 AnimationPlayer& player = *players[i].get(); |
68 bool hadCompositorAnimation = player.hasActiveAnimationsOnCompositor(); | 73 bool hadCompositorAnimation = player.hasActiveAnimationsOnCompositor(); |
69 player.preCommit(startOnCompositor); | 74 player.preCommit(compositorGroup, startOnCompositor); |
70 if (player.hasActiveAnimationsOnCompositor() && !hadCompositorAnimation)
{ | 75 if (player.hasActiveAnimationsOnCompositor() && !hadCompositorAnimation)
{ |
71 startedSynchronizedOnCompositor = true; | 76 startedSynchronizedOnCompositor = true; |
72 } | 77 } |
73 | 78 |
74 if (player.playing() && !player.hasStartTime()) { | 79 if (player.playing() && !player.hasStartTime()) { |
75 waitingForStartTime.append(&player); | 80 waitingForStartTime.append(&player); |
76 } | 81 } |
77 } | 82 } |
78 | 83 |
79 // If any synchronized animations were started on the compositor, all | 84 // If any synchronized animations were started on the compositor, all |
(...skipping 27 matching lines...) Expand all Loading... |
107 if (m_waitingForCompositorAnimationStart.isEmpty()) | 112 if (m_waitingForCompositorAnimationStart.isEmpty()) |
108 return false; | 113 return false; |
109 | 114 |
110 // Check if we're still waiting for any compositor animations to start. | 115 // Check if we're still waiting for any compositor animations to start. |
111 for (size_t i = 0; i < m_waitingForCompositorAnimationStart.size(); ++i) { | 116 for (size_t i = 0; i < m_waitingForCompositorAnimationStart.size(); ++i) { |
112 if (m_waitingForCompositorAnimationStart[i].get()->hasActiveAnimationsOn
Compositor()) | 117 if (m_waitingForCompositorAnimationStart[i].get()->hasActiveAnimationsOn
Compositor()) |
113 return true; | 118 return true; |
114 } | 119 } |
115 | 120 |
116 // If not, go ahead and start any animations that were waiting. | 121 // If not, go ahead and start any animations that were waiting. |
117 notifyAnimationStarted(monotonicallyIncreasingTime(), false); | 122 notifyCompositorAnimationStarted(monotonicallyIncreasingTime()); |
118 | 123 |
119 ASSERT(m_pending.isEmpty()); | 124 ASSERT(m_pending.isEmpty()); |
120 return false; | 125 return false; |
121 } | 126 } |
122 | 127 |
123 void CompositorPendingAnimations::notifyAnimationStarted(double monotonicAnimati
onStartTime, bool startedOnCompositor) | 128 void CompositorPendingAnimations::notifyCompositorAnimationStarted(double monoto
nicAnimationStartTime, int compositorGroup) |
124 { | 129 { |
125 TRACE_EVENT0("blink", "CompositorPendingAnimations::notifyCompositorAnimatio
nStarted"); | 130 TRACE_EVENT0("blink", "CompositorPendingAnimations::notifyCompositorAnimatio
nStarted"); |
126 for (size_t i = 0; i < m_waitingForCompositorAnimationStart.size(); ++i) { | 131 WillBeHeapVector<RefPtrWillBeMember<AnimationPlayer> > players; |
127 AnimationPlayer* player = m_waitingForCompositorAnimationStart[i].get(); | 132 players.swap(m_waitingForCompositorAnimationStart); |
128 if (player->hasStartTime()) | 133 |
| 134 for (size_t i = 0; i < players.size(); ++i) { |
| 135 AnimationPlayer* player = players[i].get(); |
| 136 if (player->hasStartTime() || player->playStateInternal() != AnimationPl
ayer::Pending) { |
| 137 // Already started or no longer relevant. |
129 continue; | 138 continue; |
130 double effectiveStartTime = monotonicAnimationStartTime - player->timeli
ne()->zeroTime(); | |
131 if (startedOnCompositor) { | |
132 player->notifyCompositorStartTime(effectiveStartTime); | |
133 } else { | |
134 player->notifyStartTime(effectiveStartTime); | |
135 } | 139 } |
| 140 if (compositorGroup && player->compositorGroup() != compositorGroup) { |
| 141 // Still waiting. |
| 142 m_waitingForCompositorAnimationStart.append(player); |
| 143 continue; |
| 144 } |
| 145 player->notifyCompositorStartTime(monotonicAnimationStartTime - player->
timeline()->zeroTime()); |
136 } | 146 } |
137 | 147 |
138 m_waitingForCompositorAnimationStart.clear(); | |
139 } | |
140 | |
141 void CompositorPendingAnimations::notifyCompositorAnimationStarted(double monoto
nicAnimationStartTime) | |
142 { | |
143 TRACE_EVENT0("blink", "CompositorPendingAnimations::notifyCompositorAnimatio
nStarted"); | |
144 notifyAnimationStarted(monotonicAnimationStartTime, true); | |
145 } | 148 } |
146 | 149 |
147 void CompositorPendingAnimations::trace(Visitor* visitor) | 150 void CompositorPendingAnimations::trace(Visitor* visitor) |
148 { | 151 { |
149 visitor->trace(m_pending); | 152 visitor->trace(m_pending); |
150 visitor->trace(m_waitingForCompositorAnimationStart); | 153 visitor->trace(m_waitingForCompositorAnimationStart); |
151 } | 154 } |
152 | 155 |
153 } // namespace | 156 } // namespace |
OLD | NEW |