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

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

Issue 1950243005: Communicate MT changes to impl-only scroll offset animations (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: review comments Created 4 years, 7 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
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/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;
34
35 struct ScrollOffsetAnimationUpdate;
loyso (OOO) 2016/05/11 06:25:45 Is it used in this header?
ymalik 2016/05/12 22:31:25 No. Thanks!
33 36
34 enum class ThreadInstance { MAIN, IMPL }; 37 enum class ThreadInstance { MAIN, IMPL };
35 38
36 // An AnimationHost contains all the state required to play animations. 39 // An AnimationHost contains all the state required to play animations.
37 // Specifically, it owns all the AnimationTimelines objects. 40 // Specifically, it owns all the AnimationTimelines objects.
38 // There is just one AnimationHost for LayerTreeHost on main renderer thread 41 // There is just one AnimationHost for LayerTreeHost on main renderer thread
39 // and just one AnimationHost for LayerTreeHostImpl on impl thread. 42 // and just one AnimationHost for LayerTreeHostImpl on impl thread.
40 // We synchronize them during the commit process in a one-way data flow process 43 // We synchronize them during the commit process in a one-way data flow process
41 // (PushPropertiesTo). 44 // (PushPropertiesTo).
42 // An AnimationHost talks to its correspondent LayerTreeHost via 45 // An AnimationHost talks to its correspondent LayerTreeHost via
(...skipping 25 matching lines...) Expand all
68 // Parent LayerTreeHost or LayerTreeHostImpl. 71 // Parent LayerTreeHost or LayerTreeHostImpl.
69 MutatorHostClient* mutator_host_client() { return mutator_host_client_; } 72 MutatorHostClient* mutator_host_client() { return mutator_host_client_; }
70 const MutatorHostClient* mutator_host_client() const { 73 const MutatorHostClient* mutator_host_client() const {
71 return mutator_host_client_; 74 return mutator_host_client_;
72 } 75 }
73 void SetMutatorHostClient(MutatorHostClient* client); 76 void SetMutatorHostClient(MutatorHostClient* client);
74 77
75 void SetNeedsCommit(); 78 void SetNeedsCommit();
76 void SetNeedsRebuildPropertyTrees(); 79 void SetNeedsRebuildPropertyTrees();
77 80
78 void PushPropertiesTo(AnimationHost* host_impl); 81 void PushPropertiesTo(
82 AnimationHost* host_impl,
83 base::TimeTicks frame_monotonic_time = base::TimeTicks());
loyso (OOO) 2016/05/11 06:25:45 Can we avoid the default value and make it explici
ymalik 2016/05/12 22:31:25 No other rationale. But you're right, this should
79 84
80 void SetSupportsScrollAnimations(bool supports_scroll_animations); 85 void SetSupportsScrollAnimations(bool supports_scroll_animations);
81 bool SupportsScrollAnimations() const; 86 bool SupportsScrollAnimations() const;
82 bool NeedsAnimateLayers() const; 87 bool NeedsAnimateLayers() const;
83 88
84 bool ActivateAnimations(); 89 bool ActivateAnimations();
85 bool AnimateLayers(base::TimeTicks monotonic_time); 90 bool AnimateLayers(base::TimeTicks monotonic_time);
86 bool UpdateAnimationState(bool start_ready_animations, 91 bool UpdateAnimationState(bool start_ready_animations,
87 AnimationEvents* events); 92 AnimationEvents* events);
88 93
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 const gfx::ScrollOffset& target_offset, 147 const gfx::ScrollOffset& target_offset,
143 const gfx::ScrollOffset& current_offset); 148 const gfx::ScrollOffset& current_offset);
144 bool ImplOnlyScrollAnimationUpdateTarget( 149 bool ImplOnlyScrollAnimationUpdateTarget(
145 ElementId element_id, 150 ElementId element_id,
146 const gfx::Vector2dF& scroll_delta, 151 const gfx::Vector2dF& scroll_delta,
147 const gfx::ScrollOffset& max_scroll_offset, 152 const gfx::ScrollOffset& max_scroll_offset,
148 base::TimeTicks frame_monotonic_time); 153 base::TimeTicks frame_monotonic_time);
149 154
150 void ScrollAnimationAbort(bool needs_completion); 155 void ScrollAnimationAbort(bool needs_completion);
151 156
157 // This should only be called from the main thread.
158 ScrollOffsetAnimations& scroll_offset_animations() const;
159
152 // Registers the given element animations as active. An active element 160 // Registers the given element animations as active. An active element
153 // animations is one that has a running animation that needs to be ticked. 161 // animations is one that has a running animation that needs to be ticked.
154 void DidActivateElementAnimations(ElementAnimations* element_animations); 162 void DidActivateElementAnimations(ElementAnimations* element_animations);
155 163
156 // Unregisters the given element animations. When this happens, the 164 // Unregisters the given element animations. When this happens, the
157 // element animations will no longer be ticked (since it's not active). 165 // element animations will no longer be ticked (since it's not active).
158 void DidDeactivateElementAnimations(ElementAnimations* element_animations); 166 void DidDeactivateElementAnimations(ElementAnimations* element_animations);
159 167
160 // Registers the given ElementAnimations as alive. 168 // Registers the given ElementAnimations as alive.
161 void RegisterElementAnimations(ElementAnimations* element_animations); 169 void RegisterElementAnimations(ElementAnimations* element_animations);
162 // Unregisters the given ElementAnimations as alive. 170 // Unregisters the given ElementAnimations as alive.
163 void UnregisterElementAnimations(ElementAnimations* element_animations); 171 void UnregisterElementAnimations(ElementAnimations* element_animations);
164 172
165 const ElementToAnimationsMap& active_element_animations_for_testing() const; 173 const ElementToAnimationsMap& active_element_animations_for_testing() const;
166 const ElementToAnimationsMap& all_element_animations_for_testing() const; 174 const ElementToAnimationsMap& all_element_animations_for_testing() const;
167 175
168 bool animation_waiting_for_deletion() const { 176 bool animation_waiting_for_deletion() const {
169 return animation_waiting_for_deletion_; 177 return animation_waiting_for_deletion_;
170 } 178 }
171 void OnAnimationWaitingForDeletion(); 179 void OnAnimationWaitingForDeletion();
172 180
173 private: 181 private:
174 explicit AnimationHost(ThreadInstance thread_instance); 182 explicit AnimationHost(ThreadInstance thread_instance);
175 183
176 void PushTimelinesToImplThread(AnimationHost* host_impl) const; 184 void PushTimelinesToImplThread(AnimationHost* host_impl) const;
177 void RemoveTimelinesFromImplThread(AnimationHost* host_impl) const; 185 void RemoveTimelinesFromImplThread(AnimationHost* host_impl) const;
178 void PushPropertiesToImplThread(AnimationHost* host_impl); 186 void PushPropertiesToImplThread(AnimationHost* host_impl,
187 base::TimeTicks frame_monotonic_time);
179 188
180 void EraseTimeline(scoped_refptr<AnimationTimeline> timeline); 189 void EraseTimeline(scoped_refptr<AnimationTimeline> timeline);
181 190
182 ElementToAnimationsMap element_to_animations_map_; 191 ElementToAnimationsMap element_to_animations_map_;
183 ElementToAnimationsMap active_element_to_animations_map_; 192 ElementToAnimationsMap active_element_to_animations_map_;
184 193
185 // A list of all timelines which this host owns. 194 // A list of all timelines which this host owns.
186 using IdToTimelineMap = 195 using IdToTimelineMap =
187 std::unordered_map<int, scoped_refptr<AnimationTimeline>>; 196 std::unordered_map<int, scoped_refptr<AnimationTimeline>>;
188 IdToTimelineMap id_to_timeline_map_; 197 IdToTimelineMap id_to_timeline_map_;
189 198
190 MutatorHostClient* mutator_host_client_; 199 MutatorHostClient* mutator_host_client_;
191 200
201 std::unique_ptr<ScrollOffsetAnimations> scroll_offset_animations_;
192 std::unique_ptr<ScrollOffsetAnimationsImpl> scroll_offset_animations_impl_; 202 std::unique_ptr<ScrollOffsetAnimationsImpl> scroll_offset_animations_impl_;
193 203
194 const ThreadInstance thread_instance_; 204 const ThreadInstance thread_instance_;
195 205
196 bool supports_scroll_animations_; 206 bool supports_scroll_animations_;
197 bool animation_waiting_for_deletion_; 207 bool animation_waiting_for_deletion_;
198 208
199 DISALLOW_COPY_AND_ASSIGN(AnimationHost); 209 DISALLOW_COPY_AND_ASSIGN(AnimationHost);
200 }; 210 };
201 211
202 } // namespace cc 212 } // namespace cc
203 213
204 #endif // CC_ANIMATION_ANIMATION_HOST_H_ 214 #endif // CC_ANIMATION_ANIMATION_HOST_H_
OLDNEW
« no previous file with comments | « cc/BUILD.gn ('k') | cc/animation/animation_host.cc » ('j') | cc/animation/animation_host.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698