| 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 <unordered_map> | 8 #include <unordered_map> |
| 9 #include <vector> | |
| 10 | 9 |
| 11 #include "base/macros.h" | 10 #include "base/macros.h" |
| 12 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
| 13 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 14 #include "base/time/time.h" | 13 #include "base/time/time.h" |
| 15 #include "cc/animation/animation.h" | 14 #include "cc/animation/animation.h" |
| 16 #include "cc/base/cc_export.h" | 15 #include "cc/base/cc_export.h" |
| 17 #include "cc/trees/mutator_host_client.h" | 16 #include "cc/trees/mutator_host_client.h" |
| 18 #include "ui/gfx/geometry/box_f.h" | 17 #include "ui/gfx/geometry/box_f.h" |
| 19 #include "ui/gfx/geometry/vector2d_f.h" | 18 #include "ui/gfx/geometry/vector2d_f.h" |
| 20 | 19 |
| 21 namespace gfx { | 20 namespace gfx { |
| 22 class ScrollOffset; | 21 class ScrollOffset; |
| 23 } | 22 } |
| 24 | 23 |
| 25 namespace cc { | 24 namespace cc { |
| 26 | 25 |
| 27 class AnimationEvents; | 26 class AnimationEvents; |
| 28 class AnimationPlayer; | 27 class AnimationPlayer; |
| 29 class AnimationRegistrar; | 28 class AnimationRegistrar; |
| 30 class AnimationTimeline; | 29 class AnimationTimeline; |
| 31 class ElementAnimations; | 30 class ElementAnimations; |
| 32 class LayerAnimationController; | 31 class LayerAnimationController; |
| 33 class LayerTreeHost; | 32 class LayerTreeHost; |
| 34 | 33 |
| 35 enum class ThreadInstance { MAIN, IMPL }; | 34 enum class ThreadInstance { MAIN, IMPL }; |
| 36 | 35 |
| 37 typedef std::vector<scoped_refptr<AnimationTimeline>> AnimationTimelineList; | |
| 38 | |
| 39 // An AnimationHost contains all the state required to play animations. | 36 // An AnimationHost contains all the state required to play animations. |
| 40 // Specifically, it owns all the AnimationTimelines objects. | 37 // Specifically, it owns all the AnimationTimelines objects. |
| 41 // There is just one AnimationHost for LayerTreeHost on main renderer thread | 38 // There is just one AnimationHost for LayerTreeHost on main renderer thread |
| 42 // and just one AnimationHost for LayerTreeHostImpl on impl thread. | 39 // and just one AnimationHost for LayerTreeHostImpl on impl thread. |
| 43 // 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 |
| 44 // (PushPropertiesTo). | 41 // (PushPropertiesTo). |
| 45 // An AnimationHost talks to its correspondent LayerTreeHost via | 42 // An AnimationHost talks to its correspondent LayerTreeHost via |
| 46 // LayerTreeMutatorsClient interface. | 43 // LayerTreeMutatorsClient interface. |
| 47 // AnimationHost has it's own instance of AnimationRegistrar, | 44 // AnimationHost has it's own instance of AnimationRegistrar, |
| 48 // we want to merge AnimationRegistrar into AnimationHost. | 45 // we want to merge AnimationRegistrar into AnimationHost. |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 | 151 |
| 155 void ScrollAnimationAbort(bool needs_completion); | 152 void ScrollAnimationAbort(bool needs_completion); |
| 156 | 153 |
| 157 private: | 154 private: |
| 158 explicit AnimationHost(ThreadInstance thread_instance); | 155 explicit AnimationHost(ThreadInstance thread_instance); |
| 159 | 156 |
| 160 void PushTimelinesToImplThread(AnimationHost* host_impl) const; | 157 void PushTimelinesToImplThread(AnimationHost* host_impl) const; |
| 161 void RemoveTimelinesFromImplThread(AnimationHost* host_impl) const; | 158 void RemoveTimelinesFromImplThread(AnimationHost* host_impl) const; |
| 162 void PushPropertiesToImplThread(AnimationHost* host_impl); | 159 void PushPropertiesToImplThread(AnimationHost* host_impl); |
| 163 | 160 |
| 164 void EraseTimelines(AnimationTimelineList::iterator begin, | 161 void EraseTimeline(scoped_refptr<AnimationTimeline> timeline); |
| 165 AnimationTimelineList::iterator end); | |
| 166 | 162 |
| 167 // TODO(loyso): For now AnimationPlayers share LayerAnimationController object | 163 // TODO(loyso): For now AnimationPlayers share LayerAnimationController object |
| 168 // 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 |
| 169 // contain many Layers. | 165 // contain many Layers. |
| 170 using LayerToElementAnimationsMap = | 166 using LayerToElementAnimationsMap = |
| 171 std::unordered_map<int, scoped_ptr<ElementAnimations>>; | 167 std::unordered_map<int, scoped_ptr<ElementAnimations>>; |
| 172 LayerToElementAnimationsMap layer_to_element_animations_map_; | 168 LayerToElementAnimationsMap layer_to_element_animations_map_; |
| 173 | 169 |
| 174 AnimationTimelineList timelines_; | 170 // A list of all timelines which this host owns. |
| 171 using IdToTimelineMap = |
| 172 std::unordered_map<int, scoped_refptr<AnimationTimeline>>; |
| 173 IdToTimelineMap id_to_timeline_map_; |
| 174 |
| 175 scoped_ptr<AnimationRegistrar> animation_registrar_; | 175 scoped_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 scoped_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 |