OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_COMPOSITOR_LAYER_ANIMATION_OBSERVER_H_ | 5 #ifndef UI_GFX_COMPOSITOR_LAYER_ANIMATION_OBSERVER_H_ |
6 #define UI_GFX_COMPOSITOR_LAYER_ANIMATION_OBSERVER_H_ | 6 #define UI_GFX_COMPOSITOR_LAYER_ANIMATION_OBSERVER_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <set> | 9 #include <set> |
10 | 10 |
11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
13 #include "ui/gfx/compositor/compositor_export.h" | 13 #include "ui/gfx/compositor/compositor_export.h" |
14 | 14 |
15 namespace ui { | 15 namespace ui { |
16 | 16 |
17 class LayerAnimationSequence; | 17 class LayerAnimationSequence; |
18 class ScopedLayerAnimationSettings; | 18 class ScopedLayerAnimationSettings; |
| 19 class ImplicitAnimationObserver; |
19 | 20 |
20 // LayerAnimationObservers are notified when animations complete. | 21 // LayerAnimationObservers are notified when animations complete. |
21 class COMPOSITOR_EXPORT LayerAnimationObserver { | 22 class COMPOSITOR_EXPORT LayerAnimationObserver { |
22 public: | 23 public: |
23 // Called when the |sequence| ends. Not called if |sequence| is aborted. | 24 // Called when the |sequence| ends. Not called if |sequence| is aborted. |
24 virtual void OnLayerAnimationEnded( | 25 virtual void OnLayerAnimationEnded( |
25 const LayerAnimationSequence* sequence) = 0; | 26 const LayerAnimationSequence* sequence) = 0; |
26 | 27 |
27 // Called if |sequence| is aborted for any reason. Should never do anything | 28 // Called if |sequence| is aborted for any reason. Should never do anything |
28 // that may cause another animation to be started. | 29 // that may cause another animation to be started. |
29 virtual void OnLayerAnimationAborted( | 30 virtual void OnLayerAnimationAborted( |
30 const LayerAnimationSequence* sequence) = 0; | 31 const LayerAnimationSequence* sequence) = 0; |
31 | 32 |
32 // Called when the animation is scheduled. | 33 // Called when the animation is scheduled. |
33 virtual void OnLayerAnimationScheduled( | 34 virtual void OnLayerAnimationScheduled( |
34 const LayerAnimationSequence* sequence) = 0; | 35 const LayerAnimationSequence* sequence) = 0; |
35 | 36 |
36 // If the animator is destroyed during an animation, the animations are | 37 // If the animator is destroyed during an animation, the animations are |
37 // aborted. The resulting NotifyAborted notifications will NOT be sent to | 38 // aborted. The resulting NotifyAborted notifications will NOT be sent to |
38 // this observer if this function returns false. NOTE: IF YOU OVERRIDE THIS | 39 // this observer if this function returns false. NOTE: IF YOU OVERRIDE THIS |
39 // FUNCTION TO RETURN TRUE, YOU MUST REMEMBER TO REMOVE YOURSELF AS AN | 40 // FUNCTION TO RETURN TRUE, YOU MUST REMEMBER TO REMOVE YOURSELF AS AN |
40 // OBSERVER WHEN YOU ARE DESTROYED. | 41 // OBSERVER WHEN YOU ARE DESTROYED. |
41 virtual bool RequiresNotificationWhenAnimatorDestroyed() const; | 42 virtual bool RequiresNotificationWhenAnimatorDestroyed() const; |
42 | 43 |
| 44 virtual ImplicitAnimationObserver* AsImplicitObserver() { return NULL; } |
| 45 |
43 protected: | 46 protected: |
44 LayerAnimationObserver(); | 47 LayerAnimationObserver(); |
45 virtual ~LayerAnimationObserver(); | 48 virtual ~LayerAnimationObserver(); |
46 | 49 |
47 private: | 50 private: |
48 friend class LayerAnimationSequence; | 51 friend class LayerAnimationSequence; |
49 | 52 |
50 // Called when |this| is added to |sequence|'s observer list. | 53 // Called when |this| is added to |sequence|'s observer list. |
51 void AttachedToSequence(LayerAnimationSequence* sequence); | 54 void AttachedToSequence(LayerAnimationSequence* sequence); |
52 | 55 |
(...skipping 21 matching lines...) Expand all Loading... |
74 bool active() const { return active_; } | 77 bool active() const { return active_; } |
75 void SetActive(bool active); | 78 void SetActive(bool active); |
76 | 79 |
77 // LayerAnimationObserver implementation | 80 // LayerAnimationObserver implementation |
78 virtual void OnLayerAnimationEnded( | 81 virtual void OnLayerAnimationEnded( |
79 const LayerAnimationSequence* sequence) OVERRIDE; | 82 const LayerAnimationSequence* sequence) OVERRIDE; |
80 virtual void OnLayerAnimationAborted( | 83 virtual void OnLayerAnimationAborted( |
81 const LayerAnimationSequence* sequence) OVERRIDE; | 84 const LayerAnimationSequence* sequence) OVERRIDE; |
82 virtual void OnLayerAnimationScheduled( | 85 virtual void OnLayerAnimationScheduled( |
83 const LayerAnimationSequence* sequence) OVERRIDE; | 86 const LayerAnimationSequence* sequence) OVERRIDE; |
| 87 virtual ImplicitAnimationObserver* AsImplicitObserver() { return this; } |
84 | 88 |
85 void CheckCompleted(); | 89 void CheckCompleted(); |
86 | 90 |
87 bool active_; | 91 bool active_; |
88 | 92 |
89 // This tracks the number of scheduled animations that have yet to complete. | 93 // This tracks the number of scheduled animations that have yet to complete. |
90 // If this value is zero, and the observer is active, then | 94 // If this value is zero, and the observer is active, then |
91 // OnImplicitAnimationsCompleted is fired. | 95 // OnImplicitAnimationsCompleted is fired. |
92 size_t animation_count_; | 96 size_t animation_count_; |
93 }; | 97 }; |
94 | 98 |
95 } // namespace ui | 99 } // namespace ui |
96 | 100 |
97 #endif // UI_GFX_COMPOSITOR_LAYER_ANIMATION_OBSERVER_H_ | 101 #endif // UI_GFX_COMPOSITOR_LAYER_ANIMATION_OBSERVER_H_ |
OLD | NEW |