| 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 "cc/animation/animation_host.h" | 9 #include "cc/animation/animation_host.h" |
| 9 #include "cc/animation/animation_player.h" | 10 #include "cc/animation/animation_player.h" |
| 10 #include "cc/animation/animation_registrar.h" | 11 #include "cc/animation/animation_registrar.h" |
| 11 #include "cc/animation/layer_animation_value_observer.h" | 12 #include "cc/animation/layer_animation_value_observer.h" |
| 12 #include "cc/trees/mutator_host_client.h" | 13 #include "cc/trees/mutator_host_client.h" |
| 13 | 14 |
| 14 namespace cc { | 15 namespace cc { |
| 15 | 16 |
| 16 class ElementAnimations::ValueObserver : public LayerAnimationValueObserver { | 17 class ElementAnimations::ValueObserver : public LayerAnimationValueObserver { |
| 17 public: | 18 public: |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 | 50 |
| 50 bool IsActive() const override { return tree_type_ == LayerTreeType::ACTIVE; } | 51 bool IsActive() const override { return tree_type_ == LayerTreeType::ACTIVE; } |
| 51 | 52 |
| 52 private: | 53 private: |
| 53 ElementAnimations* element_animations_; | 54 ElementAnimations* element_animations_; |
| 54 const LayerTreeType tree_type_; | 55 const LayerTreeType tree_type_; |
| 55 | 56 |
| 56 DISALLOW_COPY_AND_ASSIGN(ValueObserver); | 57 DISALLOW_COPY_AND_ASSIGN(ValueObserver); |
| 57 }; | 58 }; |
| 58 | 59 |
| 59 scoped_ptr<ElementAnimations> ElementAnimations::Create(AnimationHost* host) { | 60 std::unique_ptr<ElementAnimations> ElementAnimations::Create( |
| 60 return make_scoped_ptr(new ElementAnimations(host)); | 61 AnimationHost* host) { |
| 62 return base::WrapUnique(new ElementAnimations(host)); |
| 61 } | 63 } |
| 62 | 64 |
| 63 ElementAnimations::ElementAnimations(AnimationHost* host) | 65 ElementAnimations::ElementAnimations(AnimationHost* host) |
| 64 : players_list_(make_scoped_ptr(new PlayersList())), animation_host_(host) { | 66 : players_list_(new PlayersList()), animation_host_(host) { |
| 65 DCHECK(animation_host_); | 67 DCHECK(animation_host_); |
| 66 } | 68 } |
| 67 | 69 |
| 68 ElementAnimations::~ElementAnimations() { | 70 ElementAnimations::~ElementAnimations() { |
| 69 DCHECK(!layer_animation_controller_); | 71 DCHECK(!layer_animation_controller_); |
| 70 } | 72 } |
| 71 | 73 |
| 72 void ElementAnimations::CreateLayerAnimationController(int layer_id) { | 74 void ElementAnimations::CreateLayerAnimationController(int layer_id) { |
| 73 DCHECK(layer_id); | 75 DCHECK(layer_id); |
| 74 DCHECK(!layer_animation_controller_); | 76 DCHECK(!layer_animation_controller_); |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 animation_host() | 206 animation_host() |
| 205 ->mutator_host_client() | 207 ->mutator_host_client() |
| 206 ->LayerTransformIsPotentiallyAnimatingChanged(layer_id(), tree_type, | 208 ->LayerTransformIsPotentiallyAnimatingChanged(layer_id(), tree_type, |
| 207 is_animating); | 209 is_animating); |
| 208 } | 210 } |
| 209 | 211 |
| 210 void ElementAnimations::CreateActiveValueObserver() { | 212 void ElementAnimations::CreateActiveValueObserver() { |
| 211 DCHECK(layer_animation_controller_); | 213 DCHECK(layer_animation_controller_); |
| 212 DCHECK(!active_value_observer_); | 214 DCHECK(!active_value_observer_); |
| 213 active_value_observer_ = | 215 active_value_observer_ = |
| 214 make_scoped_ptr(new ValueObserver(this, LayerTreeType::ACTIVE)); | 216 base::WrapUnique(new ValueObserver(this, LayerTreeType::ACTIVE)); |
| 215 layer_animation_controller_->AddValueObserver(active_value_observer_.get()); | 217 layer_animation_controller_->AddValueObserver(active_value_observer_.get()); |
| 216 } | 218 } |
| 217 | 219 |
| 218 void ElementAnimations::DestroyActiveValueObserver() { | 220 void ElementAnimations::DestroyActiveValueObserver() { |
| 219 if (layer_animation_controller_ && active_value_observer_) | 221 if (layer_animation_controller_ && active_value_observer_) |
| 220 layer_animation_controller_->RemoveValueObserver( | 222 layer_animation_controller_->RemoveValueObserver( |
| 221 active_value_observer_.get()); | 223 active_value_observer_.get()); |
| 222 active_value_observer_ = nullptr; | 224 active_value_observer_ = nullptr; |
| 223 } | 225 } |
| 224 | 226 |
| 225 void ElementAnimations::CreatePendingValueObserver() { | 227 void ElementAnimations::CreatePendingValueObserver() { |
| 226 DCHECK(layer_animation_controller_); | 228 DCHECK(layer_animation_controller_); |
| 227 DCHECK(!pending_value_observer_); | 229 DCHECK(!pending_value_observer_); |
| 228 pending_value_observer_ = | 230 pending_value_observer_ = |
| 229 make_scoped_ptr(new ValueObserver(this, LayerTreeType::PENDING)); | 231 base::WrapUnique(new ValueObserver(this, LayerTreeType::PENDING)); |
| 230 layer_animation_controller_->AddValueObserver(pending_value_observer_.get()); | 232 layer_animation_controller_->AddValueObserver(pending_value_observer_.get()); |
| 231 } | 233 } |
| 232 | 234 |
| 233 void ElementAnimations::DestroyPendingValueObserver() { | 235 void ElementAnimations::DestroyPendingValueObserver() { |
| 234 if (layer_animation_controller_ && pending_value_observer_) | 236 if (layer_animation_controller_ && pending_value_observer_) |
| 235 layer_animation_controller_->RemoveValueObserver( | 237 layer_animation_controller_->RemoveValueObserver( |
| 236 pending_value_observer_.get()); | 238 pending_value_observer_.get()); |
| 237 pending_value_observer_ = nullptr; | 239 pending_value_observer_ = nullptr; |
| 238 } | 240 } |
| 239 | 241 |
| (...skipping 27 matching lines...) Expand all Loading... |
| 267 node != players_list_->end(); node = node->next()) { | 269 node != players_list_->end(); node = node->next()) { |
| 268 AnimationPlayer* player = node->value(); | 270 AnimationPlayer* player = node->value(); |
| 269 player->NotifyAnimationAborted(monotonic_time, target_property, group); | 271 player->NotifyAnimationAborted(monotonic_time, target_property, group); |
| 270 } | 272 } |
| 271 } | 273 } |
| 272 | 274 |
| 273 void ElementAnimations::NotifyAnimationTakeover( | 275 void ElementAnimations::NotifyAnimationTakeover( |
| 274 base::TimeTicks monotonic_time, | 276 base::TimeTicks monotonic_time, |
| 275 TargetProperty::Type target_property, | 277 TargetProperty::Type target_property, |
| 276 double animation_start_time, | 278 double animation_start_time, |
| 277 scoped_ptr<AnimationCurve> curve) { | 279 std::unique_ptr<AnimationCurve> curve) { |
| 278 DCHECK(curve); | 280 DCHECK(curve); |
| 279 for (PlayersListNode* node = players_list_->head(); | 281 for (PlayersListNode* node = players_list_->head(); |
| 280 node != players_list_->end(); node = node->next()) { | 282 node != players_list_->end(); node = node->next()) { |
| 281 scoped_ptr<AnimationCurve> animation_curve = curve->Clone(); | 283 std::unique_ptr<AnimationCurve> animation_curve = curve->Clone(); |
| 282 AnimationPlayer* player = node->value(); | 284 AnimationPlayer* player = node->value(); |
| 283 player->NotifyAnimationTakeover(monotonic_time, target_property, | 285 player->NotifyAnimationTakeover(monotonic_time, target_property, |
| 284 animation_start_time, | 286 animation_start_time, |
| 285 std::move(animation_curve)); | 287 std::move(animation_curve)); |
| 286 } | 288 } |
| 287 } | 289 } |
| 288 | 290 |
| 289 gfx::ScrollOffset ElementAnimations::ScrollOffsetForAnimation() const { | 291 gfx::ScrollOffset ElementAnimations::ScrollOffsetForAnimation() const { |
| 290 DCHECK(layer_animation_controller_); | 292 DCHECK(layer_animation_controller_); |
| 291 if (animation_host()) { | 293 if (animation_host()) { |
| 292 DCHECK(animation_host()->mutator_host_client()); | 294 DCHECK(animation_host()->mutator_host_client()); |
| 293 return animation_host()->mutator_host_client()->GetScrollOffsetForAnimation( | 295 return animation_host()->mutator_host_client()->GetScrollOffsetForAnimation( |
| 294 layer_id()); | 296 layer_id()); |
| 295 } | 297 } |
| 296 | 298 |
| 297 return gfx::ScrollOffset(); | 299 return gfx::ScrollOffset(); |
| 298 } | 300 } |
| 299 | 301 |
| 300 } // namespace cc | 302 } // namespace cc |
| OLD | NEW |