| 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 #include <vector> |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 void RegisterElement(ElementId element_id, | 88 void RegisterElement(ElementId element_id, |
| 89 ElementListType list_type) override; | 89 ElementListType list_type) override; |
| 90 void UnregisterElement(ElementId element_id, | 90 void UnregisterElement(ElementId element_id, |
| 91 ElementListType list_type) override; | 91 ElementListType list_type) override; |
| 92 | 92 |
| 93 void SetMutatorHostClient(MutatorHostClient* client) override; | 93 void SetMutatorHostClient(MutatorHostClient* client) override; |
| 94 | 94 |
| 95 void PushPropertiesTo(MutatorHost* host_impl) override; | 95 void PushPropertiesTo(MutatorHost* host_impl) override; |
| 96 | 96 |
| 97 void SetSupportsScrollAnimations(bool supports_scroll_animations) override; | 97 void SetSupportsScrollAnimations(bool supports_scroll_animations) override; |
| 98 bool NeedsAnimateLayers() const override; | 98 bool NeedsTickAnimations() const override; |
| 99 | 99 |
| 100 bool ActivateAnimations() override; | 100 bool ActivateAnimations() override; |
| 101 bool AnimateLayers(base::TimeTicks monotonic_time) override; | 101 bool TickAnimations(base::TimeTicks monotonic_time) override; |
| 102 bool UpdateAnimationState(bool start_ready_animations, | 102 bool UpdateAnimationState(bool start_ready_animations, |
| 103 MutatorEvents* events) override; | 103 MutatorEvents* events) override; |
| 104 | 104 |
| 105 std::unique_ptr<MutatorEvents> CreateEvents() override; | 105 std::unique_ptr<MutatorEvents> CreateEvents() override; |
| 106 void SetAnimationEvents(std::unique_ptr<MutatorEvents> events) override; | 106 void SetAnimationEvents(std::unique_ptr<MutatorEvents> events) override; |
| 107 | 107 |
| 108 bool ScrollOffsetAnimationWasInterrupted(ElementId element_id) const override; | 108 bool ScrollOffsetAnimationWasInterrupted(ElementId element_id) const override; |
| 109 | 109 |
| 110 bool IsAnimatingFilterProperty(ElementId element_id, | 110 bool IsAnimatingFilterProperty(ElementId element_id, |
| 111 ElementListType list_type) const override; | 111 ElementListType list_type) const override; |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 bool AnimationsPreserveAxisAlignment(ElementId element_id) const override; | 146 bool AnimationsPreserveAxisAlignment(ElementId element_id) const override; |
| 147 | 147 |
| 148 bool MaximumTargetScale(ElementId element_id, | 148 bool MaximumTargetScale(ElementId element_id, |
| 149 ElementListType list_type, | 149 ElementListType list_type, |
| 150 float* max_scale) const override; | 150 float* max_scale) const override; |
| 151 bool AnimationStartScale(ElementId element_id, | 151 bool AnimationStartScale(ElementId element_id, |
| 152 ElementListType list_type, | 152 ElementListType list_type, |
| 153 float* start_scale) const override; | 153 float* start_scale) const override; |
| 154 | 154 |
| 155 bool HasAnyAnimation(ElementId element_id) const override; | 155 bool HasAnyAnimation(ElementId element_id) const override; |
| 156 bool HasActiveAnimationForTesting(ElementId element_id) const override; | 156 bool HasTickingAnimationForTesting(ElementId element_id) const override; |
| 157 | 157 |
| 158 void ImplOnlyScrollAnimationCreate(ElementId element_id, | 158 void ImplOnlyScrollAnimationCreate(ElementId element_id, |
| 159 const gfx::ScrollOffset& target_offset, | 159 const gfx::ScrollOffset& target_offset, |
| 160 const gfx::ScrollOffset& current_offset, | 160 const gfx::ScrollOffset& current_offset, |
| 161 base::TimeDelta delayed_by) override; | 161 base::TimeDelta delayed_by) override; |
| 162 bool ImplOnlyScrollAnimationUpdateTarget( | 162 bool ImplOnlyScrollAnimationUpdateTarget( |
| 163 ElementId element_id, | 163 ElementId element_id, |
| 164 const gfx::Vector2dF& scroll_delta, | 164 const gfx::Vector2dF& scroll_delta, |
| 165 const gfx::ScrollOffset& max_scroll_offset, | 165 const gfx::ScrollOffset& max_scroll_offset, |
| 166 base::TimeTicks frame_monotonic_time, | 166 base::TimeTicks frame_monotonic_time, |
| 167 base::TimeDelta delayed_by) override; | 167 base::TimeDelta delayed_by) override; |
| 168 | 168 |
| 169 void ScrollAnimationAbort(bool needs_completion) override; | 169 void ScrollAnimationAbort(bool needs_completion) override; |
| 170 | 170 |
| 171 // This should only be called from the main thread. | 171 // This should only be called from the main thread. |
| 172 ScrollOffsetAnimations& scroll_offset_animations() const; | 172 ScrollOffsetAnimations& scroll_offset_animations() const; |
| 173 | 173 |
| 174 // Registers the given animation player as active. An active animation | 174 // Registers the given animation player as ticking. A ticking animation |
| 175 // player is one that has a running animation that needs to be ticked. | 175 // player is one that has a running animation. |
| 176 void ActivateAnimationPlayer(scoped_refptr<AnimationPlayer> player); | 176 void AddToTicking(scoped_refptr<AnimationPlayer> player); |
| 177 | 177 |
| 178 // Unregisters the given animation player. When this happens, the | 178 // Unregisters the given animation player. When this happens, the |
| 179 // animation player will no longer be ticked (since it's not active). | 179 // animation player will no longer be ticked. |
| 180 void DeactivateAnimationPlayer(scoped_refptr<AnimationPlayer> player); | 180 void RemoveFromTicking(scoped_refptr<AnimationPlayer> player); |
| 181 | 181 |
| 182 const PlayersList& active_players_for_testing() const; | 182 const PlayersList& ticking_players_for_testing() const; |
| 183 const ElementToAnimationsMap& all_element_animations_for_testing() const; | 183 const ElementToAnimationsMap& element_animations_for_testing() const; |
| 184 | 184 |
| 185 private: | 185 private: |
| 186 explicit AnimationHost(ThreadInstance thread_instance); | 186 explicit AnimationHost(ThreadInstance thread_instance); |
| 187 | 187 |
| 188 void PushTimelinesToImplThread(AnimationHost* host_impl) const; | 188 void PushTimelinesToImplThread(AnimationHost* host_impl) const; |
| 189 void RemoveTimelinesFromImplThread(AnimationHost* host_impl) const; | 189 void RemoveTimelinesFromImplThread(AnimationHost* host_impl) const; |
| 190 void PushPropertiesToImplThread(AnimationHost* host_impl); | 190 void PushPropertiesToImplThread(AnimationHost* host_impl); |
| 191 | 191 |
| 192 void EraseTimeline(scoped_refptr<AnimationTimeline> timeline); | 192 void EraseTimeline(scoped_refptr<AnimationTimeline> timeline); |
| 193 | 193 |
| 194 ElementToAnimationsMap element_to_animations_map_; | 194 ElementToAnimationsMap element_to_animations_map_; |
| 195 PlayersList active_players_; | 195 PlayersList ticking_players_; |
| 196 | 196 |
| 197 // A list of all timelines which this host owns. | 197 // A list of all timelines which this host owns. |
| 198 using IdToTimelineMap = | 198 using IdToTimelineMap = |
| 199 std::unordered_map<int, scoped_refptr<AnimationTimeline>>; | 199 std::unordered_map<int, scoped_refptr<AnimationTimeline>>; |
| 200 IdToTimelineMap id_to_timeline_map_; | 200 IdToTimelineMap id_to_timeline_map_; |
| 201 | 201 |
| 202 MutatorHostClient* mutator_host_client_; | 202 MutatorHostClient* mutator_host_client_; |
| 203 | 203 |
| 204 std::unique_ptr<ScrollOffsetAnimations> scroll_offset_animations_; | 204 std::unique_ptr<ScrollOffsetAnimations> scroll_offset_animations_; |
| 205 std::unique_ptr<ScrollOffsetAnimationsImpl> scroll_offset_animations_impl_; | 205 std::unique_ptr<ScrollOffsetAnimationsImpl> scroll_offset_animations_impl_; |
| 206 | 206 |
| 207 const ThreadInstance thread_instance_; | 207 const ThreadInstance thread_instance_; |
| 208 | 208 |
| 209 bool supports_scroll_animations_; | 209 bool supports_scroll_animations_; |
| 210 bool needs_push_properties_; | 210 bool needs_push_properties_; |
| 211 | 211 |
| 212 DISALLOW_COPY_AND_ASSIGN(AnimationHost); | 212 DISALLOW_COPY_AND_ASSIGN(AnimationHost); |
| 213 }; | 213 }; |
| 214 | 214 |
| 215 } // namespace cc | 215 } // namespace cc |
| 216 | 216 |
| 217 #endif // CC_ANIMATION_ANIMATION_HOST_H_ | 217 #endif // CC_ANIMATION_ANIMATION_HOST_H_ |
| OLD | NEW |