| 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/element_animations.h" | 5 #include "cc/animation/element_animations.h" |
| 6 | 6 |
| 7 #include "base/macros.h" | 7 #include "base/macros.h" |
| 8 #include "base/memory/ptr_util.h" | 8 #include "base/memory/ptr_util.h" |
| 9 #include "cc/animation/animation_host.h" | 9 #include "cc/animation/animation_host.h" |
| 10 #include "cc/animation/animation_player.h" | 10 #include "cc/animation/animation_player.h" |
| 11 #include "cc/animation/animation_registrar.h" | |
| 12 #include "cc/animation/layer_animation_value_observer.h" | 11 #include "cc/animation/layer_animation_value_observer.h" |
| 13 #include "cc/trees/mutator_host_client.h" | 12 #include "cc/trees/mutator_host_client.h" |
| 14 | 13 |
| 15 namespace cc { | 14 namespace cc { |
| 16 | 15 |
| 17 class ElementAnimations::ValueObserver : public LayerAnimationValueObserver { | 16 class ElementAnimations::ValueObserver : public LayerAnimationValueObserver { |
| 18 public: | 17 public: |
| 19 ValueObserver(ElementAnimations* element_animation, LayerTreeType tree_type) | 18 ValueObserver(ElementAnimations* element_animation, LayerTreeType tree_type) |
| 20 : element_animations_(element_animation), tree_type_(tree_type) { | 19 : element_animations_(element_animation), tree_type_(tree_type) { |
| 21 DCHECK(element_animations_); | 20 DCHECK(element_animations_); |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 | 68 |
| 70 ElementAnimations::~ElementAnimations() { | 69 ElementAnimations::~ElementAnimations() { |
| 71 DCHECK(!layer_animation_controller_); | 70 DCHECK(!layer_animation_controller_); |
| 72 } | 71 } |
| 73 | 72 |
| 74 void ElementAnimations::CreateLayerAnimationController(int layer_id) { | 73 void ElementAnimations::CreateLayerAnimationController(int layer_id) { |
| 75 DCHECK(layer_id); | 74 DCHECK(layer_id); |
| 76 DCHECK(!layer_animation_controller_); | 75 DCHECK(!layer_animation_controller_); |
| 77 DCHECK(animation_host_); | 76 DCHECK(animation_host_); |
| 78 | 77 |
| 79 AnimationRegistrar* registrar = animation_host_->animation_registrar(); | |
| 80 DCHECK(registrar); | |
| 81 | |
| 82 layer_animation_controller_ = | 78 layer_animation_controller_ = |
| 83 registrar->GetAnimationControllerForId(layer_id); | 79 animation_host_->GetAnimationControllerForId(layer_id); |
| 84 layer_animation_controller_->SetAnimationRegistrar(registrar); | 80 animation_host_->SetAnimationRegistrarFor(layer_animation_controller_); |
| 85 layer_animation_controller_->set_layer_animation_delegate(this); | 81 layer_animation_controller_->set_layer_animation_delegate(this); |
| 86 layer_animation_controller_->set_value_provider(this); | 82 layer_animation_controller_->set_value_provider(this); |
| 87 | 83 |
| 88 DCHECK(animation_host_->mutator_host_client()); | 84 DCHECK(animation_host_->mutator_host_client()); |
| 89 if (animation_host_->mutator_host_client()->IsLayerInTree( | 85 if (animation_host_->mutator_host_client()->IsLayerInTree( |
| 90 layer_id, LayerTreeType::ACTIVE)) | 86 layer_id, LayerTreeType::ACTIVE)) |
| 91 CreateActiveValueObserver(); | 87 CreateActiveValueObserver(); |
| 92 if (animation_host_->mutator_host_client()->IsLayerInTree( | 88 if (animation_host_->mutator_host_client()->IsLayerInTree( |
| 93 layer_id, LayerTreeType::PENDING)) | 89 layer_id, LayerTreeType::PENDING)) |
| 94 CreatePendingValueObserver(); | 90 CreatePendingValueObserver(); |
| 95 } | 91 } |
| 96 | 92 |
| 97 void ElementAnimations::DestroyLayerAnimationController() { | 93 void ElementAnimations::DestroyLayerAnimationController() { |
| 98 DCHECK(animation_host_); | 94 DCHECK(animation_host_); |
| 99 | 95 |
| 100 if (active_value_observer_) | 96 if (active_value_observer_) |
| 101 SetTransformIsPotentiallyAnimatingChanged(LayerTreeType::ACTIVE, false); | 97 SetTransformIsPotentiallyAnimatingChanged(LayerTreeType::ACTIVE, false); |
| 102 if (pending_value_observer_) | 98 if (pending_value_observer_) |
| 103 SetTransformIsPotentiallyAnimatingChanged(LayerTreeType::PENDING, false); | 99 SetTransformIsPotentiallyAnimatingChanged(LayerTreeType::PENDING, false); |
| 104 | 100 |
| 105 DestroyPendingValueObserver(); | 101 DestroyPendingValueObserver(); |
| 106 DestroyActiveValueObserver(); | 102 DestroyActiveValueObserver(); |
| 107 | 103 |
| 108 if (layer_animation_controller_) { | 104 if (layer_animation_controller_) { |
| 109 layer_animation_controller_->remove_value_provider(this); | 105 layer_animation_controller_->remove_value_provider(this); |
| 110 layer_animation_controller_->remove_layer_animation_delegate(this); | 106 layer_animation_controller_->remove_layer_animation_delegate(this); |
| 111 layer_animation_controller_->SetAnimationRegistrar(nullptr); | 107 animation_host_->ResetAnimationRegistrarFor(layer_animation_controller_); |
| 112 layer_animation_controller_ = nullptr; | 108 layer_animation_controller_ = nullptr; |
| 113 } | 109 } |
| 114 } | 110 } |
| 115 | 111 |
| 116 void ElementAnimations::LayerRegistered(int layer_id, LayerTreeType tree_type) { | 112 void ElementAnimations::LayerRegistered(int layer_id, LayerTreeType tree_type) { |
| 117 DCHECK(layer_animation_controller_); | 113 DCHECK(layer_animation_controller_); |
| 118 DCHECK_EQ(layer_animation_controller_->id(), layer_id); | 114 DCHECK_EQ(layer_animation_controller_->id(), layer_id); |
| 119 | 115 |
| 120 if (tree_type == LayerTreeType::ACTIVE) { | 116 if (tree_type == LayerTreeType::ACTIVE) { |
| 121 if (!active_value_observer_) | 117 if (!active_value_observer_) |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 293 if (animation_host()) { | 289 if (animation_host()) { |
| 294 DCHECK(animation_host()->mutator_host_client()); | 290 DCHECK(animation_host()->mutator_host_client()); |
| 295 return animation_host()->mutator_host_client()->GetScrollOffsetForAnimation( | 291 return animation_host()->mutator_host_client()->GetScrollOffsetForAnimation( |
| 296 layer_id()); | 292 layer_id()); |
| 297 } | 293 } |
| 298 | 294 |
| 299 return gfx::ScrollOffset(); | 295 return gfx::ScrollOffset(); |
| 300 } | 296 } |
| 301 | 297 |
| 302 } // namespace cc | 298 } // namespace cc |
| OLD | NEW |