| 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 | 10 |
| 11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "base/memory/ptr_util.h" | 12 #include "base/memory/ptr_util.h" |
| 13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
| 14 #include "base/time/time.h" | 14 #include "base/time/time.h" |
| 15 #include "cc/animation/animation.h" | 15 #include "cc/animation/animation.h" |
| 16 #include "cc/animation/scroll_offset_animations_impl.h" | |
| 17 #include "cc/base/cc_export.h" | 16 #include "cc/base/cc_export.h" |
| 18 #include "cc/trees/mutator_host_client.h" | 17 #include "cc/trees/mutator_host_client.h" |
| 19 #include "ui/gfx/geometry/box_f.h" | 18 #include "ui/gfx/geometry/box_f.h" |
| 20 #include "ui/gfx/geometry/vector2d_f.h" | 19 #include "ui/gfx/geometry/vector2d_f.h" |
| 21 | 20 |
| 22 namespace gfx { | 21 namespace gfx { |
| 23 class ScrollOffset; | 22 class ScrollOffset; |
| 24 } | 23 } |
| 25 | 24 |
| 26 namespace cc { | 25 namespace cc { |
| 27 | 26 |
| 28 class AnimationEvents; | 27 class AnimationEvents; |
| 29 class AnimationPlayer; | 28 class AnimationPlayer; |
| 30 class AnimationTimeline; | 29 class AnimationTimeline; |
| 31 class ElementAnimations; | 30 class ElementAnimations; |
| 32 class LayerTreeHost; | 31 class LayerTreeHost; |
| 32 class ScrollOffsetAnimations; |
| 33 class ScrollOffsetAnimationsImpl; |
| 33 | 34 |
| 34 enum class ThreadInstance { MAIN, IMPL }; | 35 enum class ThreadInstance { MAIN, IMPL }; |
| 35 | 36 |
| 36 // An AnimationHost contains all the state required to play animations. | 37 // An AnimationHost contains all the state required to play animations. |
| 37 // Specifically, it owns all the AnimationTimelines objects. | 38 // Specifically, it owns all the AnimationTimelines objects. |
| 38 // There is just one AnimationHost for LayerTreeHost on main renderer thread | 39 // There is just one AnimationHost for LayerTreeHost on main renderer thread |
| 39 // and just one AnimationHost for LayerTreeHostImpl on impl thread. | 40 // and just one AnimationHost for LayerTreeHostImpl on impl thread. |
| 40 // We synchronize them during the commit process in a one-way data flow process | 41 // We synchronize them during the commit process in a one-way data flow process |
| 41 // (PushPropertiesTo). | 42 // (PushPropertiesTo). |
| 42 // An AnimationHost talks to its correspondent LayerTreeHost via | 43 // An AnimationHost talks to its correspondent LayerTreeHost via |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 const gfx::ScrollOffset& target_offset, | 143 const gfx::ScrollOffset& target_offset, |
| 143 const gfx::ScrollOffset& current_offset); | 144 const gfx::ScrollOffset& current_offset); |
| 144 bool ImplOnlyScrollAnimationUpdateTarget( | 145 bool ImplOnlyScrollAnimationUpdateTarget( |
| 145 ElementId element_id, | 146 ElementId element_id, |
| 146 const gfx::Vector2dF& scroll_delta, | 147 const gfx::Vector2dF& scroll_delta, |
| 147 const gfx::ScrollOffset& max_scroll_offset, | 148 const gfx::ScrollOffset& max_scroll_offset, |
| 148 base::TimeTicks frame_monotonic_time); | 149 base::TimeTicks frame_monotonic_time); |
| 149 | 150 |
| 150 void ScrollAnimationAbort(bool needs_completion); | 151 void ScrollAnimationAbort(bool needs_completion); |
| 151 | 152 |
| 153 // This should only be called from the main thread. |
| 154 ScrollOffsetAnimations& scroll_offset_animations() const; |
| 155 |
| 152 // Registers the given element animations as active. An active element | 156 // Registers the given element animations as active. An active element |
| 153 // animations is one that has a running animation that needs to be ticked. | 157 // animations is one that has a running animation that needs to be ticked. |
| 154 void DidActivateElementAnimations(ElementAnimations* element_animations); | 158 void DidActivateElementAnimations(ElementAnimations* element_animations); |
| 155 | 159 |
| 156 // Unregisters the given element animations. When this happens, the | 160 // Unregisters the given element animations. When this happens, the |
| 157 // element animations will no longer be ticked (since it's not active). | 161 // element animations will no longer be ticked (since it's not active). |
| 158 void DidDeactivateElementAnimations(ElementAnimations* element_animations); | 162 void DidDeactivateElementAnimations(ElementAnimations* element_animations); |
| 159 | 163 |
| 160 // Registers the given ElementAnimations as alive. | 164 // Registers the given ElementAnimations as alive. |
| 161 void RegisterElementAnimations(ElementAnimations* element_animations); | 165 void RegisterElementAnimations(ElementAnimations* element_animations); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 182 ElementToAnimationsMap element_to_animations_map_; | 186 ElementToAnimationsMap element_to_animations_map_; |
| 183 ElementToAnimationsMap active_element_to_animations_map_; | 187 ElementToAnimationsMap active_element_to_animations_map_; |
| 184 | 188 |
| 185 // A list of all timelines which this host owns. | 189 // A list of all timelines which this host owns. |
| 186 using IdToTimelineMap = | 190 using IdToTimelineMap = |
| 187 std::unordered_map<int, scoped_refptr<AnimationTimeline>>; | 191 std::unordered_map<int, scoped_refptr<AnimationTimeline>>; |
| 188 IdToTimelineMap id_to_timeline_map_; | 192 IdToTimelineMap id_to_timeline_map_; |
| 189 | 193 |
| 190 MutatorHostClient* mutator_host_client_; | 194 MutatorHostClient* mutator_host_client_; |
| 191 | 195 |
| 196 std::unique_ptr<ScrollOffsetAnimations> scroll_offset_animations_; |
| 192 std::unique_ptr<ScrollOffsetAnimationsImpl> scroll_offset_animations_impl_; | 197 std::unique_ptr<ScrollOffsetAnimationsImpl> scroll_offset_animations_impl_; |
| 193 | 198 |
| 194 const ThreadInstance thread_instance_; | 199 const ThreadInstance thread_instance_; |
| 195 | 200 |
| 196 bool supports_scroll_animations_; | 201 bool supports_scroll_animations_; |
| 197 bool animation_waiting_for_deletion_; | 202 bool animation_waiting_for_deletion_; |
| 198 | 203 |
| 199 DISALLOW_COPY_AND_ASSIGN(AnimationHost); | 204 DISALLOW_COPY_AND_ASSIGN(AnimationHost); |
| 200 }; | 205 }; |
| 201 | 206 |
| 202 } // namespace cc | 207 } // namespace cc |
| 203 | 208 |
| 204 #endif // CC_ANIMATION_ANIMATION_HOST_H_ | 209 #endif // CC_ANIMATION_ANIMATION_HOST_H_ |
| OLD | NEW |