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 <memory> |
9 #include <unordered_map> | 9 #include <unordered_map> |
| 10 #include <vector> |
10 | 11 |
11 #include "base/macros.h" | 12 #include "base/macros.h" |
12 #include "base/memory/ptr_util.h" | 13 #include "base/memory/ptr_util.h" |
13 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
14 #include "base/time/time.h" | 15 #include "base/time/time.h" |
15 #include "cc/animation/animation.h" | 16 #include "cc/animation/animation.h" |
16 #include "cc/animation/animation_export.h" | 17 #include "cc/animation/animation_export.h" |
17 #include "cc/trees/mutator_host.h" | 18 #include "cc/trees/mutator_host.h" |
18 #include "cc/trees/mutator_host_client.h" | 19 #include "cc/trees/mutator_host_client.h" |
19 #include "ui/gfx/geometry/box_f.h" | 20 #include "ui/gfx/geometry/box_f.h" |
(...skipping 22 matching lines...) Expand all Loading... |
42 // (PushPropertiesTo). | 43 // (PushPropertiesTo). |
43 // An AnimationHost talks to its correspondent LayerTreeHost via | 44 // An AnimationHost talks to its correspondent LayerTreeHost via |
44 // MutatorHostClient interface. | 45 // MutatorHostClient interface. |
45 class CC_ANIMATION_EXPORT AnimationHost | 46 class CC_ANIMATION_EXPORT AnimationHost |
46 : public NON_EXPORTED_BASE(MutatorHost) { | 47 : public NON_EXPORTED_BASE(MutatorHost) { |
47 public: | 48 public: |
48 using ElementToAnimationsMap = | 49 using ElementToAnimationsMap = |
49 std::unordered_map<ElementId, | 50 std::unordered_map<ElementId, |
50 scoped_refptr<ElementAnimations>, | 51 scoped_refptr<ElementAnimations>, |
51 ElementIdHash>; | 52 ElementIdHash>; |
| 53 using PlayersList = std::vector<scoped_refptr<AnimationPlayer>>; |
52 | 54 |
53 static std::unique_ptr<AnimationHost> CreateMainInstance(); | 55 static std::unique_ptr<AnimationHost> CreateMainInstance(); |
54 static std::unique_ptr<AnimationHost> CreateForTesting( | 56 static std::unique_ptr<AnimationHost> CreateForTesting( |
55 ThreadInstance thread_instance); | 57 ThreadInstance thread_instance); |
56 ~AnimationHost() override; | 58 ~AnimationHost() override; |
57 | 59 |
58 void AddAnimationTimeline(scoped_refptr<AnimationTimeline> timeline); | 60 void AddAnimationTimeline(scoped_refptr<AnimationTimeline> timeline); |
59 void RemoveAnimationTimeline(scoped_refptr<AnimationTimeline> timeline); | 61 void RemoveAnimationTimeline(scoped_refptr<AnimationTimeline> timeline); |
60 AnimationTimeline* GetTimelineById(int timeline_id) const; | 62 AnimationTimeline* GetTimelineById(int timeline_id) const; |
61 | 63 |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 const gfx::Vector2dF& scroll_delta, | 164 const gfx::Vector2dF& scroll_delta, |
163 const gfx::ScrollOffset& max_scroll_offset, | 165 const gfx::ScrollOffset& max_scroll_offset, |
164 base::TimeTicks frame_monotonic_time, | 166 base::TimeTicks frame_monotonic_time, |
165 base::TimeDelta delayed_by) override; | 167 base::TimeDelta delayed_by) override; |
166 | 168 |
167 void ScrollAnimationAbort(bool needs_completion) override; | 169 void ScrollAnimationAbort(bool needs_completion) override; |
168 | 170 |
169 // This should only be called from the main thread. | 171 // This should only be called from the main thread. |
170 ScrollOffsetAnimations& scroll_offset_animations() const; | 172 ScrollOffsetAnimations& scroll_offset_animations() const; |
171 | 173 |
172 // Registers the given element animations as active. An active element | 174 // Registers the given animation player as active. An active animation |
173 // animations is one that has a running animation that needs to be ticked. | 175 // player is one that has a running animation that needs to be ticked. |
174 void DidActivateElementAnimations(ElementAnimations* element_animations); | 176 void ActivateAnimationPlayer(scoped_refptr<AnimationPlayer> player); |
175 | 177 |
176 // Unregisters the given element animations. When this happens, the | 178 // Unregisters the given animation player. When this happens, the |
177 // element animations will no longer be ticked (since it's not active). | 179 // animation player will no longer be ticked (since it's not active). |
178 void DidDeactivateElementAnimations(ElementAnimations* element_animations); | 180 void DeactivateAnimationPlayer(scoped_refptr<AnimationPlayer> player); |
179 | 181 |
180 const ElementToAnimationsMap& active_element_animations_for_testing() const; | 182 const PlayersList& active_players_for_testing() const; |
181 const ElementToAnimationsMap& all_element_animations_for_testing() const; | 183 const ElementToAnimationsMap& all_element_animations_for_testing() const; |
182 | 184 |
183 private: | 185 private: |
184 explicit AnimationHost(ThreadInstance thread_instance); | 186 explicit AnimationHost(ThreadInstance thread_instance); |
185 | 187 |
186 void PushTimelinesToImplThread(AnimationHost* host_impl) const; | 188 void PushTimelinesToImplThread(AnimationHost* host_impl) const; |
187 void RemoveTimelinesFromImplThread(AnimationHost* host_impl) const; | 189 void RemoveTimelinesFromImplThread(AnimationHost* host_impl) const; |
188 void PushPropertiesToImplThread(AnimationHost* host_impl); | 190 void PushPropertiesToImplThread(AnimationHost* host_impl); |
189 | 191 |
190 void EraseTimeline(scoped_refptr<AnimationTimeline> timeline); | 192 void EraseTimeline(scoped_refptr<AnimationTimeline> timeline); |
191 | 193 |
192 ElementToAnimationsMap element_to_animations_map_; | 194 ElementToAnimationsMap element_to_animations_map_; |
193 ElementToAnimationsMap active_element_to_animations_map_; | 195 PlayersList active_players_; |
194 | 196 |
195 // A list of all timelines which this host owns. | 197 // A list of all timelines which this host owns. |
196 using IdToTimelineMap = | 198 using IdToTimelineMap = |
197 std::unordered_map<int, scoped_refptr<AnimationTimeline>>; | 199 std::unordered_map<int, scoped_refptr<AnimationTimeline>>; |
198 IdToTimelineMap id_to_timeline_map_; | 200 IdToTimelineMap id_to_timeline_map_; |
199 | 201 |
200 MutatorHostClient* mutator_host_client_; | 202 MutatorHostClient* mutator_host_client_; |
201 | 203 |
202 std::unique_ptr<ScrollOffsetAnimations> scroll_offset_animations_; | 204 std::unique_ptr<ScrollOffsetAnimations> scroll_offset_animations_; |
203 std::unique_ptr<ScrollOffsetAnimationsImpl> scroll_offset_animations_impl_; | 205 std::unique_ptr<ScrollOffsetAnimationsImpl> scroll_offset_animations_impl_; |
204 | 206 |
205 const ThreadInstance thread_instance_; | 207 const ThreadInstance thread_instance_; |
206 | 208 |
207 bool supports_scroll_animations_; | 209 bool supports_scroll_animations_; |
208 bool needs_push_properties_; | 210 bool needs_push_properties_; |
209 | 211 |
210 DISALLOW_COPY_AND_ASSIGN(AnimationHost); | 212 DISALLOW_COPY_AND_ASSIGN(AnimationHost); |
211 }; | 213 }; |
212 | 214 |
213 } // namespace cc | 215 } // namespace cc |
214 | 216 |
215 #endif // CC_ANIMATION_ANIMATION_HOST_H_ | 217 #endif // CC_ANIMATION_ANIMATION_HOST_H_ |
OLD | NEW |