| 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 <memory> | |
| 9 #include <unordered_map> | |
| 10 | |
| 11 #include "base/macros.h" | |
| 12 #include "base/memory/ptr_util.h" | |
| 13 #include "base/memory/ref_counted.h" | |
| 14 #include "base/time/time.h" | |
| 15 #include "cc/base/cc_export.h" | |
| 16 | |
| 17 namespace cc { | |
| 18 | |
| 19 class AnimationEvents; | |
| 20 class LayerAnimationController; | |
| 21 | |
| 22 class CC_EXPORT AnimationRegistrar { | |
| 23 public: | |
| 24 using AnimationControllerMap = | |
| 25 std::unordered_map<int, LayerAnimationController*>; | |
| 26 | |
| 27 static std::unique_ptr<AnimationRegistrar> Create() { | |
| 28 return base::WrapUnique(new AnimationRegistrar()); | |
| 29 } | |
| 30 | |
| 31 virtual ~AnimationRegistrar(); | |
| 32 | |
| 33 // If an animation has been registered for the given id, return it. Otherwise | |
| 34 // creates a new one and returns a scoped_refptr to it. | |
| 35 scoped_refptr<LayerAnimationController> GetAnimationControllerForId(int id); | |
| 36 | |
| 37 // Registers the given animation controller as active. An active animation | |
| 38 // controller is one that has a running animation that needs to be ticked. | |
| 39 void DidActivateAnimationController(LayerAnimationController* controller); | |
| 40 | |
| 41 // Unregisters the given animation controller. When this happens, the | |
| 42 // animation controller will no longer be ticked (since it's not active). It | |
| 43 // is not an error to call this function with a deactivated controller. | |
| 44 void DidDeactivateAnimationController(LayerAnimationController* controller); | |
| 45 | |
| 46 // Registers the given controller as alive. | |
| 47 void RegisterAnimationController(LayerAnimationController* controller); | |
| 48 | |
| 49 // Unregisters the given controller as alive. | |
| 50 void UnregisterAnimationController(LayerAnimationController* controller); | |
| 51 | |
| 52 const AnimationControllerMap& active_animation_controllers_for_testing() | |
| 53 const { | |
| 54 return active_animation_controllers_; | |
| 55 } | |
| 56 | |
| 57 const AnimationControllerMap& all_animation_controllers_for_testing() const { | |
| 58 return all_animation_controllers_; | |
| 59 } | |
| 60 | |
| 61 void set_supports_scroll_animations(bool supports_scroll_animations) { | |
| 62 supports_scroll_animations_ = supports_scroll_animations; | |
| 63 } | |
| 64 | |
| 65 bool supports_scroll_animations() { return supports_scroll_animations_; } | |
| 66 | |
| 67 bool needs_animate_layers() const { | |
| 68 return !active_animation_controllers_.empty(); | |
| 69 } | |
| 70 | |
| 71 bool ActivateAnimations(); | |
| 72 bool AnimateLayers(base::TimeTicks monotonic_time); | |
| 73 bool UpdateAnimationState(bool start_ready_animations, | |
| 74 AnimationEvents* events); | |
| 75 | |
| 76 std::unique_ptr<AnimationEvents> CreateEvents(); | |
| 77 void SetAnimationEvents(std::unique_ptr<AnimationEvents> events); | |
| 78 | |
| 79 private: | |
| 80 AnimationRegistrar(); | |
| 81 | |
| 82 AnimationControllerMap active_animation_controllers_; | |
| 83 AnimationControllerMap all_animation_controllers_; | |
| 84 | |
| 85 bool supports_scroll_animations_; | |
| 86 | |
| 87 DISALLOW_COPY_AND_ASSIGN(AnimationRegistrar); | |
| 88 }; | |
| 89 | |
| 90 } // namespace cc | |
| 91 | |
| 92 #endif // CC_ANIMATION_ANIMATION_REGISTRAR_H_ | |
| OLD | NEW |