OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "ui/compositor/layer_animator_collection.h" |
| 6 |
| 7 #include <set> |
| 8 |
| 9 #include "base/time/time.h" |
| 10 #include "ui/compositor/layer_animator.h" |
| 11 #include "ui/gfx/frame_time.h" |
| 12 |
| 13 namespace ui { |
| 14 |
| 15 LayerAnimatorCollection::LayerAnimatorCollection( |
| 16 LayerAnimatorCollectionDelegate* delegate) |
| 17 : delegate_(delegate), |
| 18 last_tick_time_(gfx::FrameTime::Now()) { |
| 19 } |
| 20 |
| 21 LayerAnimatorCollection::~LayerAnimatorCollection() { |
| 22 } |
| 23 |
| 24 void LayerAnimatorCollection::StartAnimator( |
| 25 scoped_refptr<LayerAnimator> animator) { |
| 26 if (!animators_.size()) |
| 27 last_tick_time_ = gfx::FrameTime::Now(); |
| 28 animators_.insert(animator); |
| 29 if (delegate_) |
| 30 delegate_->ScheduleAnimationForLayerCollection(); |
| 31 } |
| 32 |
| 33 void LayerAnimatorCollection::StopAnimator( |
| 34 scoped_refptr<LayerAnimator> animator) { |
| 35 DCHECK_GT(animators_.count(animator), 0U); |
| 36 animators_.erase(animator); |
| 37 } |
| 38 |
| 39 bool LayerAnimatorCollection::HasActiveAnimators() const { |
| 40 return !animators_.empty(); |
| 41 } |
| 42 |
| 43 void LayerAnimatorCollection::Progress(base::TimeTicks now) { |
| 44 std::set<scoped_refptr<LayerAnimator> > list = animators_; |
| 45 for (std::set<scoped_refptr<LayerAnimator> >::iterator iter = list.begin(); |
| 46 iter != list.end(); |
| 47 ++iter) { |
| 48 // Make sure the animator is still valid. |
| 49 if (animators_.count(*iter) > 0) |
| 50 (*iter)->Step(now); |
| 51 } |
| 52 last_tick_time_ = now; |
| 53 } |
| 54 |
| 55 } // namespace ui |
OLD | NEW |