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 #ifndef UI_COMPOSITOR_LAYER_ANIMATOR_COLLECTION_H_ | 5 #ifndef UI_COMPOSITOR_LAYER_ANIMATOR_COLLECTION_H_ |
6 #define UI_COMPOSITOR_LAYER_ANIMATOR_COLLECTION_H_ | 6 #define UI_COMPOSITOR_LAYER_ANIMATOR_COLLECTION_H_ |
7 | 7 |
8 #include <set> | 8 #include <set> |
9 | 9 |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
12 #include "base/time/time.h" | 12 #include "base/time/time.h" |
| 13 #include "ui/compositor/compositor_animation_observer.h" |
13 #include "ui/compositor/compositor_export.h" | 14 #include "ui/compositor/compositor_export.h" |
14 | 15 |
15 namespace base { | |
16 class TimeTicks; | |
17 } | |
18 | |
19 namespace ui { | 16 namespace ui { |
20 | 17 |
| 18 class Compositor; |
21 class LayerAnimator; | 19 class LayerAnimator; |
22 | 20 |
23 class COMPOSITOR_EXPORT LayerAnimatorCollectionDelegate { | |
24 public: | |
25 virtual ~LayerAnimatorCollectionDelegate() {} | |
26 | |
27 virtual void ScheduleAnimationForLayerCollection() = 0; | |
28 }; | |
29 | |
30 // A collection of LayerAnimators that should be updated at each animation step | 21 // A collection of LayerAnimators that should be updated at each animation step |
31 // in the compositor. | 22 // in the compositor. |
32 class COMPOSITOR_EXPORT LayerAnimatorCollection { | 23 class COMPOSITOR_EXPORT LayerAnimatorCollection |
| 24 : public CompositorAnimationObserver { |
33 public: | 25 public: |
34 explicit LayerAnimatorCollection(LayerAnimatorCollectionDelegate* delegate); | 26 explicit LayerAnimatorCollection(Compositor* compositor); |
35 ~LayerAnimatorCollection(); | 27 virtual ~LayerAnimatorCollection(); |
36 | 28 |
37 void StartAnimator(scoped_refptr<LayerAnimator> animator); | 29 void StartAnimator(scoped_refptr<LayerAnimator> animator); |
38 void StopAnimator(scoped_refptr<LayerAnimator> animator); | 30 void StopAnimator(scoped_refptr<LayerAnimator> animator); |
39 | 31 |
40 bool HasActiveAnimators() const; | 32 bool HasActiveAnimators() const; |
41 | 33 |
42 void Progress(base::TimeTicks now); | |
43 | |
44 base::TimeTicks last_tick_time() const { return last_tick_time_; } | 34 base::TimeTicks last_tick_time() const { return last_tick_time_; } |
45 | 35 |
| 36 // CompositorAnimationObserver: |
| 37 virtual void OnAnimationStep(base::TimeTicks timestamp) OVERRIDE; |
| 38 |
46 private: | 39 private: |
47 LayerAnimatorCollectionDelegate* delegate_; | 40 Compositor* compositor_; |
48 base::TimeTicks last_tick_time_; | 41 base::TimeTicks last_tick_time_; |
49 std::set<scoped_refptr<LayerAnimator> > animators_; | 42 std::set<scoped_refptr<LayerAnimator> > animators_; |
50 | 43 |
51 DISALLOW_COPY_AND_ASSIGN(LayerAnimatorCollection); | 44 DISALLOW_COPY_AND_ASSIGN(LayerAnimatorCollection); |
52 }; | 45 }; |
53 | 46 |
54 } // namespace ui | 47 } // namespace ui |
55 | 48 |
56 #endif // UI_COMPOSITOR_LAYER_ANIMATOR_COLLECTION_H_ | 49 #endif // UI_COMPOSITOR_LAYER_ANIMATOR_COLLECTION_H_ |
OLD | NEW |