OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_GFX_ANIMATION_ANIMATION_CONTAINER_H_ | 5 #ifndef UI_GFX_ANIMATION_ANIMATION_CONTAINER_H_ |
6 #define UI_GFX_ANIMATION_ANIMATION_CONTAINER_H_ | 6 #define UI_GFX_ANIMATION_ANIMATION_CONTAINER_H_ |
7 | 7 |
8 #include <set> | 8 #include <set> |
9 | 9 |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
11 #include "base/time/time.h" | 11 #include "base/time/time.h" |
12 #include "base/timer/timer.h" | 12 #include "base/timer/timer.h" |
13 #include "ui/gfx/gfx_export.h" | 13 #include "ui/gfx/gfx_export.h" |
| 14 #include "ui/gfx/frame_time.h" |
14 | 15 |
15 namespace gfx { | 16 namespace gfx { |
16 | 17 |
17 class AnimationContainerElement; | 18 class AnimationContainerElement; |
18 class AnimationContainerObserver; | 19 class AnimationContainerObserver; |
19 | 20 |
20 // AnimationContainer is used by Animation to manage the underlying timer. | 21 // AnimationContainer is used by Animation to manage the underlying timer. |
21 // Internally each Animation creates a single AnimationContainer. You can | 22 // Internally each Animation creates a single AnimationContainer. You can |
22 // group a set of Animations into the same AnimationContainer by way of | 23 // group a set of Animations into the same AnimationContainer by way of |
23 // Animation::SetContainer. Grouping a set of Animations into the same | 24 // Animation::SetContainer. Grouping a set of Animations into the same |
(...skipping 15 matching lines...) Expand all Loading... |
39 // running the timer stops. | 40 // running the timer stops. |
40 // NOTE: This is invoked by Animation for you, you shouldn't invoke this | 41 // NOTE: This is invoked by Animation for you, you shouldn't invoke this |
41 // directly. | 42 // directly. |
42 void Stop(AnimationContainerElement* animation); | 43 void Stop(AnimationContainerElement* animation); |
43 | 44 |
44 void set_observer(AnimationContainerObserver* observer) { | 45 void set_observer(AnimationContainerObserver* observer) { |
45 observer_ = observer; | 46 observer_ = observer; |
46 } | 47 } |
47 | 48 |
48 // The time the last animation ran at. | 49 // The time the last animation ran at. |
49 base::TimeTicks last_tick_time() const { return last_tick_time_; } | 50 gfx::FrameTime last_tick_time() const { return last_tick_time_; } |
50 | 51 |
51 // Are there any timers running? | 52 // Are there any timers running? |
52 bool is_running() const { return !elements_.empty(); } | 53 bool is_running() const { return !elements_.empty(); } |
53 | 54 |
54 private: | 55 private: |
55 friend class base::RefCounted<AnimationContainer>; | 56 friend class base::RefCounted<AnimationContainer>; |
56 | 57 |
57 typedef std::set<AnimationContainerElement*> Elements; | 58 typedef std::set<AnimationContainerElement*> Elements; |
58 | 59 |
59 ~AnimationContainer(); | 60 ~AnimationContainer(); |
60 | 61 |
61 // Timer callback method. | 62 // Timer callback method. |
62 void Run(); | 63 void Run(); |
63 | 64 |
64 // Sets min_timer_interval_ and restarts the timer. | 65 // Sets min_timer_interval_ and restarts the timer. |
65 void SetMinTimerInterval(base::TimeDelta delta); | 66 void SetMinTimerInterval(base::TimeDelta delta); |
66 | 67 |
67 // Returns the min timer interval of all the timers. | 68 // Returns the min timer interval of all the timers. |
68 base::TimeDelta GetMinInterval(); | 69 base::TimeDelta GetMinInterval(); |
69 | 70 |
70 // Represents one of two possible values: | 71 // Represents one of two possible values: |
71 // . If only a single animation has been started and the timer hasn't yet | 72 // . If only a single animation has been started and the timer hasn't yet |
72 // fired this is the time the animation was added. | 73 // fired this is the time the animation was added. |
73 // . The time the last animation ran at (::Run was invoked). | 74 // . The time the last animation ran at (::Run was invoked). |
74 base::TimeTicks last_tick_time_; | 75 gfx::FrameTime last_tick_time_; |
75 | 76 |
76 // Set of elements (animations) being managed. | 77 // Set of elements (animations) being managed. |
77 Elements elements_; | 78 Elements elements_; |
78 | 79 |
79 // Minimum interval the timers run at. | 80 // Minimum interval the timers run at. |
80 base::TimeDelta min_timer_interval_; | 81 base::TimeDelta min_timer_interval_; |
81 | 82 |
82 base::RepeatingTimer<AnimationContainer> timer_; | 83 base::RepeatingTimer<AnimationContainer> timer_; |
83 | 84 |
84 AnimationContainerObserver* observer_; | 85 AnimationContainerObserver* observer_; |
85 | 86 |
86 DISALLOW_COPY_AND_ASSIGN(AnimationContainer); | 87 DISALLOW_COPY_AND_ASSIGN(AnimationContainer); |
87 }; | 88 }; |
88 | 89 |
89 } // namespace gfx | 90 } // namespace gfx |
90 | 91 |
91 #endif // UI_GFX_ANIMATION_ANIMATION_CONTAINER_H_ | 92 #endif // UI_GFX_ANIMATION_ANIMATION_CONTAINER_H_ |
OLD | NEW |