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

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

Issue 1893253002: CC Animation: Make LayerAnimationController to have just one event observer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@rc
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/element_animations.cc ('k') | cc/animation/layer_animation_controller.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 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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_LAYER_ANIMATION_CONTROLLER_H_ 5 #ifndef CC_ANIMATION_LAYER_ANIMATION_CONTROLLER_H_
6 #define CC_ANIMATION_LAYER_ANIMATION_CONTROLLER_H_ 6 #define CC_ANIMATION_LAYER_ANIMATION_CONTROLLER_H_
7 7
8 #include <bitset> 8 #include <bitset>
9 #include <memory> 9 #include <memory>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "base/memory/ref_counted.h" 13 #include "base/memory/ref_counted.h"
14 #include "base/observer_list.h"
15 #include "base/time/time.h" 14 #include "base/time/time.h"
16 #include "cc/animation/animation.h" 15 #include "cc/animation/animation.h"
17 #include "cc/animation/layer_animation_event_observer.h" 16 #include "cc/animation/layer_animation_event_observer.h"
18 #include "cc/animation/target_property.h" 17 #include "cc/animation/target_property.h"
19 #include "cc/base/cc_export.h" 18 #include "cc/base/cc_export.h"
20 #include "ui/gfx/geometry/scroll_offset.h" 19 #include "ui/gfx/geometry/scroll_offset.h"
21 #include "ui/gfx/transform.h" 20 #include "ui/gfx/transform.h"
22 21
23 namespace gfx { 22 namespace gfx {
24 class BoxF; 23 class BoxF;
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 113
115 void set_needs_active_value_observations( 114 void set_needs_active_value_observations(
116 bool needs_active_value_observations) { 115 bool needs_active_value_observations) {
117 needs_active_value_observations_ = needs_active_value_observations; 116 needs_active_value_observations_ = needs_active_value_observations;
118 } 117 }
119 void set_needs_pending_value_observations( 118 void set_needs_pending_value_observations(
120 bool needs_pending_value_observations) { 119 bool needs_pending_value_observations) {
121 needs_pending_value_observations_ = needs_pending_value_observations; 120 needs_pending_value_observations_ = needs_pending_value_observations;
122 } 121 }
123 122
124 void AddEventObserver(LayerAnimationEventObserver* observer); 123 void SetEventObserver(LayerAnimationEventObserver* observer);
125 void RemoveEventObserver(LayerAnimationEventObserver* observer);
126 124
127 void set_value_provider(LayerAnimationValueProvider* provider) { 125 void set_value_provider(LayerAnimationValueProvider* provider) {
128 value_provider_ = provider; 126 value_provider_ = provider;
129 } 127 }
130 128
131 void remove_value_provider(LayerAnimationValueProvider* provider) { 129 void remove_value_provider(LayerAnimationValueProvider* provider) {
132 if (value_provider_ == provider) 130 if (value_provider_ == provider)
133 value_provider_ = nullptr; 131 value_provider_ = nullptr;
134 } 132 }
135 133
(...skipping 26 matching lines...) Expand all
162 160
163 // Sets |start_scale| to the maximum of starting animation scale along any 161 // Sets |start_scale| to the maximum of starting animation scale along any
164 // dimension at any destination in active animations. Returns false if the 162 // dimension at any destination in active animations. Returns false if the
165 // starting scale cannot be computed. 163 // starting scale cannot be computed.
166 bool AnimationStartScale(ObserverType observer_type, 164 bool AnimationStartScale(ObserverType observer_type,
167 float* start_scale) const; 165 float* start_scale) const;
168 166
169 // Sets |max_scale| to the maximum scale along any dimension at any 167 // Sets |max_scale| to the maximum scale along any dimension at any
170 // destination in active animations. Returns false if the maximum scale cannot 168 // destination in active animations. Returns false if the maximum scale cannot
171 // be computed. 169 // be computed.
172 bool MaximumTargetScale(ObserverType event_observers_, 170 bool MaximumTargetScale(ObserverType observer_type, float* max_scale) const;
173 float* max_scale) const;
174 171
175 // When a scroll animation is removed on the main thread, its compositor 172 // When a scroll animation is removed on the main thread, its compositor
176 // thread counterpart continues producing scroll deltas until activation. 173 // thread counterpart continues producing scroll deltas until activation.
177 // These scroll deltas need to be cleared at activation, so that the active 174 // These scroll deltas need to be cleared at activation, so that the active
178 // layer's scroll offset matches the offset provided by the main thread 175 // layer's scroll offset matches the offset provided by the main thread
179 // rather than a combination of this offset and scroll deltas produced by 176 // rather than a combination of this offset and scroll deltas produced by
180 // the removed animation. This is to provide the illusion of synchronicity to 177 // the removed animation. This is to provide the illusion of synchronicity to
181 // JS that simultaneously removes an animation and sets the scroll offset. 178 // JS that simultaneously removes an animation and sets the scroll offset.
182 bool scroll_offset_animation_was_interrupted() const { 179 bool scroll_offset_animation_was_interrupted() const {
183 return scroll_offset_animation_was_interrupted_; 180 return scroll_offset_animation_was_interrupted_;
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 242
246 AnimationHost* host_; 243 AnimationHost* host_;
247 int id_; 244 int id_;
248 std::vector<std::unique_ptr<Animation>> animations_; 245 std::vector<std::unique_ptr<Animation>> animations_;
249 246
250 // This is used to ensure that we don't spam the animation host. 247 // This is used to ensure that we don't spam the animation host.
251 bool is_active_; 248 bool is_active_;
252 249
253 base::TimeTicks last_tick_time_; 250 base::TimeTicks last_tick_time_;
254 251
255 base::ObserverList<LayerAnimationEventObserver> event_observers_; 252 LayerAnimationEventObserver* event_observer_;
256 LayerAnimationValueObserver* value_observer_; 253 LayerAnimationValueObserver* value_observer_;
257 LayerAnimationValueProvider* value_provider_; 254 LayerAnimationValueProvider* value_provider_;
258 AnimationDelegate* layer_animation_delegate_; 255 AnimationDelegate* layer_animation_delegate_;
259 256
260 bool needs_active_value_observations_; 257 bool needs_active_value_observations_;
261 bool needs_pending_value_observations_; 258 bool needs_pending_value_observations_;
262 259
263 // Only try to start animations when new animations are added or when the 260 // Only try to start animations when new animations are added or when the
264 // previous attempt at starting animations failed to start all animations. 261 // previous attempt at starting animations failed to start all animations.
265 bool needs_to_start_animations_; 262 bool needs_to_start_animations_;
266 263
267 bool scroll_offset_animation_was_interrupted_; 264 bool scroll_offset_animation_was_interrupted_;
268 265
269 bool potentially_animating_transform_for_active_observers_; 266 bool potentially_animating_transform_for_active_observers_;
270 bool potentially_animating_transform_for_pending_observers_; 267 bool potentially_animating_transform_for_pending_observers_;
271 268
272 DISALLOW_COPY_AND_ASSIGN(LayerAnimationController); 269 DISALLOW_COPY_AND_ASSIGN(LayerAnimationController);
273 }; 270 };
274 271
275 } // namespace cc 272 } // namespace cc
276 273
277 #endif // CC_ANIMATION_LAYER_ANIMATION_CONTROLLER_H_ 274 #endif // CC_ANIMATION_LAYER_ANIMATION_CONTROLLER_H_
OLDNEW
« no previous file with comments | « cc/animation/element_animations.cc ('k') | cc/animation/layer_animation_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698