| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "cc/animation/animation_host.h" | 5 #include "cc/animation/animation_host.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "cc/animation/animation_delegate.h" | 10 #include "cc/animation/animation_delegate.h" |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 218 AnimationPlayer* player) { | 218 AnimationPlayer* player) { |
| 219 DCHECK(layer_id); | 219 DCHECK(layer_id); |
| 220 DCHECK(player); | 220 DCHECK(player); |
| 221 | 221 |
| 222 ElementAnimations* element_animations = | 222 ElementAnimations* element_animations = |
| 223 GetElementAnimationsForLayerId(layer_id); | 223 GetElementAnimationsForLayerId(layer_id); |
| 224 if (!element_animations) { | 224 if (!element_animations) { |
| 225 auto new_element_animations = ElementAnimations::Create(this); | 225 auto new_element_animations = ElementAnimations::Create(this); |
| 226 element_animations = new_element_animations.get(); | 226 element_animations = new_element_animations.get(); |
| 227 | 227 |
| 228 layer_to_element_animations_map_.add(layer_id, | 228 layer_to_element_animations_map_[layer_id] = |
| 229 std::move(new_element_animations)); | 229 std::move(new_element_animations); |
| 230 element_animations->CreateLayerAnimationController(layer_id); | 230 element_animations->CreateLayerAnimationController(layer_id); |
| 231 } | 231 } |
| 232 | 232 |
| 233 DCHECK(element_animations); | 233 DCHECK(element_animations); |
| 234 element_animations->AddPlayer(player); | 234 element_animations->AddPlayer(player); |
| 235 } | 235 } |
| 236 | 236 |
| 237 void AnimationHost::UnregisterPlayerForLayer(int layer_id, | 237 void AnimationHost::UnregisterPlayerForLayer(int layer_id, |
| 238 AnimationPlayer* player) { | 238 AnimationPlayer* player) { |
| 239 DCHECK(layer_id); | 239 DCHECK(layer_id); |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 305 // layer animation controllers. | 305 // layer animation controllers. |
| 306 for (auto& timeline : timelines_) { | 306 for (auto& timeline : timelines_) { |
| 307 AnimationTimeline* timeline_impl = | 307 AnimationTimeline* timeline_impl = |
| 308 host_impl->GetTimelineById(timeline->id()); | 308 host_impl->GetTimelineById(timeline->id()); |
| 309 if (timeline_impl) | 309 if (timeline_impl) |
| 310 timeline->PushPropertiesTo(timeline_impl); | 310 timeline->PushPropertiesTo(timeline_impl); |
| 311 } | 311 } |
| 312 | 312 |
| 313 // Secondly, sync properties for created layer animation controllers. | 313 // Secondly, sync properties for created layer animation controllers. |
| 314 for (auto& kv : layer_to_element_animations_map_) { | 314 for (auto& kv : layer_to_element_animations_map_) { |
| 315 ElementAnimations* element_animations = kv.second; | 315 ElementAnimations* element_animations = kv.second.get(); |
| 316 ElementAnimations* element_animations_impl = | 316 ElementAnimations* element_animations_impl = |
| 317 host_impl->GetElementAnimationsForLayerId(kv.first); | 317 host_impl->GetElementAnimationsForLayerId(kv.first); |
| 318 if (element_animations_impl) | 318 if (element_animations_impl) |
| 319 element_animations->PushPropertiesTo(element_animations_impl); | 319 element_animations->PushPropertiesTo(element_animations_impl); |
| 320 } | 320 } |
| 321 } | 321 } |
| 322 | 322 |
| 323 LayerAnimationController* AnimationHost::GetControllerForLayerId( | 323 LayerAnimationController* AnimationHost::GetControllerForLayerId( |
| 324 int layer_id) const { | 324 int layer_id) const { |
| 325 const ElementAnimations* element_animations = | 325 const ElementAnimations* element_animations = |
| 326 GetElementAnimationsForLayerId(layer_id); | 326 GetElementAnimationsForLayerId(layer_id); |
| 327 if (!element_animations) | 327 if (!element_animations) |
| 328 return nullptr; | 328 return nullptr; |
| 329 | 329 |
| 330 return element_animations->layer_animation_controller(); | 330 return element_animations->layer_animation_controller(); |
| 331 } | 331 } |
| 332 | 332 |
| 333 ElementAnimations* AnimationHost::GetElementAnimationsForLayerId( | 333 ElementAnimations* AnimationHost::GetElementAnimationsForLayerId( |
| 334 int layer_id) const { | 334 int layer_id) const { |
| 335 DCHECK(layer_id); | 335 DCHECK(layer_id); |
| 336 auto iter = layer_to_element_animations_map_.find(layer_id); | 336 auto iter = layer_to_element_animations_map_.find(layer_id); |
| 337 return iter == layer_to_element_animations_map_.end() ? nullptr | 337 return iter == layer_to_element_animations_map_.end() ? nullptr |
| 338 : iter->second; | 338 : iter->second.get(); |
| 339 } | 339 } |
| 340 | 340 |
| 341 void AnimationHost::SetSupportsScrollAnimations( | 341 void AnimationHost::SetSupportsScrollAnimations( |
| 342 bool supports_scroll_animations) { | 342 bool supports_scroll_animations) { |
| 343 animation_registrar_->set_supports_scroll_animations( | 343 animation_registrar_->set_supports_scroll_animations( |
| 344 supports_scroll_animations); | 344 supports_scroll_animations); |
| 345 } | 345 } |
| 346 | 346 |
| 347 bool AnimationHost::SupportsScrollAnimations() const { | 347 bool AnimationHost::SupportsScrollAnimations() const { |
| 348 return animation_registrar_->supports_scroll_animations(); | 348 return animation_registrar_->supports_scroll_animations(); |
| (...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 582 return scroll_offset_animations_->ScrollAnimationUpdateTarget( | 582 return scroll_offset_animations_->ScrollAnimationUpdateTarget( |
| 583 layer_id, scroll_delta, max_scroll_offset, frame_monotonic_time); | 583 layer_id, scroll_delta, max_scroll_offset, frame_monotonic_time); |
| 584 } | 584 } |
| 585 | 585 |
| 586 void AnimationHost::ScrollAnimationAbort() { | 586 void AnimationHost::ScrollAnimationAbort() { |
| 587 DCHECK(scroll_offset_animations_); | 587 DCHECK(scroll_offset_animations_); |
| 588 return scroll_offset_animations_->ScrollAnimationAbort(); | 588 return scroll_offset_animations_->ScrollAnimationAbort(); |
| 589 } | 589 } |
| 590 | 590 |
| 591 } // namespace cc | 591 } // namespace cc |
| OLD | NEW |