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

Side by Side Diff: cc/animation/element_animations.cc

Issue 1912023003: CC Animation: Remove Observers and Observations in namings. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@observertype
Patch Set: Rename it in .cc comments as well 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.h ('k') | cc/animation/element_animations_unittest.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 #include "cc/animation/element_animations.h" 5 #include "cc/animation/element_animations.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 10
(...skipping 12 matching lines...) Expand all
23 23
24 scoped_refptr<ElementAnimations> ElementAnimations::Create() { 24 scoped_refptr<ElementAnimations> ElementAnimations::Create() {
25 return make_scoped_refptr(new ElementAnimations()); 25 return make_scoped_refptr(new ElementAnimations());
26 } 26 }
27 27
28 ElementAnimations::ElementAnimations() 28 ElementAnimations::ElementAnimations()
29 : players_list_(new PlayersList()), 29 : players_list_(new PlayersList()),
30 animation_host_(), 30 animation_host_(),
31 layer_id_(), 31 layer_id_(),
32 is_active_(false), 32 is_active_(false),
33 needs_active_value_observations_(false), 33 has_element_in_active_list_(false),
34 needs_pending_value_observations_(false), 34 has_element_in_pending_list_(false),
35 needs_to_start_animations_(false), 35 needs_to_start_animations_(false),
36 scroll_offset_animation_was_interrupted_(false), 36 scroll_offset_animation_was_interrupted_(false),
37 potentially_animating_transform_for_active_observers_(false), 37 potentially_animating_transform_for_active_elements_(false),
38 potentially_animating_transform_for_pending_observers_(false) {} 38 potentially_animating_transform_for_pending_elements_(false) {}
39 39
40 ElementAnimations::~ElementAnimations() {} 40 ElementAnimations::~ElementAnimations() {}
41 41
42 void ElementAnimations::SetAnimationHost(AnimationHost* host) { 42 void ElementAnimations::SetAnimationHost(AnimationHost* host) {
43 animation_host_ = host; 43 animation_host_ = host;
44 } 44 }
45 45
46 void ElementAnimations::SetLayerId(int layer_id) { 46 void ElementAnimations::SetLayerId(int layer_id) {
47 layer_id_ = layer_id; 47 layer_id_ = layer_id;
48 } 48 }
49 49
50 void ElementAnimations::InitValueObservations() { 50 void ElementAnimations::InitAffectedElementTypes() {
51 DCHECK(layer_id_); 51 DCHECK(layer_id_);
52 DCHECK(animation_host_); 52 DCHECK(animation_host_);
53 53
54 UpdateActivation(FORCE_ACTIVATION); 54 UpdateActivation(FORCE_ACTIVATION);
55 55
56 DCHECK(animation_host_->mutator_host_client()); 56 DCHECK(animation_host_->mutator_host_client());
57 if (animation_host_->mutator_host_client()->IsLayerInTree( 57 if (animation_host_->mutator_host_client()->IsLayerInTree(
58 layer_id_, LayerTreeType::ACTIVE)) { 58 layer_id_, LayerTreeType::ACTIVE)) {
59 set_needs_active_value_observations(true); 59 set_has_element_in_active_list(true);
60 } 60 }
61 if (animation_host_->mutator_host_client()->IsLayerInTree( 61 if (animation_host_->mutator_host_client()->IsLayerInTree(
62 layer_id_, LayerTreeType::PENDING)) { 62 layer_id_, LayerTreeType::PENDING)) {
63 set_needs_pending_value_observations(true); 63 set_has_element_in_pending_list(true);
64 } 64 }
65 } 65 }
66 66
67 void ElementAnimations::ClearValueObservations() { 67 void ElementAnimations::ClearAffectedElementTypes() {
68 DCHECK(animation_host_); 68 DCHECK(animation_host_);
69 69
70 if (needs_active_value_observations()) 70 if (has_element_in_active_list())
71 OnTransformIsPotentiallyAnimatingChanged(LayerTreeType::ACTIVE, false); 71 OnTransformIsPotentiallyAnimatingChanged(LayerTreeType::ACTIVE, false);
72 set_needs_active_value_observations(false); 72 set_has_element_in_active_list(false);
73 73
74 if (needs_pending_value_observations()) 74 if (has_element_in_pending_list())
75 OnTransformIsPotentiallyAnimatingChanged(LayerTreeType::PENDING, false); 75 OnTransformIsPotentiallyAnimatingChanged(LayerTreeType::PENDING, false);
76 set_needs_pending_value_observations(false); 76 set_has_element_in_pending_list(false);
77 77
78 animation_host_->DidDeactivateElementAnimations(this); 78 animation_host_->DidDeactivateElementAnimations(this);
79 UpdateActivation(FORCE_ACTIVATION); 79 UpdateActivation(FORCE_ACTIVATION);
80 } 80 }
81 81
82 void ElementAnimations::LayerRegistered(int layer_id, LayerTreeType tree_type) { 82 void ElementAnimations::LayerRegistered(int layer_id, LayerTreeType tree_type) {
83 DCHECK_EQ(layer_id_, layer_id); 83 DCHECK_EQ(layer_id_, layer_id);
84 84
85 if (tree_type == LayerTreeType::ACTIVE) 85 if (tree_type == LayerTreeType::ACTIVE)
86 set_needs_active_value_observations(true); 86 set_has_element_in_active_list(true);
87 else 87 else
88 set_needs_pending_value_observations(true); 88 set_has_element_in_pending_list(true);
89 } 89 }
90 90
91 void ElementAnimations::LayerUnregistered(int layer_id, 91 void ElementAnimations::LayerUnregistered(int layer_id,
92 LayerTreeType tree_type) { 92 LayerTreeType tree_type) {
93 DCHECK_EQ(this->layer_id(), layer_id); 93 DCHECK_EQ(this->layer_id(), layer_id);
94 if (tree_type == LayerTreeType::ACTIVE) 94 if (tree_type == LayerTreeType::ACTIVE)
95 set_needs_active_value_observations(false); 95 set_has_element_in_active_list(false);
96 else 96 else
97 set_needs_pending_value_observations(false); 97 set_has_element_in_pending_list(false);
98 } 98 }
99 99
100 void ElementAnimations::AddPlayer(AnimationPlayer* player) { 100 void ElementAnimations::AddPlayer(AnimationPlayer* player) {
101 players_list_->Append(player); 101 players_list_->Append(player);
102 } 102 }
103 103
104 void ElementAnimations::RemovePlayer(AnimationPlayer* player) { 104 void ElementAnimations::RemovePlayer(AnimationPlayer* player) {
105 for (PlayersListNode* node = players_list_->head(); 105 for (PlayersListNode* node = players_list_->head();
106 node != players_list_->end(); node = node->next()) { 106 node != players_list_->end(); node = node->next()) {
107 if (node->value() == player) { 107 if (node->value() == player) {
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 animation->target_property() == TargetProperty::TRANSFORM; 139 animation->target_property() == TargetProperty::TRANSFORM;
140 animations_.push_back(std::move(animation)); 140 animations_.push_back(std::move(animation));
141 needs_to_start_animations_ = true; 141 needs_to_start_animations_ = true;
142 UpdateActivation(NORMAL_ACTIVATION); 142 UpdateActivation(NORMAL_ACTIVATION);
143 if (added_transform_animation) 143 if (added_transform_animation)
144 UpdatePotentiallyAnimatingTransform(); 144 UpdatePotentiallyAnimatingTransform();
145 } 145 }
146 146
147 void ElementAnimations::Animate(base::TimeTicks monotonic_time) { 147 void ElementAnimations::Animate(base::TimeTicks monotonic_time) {
148 DCHECK(!monotonic_time.is_null()); 148 DCHECK(!monotonic_time.is_null());
149 if (!needs_active_value_observations() && !needs_pending_value_observations()) 149 if (!has_element_in_active_list() && !has_element_in_pending_list())
150 return; 150 return;
151 151
152 if (needs_to_start_animations_) 152 if (needs_to_start_animations_)
153 StartAnimations(monotonic_time); 153 StartAnimations(monotonic_time);
154 TickAnimations(monotonic_time); 154 TickAnimations(monotonic_time);
155 last_tick_time_ = monotonic_time; 155 last_tick_time_ = monotonic_time;
156 } 156 }
157 157
158 void ElementAnimations::AccumulatePropertyUpdates( 158 void ElementAnimations::AccumulatePropertyUpdates(
159 base::TimeTicks monotonic_time, 159 base::TimeTicks monotonic_time,
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 // main thread (e.g. for user-driven scrolling), so a PROPERTY_UPDATE 217 // main thread (e.g. for user-driven scrolling), so a PROPERTY_UPDATE
218 // isn't needed. 218 // isn't needed.
219 break; 219 break;
220 } 220 }
221 } 221 }
222 } 222 }
223 } 223 }
224 224
225 void ElementAnimations::UpdateState(bool start_ready_animations, 225 void ElementAnimations::UpdateState(bool start_ready_animations,
226 AnimationEvents* events) { 226 AnimationEvents* events) {
227 if (!needs_active_value_observations()) 227 if (!has_element_in_active_list())
228 return; 228 return;
229 229
230 // Animate hasn't been called, this happens if an observer has been added 230 // Animate hasn't been called, this happens if an element has been added
231 // between the Commit and Draw phases. 231 // between the Commit and Draw phases.
232 if (last_tick_time_ == base::TimeTicks()) 232 if (last_tick_time_ == base::TimeTicks())
233 return; 233 return;
234 234
235 if (start_ready_animations) 235 if (start_ready_animations)
236 PromoteStartedAnimations(last_tick_time_, events); 236 PromoteStartedAnimations(last_tick_time_, events);
237 237
238 MarkFinishedAnimations(last_tick_time_); 238 MarkFinishedAnimations(last_tick_time_);
239 MarkAnimationsForDeletion(last_tick_time_, events); 239 MarkAnimationsForDeletion(last_tick_time_, events);
240 240
241 if (needs_to_start_animations_ && start_ready_animations) { 241 if (needs_to_start_animations_ && start_ready_animations) {
242 StartAnimations(last_tick_time_); 242 StartAnimations(last_tick_time_);
243 PromoteStartedAnimations(last_tick_time_, events); 243 PromoteStartedAnimations(last_tick_time_, events);
244 } 244 }
245 245
246 AccumulatePropertyUpdates(last_tick_time_, events); 246 AccumulatePropertyUpdates(last_tick_time_, events);
247 247
248 UpdateActivation(NORMAL_ACTIVATION); 248 UpdateActivation(NORMAL_ACTIVATION);
249 } 249 }
250 250
251 void ElementAnimations::ActivateAnimations() { 251 void ElementAnimations::ActivateAnimations() {
252 bool changed_transform_animation = false; 252 bool changed_transform_animation = false;
253 for (size_t i = 0; i < animations_.size(); ++i) { 253 for (size_t i = 0; i < animations_.size(); ++i) {
254 if (animations_[i]->affects_active_observers() != 254 if (animations_[i]->affects_active_elements() !=
255 animations_[i]->affects_pending_observers() && 255 animations_[i]->affects_pending_elements() &&
256 animations_[i]->target_property() == TargetProperty::TRANSFORM) 256 animations_[i]->target_property() == TargetProperty::TRANSFORM)
257 changed_transform_animation = true; 257 changed_transform_animation = true;
258 animations_[i]->set_affects_active_observers( 258 animations_[i]->set_affects_active_elements(
259 animations_[i]->affects_pending_observers()); 259 animations_[i]->affects_pending_elements());
260 } 260 }
261 auto affects_no_observers = [](const std::unique_ptr<Animation>& animation) { 261 auto affects_no_elements = [](const std::unique_ptr<Animation>& animation) {
262 return !animation->affects_active_observers() && 262 return !animation->affects_active_elements() &&
263 !animation->affects_pending_observers(); 263 !animation->affects_pending_elements();
264 }; 264 };
265 animations_.erase(std::remove_if(animations_.begin(), animations_.end(), 265 animations_.erase(std::remove_if(animations_.begin(), animations_.end(),
266 affects_no_observers), 266 affects_no_elements),
267 animations_.end()); 267 animations_.end());
268 scroll_offset_animation_was_interrupted_ = false; 268 scroll_offset_animation_was_interrupted_ = false;
269 UpdateActivation(NORMAL_ACTIVATION); 269 UpdateActivation(NORMAL_ACTIVATION);
270 if (changed_transform_animation) 270 if (changed_transform_animation)
271 UpdatePotentiallyAnimatingTransform(); 271 UpdatePotentiallyAnimatingTransform();
272 } 272 }
273 273
274 void ElementAnimations::NotifyAnimationStarted(const AnimationEvent& event) { 274 void ElementAnimations::NotifyAnimationStarted(const AnimationEvent& event) {
275 if (event.is_impl_only) { 275 if (event.is_impl_only) {
276 NotifyPlayersAnimationStarted(event.monotonic_time, event.target_property, 276 NotifyPlayersAnimationStarted(event.monotonic_time, event.target_property,
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 aborted_transform_animation = true; 336 aborted_transform_animation = true;
337 break; 337 break;
338 } 338 }
339 } 339 }
340 if (aborted_transform_animation) 340 if (aborted_transform_animation)
341 UpdatePotentiallyAnimatingTransform(); 341 UpdatePotentiallyAnimatingTransform();
342 } 342 }
343 343
344 void ElementAnimations::NotifyAnimationPropertyUpdate( 344 void ElementAnimations::NotifyAnimationPropertyUpdate(
345 const AnimationEvent& event) { 345 const AnimationEvent& event) {
346 bool notify_active_observers = true; 346 bool notify_active_elements = true;
347 bool notify_pending_observers = true; 347 bool notify_pending_elements = true;
348 switch (event.target_property) { 348 switch (event.target_property) {
349 case TargetProperty::OPACITY: 349 case TargetProperty::OPACITY:
350 NotifyObserversOpacityAnimated(event.opacity, notify_active_observers, 350 NotifyClientOpacityAnimated(event.opacity, notify_active_elements,
351 notify_pending_observers); 351 notify_pending_elements);
352 break; 352 break;
353 case TargetProperty::TRANSFORM: 353 case TargetProperty::TRANSFORM:
354 NotifyObserversTransformAnimated(event.transform, notify_active_observers, 354 NotifyClientTransformAnimated(event.transform, notify_active_elements,
355 notify_pending_observers); 355 notify_pending_elements);
356 break; 356 break;
357 default: 357 default:
358 NOTREACHED(); 358 NOTREACHED();
359 } 359 }
360 } 360 }
361 361
362 bool ElementAnimations::HasFilterAnimationThatInflatesBounds() const { 362 bool ElementAnimations::HasFilterAnimationThatInflatesBounds() const {
363 for (size_t i = 0; i < animations_.size(); ++i) { 363 for (size_t i = 0; i < animations_.size(); ++i) {
364 if (!animations_[i]->is_finished() && 364 if (!animations_[i]->is_finished() &&
365 animations_[i]->target_property() == TargetProperty::FILTER && 365 animations_[i]->target_property() == TargetProperty::FILTER &&
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
426 const TransformAnimationCurve* transform_animation_curve = 426 const TransformAnimationCurve* transform_animation_curve =
427 animations_[i]->curve()->ToTransformAnimationCurve(); 427 animations_[i]->curve()->ToTransformAnimationCurve();
428 if (transform_animation_curve->AffectsScale()) 428 if (transform_animation_curve->AffectsScale())
429 return true; 429 return true;
430 } 430 }
431 431
432 return false; 432 return false;
433 } 433 }
434 434
435 bool ElementAnimations::HasOnlyTranslationTransforms( 435 bool ElementAnimations::HasOnlyTranslationTransforms(
436 LayerTreeType observer_type) const { 436 LayerTreeType tree_type) const {
437 for (size_t i = 0; i < animations_.size(); ++i) { 437 for (size_t i = 0; i < animations_.size(); ++i) {
438 if (animations_[i]->is_finished() || 438 if (animations_[i]->is_finished() ||
439 animations_[i]->target_property() != TargetProperty::TRANSFORM) 439 animations_[i]->target_property() != TargetProperty::TRANSFORM)
440 continue; 440 continue;
441 441
442 if ((observer_type == LayerTreeType::ACTIVE && 442 if ((tree_type == LayerTreeType::ACTIVE &&
443 !animations_[i]->affects_active_observers()) || 443 !animations_[i]->affects_active_elements()) ||
444 (observer_type == LayerTreeType::PENDING && 444 (tree_type == LayerTreeType::PENDING &&
445 !animations_[i]->affects_pending_observers())) 445 !animations_[i]->affects_pending_elements()))
446 continue; 446 continue;
447 447
448 const TransformAnimationCurve* transform_animation_curve = 448 const TransformAnimationCurve* transform_animation_curve =
449 animations_[i]->curve()->ToTransformAnimationCurve(); 449 animations_[i]->curve()->ToTransformAnimationCurve();
450 if (!transform_animation_curve->IsTranslation()) 450 if (!transform_animation_curve->IsTranslation())
451 return false; 451 return false;
452 } 452 }
453 453
454 return true; 454 return true;
455 } 455 }
456 456
457 bool ElementAnimations::AnimationsPreserveAxisAlignment() const { 457 bool ElementAnimations::AnimationsPreserveAxisAlignment() const {
458 for (size_t i = 0; i < animations_.size(); ++i) { 458 for (size_t i = 0; i < animations_.size(); ++i) {
459 if (animations_[i]->is_finished() || 459 if (animations_[i]->is_finished() ||
460 animations_[i]->target_property() != TargetProperty::TRANSFORM) 460 animations_[i]->target_property() != TargetProperty::TRANSFORM)
461 continue; 461 continue;
462 462
463 const TransformAnimationCurve* transform_animation_curve = 463 const TransformAnimationCurve* transform_animation_curve =
464 animations_[i]->curve()->ToTransformAnimationCurve(); 464 animations_[i]->curve()->ToTransformAnimationCurve();
465 if (!transform_animation_curve->PreservesAxisAlignment()) 465 if (!transform_animation_curve->PreservesAxisAlignment())
466 return false; 466 return false;
467 } 467 }
468 468
469 return true; 469 return true;
470 } 470 }
471 471
472 bool ElementAnimations::AnimationStartScale(LayerTreeType observer_type, 472 bool ElementAnimations::AnimationStartScale(LayerTreeType tree_type,
473 float* start_scale) const { 473 float* start_scale) const {
474 *start_scale = 0.f; 474 *start_scale = 0.f;
475 for (size_t i = 0; i < animations_.size(); ++i) { 475 for (size_t i = 0; i < animations_.size(); ++i) {
476 if (animations_[i]->is_finished() || 476 if (animations_[i]->is_finished() ||
477 animations_[i]->target_property() != TargetProperty::TRANSFORM) 477 animations_[i]->target_property() != TargetProperty::TRANSFORM)
478 continue; 478 continue;
479 479
480 if ((observer_type == LayerTreeType::ACTIVE && 480 if ((tree_type == LayerTreeType::ACTIVE &&
481 !animations_[i]->affects_active_observers()) || 481 !animations_[i]->affects_active_elements()) ||
482 (observer_type == LayerTreeType::PENDING && 482 (tree_type == LayerTreeType::PENDING &&
483 !animations_[i]->affects_pending_observers())) 483 !animations_[i]->affects_pending_elements()))
484 continue; 484 continue;
485 485
486 bool forward_direction = true; 486 bool forward_direction = true;
487 switch (animations_[i]->direction()) { 487 switch (animations_[i]->direction()) {
488 case Animation::DIRECTION_NORMAL: 488 case Animation::DIRECTION_NORMAL:
489 case Animation::DIRECTION_ALTERNATE: 489 case Animation::DIRECTION_ALTERNATE:
490 forward_direction = animations_[i]->playback_rate() >= 0.0; 490 forward_direction = animations_[i]->playback_rate() >= 0.0;
491 break; 491 break;
492 case Animation::DIRECTION_REVERSE: 492 case Animation::DIRECTION_REVERSE:
493 case Animation::DIRECTION_ALTERNATE_REVERSE: 493 case Animation::DIRECTION_ALTERNATE_REVERSE:
494 forward_direction = animations_[i]->playback_rate() < 0.0; 494 forward_direction = animations_[i]->playback_rate() < 0.0;
495 break; 495 break;
496 } 496 }
497 497
498 const TransformAnimationCurve* transform_animation_curve = 498 const TransformAnimationCurve* transform_animation_curve =
499 animations_[i]->curve()->ToTransformAnimationCurve(); 499 animations_[i]->curve()->ToTransformAnimationCurve();
500 float animation_start_scale = 0.f; 500 float animation_start_scale = 0.f;
501 if (!transform_animation_curve->AnimationStartScale(forward_direction, 501 if (!transform_animation_curve->AnimationStartScale(forward_direction,
502 &animation_start_scale)) 502 &animation_start_scale))
503 return false; 503 return false;
504 *start_scale = std::max(*start_scale, animation_start_scale); 504 *start_scale = std::max(*start_scale, animation_start_scale);
505 } 505 }
506 return true; 506 return true;
507 } 507 }
508 508
509 bool ElementAnimations::MaximumTargetScale(LayerTreeType observer_type, 509 bool ElementAnimations::MaximumTargetScale(LayerTreeType tree_type,
510 float* max_scale) const { 510 float* max_scale) const {
511 *max_scale = 0.f; 511 *max_scale = 0.f;
512 for (size_t i = 0; i < animations_.size(); ++i) { 512 for (size_t i = 0; i < animations_.size(); ++i) {
513 if (animations_[i]->is_finished() || 513 if (animations_[i]->is_finished() ||
514 animations_[i]->target_property() != TargetProperty::TRANSFORM) 514 animations_[i]->target_property() != TargetProperty::TRANSFORM)
515 continue; 515 continue;
516 516
517 if ((observer_type == LayerTreeType::ACTIVE && 517 if ((tree_type == LayerTreeType::ACTIVE &&
518 !animations_[i]->affects_active_observers()) || 518 !animations_[i]->affects_active_elements()) ||
519 (observer_type == LayerTreeType::PENDING && 519 (tree_type == LayerTreeType::PENDING &&
520 !animations_[i]->affects_pending_observers())) 520 !animations_[i]->affects_pending_elements()))
521 continue; 521 continue;
522 522
523 bool forward_direction = true; 523 bool forward_direction = true;
524 switch (animations_[i]->direction()) { 524 switch (animations_[i]->direction()) {
525 case Animation::DIRECTION_NORMAL: 525 case Animation::DIRECTION_NORMAL:
526 case Animation::DIRECTION_ALTERNATE: 526 case Animation::DIRECTION_ALTERNATE:
527 forward_direction = animations_[i]->playback_rate() >= 0.0; 527 forward_direction = animations_[i]->playback_rate() >= 0.0;
528 break; 528 break;
529 case Animation::DIRECTION_REVERSE: 529 case Animation::DIRECTION_REVERSE:
530 case Animation::DIRECTION_ALTERNATE_REVERSE: 530 case Animation::DIRECTION_ALTERNATE_REVERSE:
(...skipping 22 matching lines...) Expand all
553 // need to copy it over. 553 // need to copy it over.
554 if (element_animations_impl->GetAnimationById(animations_[i]->id())) 554 if (element_animations_impl->GetAnimationById(animations_[i]->id()))
555 continue; 555 continue;
556 556
557 if (animations_[i]->target_property() == TargetProperty::SCROLL_OFFSET && 557 if (animations_[i]->target_property() == TargetProperty::SCROLL_OFFSET &&
558 !animations_[i] 558 !animations_[i]
559 ->curve() 559 ->curve()
560 ->ToScrollOffsetAnimationCurve() 560 ->ToScrollOffsetAnimationCurve()
561 ->HasSetInitialValue()) { 561 ->HasSetInitialValue()) {
562 gfx::ScrollOffset current_scroll_offset; 562 gfx::ScrollOffset current_scroll_offset;
563 if (element_animations_impl->needs_active_value_observations()) { 563 if (element_animations_impl->has_element_in_active_list()) {
564 current_scroll_offset = 564 current_scroll_offset =
565 element_animations_impl->ScrollOffsetForAnimation(); 565 element_animations_impl->ScrollOffsetForAnimation();
566 } else { 566 } else {
567 // The owning layer isn't yet in the active tree, so the main thread 567 // The owning layer isn't yet in the active tree, so the main thread
568 // scroll offset will be up-to-date. 568 // scroll offset will be up-to-date.
569 current_scroll_offset = ScrollOffsetForAnimation(); 569 current_scroll_offset = ScrollOffsetForAnimation();
570 } 570 }
571 animations_[i]->curve()->ToScrollOffsetAnimationCurve()->SetInitialValue( 571 animations_[i]->curve()->ToScrollOffsetAnimationCurve()->SetInitialValue(
572 current_scroll_offset); 572 current_scroll_offset);
573 } 573 }
574 574
575 // The new animation should be set to run as soon as possible. 575 // The new animation should be set to run as soon as possible.
576 Animation::RunState initial_run_state = 576 Animation::RunState initial_run_state =
577 Animation::WAITING_FOR_TARGET_AVAILABILITY; 577 Animation::WAITING_FOR_TARGET_AVAILABILITY;
578 std::unique_ptr<Animation> to_add( 578 std::unique_ptr<Animation> to_add(
579 animations_[i]->CloneAndInitialize(initial_run_state)); 579 animations_[i]->CloneAndInitialize(initial_run_state));
580 DCHECK(!to_add->needs_synchronized_start_time()); 580 DCHECK(!to_add->needs_synchronized_start_time());
581 to_add->set_affects_active_observers(false); 581 to_add->set_affects_active_elements(false);
582 element_animations_impl->AddAnimation(std::move(to_add)); 582 element_animations_impl->AddAnimation(std::move(to_add));
583 } 583 }
584 } 584 }
585 585
586 static bool IsCompleted( 586 static bool IsCompleted(
587 Animation* animation, 587 Animation* animation,
588 const ElementAnimations* main_thread_element_animations) { 588 const ElementAnimations* main_thread_element_animations) {
589 if (animation->is_impl_only()) { 589 if (animation->is_impl_only()) {
590 return (animation->run_state() == Animation::WAITING_FOR_DELETION); 590 return (animation->run_state() == Animation::WAITING_FOR_DELETION);
591 } else { 591 } else {
592 return !main_thread_element_animations->GetAnimationById(animation->id()); 592 return !main_thread_element_animations->GetAnimationById(animation->id());
593 } 593 }
594 } 594 }
595 595
596 void ElementAnimations::RemoveAnimationsCompletedOnMainThread( 596 void ElementAnimations::RemoveAnimationsCompletedOnMainThread(
597 ElementAnimations* element_animations_impl) const { 597 ElementAnimations* element_animations_impl) const {
598 bool removed_transform_animation = false; 598 bool removed_transform_animation = false;
599 // Animations removed on the main thread should no longer affect pending 599 // Animations removed on the main thread should no longer affect pending
600 // observers, and should stop affecting active observers after the next call 600 // elements, and should stop affecting active elements after the next call
601 // to ActivateAnimations. If already WAITING_FOR_DELETION, they can be removed 601 // to ActivateAnimations. If already WAITING_FOR_DELETION, they can be removed
602 // immediately. 602 // immediately.
603 auto& animations = element_animations_impl->animations_; 603 auto& animations = element_animations_impl->animations_;
604 for (const auto& animation : animations) { 604 for (const auto& animation : animations) {
605 if (IsCompleted(animation.get(), this)) { 605 if (IsCompleted(animation.get(), this)) {
606 animation->set_affects_pending_observers(false); 606 animation->set_affects_pending_elements(false);
607 if (animation->target_property() == TargetProperty::TRANSFORM) 607 if (animation->target_property() == TargetProperty::TRANSFORM)
608 removed_transform_animation = true; 608 removed_transform_animation = true;
609 } 609 }
610 } 610 }
611 auto affects_active_only_and_is_waiting_for_deletion = 611 auto affects_active_only_and_is_waiting_for_deletion =
612 [](const std::unique_ptr<Animation>& animation) { 612 [](const std::unique_ptr<Animation>& animation) {
613 return animation->run_state() == Animation::WAITING_FOR_DELETION && 613 return animation->run_state() == Animation::WAITING_FOR_DELETION &&
614 !animation->affects_pending_observers(); 614 !animation->affects_pending_elements();
615 }; 615 };
616 animations.erase( 616 animations.erase(
617 std::remove_if(animations.begin(), animations.end(), 617 std::remove_if(animations.begin(), animations.end(),
618 affects_active_only_and_is_waiting_for_deletion), 618 affects_active_only_and_is_waiting_for_deletion),
619 animations.end()); 619 animations.end());
620 620
621 if (removed_transform_animation) 621 if (removed_transform_animation)
622 element_animations_impl->UpdatePotentiallyAnimatingTransform(); 622 element_animations_impl->UpdatePotentiallyAnimatingTransform();
623 } 623 }
624 624
625 void ElementAnimations::PushPropertiesToImplThread( 625 void ElementAnimations::PushPropertiesToImplThread(
626 ElementAnimations* element_animations_impl) { 626 ElementAnimations* element_animations_impl) {
627 for (size_t i = 0; i < animations_.size(); ++i) { 627 for (size_t i = 0; i < animations_.size(); ++i) {
628 Animation* current_impl = 628 Animation* current_impl =
629 element_animations_impl->GetAnimationById(animations_[i]->id()); 629 element_animations_impl->GetAnimationById(animations_[i]->id());
630 if (current_impl) 630 if (current_impl)
631 animations_[i]->PushPropertiesTo(current_impl); 631 animations_[i]->PushPropertiesTo(current_impl);
632 } 632 }
633 element_animations_impl->scroll_offset_animation_was_interrupted_ = 633 element_animations_impl->scroll_offset_animation_was_interrupted_ =
634 scroll_offset_animation_was_interrupted_; 634 scroll_offset_animation_was_interrupted_;
635 scroll_offset_animation_was_interrupted_ = false; 635 scroll_offset_animation_was_interrupted_ = false;
636 } 636 }
637 637
638 void ElementAnimations::StartAnimations(base::TimeTicks monotonic_time) { 638 void ElementAnimations::StartAnimations(base::TimeTicks monotonic_time) {
639 DCHECK(needs_to_start_animations_); 639 DCHECK(needs_to_start_animations_);
640 needs_to_start_animations_ = false; 640 needs_to_start_animations_ = false;
641 // First collect running properties affecting each type of observer. 641 // First collect running properties affecting each type of element.
642 TargetProperties blocked_properties_for_active_observers; 642 TargetProperties blocked_properties_for_active_elements;
643 TargetProperties blocked_properties_for_pending_observers; 643 TargetProperties blocked_properties_for_pending_elements;
644 std::vector<size_t> animations_waiting_for_target; 644 std::vector<size_t> animations_waiting_for_target;
645 645
646 animations_waiting_for_target.reserve(animations_.size()); 646 animations_waiting_for_target.reserve(animations_.size());
647 for (size_t i = 0; i < animations_.size(); ++i) { 647 for (size_t i = 0; i < animations_.size(); ++i) {
648 if (animations_[i]->run_state() == Animation::STARTING || 648 if (animations_[i]->run_state() == Animation::STARTING ||
649 animations_[i]->run_state() == Animation::RUNNING) { 649 animations_[i]->run_state() == Animation::RUNNING) {
650 if (animations_[i]->affects_active_observers()) { 650 if (animations_[i]->affects_active_elements()) {
651 blocked_properties_for_active_observers[animations_[i] 651 blocked_properties_for_active_elements[animations_[i]
652 ->target_property()] = true;
653 }
654 if (animations_[i]->affects_pending_elements()) {
655 blocked_properties_for_pending_elements[animations_[i]
652 ->target_property()] = true; 656 ->target_property()] = true;
653 } 657 }
654 if (animations_[i]->affects_pending_observers()) {
655 blocked_properties_for_pending_observers[animations_[i]
656 ->target_property()] =
657 true;
658 }
659 } else if (animations_[i]->run_state() == 658 } else if (animations_[i]->run_state() ==
660 Animation::WAITING_FOR_TARGET_AVAILABILITY) { 659 Animation::WAITING_FOR_TARGET_AVAILABILITY) {
661 animations_waiting_for_target.push_back(i); 660 animations_waiting_for_target.push_back(i);
662 } 661 }
663 } 662 }
664 663
665 for (size_t i = 0; i < animations_waiting_for_target.size(); ++i) { 664 for (size_t i = 0; i < animations_waiting_for_target.size(); ++i) {
666 // Collect all properties for animations with the same group id (they 665 // Collect all properties for animations with the same group id (they
667 // should all also be in the list of animations). 666 // should all also be in the list of animations).
668 size_t animation_index = animations_waiting_for_target[i]; 667 size_t animation_index = animations_waiting_for_target[i];
669 Animation* animation_waiting_for_target = 668 Animation* animation_waiting_for_target =
670 animations_[animation_index].get(); 669 animations_[animation_index].get();
671 // Check for the run state again even though the animation was waiting 670 // Check for the run state again even though the animation was waiting
672 // for target because it might have changed the run state while handling 671 // for target because it might have changed the run state while handling
673 // previous animation in this loop (if they belong to same group). 672 // previous animation in this loop (if they belong to same group).
674 if (animation_waiting_for_target->run_state() == 673 if (animation_waiting_for_target->run_state() ==
675 Animation::WAITING_FOR_TARGET_AVAILABILITY) { 674 Animation::WAITING_FOR_TARGET_AVAILABILITY) {
676 TargetProperties enqueued_properties; 675 TargetProperties enqueued_properties;
677 bool affects_active_observers = 676 bool affects_active_elements =
678 animation_waiting_for_target->affects_active_observers(); 677 animation_waiting_for_target->affects_active_elements();
679 bool affects_pending_observers = 678 bool affects_pending_elements =
680 animation_waiting_for_target->affects_pending_observers(); 679 animation_waiting_for_target->affects_pending_elements();
681 enqueued_properties[animation_waiting_for_target->target_property()] = 680 enqueued_properties[animation_waiting_for_target->target_property()] =
682 true; 681 true;
683 for (size_t j = animation_index + 1; j < animations_.size(); ++j) { 682 for (size_t j = animation_index + 1; j < animations_.size(); ++j) {
684 if (animation_waiting_for_target->group() == animations_[j]->group()) { 683 if (animation_waiting_for_target->group() == animations_[j]->group()) {
685 enqueued_properties[animations_[j]->target_property()] = true; 684 enqueued_properties[animations_[j]->target_property()] = true;
686 affects_active_observers |= 685 affects_active_elements |= animations_[j]->affects_active_elements();
687 animations_[j]->affects_active_observers(); 686 affects_pending_elements |=
688 affects_pending_observers |= 687 animations_[j]->affects_pending_elements();
689 animations_[j]->affects_pending_observers();
690 } 688 }
691 } 689 }
692 690
693 // Check to see if intersection of the list of properties affected by 691 // Check to see if intersection of the list of properties affected by
694 // the group and the list of currently blocked properties is null, taking 692 // the group and the list of currently blocked properties is null, taking
695 // into account the type(s) of observers affected by the group. In any 693 // into account the type(s) of elements affected by the group. In any
696 // case, the group's target properties need to be added to the lists of 694 // case, the group's target properties need to be added to the lists of
697 // blocked properties. 695 // blocked properties.
698 bool null_intersection = true; 696 bool null_intersection = true;
699 static_assert(TargetProperty::FIRST_TARGET_PROPERTY == 0, 697 static_assert(TargetProperty::FIRST_TARGET_PROPERTY == 0,
700 "TargetProperty must be 0-based enum"); 698 "TargetProperty must be 0-based enum");
701 for (int property = TargetProperty::FIRST_TARGET_PROPERTY; 699 for (int property = TargetProperty::FIRST_TARGET_PROPERTY;
702 property <= TargetProperty::LAST_TARGET_PROPERTY; ++property) { 700 property <= TargetProperty::LAST_TARGET_PROPERTY; ++property) {
703 if (enqueued_properties[property]) { 701 if (enqueued_properties[property]) {
704 if (affects_active_observers) { 702 if (affects_active_elements) {
705 if (blocked_properties_for_active_observers[property]) 703 if (blocked_properties_for_active_elements[property])
706 null_intersection = false; 704 null_intersection = false;
707 else 705 else
708 blocked_properties_for_active_observers[property] = true; 706 blocked_properties_for_active_elements[property] = true;
709 } 707 }
710 if (affects_pending_observers) { 708 if (affects_pending_elements) {
711 if (blocked_properties_for_pending_observers[property]) 709 if (blocked_properties_for_pending_elements[property])
712 null_intersection = false; 710 null_intersection = false;
713 else 711 else
714 blocked_properties_for_pending_observers[property] = true; 712 blocked_properties_for_pending_elements[property] = true;
715 } 713 }
716 } 714 }
717 } 715 }
718 716
719 // If the intersection is null, then we are free to start the animations 717 // If the intersection is null, then we are free to start the animations
720 // in the group. 718 // in the group.
721 if (null_intersection) { 719 if (null_intersection) {
722 animation_waiting_for_target->SetRunState(Animation::STARTING, 720 animation_waiting_for_target->SetRunState(Animation::STARTING,
723 monotonic_time); 721 monotonic_time);
724 for (size_t j = animation_index + 1; j < animations_.size(); ++j) { 722 for (size_t j = animation_index + 1; j < animations_.size(); ++j) {
725 if (animation_waiting_for_target->group() == 723 if (animation_waiting_for_target->group() ==
726 animations_[j]->group()) { 724 animations_[j]->group()) {
727 animations_[j]->SetRunState(Animation::STARTING, monotonic_time); 725 animations_[j]->SetRunState(Animation::STARTING, monotonic_time);
728 } 726 }
729 } 727 }
730 } else { 728 } else {
731 needs_to_start_animations_ = true; 729 needs_to_start_animations_ = true;
732 } 730 }
733 } 731 }
734 } 732 }
735 } 733 }
736 734
737 void ElementAnimations::PromoteStartedAnimations(base::TimeTicks monotonic_time, 735 void ElementAnimations::PromoteStartedAnimations(base::TimeTicks monotonic_time,
738 AnimationEvents* events) { 736 AnimationEvents* events) {
739 for (size_t i = 0; i < animations_.size(); ++i) { 737 for (size_t i = 0; i < animations_.size(); ++i) {
740 if (animations_[i]->run_state() == Animation::STARTING && 738 if (animations_[i]->run_state() == Animation::STARTING &&
741 animations_[i]->affects_active_observers()) { 739 animations_[i]->affects_active_elements()) {
742 animations_[i]->SetRunState(Animation::RUNNING, monotonic_time); 740 animations_[i]->SetRunState(Animation::RUNNING, monotonic_time);
743 if (!animations_[i]->has_set_start_time() && 741 if (!animations_[i]->has_set_start_time() &&
744 !animations_[i]->needs_synchronized_start_time()) 742 !animations_[i]->needs_synchronized_start_time())
745 animations_[i]->set_start_time(monotonic_time); 743 animations_[i]->set_start_time(monotonic_time);
746 if (events) { 744 if (events) {
747 base::TimeTicks start_time; 745 base::TimeTicks start_time;
748 if (animations_[i]->has_set_start_time()) 746 if (animations_[i]->has_set_start_time())
749 start_time = animations_[i]->start_time(); 747 start_time = animations_[i]->start_time();
750 else 748 else
751 start_time = monotonic_time; 749 start_time = monotonic_time;
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
893 else 891 else
894 events->events_.push_back(finished_event); 892 events->events_.push_back(finished_event);
895 } 893 }
896 animations_[animation_index]->SetRunState( 894 animations_[animation_index]->SetRunState(
897 Animation::WAITING_FOR_DELETION, monotonic_time); 895 Animation::WAITING_FOR_DELETION, monotonic_time);
898 } 896 }
899 marked_animations_for_deletions = true; 897 marked_animations_for_deletions = true;
900 } 898 }
901 } 899 }
902 if (marked_animations_for_deletions) 900 if (marked_animations_for_deletions)
903 NotifyObserversAnimationWaitingForDeletion(); 901 NotifyClientAnimationWaitingForDeletion();
904 } 902 }
905 903
906 void ElementAnimations::MarkAbortedAnimationsForDeletion( 904 void ElementAnimations::MarkAbortedAnimationsForDeletion(
907 ElementAnimations* element_animations_impl) const { 905 ElementAnimations* element_animations_impl) const {
908 bool aborted_transform_animation = false; 906 bool aborted_transform_animation = false;
909 auto& animations_impl = element_animations_impl->animations_; 907 auto& animations_impl = element_animations_impl->animations_;
910 for (const auto& animation_impl : animations_impl) { 908 for (const auto& animation_impl : animations_impl) {
911 // If the animation has been aborted on the main thread, mark it for 909 // If the animation has been aborted on the main thread, mark it for
912 // deletion. 910 // deletion.
913 if (Animation* animation = GetAnimationById(animation_impl->id())) { 911 if (Animation* animation = GetAnimationById(animation_impl->id())) {
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
947 945
948 base::TimeDelta trimmed = 946 base::TimeDelta trimmed =
949 animations_[i]->TrimTimeToCurrentIteration(monotonic_time); 947 animations_[i]->TrimTimeToCurrentIteration(monotonic_time);
950 948
951 switch (animations_[i]->target_property()) { 949 switch (animations_[i]->target_property()) {
952 case TargetProperty::TRANSFORM: { 950 case TargetProperty::TRANSFORM: {
953 const TransformAnimationCurve* transform_animation_curve = 951 const TransformAnimationCurve* transform_animation_curve =
954 animations_[i]->curve()->ToTransformAnimationCurve(); 952 animations_[i]->curve()->ToTransformAnimationCurve();
955 const gfx::Transform transform = 953 const gfx::Transform transform =
956 transform_animation_curve->GetValue(trimmed); 954 transform_animation_curve->GetValue(trimmed);
957 NotifyObserversTransformAnimated( 955 NotifyClientTransformAnimated(
958 transform, animations_[i]->affects_active_observers(), 956 transform, animations_[i]->affects_active_elements(),
959 animations_[i]->affects_pending_observers()); 957 animations_[i]->affects_pending_elements());
960 break; 958 break;
961 } 959 }
962 960
963 case TargetProperty::OPACITY: { 961 case TargetProperty::OPACITY: {
964 const FloatAnimationCurve* float_animation_curve = 962 const FloatAnimationCurve* float_animation_curve =
965 animations_[i]->curve()->ToFloatAnimationCurve(); 963 animations_[i]->curve()->ToFloatAnimationCurve();
966 const float opacity = std::max( 964 const float opacity = std::max(
967 std::min(float_animation_curve->GetValue(trimmed), 1.0f), 0.f); 965 std::min(float_animation_curve->GetValue(trimmed), 1.0f), 0.f);
968 NotifyObserversOpacityAnimated( 966 NotifyClientOpacityAnimated(
969 opacity, animations_[i]->affects_active_observers(), 967 opacity, animations_[i]->affects_active_elements(),
970 animations_[i]->affects_pending_observers()); 968 animations_[i]->affects_pending_elements());
971 break; 969 break;
972 } 970 }
973 971
974 case TargetProperty::FILTER: { 972 case TargetProperty::FILTER: {
975 const FilterAnimationCurve* filter_animation_curve = 973 const FilterAnimationCurve* filter_animation_curve =
976 animations_[i]->curve()->ToFilterAnimationCurve(); 974 animations_[i]->curve()->ToFilterAnimationCurve();
977 const FilterOperations filter = 975 const FilterOperations filter =
978 filter_animation_curve->GetValue(trimmed); 976 filter_animation_curve->GetValue(trimmed);
979 NotifyObserversFilterAnimated( 977 NotifyClientFilterAnimated(
980 filter, animations_[i]->affects_active_observers(), 978 filter, animations_[i]->affects_active_elements(),
981 animations_[i]->affects_pending_observers()); 979 animations_[i]->affects_pending_elements());
982 break; 980 break;
983 } 981 }
984 982
985 case TargetProperty::BACKGROUND_COLOR: { 983 case TargetProperty::BACKGROUND_COLOR: {
986 // Not yet implemented. 984 // Not yet implemented.
987 break; 985 break;
988 } 986 }
989 987
990 case TargetProperty::SCROLL_OFFSET: { 988 case TargetProperty::SCROLL_OFFSET: {
991 const ScrollOffsetAnimationCurve* scroll_offset_animation_curve = 989 const ScrollOffsetAnimationCurve* scroll_offset_animation_curve =
992 animations_[i]->curve()->ToScrollOffsetAnimationCurve(); 990 animations_[i]->curve()->ToScrollOffsetAnimationCurve();
993 const gfx::ScrollOffset scroll_offset = 991 const gfx::ScrollOffset scroll_offset =
994 scroll_offset_animation_curve->GetValue(trimmed); 992 scroll_offset_animation_curve->GetValue(trimmed);
995 NotifyObserversScrollOffsetAnimated( 993 NotifyClientScrollOffsetAnimated(
996 scroll_offset, animations_[i]->affects_active_observers(), 994 scroll_offset, animations_[i]->affects_active_elements(),
997 animations_[i]->affects_pending_observers()); 995 animations_[i]->affects_pending_elements());
998 break; 996 break;
999 } 997 }
1000 } 998 }
1001 } 999 }
1002 } 1000 }
1003 } 1001 }
1004 1002
1005 void ElementAnimations::UpdateActivation(UpdateActivationType type) { 1003 void ElementAnimations::UpdateActivation(UpdateActivationType type) {
1006 bool force = type == FORCE_ACTIVATION; 1004 bool force = type == FORCE_ACTIVATION;
1007 if (animation_host_) { 1005 if (animation_host_) {
1008 bool was_active = is_active_; 1006 bool was_active = is_active_;
1009 is_active_ = false; 1007 is_active_ = false;
1010 for (size_t i = 0; i < animations_.size(); ++i) { 1008 for (size_t i = 0; i < animations_.size(); ++i) {
1011 if (animations_[i]->run_state() != Animation::WAITING_FOR_DELETION) { 1009 if (animations_[i]->run_state() != Animation::WAITING_FOR_DELETION) {
1012 is_active_ = true; 1010 is_active_ = true;
1013 break; 1011 break;
1014 } 1012 }
1015 } 1013 }
1016 1014
1017 if (is_active_ && (!was_active || force)) 1015 if (is_active_ && (!was_active || force))
1018 animation_host_->DidActivateElementAnimations(this); 1016 animation_host_->DidActivateElementAnimations(this);
1019 else if (!is_active_ && (was_active || force)) 1017 else if (!is_active_ && (was_active || force))
1020 animation_host_->DidDeactivateElementAnimations(this); 1018 animation_host_->DidDeactivateElementAnimations(this);
1021 } 1019 }
1022 } 1020 }
1023 1021
1024 void ElementAnimations::NotifyObserversOpacityAnimated( 1022 void ElementAnimations::NotifyClientOpacityAnimated(
1025 float opacity, 1023 float opacity,
1026 bool notify_active_observers, 1024 bool notify_active_elements,
1027 bool notify_pending_observers) { 1025 bool notify_pending_elements) {
1028 if (notify_active_observers && needs_active_value_observations()) 1026 if (notify_active_elements && has_element_in_active_list())
1029 OnOpacityAnimated(LayerTreeType::ACTIVE, opacity); 1027 OnOpacityAnimated(LayerTreeType::ACTIVE, opacity);
1030 if (notify_pending_observers && needs_pending_value_observations()) 1028 if (notify_pending_elements && has_element_in_pending_list())
1031 OnOpacityAnimated(LayerTreeType::PENDING, opacity); 1029 OnOpacityAnimated(LayerTreeType::PENDING, opacity);
1032 } 1030 }
1033 1031
1034 void ElementAnimations::NotifyObserversTransformAnimated( 1032 void ElementAnimations::NotifyClientTransformAnimated(
1035 const gfx::Transform& transform, 1033 const gfx::Transform& transform,
1036 bool notify_active_observers, 1034 bool notify_active_elements,
1037 bool notify_pending_observers) { 1035 bool notify_pending_elements) {
1038 if (notify_active_observers && needs_active_value_observations()) 1036 if (notify_active_elements && has_element_in_active_list())
1039 OnTransformAnimated(LayerTreeType::ACTIVE, transform); 1037 OnTransformAnimated(LayerTreeType::ACTIVE, transform);
1040 if (notify_pending_observers && needs_pending_value_observations()) 1038 if (notify_pending_elements && has_element_in_pending_list())
1041 OnTransformAnimated(LayerTreeType::PENDING, transform); 1039 OnTransformAnimated(LayerTreeType::PENDING, transform);
1042 } 1040 }
1043 1041
1044 void ElementAnimations::NotifyObserversFilterAnimated( 1042 void ElementAnimations::NotifyClientFilterAnimated(
1045 const FilterOperations& filters, 1043 const FilterOperations& filters,
1046 bool notify_active_observers, 1044 bool notify_active_elements,
1047 bool notify_pending_observers) { 1045 bool notify_pending_elements) {
1048 if (notify_active_observers && needs_active_value_observations()) 1046 if (notify_active_elements && has_element_in_active_list())
1049 OnFilterAnimated(LayerTreeType::ACTIVE, filters); 1047 OnFilterAnimated(LayerTreeType::ACTIVE, filters);
1050 if (notify_pending_observers && needs_pending_value_observations()) 1048 if (notify_pending_elements && has_element_in_pending_list())
1051 OnFilterAnimated(LayerTreeType::PENDING, filters); 1049 OnFilterAnimated(LayerTreeType::PENDING, filters);
1052 } 1050 }
1053 1051
1054 void ElementAnimations::NotifyObserversScrollOffsetAnimated( 1052 void ElementAnimations::NotifyClientScrollOffsetAnimated(
1055 const gfx::ScrollOffset& scroll_offset, 1053 const gfx::ScrollOffset& scroll_offset,
1056 bool notify_active_observers, 1054 bool notify_active_elements,
1057 bool notify_pending_observers) { 1055 bool notify_pending_elements) {
1058 if (notify_active_observers && needs_active_value_observations()) 1056 if (notify_active_elements && has_element_in_active_list())
1059 OnScrollOffsetAnimated(LayerTreeType::ACTIVE, scroll_offset); 1057 OnScrollOffsetAnimated(LayerTreeType::ACTIVE, scroll_offset);
1060 if (notify_pending_observers && needs_pending_value_observations()) 1058 if (notify_pending_elements && has_element_in_pending_list())
1061 OnScrollOffsetAnimated(LayerTreeType::PENDING, scroll_offset); 1059 OnScrollOffsetAnimated(LayerTreeType::PENDING, scroll_offset);
1062 } 1060 }
1063 1061
1064 void ElementAnimations::NotifyObserversAnimationWaitingForDeletion() { 1062 void ElementAnimations::NotifyClientAnimationWaitingForDeletion() {
1065 OnAnimationWaitingForDeletion(); 1063 OnAnimationWaitingForDeletion();
1066 } 1064 }
1067 1065
1068 void ElementAnimations::NotifyObserversTransformIsPotentiallyAnimatingChanged( 1066 void ElementAnimations::NotifyClientTransformIsPotentiallyAnimatingChanged(
1069 bool notify_active_observers, 1067 bool notify_active_elements,
1070 bool notify_pending_observers) { 1068 bool notify_pending_elements) {
1071 if (notify_active_observers && needs_active_value_observations()) 1069 if (notify_active_elements && has_element_in_active_list())
1072 OnTransformIsPotentiallyAnimatingChanged( 1070 OnTransformIsPotentiallyAnimatingChanged(
1073 LayerTreeType::ACTIVE, 1071 LayerTreeType::ACTIVE,
1074 potentially_animating_transform_for_active_observers_); 1072 potentially_animating_transform_for_active_elements_);
1075 if (notify_pending_observers && needs_pending_value_observations()) 1073 if (notify_pending_elements && has_element_in_pending_list())
1076 OnTransformIsPotentiallyAnimatingChanged( 1074 OnTransformIsPotentiallyAnimatingChanged(
1077 LayerTreeType::PENDING, 1075 LayerTreeType::PENDING,
1078 potentially_animating_transform_for_pending_observers_); 1076 potentially_animating_transform_for_pending_elements_);
1079 } 1077 }
1080 1078
1081 void ElementAnimations::UpdatePotentiallyAnimatingTransform() { 1079 void ElementAnimations::UpdatePotentiallyAnimatingTransform() {
1082 bool was_potentially_animating_transform_for_active_observers = 1080 bool was_potentially_animating_transform_for_active_elements =
1083 potentially_animating_transform_for_active_observers_; 1081 potentially_animating_transform_for_active_elements_;
1084 bool was_potentially_animating_transform_for_pending_observers = 1082 bool was_potentially_animating_transform_for_pending_elements =
1085 potentially_animating_transform_for_pending_observers_; 1083 potentially_animating_transform_for_pending_elements_;
1086 1084
1087 potentially_animating_transform_for_active_observers_ = false; 1085 potentially_animating_transform_for_active_elements_ = false;
1088 potentially_animating_transform_for_pending_observers_ = false; 1086 potentially_animating_transform_for_pending_elements_ = false;
1089 1087
1090 for (const auto& animation : animations_) { 1088 for (const auto& animation : animations_) {
1091 if (!animation->is_finished() && 1089 if (!animation->is_finished() &&
1092 animation->target_property() == TargetProperty::TRANSFORM) { 1090 animation->target_property() == TargetProperty::TRANSFORM) {
1093 potentially_animating_transform_for_active_observers_ |= 1091 potentially_animating_transform_for_active_elements_ |=
1094 animation->affects_active_observers(); 1092 animation->affects_active_elements();
1095 potentially_animating_transform_for_pending_observers_ |= 1093 potentially_animating_transform_for_pending_elements_ |=
1096 animation->affects_pending_observers(); 1094 animation->affects_pending_elements();
1097 } 1095 }
1098 } 1096 }
1099 1097
1100 bool changed_for_active_observers = 1098 bool changed_for_active_elements =
1101 was_potentially_animating_transform_for_active_observers != 1099 was_potentially_animating_transform_for_active_elements !=
1102 potentially_animating_transform_for_active_observers_; 1100 potentially_animating_transform_for_active_elements_;
1103 bool changed_for_pending_observers = 1101 bool changed_for_pending_elements =
1104 was_potentially_animating_transform_for_pending_observers != 1102 was_potentially_animating_transform_for_pending_elements !=
1105 potentially_animating_transform_for_pending_observers_; 1103 potentially_animating_transform_for_pending_elements_;
1106 1104
1107 if (!changed_for_active_observers && !changed_for_pending_observers) 1105 if (!changed_for_active_elements && !changed_for_pending_elements)
1108 return; 1106 return;
1109 1107
1110 NotifyObserversTransformIsPotentiallyAnimatingChanged( 1108 NotifyClientTransformIsPotentiallyAnimatingChanged(
1111 changed_for_active_observers, changed_for_pending_observers); 1109 changed_for_active_elements, changed_for_pending_elements);
1112 } 1110 }
1113 1111
1114 bool ElementAnimations::HasActiveAnimation() const { 1112 bool ElementAnimations::HasActiveAnimation() const {
1115 for (size_t i = 0; i < animations_.size(); ++i) { 1113 for (size_t i = 0; i < animations_.size(); ++i) {
1116 if (!animations_[i]->is_finished()) 1114 if (!animations_[i]->is_finished())
1117 return true; 1115 return true;
1118 } 1116 }
1119 return false; 1117 return false;
1120 } 1118 }
1121 1119
1122 bool ElementAnimations::IsPotentiallyAnimatingProperty( 1120 bool ElementAnimations::IsPotentiallyAnimatingProperty(
1123 TargetProperty::Type target_property, 1121 TargetProperty::Type target_property,
1124 LayerTreeType observer_type) const { 1122 LayerTreeType tree_type) const {
1125 for (size_t i = 0; i < animations_.size(); ++i) { 1123 for (size_t i = 0; i < animations_.size(); ++i) {
1126 if (!animations_[i]->is_finished() && 1124 if (!animations_[i]->is_finished() &&
1127 animations_[i]->target_property() == target_property) { 1125 animations_[i]->target_property() == target_property) {
1128 if ((observer_type == LayerTreeType::ACTIVE && 1126 if ((tree_type == LayerTreeType::ACTIVE &&
1129 animations_[i]->affects_active_observers()) || 1127 animations_[i]->affects_active_elements()) ||
1130 (observer_type == LayerTreeType::PENDING && 1128 (tree_type == LayerTreeType::PENDING &&
1131 animations_[i]->affects_pending_observers())) 1129 animations_[i]->affects_pending_elements()))
1132 return true; 1130 return true;
1133 } 1131 }
1134 } 1132 }
1135 return false; 1133 return false;
1136 } 1134 }
1137 1135
1138 bool ElementAnimations::IsCurrentlyAnimatingProperty( 1136 bool ElementAnimations::IsCurrentlyAnimatingProperty(
1139 TargetProperty::Type target_property, 1137 TargetProperty::Type target_property,
1140 LayerTreeType observer_type) const { 1138 LayerTreeType tree_type) const {
1141 for (size_t i = 0; i < animations_.size(); ++i) { 1139 for (size_t i = 0; i < animations_.size(); ++i) {
1142 if (!animations_[i]->is_finished() && 1140 if (!animations_[i]->is_finished() &&
1143 animations_[i]->InEffect(last_tick_time_) && 1141 animations_[i]->InEffect(last_tick_time_) &&
1144 animations_[i]->target_property() == target_property) { 1142 animations_[i]->target_property() == target_property) {
1145 if ((observer_type == LayerTreeType::ACTIVE && 1143 if ((tree_type == LayerTreeType::ACTIVE &&
1146 animations_[i]->affects_active_observers()) || 1144 animations_[i]->affects_active_elements()) ||
1147 (observer_type == LayerTreeType::PENDING && 1145 (tree_type == LayerTreeType::PENDING &&
1148 animations_[i]->affects_pending_observers())) 1146 animations_[i]->affects_pending_elements()))
1149 return true; 1147 return true;
1150 } 1148 }
1151 } 1149 }
1152 return false; 1150 return false;
1153 } 1151 }
1154 1152
1155 void ElementAnimations::PauseAnimation(int animation_id, 1153 void ElementAnimations::PauseAnimation(int animation_id,
1156 base::TimeDelta time_offset) { 1154 base::TimeDelta time_offset) {
1157 for (size_t i = 0; i < animations_.size(); ++i) { 1155 for (size_t i = 0; i < animations_.size(); ++i) {
1158 if (animations_[i]->id() == animation_id) { 1156 if (animations_[i]->id() == animation_id) {
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
1352 if (animation_host()) { 1350 if (animation_host()) {
1353 DCHECK(animation_host()->mutator_host_client()); 1351 DCHECK(animation_host()->mutator_host_client());
1354 return animation_host()->mutator_host_client()->GetScrollOffsetForAnimation( 1352 return animation_host()->mutator_host_client()->GetScrollOffsetForAnimation(
1355 layer_id()); 1353 layer_id());
1356 } 1354 }
1357 1355
1358 return gfx::ScrollOffset(); 1356 return gfx::ScrollOffset();
1359 } 1357 }
1360 1358
1361 } // namespace cc 1359 } // namespace cc
OLDNEW
« no previous file with comments | « cc/animation/element_animations.h ('k') | cc/animation/element_animations_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698