OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_HOST_H_ | 5 #ifndef CC_ANIMATION_ANIMATION_HOST_H_ |
6 #define CC_ANIMATION_ANIMATION_HOST_H_ | 6 #define CC_ANIMATION_ANIMATION_HOST_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" |
11 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
12 #include "base/memory/scoped_ptr.h" | |
13 #include "base/time/time.h" | 13 #include "base/time/time.h" |
14 #include "cc/animation/animation.h" | 14 #include "cc/animation/animation.h" |
15 #include "cc/base/cc_export.h" | 15 #include "cc/base/cc_export.h" |
16 #include "cc/trees/mutator_host_client.h" | 16 #include "cc/trees/mutator_host_client.h" |
17 #include "ui/gfx/geometry/box_f.h" | 17 #include "ui/gfx/geometry/box_f.h" |
18 #include "ui/gfx/geometry/vector2d_f.h" | 18 #include "ui/gfx/geometry/vector2d_f.h" |
19 | 19 |
20 namespace gfx { | 20 namespace gfx { |
21 class ScrollOffset; | 21 class ScrollOffset; |
22 } | 22 } |
(...skipping 15 matching lines...) Expand all Loading... |
38 // There is just one AnimationHost for LayerTreeHost on main renderer thread | 38 // There is just one AnimationHost for LayerTreeHost on main renderer thread |
39 // and just one AnimationHost for LayerTreeHostImpl on impl thread. | 39 // and just one AnimationHost for LayerTreeHostImpl on impl thread. |
40 // We synchronize them during the commit process in a one-way data flow process | 40 // We synchronize them during the commit process in a one-way data flow process |
41 // (PushPropertiesTo). | 41 // (PushPropertiesTo). |
42 // An AnimationHost talks to its correspondent LayerTreeHost via | 42 // An AnimationHost talks to its correspondent LayerTreeHost via |
43 // LayerTreeMutatorsClient interface. | 43 // LayerTreeMutatorsClient interface. |
44 // AnimationHost has it's own instance of AnimationRegistrar, | 44 // AnimationHost has it's own instance of AnimationRegistrar, |
45 // we want to merge AnimationRegistrar into AnimationHost. | 45 // we want to merge AnimationRegistrar into AnimationHost. |
46 class CC_EXPORT AnimationHost { | 46 class CC_EXPORT AnimationHost { |
47 public: | 47 public: |
48 static scoped_ptr<AnimationHost> Create(ThreadInstance thread_instance); | 48 static std::unique_ptr<AnimationHost> Create(ThreadInstance thread_instance); |
49 virtual ~AnimationHost(); | 49 virtual ~AnimationHost(); |
50 | 50 |
51 void AddAnimationTimeline(scoped_refptr<AnimationTimeline> timeline); | 51 void AddAnimationTimeline(scoped_refptr<AnimationTimeline> timeline); |
52 void RemoveAnimationTimeline(scoped_refptr<AnimationTimeline> timeline); | 52 void RemoveAnimationTimeline(scoped_refptr<AnimationTimeline> timeline); |
53 AnimationTimeline* GetTimelineById(int timeline_id) const; | 53 AnimationTimeline* GetTimelineById(int timeline_id) const; |
54 | 54 |
55 void ClearTimelines(); | 55 void ClearTimelines(); |
56 | 56 |
57 void RegisterLayer(int layer_id, LayerTreeType tree_type); | 57 void RegisterLayer(int layer_id, LayerTreeType tree_type); |
58 void UnregisterLayer(int layer_id, LayerTreeType tree_type); | 58 void UnregisterLayer(int layer_id, LayerTreeType tree_type); |
(...skipping 24 matching lines...) Expand all Loading... |
83 | 83 |
84 void SetSupportsScrollAnimations(bool supports_scroll_animations); | 84 void SetSupportsScrollAnimations(bool supports_scroll_animations); |
85 bool SupportsScrollAnimations() const; | 85 bool SupportsScrollAnimations() const; |
86 bool NeedsAnimateLayers() const; | 86 bool NeedsAnimateLayers() const; |
87 | 87 |
88 bool ActivateAnimations(); | 88 bool ActivateAnimations(); |
89 bool AnimateLayers(base::TimeTicks monotonic_time); | 89 bool AnimateLayers(base::TimeTicks monotonic_time); |
90 bool UpdateAnimationState(bool start_ready_animations, | 90 bool UpdateAnimationState(bool start_ready_animations, |
91 AnimationEvents* events); | 91 AnimationEvents* events); |
92 | 92 |
93 scoped_ptr<AnimationEvents> CreateEvents(); | 93 std::unique_ptr<AnimationEvents> CreateEvents(); |
94 void SetAnimationEvents(scoped_ptr<AnimationEvents> events); | 94 void SetAnimationEvents(std::unique_ptr<AnimationEvents> events); |
95 | 95 |
96 bool ScrollOffsetAnimationWasInterrupted(int layer_id) const; | 96 bool ScrollOffsetAnimationWasInterrupted(int layer_id) const; |
97 | 97 |
98 bool IsAnimatingFilterProperty(int layer_id, LayerTreeType tree_type) const; | 98 bool IsAnimatingFilterProperty(int layer_id, LayerTreeType tree_type) const; |
99 bool IsAnimatingOpacityProperty(int layer_id, LayerTreeType tree_type) const; | 99 bool IsAnimatingOpacityProperty(int layer_id, LayerTreeType tree_type) const; |
100 bool IsAnimatingTransformProperty(int layer_id, | 100 bool IsAnimatingTransformProperty(int layer_id, |
101 LayerTreeType tree_type) const; | 101 LayerTreeType tree_type) const; |
102 | 102 |
103 bool HasPotentiallyRunningFilterAnimation(int layer_id, | 103 bool HasPotentiallyRunningFilterAnimation(int layer_id, |
104 LayerTreeType tree_type) const; | 104 LayerTreeType tree_type) const; |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 void PushTimelinesToImplThread(AnimationHost* host_impl) const; | 157 void PushTimelinesToImplThread(AnimationHost* host_impl) const; |
158 void RemoveTimelinesFromImplThread(AnimationHost* host_impl) const; | 158 void RemoveTimelinesFromImplThread(AnimationHost* host_impl) const; |
159 void PushPropertiesToImplThread(AnimationHost* host_impl); | 159 void PushPropertiesToImplThread(AnimationHost* host_impl); |
160 | 160 |
161 void EraseTimeline(scoped_refptr<AnimationTimeline> timeline); | 161 void EraseTimeline(scoped_refptr<AnimationTimeline> timeline); |
162 | 162 |
163 // TODO(loyso): For now AnimationPlayers share LayerAnimationController object | 163 // TODO(loyso): For now AnimationPlayers share LayerAnimationController object |
164 // if they are attached to the same element(layer). Note that Element can | 164 // if they are attached to the same element(layer). Note that Element can |
165 // contain many Layers. | 165 // contain many Layers. |
166 using LayerToElementAnimationsMap = | 166 using LayerToElementAnimationsMap = |
167 std::unordered_map<int, scoped_ptr<ElementAnimations>>; | 167 std::unordered_map<int, std::unique_ptr<ElementAnimations>>; |
168 LayerToElementAnimationsMap layer_to_element_animations_map_; | 168 LayerToElementAnimationsMap layer_to_element_animations_map_; |
169 | 169 |
170 // A list of all timelines which this host owns. | 170 // A list of all timelines which this host owns. |
171 using IdToTimelineMap = | 171 using IdToTimelineMap = |
172 std::unordered_map<int, scoped_refptr<AnimationTimeline>>; | 172 std::unordered_map<int, scoped_refptr<AnimationTimeline>>; |
173 IdToTimelineMap id_to_timeline_map_; | 173 IdToTimelineMap id_to_timeline_map_; |
174 | 174 |
175 scoped_ptr<AnimationRegistrar> animation_registrar_; | 175 std::unique_ptr<AnimationRegistrar> animation_registrar_; |
176 MutatorHostClient* mutator_host_client_; | 176 MutatorHostClient* mutator_host_client_; |
177 | 177 |
178 class ScrollOffsetAnimations; | 178 class ScrollOffsetAnimations; |
179 scoped_ptr<ScrollOffsetAnimations> scroll_offset_animations_; | 179 std::unique_ptr<ScrollOffsetAnimations> scroll_offset_animations_; |
180 | 180 |
181 const ThreadInstance thread_instance_; | 181 const ThreadInstance thread_instance_; |
182 | 182 |
183 DISALLOW_COPY_AND_ASSIGN(AnimationHost); | 183 DISALLOW_COPY_AND_ASSIGN(AnimationHost); |
184 }; | 184 }; |
185 | 185 |
186 } // namespace cc | 186 } // namespace cc |
187 | 187 |
188 #endif // CC_ANIMATION_ANIMATION_HOST_H_ | 188 #endif // CC_ANIMATION_ANIMATION_HOST_H_ |
OLD | NEW |