| 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 #include "ui/gfx/frame_time.h" | |
| 13 | 12 |
| 14 namespace ui { | 13 namespace ui { |
| 15 | 14 |
| 16 LayerAnimatorCollection::LayerAnimatorCollection(Compositor* compositor) | 15 LayerAnimatorCollection::LayerAnimatorCollection(Compositor* compositor) |
| 17 : compositor_(compositor), last_tick_time_(gfx::FrameTime::Now()) { | 16 : compositor_(compositor), last_tick_time_(base::TimeTicks::Now()) { |
| 18 } | 17 } |
| 19 | 18 |
| 20 LayerAnimatorCollection::~LayerAnimatorCollection() { | 19 LayerAnimatorCollection::~LayerAnimatorCollection() { |
| 21 if (compositor_ && compositor_->HasAnimationObserver(this)) | 20 if (compositor_ && compositor_->HasAnimationObserver(this)) |
| 22 compositor_->RemoveAnimationObserver(this); | 21 compositor_->RemoveAnimationObserver(this); |
| 23 } | 22 } |
| 24 | 23 |
| 25 void LayerAnimatorCollection::StartAnimator( | 24 void LayerAnimatorCollection::StartAnimator( |
| 26 scoped_refptr<LayerAnimator> animator) { | 25 scoped_refptr<LayerAnimator> animator) { |
| 27 DCHECK_EQ(0U, animators_.count(animator)); | 26 DCHECK_EQ(0U, animators_.count(animator)); |
| 28 if (!animators_.size()) | 27 if (!animators_.size()) |
| 29 last_tick_time_ = gfx::FrameTime::Now(); | 28 last_tick_time_ = base::TimeTicks::Now(); |
| 30 animators_.insert(animator); | 29 animators_.insert(animator); |
| 31 if (animators_.size() == 1U && compositor_) | 30 if (animators_.size() == 1U && compositor_) |
| 32 compositor_->AddAnimationObserver(this); | 31 compositor_->AddAnimationObserver(this); |
| 33 } | 32 } |
| 34 | 33 |
| 35 void LayerAnimatorCollection::StopAnimator( | 34 void LayerAnimatorCollection::StopAnimator( |
| 36 scoped_refptr<LayerAnimator> animator) { | 35 scoped_refptr<LayerAnimator> animator) { |
| 37 DCHECK_GT(animators_.count(animator), 0U); | 36 DCHECK_GT(animators_.count(animator), 0U); |
| 38 animators_.erase(animator); | 37 animators_.erase(animator); |
| 39 if (animators_.empty() && compositor_) | 38 if (animators_.empty() && compositor_) |
| (...skipping 12 matching lines...) Expand all Loading... |
| 52 ++iter) { | 51 ++iter) { |
| 53 // Make sure the animator is still valid. | 52 // Make sure the animator is still valid. |
| 54 if (animators_.count(*iter) > 0) | 53 if (animators_.count(*iter) > 0) |
| 55 (*iter)->Step(now); | 54 (*iter)->Step(now); |
| 56 } | 55 } |
| 57 if (!HasActiveAnimators() && compositor_) | 56 if (!HasActiveAnimators() && compositor_) |
| 58 compositor_->RemoveAnimationObserver(this); | 57 compositor_->RemoveAnimationObserver(this); |
| 59 } | 58 } |
| 60 | 59 |
| 61 } // namespace ui | 60 } // namespace ui |
| OLD | NEW |