| OLD | NEW |
| (Empty) |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CC_ANIMATION_ANIMATION_REGISTRAR_H_ | |
| 6 #define CC_ANIMATION_ANIMATION_REGISTRAR_H_ | |
| 7 | |
| 8 #include "base/containers/hash_tables.h" | |
| 9 #include "base/memory/ref_counted.h" | |
| 10 #include "base/memory/scoped_ptr.h" | |
| 11 #include "cc/animation/animation_events.h" | |
| 12 #include "cc/base/cc_export.h" | |
| 13 | |
| 14 namespace cc { | |
| 15 | |
| 16 class LayerAnimationController; | |
| 17 | |
| 18 class CC_EXPORT AnimationRegistrar { | |
| 19 public: | |
| 20 typedef base::hash_map<int, LayerAnimationController*> AnimationControllerMap; | |
| 21 | |
| 22 static scoped_ptr<AnimationRegistrar> Create() { | |
| 23 return make_scoped_ptr(new AnimationRegistrar()); | |
| 24 } | |
| 25 | |
| 26 virtual ~AnimationRegistrar(); | |
| 27 | |
| 28 // If an animation has been registered for the given id, return it. Otherwise | |
| 29 // creates a new one and returns a scoped_refptr to it. | |
| 30 scoped_refptr<LayerAnimationController> GetAnimationControllerForId(int id); | |
| 31 | |
| 32 // Registers the given animation controller as active. An active animation | |
| 33 // controller is one that has a running animation that needs to be ticked. | |
| 34 void DidActivateAnimationController(LayerAnimationController* controller); | |
| 35 | |
| 36 // Unregisters the given animation controller. When this happens, the | |
| 37 // animation controller will no longer be ticked (since it's not active). It | |
| 38 // is not an error to call this function with a deactivated controller. | |
| 39 void DidDeactivateAnimationController(LayerAnimationController* controller); | |
| 40 | |
| 41 // Registers the given controller as alive. | |
| 42 void RegisterAnimationController(LayerAnimationController* controller); | |
| 43 | |
| 44 // Unregisters the given controller as alive. | |
| 45 void UnregisterAnimationController(LayerAnimationController* controller); | |
| 46 | |
| 47 const AnimationControllerMap& active_animation_controllers_for_testing() | |
| 48 const { | |
| 49 return active_animation_controllers_; | |
| 50 } | |
| 51 | |
| 52 const AnimationControllerMap& all_animation_controllers_for_testing() const { | |
| 53 return all_animation_controllers_; | |
| 54 } | |
| 55 | |
| 56 void set_supports_scroll_animations(bool supports_scroll_animations) { | |
| 57 supports_scroll_animations_ = supports_scroll_animations; | |
| 58 } | |
| 59 | |
| 60 bool supports_scroll_animations() { return supports_scroll_animations_; } | |
| 61 | |
| 62 bool needs_animate_layers() const { | |
| 63 return !active_animation_controllers_.empty(); | |
| 64 } | |
| 65 | |
| 66 bool ActivateAnimations(); | |
| 67 bool AnimateLayers(base::TimeTicks monotonic_time); | |
| 68 bool UpdateAnimationState(bool start_ready_animations, | |
| 69 AnimationEventsVector* events); | |
| 70 | |
| 71 scoped_ptr<AnimationEventsVector> CreateEvents() { | |
| 72 return make_scoped_ptr(new AnimationEventsVector()); | |
| 73 } | |
| 74 | |
| 75 void SetAnimationEvents(scoped_ptr<AnimationEventsVector> events); | |
| 76 | |
| 77 private: | |
| 78 AnimationRegistrar(); | |
| 79 | |
| 80 AnimationControllerMap active_animation_controllers_; | |
| 81 AnimationControllerMap all_animation_controllers_; | |
| 82 | |
| 83 bool supports_scroll_animations_; | |
| 84 | |
| 85 DISALLOW_COPY_AND_ASSIGN(AnimationRegistrar); | |
| 86 }; | |
| 87 | |
| 88 } // namespace cc | |
| 89 | |
| 90 #endif // CC_ANIMATION_ANIMATION_REGISTRAR_H_ | |
| OLD | NEW |