OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 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 | 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 CC_ANIMATION_ANIMATION_REGISTRAR_H_ | 5 #ifndef CC_ANIMATION_ANIMATION_REGISTRAR_H_ |
6 #define CC_ANIMATION_ANIMATION_REGISTRAR_H_ | 6 #define CC_ANIMATION_ANIMATION_REGISTRAR_H_ |
7 | 7 |
| 8 #include <memory> |
8 #include <unordered_map> | 9 #include <unordered_map> |
9 | 10 |
10 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "base/memory/ptr_util.h" |
11 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
12 #include "base/memory/scoped_ptr.h" | |
13 #include "base/time/time.h" | 14 #include "base/time/time.h" |
14 #include "cc/base/cc_export.h" | 15 #include "cc/base/cc_export.h" |
15 | 16 |
16 namespace cc { | 17 namespace cc { |
17 | 18 |
18 class AnimationEvents; | 19 class AnimationEvents; |
19 class LayerAnimationController; | 20 class LayerAnimationController; |
20 | 21 |
21 class CC_EXPORT AnimationRegistrar { | 22 class CC_EXPORT AnimationRegistrar { |
22 public: | 23 public: |
23 using AnimationControllerMap = | 24 using AnimationControllerMap = |
24 std::unordered_map<int, LayerAnimationController*>; | 25 std::unordered_map<int, LayerAnimationController*>; |
25 | 26 |
26 static scoped_ptr<AnimationRegistrar> Create() { | 27 static std::unique_ptr<AnimationRegistrar> Create() { |
27 return make_scoped_ptr(new AnimationRegistrar()); | 28 return base::WrapUnique(new AnimationRegistrar()); |
28 } | 29 } |
29 | 30 |
30 virtual ~AnimationRegistrar(); | 31 virtual ~AnimationRegistrar(); |
31 | 32 |
32 // If an animation has been registered for the given id, return it. Otherwise | 33 // If an animation has been registered for the given id, return it. Otherwise |
33 // creates a new one and returns a scoped_refptr to it. | 34 // creates a new one and returns a scoped_refptr to it. |
34 scoped_refptr<LayerAnimationController> GetAnimationControllerForId(int id); | 35 scoped_refptr<LayerAnimationController> GetAnimationControllerForId(int id); |
35 | 36 |
36 // Registers the given animation controller as active. An active animation | 37 // Registers the given animation controller as active. An active animation |
37 // controller is one that has a running animation that needs to be ticked. | 38 // controller is one that has a running animation that needs to be ticked. |
(...skipping 27 matching lines...) Expand all Loading... |
65 | 66 |
66 bool needs_animate_layers() const { | 67 bool needs_animate_layers() const { |
67 return !active_animation_controllers_.empty(); | 68 return !active_animation_controllers_.empty(); |
68 } | 69 } |
69 | 70 |
70 bool ActivateAnimations(); | 71 bool ActivateAnimations(); |
71 bool AnimateLayers(base::TimeTicks monotonic_time); | 72 bool AnimateLayers(base::TimeTicks monotonic_time); |
72 bool UpdateAnimationState(bool start_ready_animations, | 73 bool UpdateAnimationState(bool start_ready_animations, |
73 AnimationEvents* events); | 74 AnimationEvents* events); |
74 | 75 |
75 scoped_ptr<AnimationEvents> CreateEvents(); | 76 std::unique_ptr<AnimationEvents> CreateEvents(); |
76 void SetAnimationEvents(scoped_ptr<AnimationEvents> events); | 77 void SetAnimationEvents(std::unique_ptr<AnimationEvents> events); |
77 | 78 |
78 private: | 79 private: |
79 AnimationRegistrar(); | 80 AnimationRegistrar(); |
80 | 81 |
81 AnimationControllerMap active_animation_controllers_; | 82 AnimationControllerMap active_animation_controllers_; |
82 AnimationControllerMap all_animation_controllers_; | 83 AnimationControllerMap all_animation_controllers_; |
83 | 84 |
84 bool supports_scroll_animations_; | 85 bool supports_scroll_animations_; |
85 | 86 |
86 DISALLOW_COPY_AND_ASSIGN(AnimationRegistrar); | 87 DISALLOW_COPY_AND_ASSIGN(AnimationRegistrar); |
87 }; | 88 }; |
88 | 89 |
89 } // namespace cc | 90 } // namespace cc |
90 | 91 |
91 #endif // CC_ANIMATION_ANIMATION_REGISTRAR_H_ | 92 #endif // CC_ANIMATION_ANIMATION_REGISTRAR_H_ |
OLD | NEW |