| 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 <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/containers/scoped_ptr_hash_map.h" | 10 #include "base/containers/scoped_ptr_hash_map.h" |
| 11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
| 12 #include "base/memory/scoped_ptr.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_events.h" | 14 #include "cc/animation/animation_events.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 | 17 |
| 18 namespace gfx { |
| 19 class ScrollOffset; |
| 20 } |
| 21 |
| 18 namespace cc { | 22 namespace cc { |
| 19 | 23 |
| 20 class AnimationPlayer; | 24 class AnimationPlayer; |
| 21 class AnimationRegistrar; | 25 class AnimationRegistrar; |
| 22 class AnimationTimeline; | 26 class AnimationTimeline; |
| 23 class ElementAnimations; | 27 class ElementAnimations; |
| 24 class LayerAnimationController; | 28 class LayerAnimationController; |
| 25 class LayerTreeHost; | 29 class LayerTreeHost; |
| 26 | 30 |
| 27 enum class ThreadInstance { MAIN, IMPL }; | 31 enum class ThreadInstance { MAIN, IMPL }; |
| 28 | 32 |
| 29 typedef std::vector<scoped_refptr<AnimationTimeline>> AnimationTimelineList; | 33 typedef std::vector<scoped_refptr<AnimationTimeline>> AnimationTimelineList; |
| 30 | 34 |
| 31 // An AnimationHost contains all the state required to play animations. | 35 // An AnimationHost contains all the state required to play animations. |
| 32 // Specifically, it owns all the AnimationTimelines objects. | 36 // Specifically, it owns all the AnimationTimelines objects. |
| 33 // There is just one AnimationHost for LayerTreeHost on main renderer thread | 37 // There is just one AnimationHost for LayerTreeHost on main renderer thread |
| 34 // and just one AnimationHost for LayerTreeHostImpl on impl thread. | 38 // and just one AnimationHost for LayerTreeHostImpl on impl thread. |
| 35 // We synchronize them during the commit process in a one-way data flow process | 39 // We synchronize them during the commit process in a one-way data flow process |
| 36 // (PushPropertiesTo). | 40 // (PushPropertiesTo). |
| 37 // An AnimationHost talks to its correspondent LayerTreeHost via | 41 // An AnimationHost talks to its correspondent LayerTreeHost via |
| 38 // LayerTreeMutatorsClient interface. | 42 // LayerTreeMutatorsClient interface. |
| 39 // AnimationHost has it's own instance of AnimationRegistrar, | 43 // AnimationHost has it's own instance of AnimationRegistrar, |
| 40 // we want to merge AnimationRegistrar into AnimationHost. | 44 // we want to merge AnimationRegistrar into AnimationHost. |
| 41 class CC_EXPORT AnimationHost { | 45 class CC_EXPORT AnimationHost { |
| 42 public: | 46 public: |
| 43 static scoped_ptr<AnimationHost> Create(); | 47 static scoped_ptr<AnimationHost> Create(ThreadInstance thread_instance); |
| 44 virtual ~AnimationHost(); | 48 virtual ~AnimationHost(); |
| 45 | 49 |
| 46 void AddAnimationTimeline(scoped_refptr<AnimationTimeline> timeline); | 50 void AddAnimationTimeline(scoped_refptr<AnimationTimeline> timeline); |
| 47 void RemoveAnimationTimeline(scoped_refptr<AnimationTimeline> timeline); | 51 void RemoveAnimationTimeline(scoped_refptr<AnimationTimeline> timeline); |
| 48 AnimationTimeline* GetTimelineById(int timeline_id) const; | 52 AnimationTimeline* GetTimelineById(int timeline_id) const; |
| 49 | 53 |
| 50 void ClearTimelines(); | 54 void ClearTimelines(); |
| 51 | 55 |
| 52 void RegisterLayer(int layer_id, LayerTreeType tree_type); | 56 void RegisterLayer(int layer_id, LayerTreeType tree_type); |
| 53 void UnregisterLayer(int layer_id, LayerTreeType tree_type); | 57 void UnregisterLayer(int layer_id, LayerTreeType tree_type); |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 | 117 |
| 114 bool HasOnlyTranslationTransforms(int layer_id) const; | 118 bool HasOnlyTranslationTransforms(int layer_id) const; |
| 115 bool AnimationsPreserveAxisAlignment(int layer_id) const; | 119 bool AnimationsPreserveAxisAlignment(int layer_id) const; |
| 116 | 120 |
| 117 bool MaximumTargetScale(int layer_id, float* max_scale) const; | 121 bool MaximumTargetScale(int layer_id, float* max_scale) const; |
| 118 bool AnimationStartScale(int layer_id, float* start_scale) const; | 122 bool AnimationStartScale(int layer_id, float* start_scale) const; |
| 119 | 123 |
| 120 bool HasAnyAnimation(int layer_id) const; | 124 bool HasAnyAnimation(int layer_id) const; |
| 121 bool HasActiveAnimation(int layer_id) const; | 125 bool HasActiveAnimation(int layer_id) const; |
| 122 | 126 |
| 127 void ImplOnlyScrollAnimationCreate(int layer_id, |
| 128 const gfx::ScrollOffset& target_offset, |
| 129 const gfx::ScrollOffset& current_offset); |
| 130 bool ImplOnlyScrollAnimationUpdateTarget( |
| 131 int layer_id, |
| 132 const gfx::Vector2dF& scroll_delta, |
| 133 const gfx::ScrollOffset& max_scroll_offset, |
| 134 base::TimeTicks frame_monotonic_time); |
| 135 |
| 123 private: | 136 private: |
| 124 AnimationHost(); | 137 explicit AnimationHost(ThreadInstance thread_instance); |
| 125 | 138 |
| 126 void PushTimelinesToImplThread(AnimationHost* host_impl) const; | 139 void PushTimelinesToImplThread(AnimationHost* host_impl) const; |
| 127 void RemoveTimelinesFromImplThread(AnimationHost* host_impl) const; | 140 void RemoveTimelinesFromImplThread(AnimationHost* host_impl) const; |
| 128 void PushPropertiesToImplThread(AnimationHost* host_impl); | 141 void PushPropertiesToImplThread(AnimationHost* host_impl); |
| 129 | 142 |
| 130 void EraseTimelines(AnimationTimelineList::iterator begin, | 143 void EraseTimelines(AnimationTimelineList::iterator begin, |
| 131 AnimationTimelineList::iterator end); | 144 AnimationTimelineList::iterator end); |
| 132 | 145 |
| 133 // TODO(loyso): For now AnimationPlayers share LayerAnimationController object | 146 // TODO(loyso): For now AnimationPlayers share LayerAnimationController object |
| 134 // if they are attached to the same element(layer). Note that Element can | 147 // if they are attached to the same element(layer). Note that Element can |
| 135 // contain many Layers. | 148 // contain many Layers. |
| 136 typedef base::ScopedPtrHashMap<int, scoped_ptr<ElementAnimations>> | 149 typedef base::ScopedPtrHashMap<int, scoped_ptr<ElementAnimations>> |
| 137 LayerToElementAnimationsMap; | 150 LayerToElementAnimationsMap; |
| 138 LayerToElementAnimationsMap layer_to_element_animations_map_; | 151 LayerToElementAnimationsMap layer_to_element_animations_map_; |
| 139 | 152 |
| 140 AnimationTimelineList timelines_; | 153 AnimationTimelineList timelines_; |
| 141 scoped_ptr<AnimationRegistrar> animation_registrar_; | 154 scoped_ptr<AnimationRegistrar> animation_registrar_; |
| 142 MutatorHostClient* mutator_host_client_; | 155 MutatorHostClient* mutator_host_client_; |
| 143 | 156 |
| 157 class ScrollOffsetAnimations; |
| 158 scoped_ptr<ScrollOffsetAnimations> scroll_offset_animations_; |
| 159 |
| 160 const ThreadInstance thread_instance_; |
| 161 |
| 144 DISALLOW_COPY_AND_ASSIGN(AnimationHost); | 162 DISALLOW_COPY_AND_ASSIGN(AnimationHost); |
| 145 }; | 163 }; |
| 146 | 164 |
| 147 } // namespace cc | 165 } // namespace cc |
| 148 | 166 |
| 149 #endif // CC_ANIMATION_ANIMATION_HOST_H_ | 167 #endif // CC_ANIMATION_ANIMATION_HOST_H_ |
| OLD | NEW |