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_ && compositor_->HasAnimationObserver(this)) | 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_.size()) |
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_) |
(...skipping 19 matching lines...) Expand all Loading... | |
50 iter != list.end(); | 50 iter != list.end(); |
51 ++iter) { | 51 ++iter) { |
52 // Make sure the animator is still valid. | 52 // Make sure the animator is still valid. |
53 if (animators_.count(*iter) > 0) | 53 if (animators_.count(*iter) > 0) |
54 (*iter)->Step(now); | 54 (*iter)->Step(now); |
55 } | 55 } |
56 if (!HasActiveAnimators() && compositor_) | 56 if (!HasActiveAnimators() && compositor_) |
57 compositor_->RemoveAnimationObserver(this); | 57 compositor_->RemoveAnimationObserver(this); |
58 } | 58 } |
59 | 59 |
60 void LayerAnimatorCollection::OnCompositingShuttingDown( | |
61 Compositor* compositor) { | |
62 if (compositor_) { | |
danakj
2015/06/02 18:24:15
how can compositor_ be null here?
| |
63 compositor_->RemoveAnimationObserver(this); | |
64 } | |
65 compositor_ = nullptr; | |
66 } | |
67 | |
60 } // namespace ui | 68 } // namespace ui |
OLD | NEW |