OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "platform/scroll/ScrollAnimatorCompositorCoordinator.h" | 5 #include "platform/scroll/ScrollAnimatorCompositorCoordinator.h" |
6 | 6 |
7 #include "platform/RuntimeEnabledFeatures.h" | 7 #include "platform/RuntimeEnabledFeatures.h" |
8 #include "platform/animation/CompositorAnimationPlayer.h" | 8 #include "platform/animation/CompositorAnimationPlayer.h" |
9 #include "platform/animation/CompositorAnimationTimeline.h" | 9 #include "platform/animation/CompositorAnimationTimeline.h" |
10 #include "platform/graphics/CompositorFactory.h" | 10 #include "platform/graphics/CompositorFactory.h" |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 case RunState::WaitingToCancelOnCompositor: | 156 case RunState::WaitingToCancelOnCompositor: |
157 m_runState = RunState::PostAnimationCleanup; | 157 m_runState = RunState::PostAnimationCleanup; |
158 // Get serviced the next time compositor updates are allowed. | 158 // Get serviced the next time compositor updates are allowed. |
159 if (scrollableArea()) | 159 if (scrollableArea()) |
160 scrollableArea()->registerForAnimation(); | 160 scrollableArea()->registerForAnimation(); |
161 else | 161 else |
162 resetAnimationState(); | 162 resetAnimationState(); |
163 } | 163 } |
164 } | 164 } |
165 | 165 |
166 void ScrollAnimatorCompositorCoordinator::reattachCompositorPlayerIfNeeded( | 166 bool ScrollAnimatorCompositorCoordinator::reattachCompositorPlayerIfNeeded( |
167 CompositorAnimationTimeline* timeline) | 167 CompositorAnimationTimeline* timeline) |
168 { | 168 { |
| 169 bool reattached = false; |
169 int compositorAnimationAttachedToLayerId = 0; | 170 int compositorAnimationAttachedToLayerId = 0; |
170 if (scrollableArea()->layerForScrolling()) | 171 if (scrollableArea()->layerForScrolling()) |
171 compositorAnimationAttachedToLayerId = scrollableArea()->layerForScrolli
ng()->platformLayer()->id(); | 172 compositorAnimationAttachedToLayerId = scrollableArea()->layerForScrolli
ng()->platformLayer()->id(); |
172 | 173 |
173 if (compositorAnimationAttachedToLayerId != m_compositorAnimationAttachedToL
ayerId) { | 174 if (compositorAnimationAttachedToLayerId != m_compositorAnimationAttachedToL
ayerId) { |
174 if (m_compositorPlayer && timeline) { | 175 if (m_compositorPlayer && timeline) { |
175 // Detach from old layer (if any). | 176 // Detach from old layer (if any). |
176 if (m_compositorAnimationAttachedToLayerId) { | 177 if (m_compositorAnimationAttachedToLayerId) { |
177 if (m_compositorPlayer->isLayerAttached()) | 178 if (m_compositorPlayer->isLayerAttached()) |
178 m_compositorPlayer->detachLayer(); | 179 m_compositorPlayer->detachLayer(); |
179 timeline->playerDestroyed(*this); | 180 timeline->playerDestroyed(*this); |
180 } | 181 } |
181 // Attach to new layer (if any). | 182 // Attach to new layer (if any). |
182 if (compositorAnimationAttachedToLayerId) { | 183 if (compositorAnimationAttachedToLayerId) { |
183 ASSERT(!m_compositorPlayer->isLayerAttached()); | 184 ASSERT(!m_compositorPlayer->isLayerAttached()); |
184 timeline->playerAttached(*this); | 185 timeline->playerAttached(*this); |
185 m_compositorPlayer->attachLayer( | 186 m_compositorPlayer->attachLayer( |
186 scrollableArea()->layerForScrolling()->platformLayer()); | 187 scrollableArea()->layerForScrolling()->platformLayer()); |
| 188 reattached = true; |
187 } | 189 } |
188 m_compositorAnimationAttachedToLayerId = compositorAnimationAttached
ToLayerId; | 190 m_compositorAnimationAttachedToLayerId = compositorAnimationAttached
ToLayerId; |
189 } | 191 } |
190 } | 192 } |
| 193 |
| 194 return reattached; |
191 } | 195 } |
192 | 196 |
193 void ScrollAnimatorCompositorCoordinator::notifyAnimationStarted( | 197 void ScrollAnimatorCompositorCoordinator::notifyAnimationStarted( |
194 double monotonicTime, int group) | 198 double monotonicTime, int group) |
195 { | 199 { |
196 } | 200 } |
197 | 201 |
198 void ScrollAnimatorCompositorCoordinator::notifyAnimationFinished( | 202 void ScrollAnimatorCompositorCoordinator::notifyAnimationFinished( |
199 double monotonicTime, int group) | 203 double monotonicTime, int group) |
200 { | 204 { |
201 notifyCompositorAnimationFinished(group); | 205 notifyCompositorAnimationFinished(group); |
202 } | 206 } |
203 | 207 |
204 void ScrollAnimatorCompositorCoordinator::notifyAnimationAborted( | 208 void ScrollAnimatorCompositorCoordinator::notifyAnimationAborted( |
205 double monotonicTime, int group) | 209 double monotonicTime, int group) |
206 { | 210 { |
207 // An animation aborted by the compositor is treated as a finished | 211 // An animation aborted by the compositor is treated as a finished |
208 // animation. | 212 // animation. |
209 notifyCompositorAnimationFinished(group); | 213 notifyCompositorAnimationFinished(group); |
210 } | 214 } |
211 | 215 |
212 CompositorAnimationPlayer* ScrollAnimatorCompositorCoordinator::compositorPlayer
() const | 216 CompositorAnimationPlayer* ScrollAnimatorCompositorCoordinator::compositorPlayer
() const |
213 { | 217 { |
214 return m_compositorPlayer.get(); | 218 return m_compositorPlayer.get(); |
215 } | 219 } |
216 | 220 |
217 } // namespace blink | 221 } // namespace blink |
OLD | NEW |