| 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 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 209 AnimationPlayer* player) { | 209 AnimationPlayer* player) { |
| 210 DCHECK(layer_id); | 210 DCHECK(layer_id); |
| 211 DCHECK(player); | 211 DCHECK(player); |
| 212 | 212 |
| 213 ElementAnimations* element_animations = | 213 ElementAnimations* element_animations = |
| 214 GetElementAnimationsForLayerId(layer_id); | 214 GetElementAnimationsForLayerId(layer_id); |
| 215 if (!element_animations) { | 215 if (!element_animations) { |
| 216 auto new_element_animations = ElementAnimations::Create(this); | 216 auto new_element_animations = ElementAnimations::Create(this); |
| 217 element_animations = new_element_animations.get(); | 217 element_animations = new_element_animations.get(); |
| 218 | 218 |
| 219 layer_to_element_animations_map_.add(layer_id, | 219 layer_to_element_animations_map_[layer_id] = |
| 220 std::move(new_element_animations)); | 220 std::move(new_element_animations); |
| 221 element_animations->CreateLayerAnimationController(layer_id); | 221 element_animations->CreateLayerAnimationController(layer_id); |
| 222 } | 222 } |
| 223 | 223 |
| 224 DCHECK(element_animations); | 224 DCHECK(element_animations); |
| 225 element_animations->AddPlayer(player); | 225 element_animations->AddPlayer(player); |
| 226 } | 226 } |
| 227 | 227 |
| 228 void AnimationHost::UnregisterPlayerForLayer(int layer_id, | 228 void AnimationHost::UnregisterPlayerForLayer(int layer_id, |
| 229 AnimationPlayer* player) { | 229 AnimationPlayer* player) { |
| 230 DCHECK(layer_id); | 230 DCHECK(layer_id); |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 296 // layer animation controllers. | 296 // layer animation controllers. |
| 297 for (auto& timeline : timelines_) { | 297 for (auto& timeline : timelines_) { |
| 298 AnimationTimeline* timeline_impl = | 298 AnimationTimeline* timeline_impl = |
| 299 host_impl->GetTimelineById(timeline->id()); | 299 host_impl->GetTimelineById(timeline->id()); |
| 300 if (timeline_impl) | 300 if (timeline_impl) |
| 301 timeline->PushPropertiesTo(timeline_impl); | 301 timeline->PushPropertiesTo(timeline_impl); |
| 302 } | 302 } |
| 303 | 303 |
| 304 // Secondly, sync properties for created layer animation controllers. | 304 // Secondly, sync properties for created layer animation controllers. |
| 305 for (auto& kv : layer_to_element_animations_map_) { | 305 for (auto& kv : layer_to_element_animations_map_) { |
| 306 ElementAnimations* element_animations = kv.second; | 306 ElementAnimations* element_animations = kv.second.get(); |
| 307 ElementAnimations* element_animations_impl = | 307 ElementAnimations* element_animations_impl = |
| 308 host_impl->GetElementAnimationsForLayerId(kv.first); | 308 host_impl->GetElementAnimationsForLayerId(kv.first); |
| 309 if (element_animations_impl) | 309 if (element_animations_impl) |
| 310 element_animations->PushPropertiesTo(element_animations_impl); | 310 element_animations->PushPropertiesTo(element_animations_impl); |
| 311 } | 311 } |
| 312 } | 312 } |
| 313 | 313 |
| 314 LayerAnimationController* AnimationHost::GetControllerForLayerId( | 314 LayerAnimationController* AnimationHost::GetControllerForLayerId( |
| 315 int layer_id) const { | 315 int layer_id) const { |
| 316 const ElementAnimations* element_animations = | 316 const ElementAnimations* element_animations = |
| 317 GetElementAnimationsForLayerId(layer_id); | 317 GetElementAnimationsForLayerId(layer_id); |
| 318 if (!element_animations) | 318 if (!element_animations) |
| 319 return nullptr; | 319 return nullptr; |
| 320 | 320 |
| 321 return element_animations->layer_animation_controller(); | 321 return element_animations->layer_animation_controller(); |
| 322 } | 322 } |
| 323 | 323 |
| 324 ElementAnimations* AnimationHost::GetElementAnimationsForLayerId( | 324 ElementAnimations* AnimationHost::GetElementAnimationsForLayerId( |
| 325 int layer_id) const { | 325 int layer_id) const { |
| 326 DCHECK(layer_id); | 326 DCHECK(layer_id); |
| 327 auto iter = layer_to_element_animations_map_.find(layer_id); | 327 auto iter = layer_to_element_animations_map_.find(layer_id); |
| 328 return iter == layer_to_element_animations_map_.end() ? nullptr | 328 return iter == layer_to_element_animations_map_.end() ? nullptr |
| 329 : iter->second; | 329 : iter->second.get(); |
| 330 } | 330 } |
| 331 | 331 |
| 332 void AnimationHost::SetSupportsScrollAnimations( | 332 void AnimationHost::SetSupportsScrollAnimations( |
| 333 bool supports_scroll_animations) { | 333 bool supports_scroll_animations) { |
| 334 animation_registrar_->set_supports_scroll_animations( | 334 animation_registrar_->set_supports_scroll_animations( |
| 335 supports_scroll_animations); | 335 supports_scroll_animations); |
| 336 } | 336 } |
| 337 | 337 |
| 338 bool AnimationHost::SupportsScrollAnimations() const { | 338 bool AnimationHost::SupportsScrollAnimations() const { |
| 339 return animation_registrar_->supports_scroll_animations(); | 339 return animation_registrar_->supports_scroll_animations(); |
| (...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 569 int layer_id, | 569 int layer_id, |
| 570 const gfx::Vector2dF& scroll_delta, | 570 const gfx::Vector2dF& scroll_delta, |
| 571 const gfx::ScrollOffset& max_scroll_offset, | 571 const gfx::ScrollOffset& max_scroll_offset, |
| 572 base::TimeTicks frame_monotonic_time) { | 572 base::TimeTicks frame_monotonic_time) { |
| 573 DCHECK(scroll_offset_animations_); | 573 DCHECK(scroll_offset_animations_); |
| 574 return scroll_offset_animations_->ScrollAnimationUpdateTarget( | 574 return scroll_offset_animations_->ScrollAnimationUpdateTarget( |
| 575 layer_id, scroll_delta, max_scroll_offset, frame_monotonic_time); | 575 layer_id, scroll_delta, max_scroll_offset, frame_monotonic_time); |
| 576 } | 576 } |
| 577 | 577 |
| 578 } // namespace cc | 578 } // namespace cc |
| OLD | NEW |