Chromium Code Reviews| 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_(base::WrapUnique(new PlayersList())), |
|
vmpstr
2016/04/08 00:53:55
I don't think you need this?
danakj
2016/04/08 00:59:01
Done.
| |
| 67 animation_host_(host) { | |
| 65 DCHECK(animation_host_); | 68 DCHECK(animation_host_); |
| 66 } | 69 } |
| 67 | 70 |
| 68 ElementAnimations::~ElementAnimations() { | 71 ElementAnimations::~ElementAnimations() { |
| 69 DCHECK(!layer_animation_controller_); | 72 DCHECK(!layer_animation_controller_); |
| 70 } | 73 } |
| 71 | 74 |
| 72 void ElementAnimations::CreateLayerAnimationController(int layer_id) { | 75 void ElementAnimations::CreateLayerAnimationController(int layer_id) { |
| 73 DCHECK(layer_id); | 76 DCHECK(layer_id); |
| 74 DCHECK(!layer_animation_controller_); | 77 DCHECK(!layer_animation_controller_); |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 204 animation_host() | 207 animation_host() |
| 205 ->mutator_host_client() | 208 ->mutator_host_client() |
| 206 ->LayerTransformIsPotentiallyAnimatingChanged(layer_id(), tree_type, | 209 ->LayerTransformIsPotentiallyAnimatingChanged(layer_id(), tree_type, |
| 207 is_animating); | 210 is_animating); |
| 208 } | 211 } |
| 209 | 212 |
| 210 void ElementAnimations::CreateActiveValueObserver() { | 213 void ElementAnimations::CreateActiveValueObserver() { |
| 211 DCHECK(layer_animation_controller_); | 214 DCHECK(layer_animation_controller_); |
| 212 DCHECK(!active_value_observer_); | 215 DCHECK(!active_value_observer_); |
| 213 active_value_observer_ = | 216 active_value_observer_ = |
| 214 make_scoped_ptr(new ValueObserver(this, LayerTreeType::ACTIVE)); | 217 base::WrapUnique(new ValueObserver(this, LayerTreeType::ACTIVE)); |
| 215 layer_animation_controller_->AddValueObserver(active_value_observer_.get()); | 218 layer_animation_controller_->AddValueObserver(active_value_observer_.get()); |
| 216 } | 219 } |
| 217 | 220 |
| 218 void ElementAnimations::DestroyActiveValueObserver() { | 221 void ElementAnimations::DestroyActiveValueObserver() { |
| 219 if (layer_animation_controller_ && active_value_observer_) | 222 if (layer_animation_controller_ && active_value_observer_) |
| 220 layer_animation_controller_->RemoveValueObserver( | 223 layer_animation_controller_->RemoveValueObserver( |
| 221 active_value_observer_.get()); | 224 active_value_observer_.get()); |
| 222 active_value_observer_ = nullptr; | 225 active_value_observer_ = nullptr; |
| 223 } | 226 } |
| 224 | 227 |
| 225 void ElementAnimations::CreatePendingValueObserver() { | 228 void ElementAnimations::CreatePendingValueObserver() { |
| 226 DCHECK(layer_animation_controller_); | 229 DCHECK(layer_animation_controller_); |
| 227 DCHECK(!pending_value_observer_); | 230 DCHECK(!pending_value_observer_); |
| 228 pending_value_observer_ = | 231 pending_value_observer_ = |
| 229 make_scoped_ptr(new ValueObserver(this, LayerTreeType::PENDING)); | 232 base::WrapUnique(new ValueObserver(this, LayerTreeType::PENDING)); |
| 230 layer_animation_controller_->AddValueObserver(pending_value_observer_.get()); | 233 layer_animation_controller_->AddValueObserver(pending_value_observer_.get()); |
| 231 } | 234 } |
| 232 | 235 |
| 233 void ElementAnimations::DestroyPendingValueObserver() { | 236 void ElementAnimations::DestroyPendingValueObserver() { |
| 234 if (layer_animation_controller_ && pending_value_observer_) | 237 if (layer_animation_controller_ && pending_value_observer_) |
| 235 layer_animation_controller_->RemoveValueObserver( | 238 layer_animation_controller_->RemoveValueObserver( |
| 236 pending_value_observer_.get()); | 239 pending_value_observer_.get()); |
| 237 pending_value_observer_ = nullptr; | 240 pending_value_observer_ = nullptr; |
| 238 } | 241 } |
| 239 | 242 |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 267 node != players_list_->end(); node = node->next()) { | 270 node != players_list_->end(); node = node->next()) { |
| 268 AnimationPlayer* player = node->value(); | 271 AnimationPlayer* player = node->value(); |
| 269 player->NotifyAnimationAborted(monotonic_time, target_property, group); | 272 player->NotifyAnimationAborted(monotonic_time, target_property, group); |
| 270 } | 273 } |
| 271 } | 274 } |
| 272 | 275 |
| 273 void ElementAnimations::NotifyAnimationTakeover( | 276 void ElementAnimations::NotifyAnimationTakeover( |
| 274 base::TimeTicks monotonic_time, | 277 base::TimeTicks monotonic_time, |
| 275 TargetProperty::Type target_property, | 278 TargetProperty::Type target_property, |
| 276 double animation_start_time, | 279 double animation_start_time, |
| 277 scoped_ptr<AnimationCurve> curve) { | 280 std::unique_ptr<AnimationCurve> curve) { |
| 278 DCHECK(curve); | 281 DCHECK(curve); |
| 279 for (PlayersListNode* node = players_list_->head(); | 282 for (PlayersListNode* node = players_list_->head(); |
| 280 node != players_list_->end(); node = node->next()) { | 283 node != players_list_->end(); node = node->next()) { |
| 281 scoped_ptr<AnimationCurve> animation_curve = curve->Clone(); | 284 std::unique_ptr<AnimationCurve> animation_curve = curve->Clone(); |
| 282 AnimationPlayer* player = node->value(); | 285 AnimationPlayer* player = node->value(); |
| 283 player->NotifyAnimationTakeover(monotonic_time, target_property, | 286 player->NotifyAnimationTakeover(monotonic_time, target_property, |
| 284 animation_start_time, | 287 animation_start_time, |
| 285 std::move(animation_curve)); | 288 std::move(animation_curve)); |
| 286 } | 289 } |
| 287 } | 290 } |
| 288 | 291 |
| 289 gfx::ScrollOffset ElementAnimations::ScrollOffsetForAnimation() const { | 292 gfx::ScrollOffset ElementAnimations::ScrollOffsetForAnimation() const { |
| 290 DCHECK(layer_animation_controller_); | 293 DCHECK(layer_animation_controller_); |
| 291 if (animation_host()) { | 294 if (animation_host()) { |
| 292 DCHECK(animation_host()->mutator_host_client()); | 295 DCHECK(animation_host()->mutator_host_client()); |
| 293 return animation_host()->mutator_host_client()->GetScrollOffsetForAnimation( | 296 return animation_host()->mutator_host_client()->GetScrollOffsetForAnimation( |
| 294 layer_id()); | 297 layer_id()); |
| 295 } | 298 } |
| 296 | 299 |
| 297 return gfx::ScrollOffset(); | 300 return gfx::ScrollOffset(); |
| 298 } | 301 } |
| 299 | 302 |
| 300 } // namespace cc | 303 } // namespace cc |
| OLD | NEW |