| 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_COMPOSITOR_LAYER_ANIMATION_OBSERVER_H_ | 5 #ifndef UI_COMPOSITOR_LAYER_ANIMATION_OBSERVER_H_ |
| 6 #define UI_COMPOSITOR_LAYER_ANIMATION_OBSERVER_H_ | 6 #define UI_COMPOSITOR_LAYER_ANIMATION_OBSERVER_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 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/compositor/compositor_export.h" | 13 #include "ui/compositor/compositor_export.h" |
| 14 #include "ui/compositor/layer_animation_element.h" | 14 #include "ui/compositor/layer_animation_element.h" |
| 15 | 15 |
| 16 namespace ui { | 16 namespace ui { |
| 17 | 17 |
| 18 namespace test { |
| 19 class LayerAnimationObserverTestApi; |
| 20 } // namespace test |
| 21 |
| 18 class LayerAnimationSequence; | 22 class LayerAnimationSequence; |
| 19 class ScopedLayerAnimationSettings; | 23 class ScopedLayerAnimationSettings; |
| 20 class ImplicitAnimationObserver; | 24 class ImplicitAnimationObserver; |
| 21 | 25 |
| 22 // LayerAnimationObservers are notified when animations complete. | 26 // LayerAnimationObservers are notified when animations complete. |
| 23 class COMPOSITOR_EXPORT LayerAnimationObserver { | 27 class COMPOSITOR_EXPORT LayerAnimationObserver { |
| 24 public: | 28 public: |
| 25 // Called when the |sequence| starts. | 29 // Called when the |sequence| starts. |
| 26 virtual void OnLayerAnimationStarted(LayerAnimationSequence* sequence); | 30 virtual void OnLayerAnimationStarted(LayerAnimationSequence* sequence); |
| 27 | 31 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 39 LayerAnimationSequence* sequence) = 0; | 43 LayerAnimationSequence* sequence) = 0; |
| 40 | 44 |
| 41 protected: | 45 protected: |
| 42 typedef std::set<LayerAnimationSequence*> AttachedSequences; | 46 typedef std::set<LayerAnimationSequence*> AttachedSequences; |
| 43 | 47 |
| 44 LayerAnimationObserver(); | 48 LayerAnimationObserver(); |
| 45 virtual ~LayerAnimationObserver(); | 49 virtual ~LayerAnimationObserver(); |
| 46 | 50 |
| 47 // If the animator is destroyed during an animation, the animations are | 51 // If the animator is destroyed during an animation, the animations are |
| 48 // aborted. The resulting NotifyAborted notifications will NOT be sent to | 52 // aborted. The resulting NotifyAborted notifications will NOT be sent to |
| 49 // this observer if this function returns false. NOTE: IF YOU override THIS | 53 // this observer if this function returns false. An observer who wants to |
| 50 // FUNCTION TO RETURN TRUE, YOU MUST REMEMBER TO REMOVE YOURSELF AS AN | 54 // receive the NotifyAborted notifications during destruction can override |
| 51 // OBSERVER WHEN YOU ARE DESTROYED. | 55 // this function to return true. |
| 56 // |
| 57 // *** IMPORTANT ***: If you override this function to return true AND you are |
| 58 // using the pattern described below, then make sure you explicity remove |
| 59 // yourself as an observer before the animator is destroyed! |
| 60 // |
| 61 // This opt-in pattern is used because it is a common pattern for a class to |
| 62 // be the observer of an animation that it itself owns. In such a case the |
| 63 // animator will be destroyed as the owning class is destructed and we don't |
| 64 // want the NotifyAbort being invoked on a partially destroyed observer. |
| 52 virtual bool RequiresNotificationWhenAnimatorDestroyed() const; | 65 virtual bool RequiresNotificationWhenAnimatorDestroyed() const; |
| 53 | 66 |
| 54 // Called when |this| is added to |sequence|'s observer list. | 67 // Called when |this| is added to |sequence|'s observer list. |
| 55 virtual void OnAttachedToSequence(LayerAnimationSequence* sequence); | 68 virtual void OnAttachedToSequence(LayerAnimationSequence* sequence); |
| 56 | 69 |
| 57 // Called when |this| is removed to |sequence|'s observer list. | 70 // Called when |this| is removed to |sequence|'s observer list. |
| 58 virtual void OnDetachedFromSequence(LayerAnimationSequence* sequence); | 71 virtual void OnDetachedFromSequence(LayerAnimationSequence* sequence); |
| 59 | 72 |
| 60 // Detaches this observer from all sequences it is currently observing. | 73 // Detaches this observer from all sequences it is currently observing. |
| 61 void StopObserving(); | 74 void StopObserving(); |
| 62 | 75 |
| 63 const AttachedSequences& attached_sequences() const { | 76 const AttachedSequences& attached_sequences() const { |
| 64 return attached_sequences_; | 77 return attached_sequences_; |
| 65 } | 78 } |
| 66 | 79 |
| 67 private: | 80 private: |
| 68 friend class LayerAnimationSequence; | 81 friend class LayerAnimationSequence; |
| 82 friend class test::LayerAnimationObserverTestApi; |
| 69 | 83 |
| 70 // Called when |this| is added to |sequence|'s observer list. | 84 // Called when |this| is added to |sequence|'s observer list. |
| 71 void AttachedToSequence(LayerAnimationSequence* sequence); | 85 void AttachedToSequence(LayerAnimationSequence* sequence); |
| 72 | 86 |
| 73 // Called when |this| is removed to |sequence|'s observer list. | 87 // Called when |this| is removed to |sequence|'s observer list. |
| 74 // This will only result in notifications if |send_notification| is true. | 88 // This will only result in notifications if |send_notification| is true. |
| 75 void DetachedFromSequence(LayerAnimationSequence* sequence, | 89 void DetachedFromSequence(LayerAnimationSequence* sequence, |
| 76 bool send_notification); | 90 bool send_notification); |
| 77 | 91 |
| 78 AttachedSequences attached_sequences_; | 92 AttachedSequences attached_sequences_; |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 AnimationStatus> PropertyAnimationStatusMap; | 160 AnimationStatus> PropertyAnimationStatusMap; |
| 147 PropertyAnimationStatusMap property_animation_status_; | 161 PropertyAnimationStatusMap property_animation_status_; |
| 148 | 162 |
| 149 // True if OnLayerAnimationScheduled() has been called at least once. | 163 // True if OnLayerAnimationScheduled() has been called at least once. |
| 150 bool first_sequence_scheduled_; | 164 bool first_sequence_scheduled_; |
| 151 }; | 165 }; |
| 152 | 166 |
| 153 } // namespace ui | 167 } // namespace ui |
| 154 | 168 |
| 155 #endif // UI_COMPOSITOR_LAYER_ANIMATION_OBSERVER_H_ | 169 #endif // UI_COMPOSITOR_LAYER_ANIMATION_OBSERVER_H_ |
| OLD | NEW |