| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "ui/compositor/layer_animator_collection.h" | 5 #include "ui/compositor/layer_animator_collection.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 | 8 |
| 9 #include "base/time/time.h" | 9 #include "base/time/time.h" |
| 10 #include "ui/compositor/compositor.h" | 10 #include "ui/compositor/compositor.h" |
| 11 #include "ui/compositor/layer_animator.h" | 11 #include "ui/compositor/layer_animator.h" |
| 12 | 12 |
| 13 namespace ui { | 13 namespace ui { |
| 14 | 14 |
| 15 LayerAnimatorCollection::LayerAnimatorCollection(Compositor* compositor) | 15 LayerAnimatorCollection::LayerAnimatorCollection(Compositor* compositor) |
| 16 : compositor_(compositor), last_tick_time_(base::TimeTicks::Now()) { | 16 : compositor_(compositor), last_tick_time_(base::TimeTicks::Now()) { |
| 17 } | 17 } |
| 18 | 18 |
| 19 LayerAnimatorCollection::~LayerAnimatorCollection() { | 19 LayerAnimatorCollection::~LayerAnimatorCollection() { |
| 20 if (compositor_) | 20 if (compositor_) |
| 21 compositor_->RemoveAnimationObserver(this); | 21 compositor_->RemoveAnimationObserver(this); |
| 22 } | 22 } |
| 23 | 23 |
| 24 void LayerAnimatorCollection::StartAnimator( | 24 void LayerAnimatorCollection::StartAnimator( |
| 25 scoped_refptr<LayerAnimator> animator) { | 25 scoped_refptr<LayerAnimator> animator) { |
| 26 DCHECK_EQ(0U, animators_.count(animator)); | 26 DCHECK_EQ(0U, animators_.count(animator)); |
| 27 if (!animators_.size()) | 27 if (animators_.empty()) |
| 28 last_tick_time_ = base::TimeTicks::Now(); | 28 last_tick_time_ = base::TimeTicks::Now(); |
| 29 animators_.insert(animator); | 29 animators_.insert(animator); |
| 30 if (animators_.size() == 1U && compositor_) | 30 if (animators_.size() == 1U && compositor_) |
| 31 compositor_->AddAnimationObserver(this); | 31 compositor_->AddAnimationObserver(this); |
| 32 } | 32 } |
| 33 | 33 |
| 34 void LayerAnimatorCollection::StopAnimator( | 34 void LayerAnimatorCollection::StopAnimator( |
| 35 scoped_refptr<LayerAnimator> animator) { | 35 scoped_refptr<LayerAnimator> animator) { |
| 36 DCHECK_GT(animators_.count(animator), 0U); | 36 DCHECK_GT(animators_.count(animator), 0U); |
| 37 animators_.erase(animator); | 37 animators_.erase(animator); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 58 } | 58 } |
| 59 | 59 |
| 60 void LayerAnimatorCollection::OnCompositingShuttingDown( | 60 void LayerAnimatorCollection::OnCompositingShuttingDown( |
| 61 Compositor* compositor) { | 61 Compositor* compositor) { |
| 62 DCHECK_EQ(compositor_, compositor); | 62 DCHECK_EQ(compositor_, compositor); |
| 63 compositor_->RemoveAnimationObserver(this); | 63 compositor_->RemoveAnimationObserver(this); |
| 64 compositor_ = nullptr; | 64 compositor_ = nullptr; |
| 65 } | 65 } |
| 66 | 66 |
| 67 } // namespace ui | 67 } // namespace ui |
| OLD | NEW |