Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(121)

Side by Side Diff: cc/animation/animation_host.h

Issue 1922833002: CC Animation: Start replacing int layer_id with ElementId element_id. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/animation/animation_events.cc ('k') | cc/animation/animation_host.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/base/cc_export.h" 16 #include "cc/base/cc_export.h"
17 #include "cc/trees/mutator_host_client.h"
17 #include "ui/gfx/geometry/box_f.h" 18 #include "ui/gfx/geometry/box_f.h"
18 #include "ui/gfx/geometry/vector2d_f.h" 19 #include "ui/gfx/geometry/vector2d_f.h"
19 20
20 namespace gfx { 21 namespace gfx {
21 class ScrollOffset; 22 class ScrollOffset;
22 } 23 }
23 24
24 namespace cc { 25 namespace cc {
25 26
26 class AnimationEvents; 27 class AnimationEvents;
27 class AnimationPlayer; 28 class AnimationPlayer;
28 class AnimationTimeline; 29 class AnimationTimeline;
29 class ElementAnimations; 30 class ElementAnimations;
30 class LayerTreeHost; 31 class LayerTreeHost;
31 class MutatorHostClient;
32 enum class LayerTreeType;
33 32
34 enum class ThreadInstance { MAIN, IMPL }; 33 enum class ThreadInstance { MAIN, IMPL };
35 34
36 // An AnimationHost contains all the state required to play animations. 35 // An AnimationHost contains all the state required to play animations.
37 // Specifically, it owns all the AnimationTimelines objects. 36 // Specifically, it owns all the AnimationTimelines objects.
38 // There is just one AnimationHost for LayerTreeHost on main renderer thread 37 // There is just one AnimationHost for LayerTreeHost on main renderer thread
39 // and just one AnimationHost for LayerTreeHostImpl on impl thread. 38 // and just one AnimationHost for LayerTreeHostImpl on impl thread.
40 // 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
41 // (PushPropertiesTo). 40 // (PushPropertiesTo).
42 // An AnimationHost talks to its correspondent LayerTreeHost via 41 // An AnimationHost talks to its correspondent LayerTreeHost via
43 // LayerTreeMutatorsClient interface. 42 // LayerTreeMutatorsClient interface.
44 class CC_EXPORT AnimationHost { 43 class CC_EXPORT AnimationHost {
45 public: 44 public:
46 using LayerToElementAnimationsMap = 45 using LayerToElementAnimationsMap =
47 std::unordered_map<int, scoped_refptr<ElementAnimations>>; 46 std::unordered_map<int, scoped_refptr<ElementAnimations>>;
48 47
49 static std::unique_ptr<AnimationHost> Create(ThreadInstance thread_instance); 48 static std::unique_ptr<AnimationHost> Create(ThreadInstance thread_instance);
50 ~AnimationHost(); 49 ~AnimationHost();
51 50
52 void AddAnimationTimeline(scoped_refptr<AnimationTimeline> timeline); 51 void AddAnimationTimeline(scoped_refptr<AnimationTimeline> timeline);
53 void RemoveAnimationTimeline(scoped_refptr<AnimationTimeline> timeline); 52 void RemoveAnimationTimeline(scoped_refptr<AnimationTimeline> timeline);
54 AnimationTimeline* GetTimelineById(int timeline_id) const; 53 AnimationTimeline* GetTimelineById(int timeline_id) const;
55 54
56 void ClearTimelines(); 55 void ClearTimelines();
57 56
58 void RegisterLayer(int layer_id, LayerTreeType tree_type); 57 void RegisterLayer(ElementId element_id, LayerTreeType tree_type);
59 void UnregisterLayer(int layer_id, LayerTreeType tree_type); 58 void UnregisterLayer(ElementId element_id, LayerTreeType tree_type);
60 59
61 void RegisterPlayerForLayer(int layer_id, AnimationPlayer* player); 60 void RegisterPlayerForLayer(ElementId element_id, AnimationPlayer* player);
62 void UnregisterPlayerForLayer(int layer_id, AnimationPlayer* player); 61 void UnregisterPlayerForLayer(ElementId element_id, AnimationPlayer* player);
63 62
64 scoped_refptr<ElementAnimations> GetElementAnimationsForLayerId( 63 scoped_refptr<ElementAnimations> GetElementAnimationsForLayerId(
65 int layer_id) const; 64 ElementId element_id) const;
66 65
67 // Parent LayerTreeHost or LayerTreeHostImpl. 66 // Parent LayerTreeHost or LayerTreeHostImpl.
68 MutatorHostClient* mutator_host_client() { return mutator_host_client_; } 67 MutatorHostClient* mutator_host_client() { return mutator_host_client_; }
69 const MutatorHostClient* mutator_host_client() const { 68 const MutatorHostClient* mutator_host_client() const {
70 return mutator_host_client_; 69 return mutator_host_client_;
71 } 70 }
72 void SetMutatorHostClient(MutatorHostClient* client); 71 void SetMutatorHostClient(MutatorHostClient* client);
73 72
74 void SetNeedsCommit(); 73 void SetNeedsCommit();
75 void SetNeedsRebuildPropertyTrees(); 74 void SetNeedsRebuildPropertyTrees();
76 75
77 void PushPropertiesTo(AnimationHost* host_impl); 76 void PushPropertiesTo(AnimationHost* host_impl);
78 77
79 void SetSupportsScrollAnimations(bool supports_scroll_animations); 78 void SetSupportsScrollAnimations(bool supports_scroll_animations);
80 bool SupportsScrollAnimations() const; 79 bool SupportsScrollAnimations() const;
81 bool NeedsAnimateLayers() const; 80 bool NeedsAnimateLayers() const;
82 81
83 bool ActivateAnimations(); 82 bool ActivateAnimations();
84 bool AnimateLayers(base::TimeTicks monotonic_time); 83 bool AnimateLayers(base::TimeTicks monotonic_time);
85 bool UpdateAnimationState(bool start_ready_animations, 84 bool UpdateAnimationState(bool start_ready_animations,
86 AnimationEvents* events); 85 AnimationEvents* events);
87 86
88 std::unique_ptr<AnimationEvents> CreateEvents(); 87 std::unique_ptr<AnimationEvents> CreateEvents();
89 void SetAnimationEvents(std::unique_ptr<AnimationEvents> events); 88 void SetAnimationEvents(std::unique_ptr<AnimationEvents> events);
90 89
91 bool ScrollOffsetAnimationWasInterrupted(int layer_id) const; 90 bool ScrollOffsetAnimationWasInterrupted(ElementId element_id) const;
92 91
93 bool IsAnimatingFilterProperty(int layer_id, LayerTreeType tree_type) const; 92 bool IsAnimatingFilterProperty(ElementId element_id,
94 bool IsAnimatingOpacityProperty(int layer_id, LayerTreeType tree_type) const; 93 LayerTreeType tree_type) const;
95 bool IsAnimatingTransformProperty(int layer_id, 94 bool IsAnimatingOpacityProperty(ElementId element_id,
95 LayerTreeType tree_type) const;
96 bool IsAnimatingTransformProperty(ElementId element_id,
96 LayerTreeType tree_type) const; 97 LayerTreeType tree_type) const;
97 98
98 bool HasPotentiallyRunningFilterAnimation(int layer_id, 99 bool HasPotentiallyRunningFilterAnimation(ElementId element_id,
99 LayerTreeType tree_type) const; 100 LayerTreeType tree_type) const;
100 bool HasPotentiallyRunningOpacityAnimation(int layer_id, 101 bool HasPotentiallyRunningOpacityAnimation(ElementId element_id,
101 LayerTreeType tree_type) const; 102 LayerTreeType tree_type) const;
102 bool HasPotentiallyRunningTransformAnimation(int layer_id, 103 bool HasPotentiallyRunningTransformAnimation(ElementId element_id,
103 LayerTreeType tree_type) const; 104 LayerTreeType tree_type) const;
104 105
105 bool HasAnyAnimationTargetingProperty(int layer_id, 106 bool HasAnyAnimationTargetingProperty(ElementId element_id,
106 TargetProperty::Type property) const; 107 TargetProperty::Type property) const;
107 108
108 bool FilterIsAnimatingOnImplOnly(int layer_id) const; 109 bool FilterIsAnimatingOnImplOnly(ElementId element_id) const;
109 bool OpacityIsAnimatingOnImplOnly(int layer_id) const; 110 bool OpacityIsAnimatingOnImplOnly(ElementId element_id) const;
110 bool ScrollOffsetIsAnimatingOnImplOnly(int layer_id) const; 111 bool ScrollOffsetIsAnimatingOnImplOnly(ElementId element_id) const;
111 bool TransformIsAnimatingOnImplOnly(int layer_id) const; 112 bool TransformIsAnimatingOnImplOnly(ElementId element_id) const;
112 113
113 bool HasFilterAnimationThatInflatesBounds(int layer_id) const; 114 bool HasFilterAnimationThatInflatesBounds(ElementId element_id) const;
114 bool HasTransformAnimationThatInflatesBounds(int layer_id) const; 115 bool HasTransformAnimationThatInflatesBounds(ElementId element_id) const;
115 bool HasAnimationThatInflatesBounds(int layer_id) const; 116 bool HasAnimationThatInflatesBounds(ElementId element_id) const;
116 117
117 bool FilterAnimationBoundsForBox(int layer_id, 118 bool FilterAnimationBoundsForBox(ElementId element_id,
118 const gfx::BoxF& box, 119 const gfx::BoxF& box,
119 gfx::BoxF* bounds) const; 120 gfx::BoxF* bounds) const;
120 bool TransformAnimationBoundsForBox(int layer_id, 121 bool TransformAnimationBoundsForBox(ElementId element_id,
121 const gfx::BoxF& box, 122 const gfx::BoxF& box,
122 gfx::BoxF* bounds) const; 123 gfx::BoxF* bounds) const;
123 124
124 bool HasOnlyTranslationTransforms(int layer_id, 125 bool HasOnlyTranslationTransforms(ElementId element_id,
125 LayerTreeType tree_type) const; 126 LayerTreeType tree_type) const;
126 bool AnimationsPreserveAxisAlignment(int layer_id) const; 127 bool AnimationsPreserveAxisAlignment(ElementId element_id) const;
127 128
128 bool MaximumTargetScale(int layer_id, 129 bool MaximumTargetScale(ElementId element_id,
129 LayerTreeType tree_type, 130 LayerTreeType tree_type,
130 float* max_scale) const; 131 float* max_scale) const;
131 bool AnimationStartScale(int layer_id, 132 bool AnimationStartScale(ElementId element_id,
132 LayerTreeType tree_type, 133 LayerTreeType tree_type,
133 float* start_scale) const; 134 float* start_scale) const;
134 135
135 bool HasAnyAnimation(int layer_id) const; 136 bool HasAnyAnimation(ElementId element_id) const;
136 bool HasActiveAnimationForTesting(int layer_id) const; 137 bool HasActiveAnimationForTesting(ElementId element_id) const;
137 138
138 void ImplOnlyScrollAnimationCreate(int layer_id, 139 void ImplOnlyScrollAnimationCreate(ElementId element_id,
139 const gfx::ScrollOffset& target_offset, 140 const gfx::ScrollOffset& target_offset,
140 const gfx::ScrollOffset& current_offset); 141 const gfx::ScrollOffset& current_offset);
141 bool ImplOnlyScrollAnimationUpdateTarget( 142 bool ImplOnlyScrollAnimationUpdateTarget(
142 int layer_id, 143 ElementId element_id,
143 const gfx::Vector2dF& scroll_delta, 144 const gfx::Vector2dF& scroll_delta,
144 const gfx::ScrollOffset& max_scroll_offset, 145 const gfx::ScrollOffset& max_scroll_offset,
145 base::TimeTicks frame_monotonic_time); 146 base::TimeTicks frame_monotonic_time);
146 147
147 void ScrollAnimationAbort(bool needs_completion); 148 void ScrollAnimationAbort(bool needs_completion);
148 149
149 // Registers the given element animations as active. An active element 150 // Registers the given element animations as active. An active element
150 // animations is one that has a running animation that needs to be ticked. 151 // animations is one that has a running animation that needs to be ticked.
151 void DidActivateElementAnimations(ElementAnimations* element_animations); 152 void DidActivateElementAnimations(ElementAnimations* element_animations);
152 153
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 195
195 bool supports_scroll_animations_; 196 bool supports_scroll_animations_;
196 bool animation_waiting_for_deletion_; 197 bool animation_waiting_for_deletion_;
197 198
198 DISALLOW_COPY_AND_ASSIGN(AnimationHost); 199 DISALLOW_COPY_AND_ASSIGN(AnimationHost);
199 }; 200 };
200 201
201 } // namespace cc 202 } // namespace cc
202 203
203 #endif // CC_ANIMATION_ANIMATION_HOST_H_ 204 #endif // CC_ANIMATION_ANIMATION_HOST_H_
OLDNEW
« no previous file with comments | « cc/animation/animation_events.cc ('k') | cc/animation/animation_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698