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 #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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 element_id_ = element_id; | 47 element_id_ = element_id; |
48 } | 48 } |
49 | 49 |
50 void ElementAnimations::InitAffectedElementTypes() { | 50 void ElementAnimations::InitAffectedElementTypes() { |
51 DCHECK(element_id_); | 51 DCHECK(element_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()->IsElementInList( |
58 element_id_, LayerTreeType::ACTIVE)) { | 58 element_id_, ElementListType::ACTIVE)) { |
59 set_has_element_in_active_list(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()->IsElementInList( |
62 element_id_, LayerTreeType::PENDING)) { | 62 element_id_, ElementListType::PENDING)) { |
63 set_has_element_in_pending_list(true); | 63 set_has_element_in_pending_list(true); |
64 } | 64 } |
65 } | 65 } |
66 | 66 |
67 void ElementAnimations::ClearAffectedElementTypes() { | 67 void ElementAnimations::ClearAffectedElementTypes() { |
68 DCHECK(animation_host_); | 68 DCHECK(animation_host_); |
69 | 69 |
70 if (has_element_in_active_list()) | 70 if (has_element_in_active_list()) |
71 OnTransformIsPotentiallyAnimatingChanged(LayerTreeType::ACTIVE, false); | 71 OnTransformIsPotentiallyAnimatingChanged(ElementListType::ACTIVE, false); |
72 set_has_element_in_active_list(false); | 72 set_has_element_in_active_list(false); |
73 | 73 |
74 if (has_element_in_pending_list()) | 74 if (has_element_in_pending_list()) |
75 OnTransformIsPotentiallyAnimatingChanged(LayerTreeType::PENDING, false); | 75 OnTransformIsPotentiallyAnimatingChanged(ElementListType::PENDING, false); |
76 set_has_element_in_pending_list(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(ElementId element_id, | 82 void ElementAnimations::ElementRegistered(ElementId element_id, |
83 LayerTreeType tree_type) { | 83 ElementListType list_type) { |
84 DCHECK_EQ(element_id_, element_id); | 84 DCHECK_EQ(element_id_, element_id); |
85 | 85 |
86 if (tree_type == LayerTreeType::ACTIVE) | 86 if (list_type == ElementListType::ACTIVE) |
87 set_has_element_in_active_list(true); | 87 set_has_element_in_active_list(true); |
88 else | 88 else |
89 set_has_element_in_pending_list(true); | 89 set_has_element_in_pending_list(true); |
90 } | 90 } |
91 | 91 |
92 void ElementAnimations::LayerUnregistered(ElementId element_id, | 92 void ElementAnimations::ElementUnregistered(ElementId element_id, |
93 LayerTreeType tree_type) { | 93 ElementListType list_type) { |
94 DCHECK_EQ(this->element_id(), element_id); | 94 DCHECK_EQ(this->element_id(), element_id); |
95 if (tree_type == LayerTreeType::ACTIVE) | 95 if (list_type == ElementListType::ACTIVE) |
96 set_has_element_in_active_list(false); | 96 set_has_element_in_active_list(false); |
97 else | 97 else |
98 set_has_element_in_pending_list(false); | 98 set_has_element_in_pending_list(false); |
99 } | 99 } |
100 | 100 |
101 void ElementAnimations::AddPlayer(AnimationPlayer* player) { | 101 void ElementAnimations::AddPlayer(AnimationPlayer* player) { |
102 players_list_->Append(player); | 102 players_list_->Append(player); |
103 } | 103 } |
104 | 104 |
105 void ElementAnimations::RemovePlayer(AnimationPlayer* player) { | 105 void ElementAnimations::RemovePlayer(AnimationPlayer* player) { |
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
369 ->ToFilterAnimationCurve() | 369 ->ToFilterAnimationCurve() |
370 ->HasFilterThatMovesPixels()) | 370 ->HasFilterThatMovesPixels()) |
371 return true; | 371 return true; |
372 } | 372 } |
373 | 373 |
374 return false; | 374 return false; |
375 } | 375 } |
376 | 376 |
377 bool ElementAnimations::HasTransformAnimationThatInflatesBounds() const { | 377 bool ElementAnimations::HasTransformAnimationThatInflatesBounds() const { |
378 return IsCurrentlyAnimatingProperty(TargetProperty::TRANSFORM, | 378 return IsCurrentlyAnimatingProperty(TargetProperty::TRANSFORM, |
379 LayerTreeType::ACTIVE) || | 379 ElementListType::ACTIVE) || |
380 IsCurrentlyAnimatingProperty(TargetProperty::TRANSFORM, | 380 IsCurrentlyAnimatingProperty(TargetProperty::TRANSFORM, |
381 LayerTreeType::PENDING); | 381 ElementListType::PENDING); |
382 } | 382 } |
383 | 383 |
384 bool ElementAnimations::FilterAnimationBoundsForBox(const gfx::BoxF& box, | 384 bool ElementAnimations::FilterAnimationBoundsForBox(const gfx::BoxF& box, |
385 gfx::BoxF* bounds) const { | 385 gfx::BoxF* bounds) const { |
386 // TODO(avallee): Implement. | 386 // TODO(avallee): Implement. |
387 return false; | 387 return false; |
388 } | 388 } |
389 | 389 |
390 bool ElementAnimations::TransformAnimationBoundsForBox( | 390 bool ElementAnimations::TransformAnimationBoundsForBox( |
391 const gfx::BoxF& box, | 391 const gfx::BoxF& box, |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
427 const TransformAnimationCurve* transform_animation_curve = | 427 const TransformAnimationCurve* transform_animation_curve = |
428 animations_[i]->curve()->ToTransformAnimationCurve(); | 428 animations_[i]->curve()->ToTransformAnimationCurve(); |
429 if (transform_animation_curve->AffectsScale()) | 429 if (transform_animation_curve->AffectsScale()) |
430 return true; | 430 return true; |
431 } | 431 } |
432 | 432 |
433 return false; | 433 return false; |
434 } | 434 } |
435 | 435 |
436 bool ElementAnimations::HasOnlyTranslationTransforms( | 436 bool ElementAnimations::HasOnlyTranslationTransforms( |
437 LayerTreeType tree_type) const { | 437 ElementListType list_type) const { |
438 for (size_t i = 0; i < animations_.size(); ++i) { | 438 for (size_t i = 0; i < animations_.size(); ++i) { |
439 if (animations_[i]->is_finished() || | 439 if (animations_[i]->is_finished() || |
440 animations_[i]->target_property() != TargetProperty::TRANSFORM) | 440 animations_[i]->target_property() != TargetProperty::TRANSFORM) |
441 continue; | 441 continue; |
442 | 442 |
443 if ((tree_type == LayerTreeType::ACTIVE && | 443 if ((list_type == ElementListType::ACTIVE && |
444 !animations_[i]->affects_active_elements()) || | 444 !animations_[i]->affects_active_elements()) || |
445 (tree_type == LayerTreeType::PENDING && | 445 (list_type == ElementListType::PENDING && |
446 !animations_[i]->affects_pending_elements())) | 446 !animations_[i]->affects_pending_elements())) |
447 continue; | 447 continue; |
448 | 448 |
449 const TransformAnimationCurve* transform_animation_curve = | 449 const TransformAnimationCurve* transform_animation_curve = |
450 animations_[i]->curve()->ToTransformAnimationCurve(); | 450 animations_[i]->curve()->ToTransformAnimationCurve(); |
451 if (!transform_animation_curve->IsTranslation()) | 451 if (!transform_animation_curve->IsTranslation()) |
452 return false; | 452 return false; |
453 } | 453 } |
454 | 454 |
455 return true; | 455 return true; |
456 } | 456 } |
457 | 457 |
458 bool ElementAnimations::AnimationsPreserveAxisAlignment() const { | 458 bool ElementAnimations::AnimationsPreserveAxisAlignment() const { |
459 for (size_t i = 0; i < animations_.size(); ++i) { | 459 for (size_t i = 0; i < animations_.size(); ++i) { |
460 if (animations_[i]->is_finished() || | 460 if (animations_[i]->is_finished() || |
461 animations_[i]->target_property() != TargetProperty::TRANSFORM) | 461 animations_[i]->target_property() != TargetProperty::TRANSFORM) |
462 continue; | 462 continue; |
463 | 463 |
464 const TransformAnimationCurve* transform_animation_curve = | 464 const TransformAnimationCurve* transform_animation_curve = |
465 animations_[i]->curve()->ToTransformAnimationCurve(); | 465 animations_[i]->curve()->ToTransformAnimationCurve(); |
466 if (!transform_animation_curve->PreservesAxisAlignment()) | 466 if (!transform_animation_curve->PreservesAxisAlignment()) |
467 return false; | 467 return false; |
468 } | 468 } |
469 | 469 |
470 return true; | 470 return true; |
471 } | 471 } |
472 | 472 |
473 bool ElementAnimations::AnimationStartScale(LayerTreeType tree_type, | 473 bool ElementAnimations::AnimationStartScale(ElementListType list_type, |
474 float* start_scale) const { | 474 float* start_scale) const { |
475 *start_scale = 0.f; | 475 *start_scale = 0.f; |
476 for (size_t i = 0; i < animations_.size(); ++i) { | 476 for (size_t i = 0; i < animations_.size(); ++i) { |
477 if (animations_[i]->is_finished() || | 477 if (animations_[i]->is_finished() || |
478 animations_[i]->target_property() != TargetProperty::TRANSFORM) | 478 animations_[i]->target_property() != TargetProperty::TRANSFORM) |
479 continue; | 479 continue; |
480 | 480 |
481 if ((tree_type == LayerTreeType::ACTIVE && | 481 if ((list_type == ElementListType::ACTIVE && |
482 !animations_[i]->affects_active_elements()) || | 482 !animations_[i]->affects_active_elements()) || |
483 (tree_type == LayerTreeType::PENDING && | 483 (list_type == ElementListType::PENDING && |
484 !animations_[i]->affects_pending_elements())) | 484 !animations_[i]->affects_pending_elements())) |
485 continue; | 485 continue; |
486 | 486 |
487 bool forward_direction = true; | 487 bool forward_direction = true; |
488 switch (animations_[i]->direction()) { | 488 switch (animations_[i]->direction()) { |
489 case Animation::DIRECTION_NORMAL: | 489 case Animation::DIRECTION_NORMAL: |
490 case Animation::DIRECTION_ALTERNATE: | 490 case Animation::DIRECTION_ALTERNATE: |
491 forward_direction = animations_[i]->playback_rate() >= 0.0; | 491 forward_direction = animations_[i]->playback_rate() >= 0.0; |
492 break; | 492 break; |
493 case Animation::DIRECTION_REVERSE: | 493 case Animation::DIRECTION_REVERSE: |
494 case Animation::DIRECTION_ALTERNATE_REVERSE: | 494 case Animation::DIRECTION_ALTERNATE_REVERSE: |
495 forward_direction = animations_[i]->playback_rate() < 0.0; | 495 forward_direction = animations_[i]->playback_rate() < 0.0; |
496 break; | 496 break; |
497 } | 497 } |
498 | 498 |
499 const TransformAnimationCurve* transform_animation_curve = | 499 const TransformAnimationCurve* transform_animation_curve = |
500 animations_[i]->curve()->ToTransformAnimationCurve(); | 500 animations_[i]->curve()->ToTransformAnimationCurve(); |
501 float animation_start_scale = 0.f; | 501 float animation_start_scale = 0.f; |
502 if (!transform_animation_curve->AnimationStartScale(forward_direction, | 502 if (!transform_animation_curve->AnimationStartScale(forward_direction, |
503 &animation_start_scale)) | 503 &animation_start_scale)) |
504 return false; | 504 return false; |
505 *start_scale = std::max(*start_scale, animation_start_scale); | 505 *start_scale = std::max(*start_scale, animation_start_scale); |
506 } | 506 } |
507 return true; | 507 return true; |
508 } | 508 } |
509 | 509 |
510 bool ElementAnimations::MaximumTargetScale(LayerTreeType tree_type, | 510 bool ElementAnimations::MaximumTargetScale(ElementListType list_type, |
511 float* max_scale) const { | 511 float* max_scale) const { |
512 *max_scale = 0.f; | 512 *max_scale = 0.f; |
513 for (size_t i = 0; i < animations_.size(); ++i) { | 513 for (size_t i = 0; i < animations_.size(); ++i) { |
514 if (animations_[i]->is_finished() || | 514 if (animations_[i]->is_finished() || |
515 animations_[i]->target_property() != TargetProperty::TRANSFORM) | 515 animations_[i]->target_property() != TargetProperty::TRANSFORM) |
516 continue; | 516 continue; |
517 | 517 |
518 if ((tree_type == LayerTreeType::ACTIVE && | 518 if ((list_type == ElementListType::ACTIVE && |
519 !animations_[i]->affects_active_elements()) || | 519 !animations_[i]->affects_active_elements()) || |
520 (tree_type == LayerTreeType::PENDING && | 520 (list_type == ElementListType::PENDING && |
521 !animations_[i]->affects_pending_elements())) | 521 !animations_[i]->affects_pending_elements())) |
522 continue; | 522 continue; |
523 | 523 |
524 bool forward_direction = true; | 524 bool forward_direction = true; |
525 switch (animations_[i]->direction()) { | 525 switch (animations_[i]->direction()) { |
526 case Animation::DIRECTION_NORMAL: | 526 case Animation::DIRECTION_NORMAL: |
527 case Animation::DIRECTION_ALTERNATE: | 527 case Animation::DIRECTION_ALTERNATE: |
528 forward_direction = animations_[i]->playback_rate() >= 0.0; | 528 forward_direction = animations_[i]->playback_rate() >= 0.0; |
529 break; | 529 break; |
530 case Animation::DIRECTION_REVERSE: | 530 case Animation::DIRECTION_REVERSE: |
(...skipping 487 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1018 else if (!is_active_ && (was_active || force)) | 1018 else if (!is_active_ && (was_active || force)) |
1019 animation_host_->DidDeactivateElementAnimations(this); | 1019 animation_host_->DidDeactivateElementAnimations(this); |
1020 } | 1020 } |
1021 } | 1021 } |
1022 | 1022 |
1023 void ElementAnimations::NotifyClientOpacityAnimated( | 1023 void ElementAnimations::NotifyClientOpacityAnimated( |
1024 float opacity, | 1024 float opacity, |
1025 bool notify_active_elements, | 1025 bool notify_active_elements, |
1026 bool notify_pending_elements) { | 1026 bool notify_pending_elements) { |
1027 if (notify_active_elements && has_element_in_active_list()) | 1027 if (notify_active_elements && has_element_in_active_list()) |
1028 OnOpacityAnimated(LayerTreeType::ACTIVE, opacity); | 1028 OnOpacityAnimated(ElementListType::ACTIVE, opacity); |
1029 if (notify_pending_elements && has_element_in_pending_list()) | 1029 if (notify_pending_elements && has_element_in_pending_list()) |
1030 OnOpacityAnimated(LayerTreeType::PENDING, opacity); | 1030 OnOpacityAnimated(ElementListType::PENDING, opacity); |
1031 } | 1031 } |
1032 | 1032 |
1033 void ElementAnimations::NotifyClientTransformAnimated( | 1033 void ElementAnimations::NotifyClientTransformAnimated( |
1034 const gfx::Transform& transform, | 1034 const gfx::Transform& transform, |
1035 bool notify_active_elements, | 1035 bool notify_active_elements, |
1036 bool notify_pending_elements) { | 1036 bool notify_pending_elements) { |
1037 if (notify_active_elements && has_element_in_active_list()) | 1037 if (notify_active_elements && has_element_in_active_list()) |
1038 OnTransformAnimated(LayerTreeType::ACTIVE, transform); | 1038 OnTransformAnimated(ElementListType::ACTIVE, transform); |
1039 if (notify_pending_elements && has_element_in_pending_list()) | 1039 if (notify_pending_elements && has_element_in_pending_list()) |
1040 OnTransformAnimated(LayerTreeType::PENDING, transform); | 1040 OnTransformAnimated(ElementListType::PENDING, transform); |
1041 } | 1041 } |
1042 | 1042 |
1043 void ElementAnimations::NotifyClientFilterAnimated( | 1043 void ElementAnimations::NotifyClientFilterAnimated( |
1044 const FilterOperations& filters, | 1044 const FilterOperations& filters, |
1045 bool notify_active_elements, | 1045 bool notify_active_elements, |
1046 bool notify_pending_elements) { | 1046 bool notify_pending_elements) { |
1047 if (notify_active_elements && has_element_in_active_list()) | 1047 if (notify_active_elements && has_element_in_active_list()) |
1048 OnFilterAnimated(LayerTreeType::ACTIVE, filters); | 1048 OnFilterAnimated(ElementListType::ACTIVE, filters); |
1049 if (notify_pending_elements && has_element_in_pending_list()) | 1049 if (notify_pending_elements && has_element_in_pending_list()) |
1050 OnFilterAnimated(LayerTreeType::PENDING, filters); | 1050 OnFilterAnimated(ElementListType::PENDING, filters); |
1051 } | 1051 } |
1052 | 1052 |
1053 void ElementAnimations::NotifyClientScrollOffsetAnimated( | 1053 void ElementAnimations::NotifyClientScrollOffsetAnimated( |
1054 const gfx::ScrollOffset& scroll_offset, | 1054 const gfx::ScrollOffset& scroll_offset, |
1055 bool notify_active_elements, | 1055 bool notify_active_elements, |
1056 bool notify_pending_elements) { | 1056 bool notify_pending_elements) { |
1057 if (notify_active_elements && has_element_in_active_list()) | 1057 if (notify_active_elements && has_element_in_active_list()) |
1058 OnScrollOffsetAnimated(LayerTreeType::ACTIVE, scroll_offset); | 1058 OnScrollOffsetAnimated(ElementListType::ACTIVE, scroll_offset); |
1059 if (notify_pending_elements && has_element_in_pending_list()) | 1059 if (notify_pending_elements && has_element_in_pending_list()) |
1060 OnScrollOffsetAnimated(LayerTreeType::PENDING, scroll_offset); | 1060 OnScrollOffsetAnimated(ElementListType::PENDING, scroll_offset); |
1061 } | 1061 } |
1062 | 1062 |
1063 void ElementAnimations::NotifyClientAnimationWaitingForDeletion() { | 1063 void ElementAnimations::NotifyClientAnimationWaitingForDeletion() { |
1064 OnAnimationWaitingForDeletion(); | 1064 OnAnimationWaitingForDeletion(); |
1065 } | 1065 } |
1066 | 1066 |
1067 void ElementAnimations::NotifyClientTransformIsPotentiallyAnimatingChanged( | 1067 void ElementAnimations::NotifyClientTransformIsPotentiallyAnimatingChanged( |
1068 bool notify_active_elements, | 1068 bool notify_active_elements, |
1069 bool notify_pending_elements) { | 1069 bool notify_pending_elements) { |
1070 if (notify_active_elements && has_element_in_active_list()) | 1070 if (notify_active_elements && has_element_in_active_list()) |
1071 OnTransformIsPotentiallyAnimatingChanged( | 1071 OnTransformIsPotentiallyAnimatingChanged( |
1072 LayerTreeType::ACTIVE, | 1072 ElementListType::ACTIVE, |
1073 potentially_animating_transform_for_active_elements_); | 1073 potentially_animating_transform_for_active_elements_); |
1074 if (notify_pending_elements && has_element_in_pending_list()) | 1074 if (notify_pending_elements && has_element_in_pending_list()) |
1075 OnTransformIsPotentiallyAnimatingChanged( | 1075 OnTransformIsPotentiallyAnimatingChanged( |
1076 LayerTreeType::PENDING, | 1076 ElementListType::PENDING, |
1077 potentially_animating_transform_for_pending_elements_); | 1077 potentially_animating_transform_for_pending_elements_); |
1078 } | 1078 } |
1079 | 1079 |
1080 void ElementAnimations::UpdatePotentiallyAnimatingTransform() { | 1080 void ElementAnimations::UpdatePotentiallyAnimatingTransform() { |
1081 bool was_potentially_animating_transform_for_active_elements = | 1081 bool was_potentially_animating_transform_for_active_elements = |
1082 potentially_animating_transform_for_active_elements_; | 1082 potentially_animating_transform_for_active_elements_; |
1083 bool was_potentially_animating_transform_for_pending_elements = | 1083 bool was_potentially_animating_transform_for_pending_elements = |
1084 potentially_animating_transform_for_pending_elements_; | 1084 potentially_animating_transform_for_pending_elements_; |
1085 | 1085 |
1086 potentially_animating_transform_for_active_elements_ = false; | 1086 potentially_animating_transform_for_active_elements_ = false; |
(...skipping 26 matching lines...) Expand all Loading... |
1113 bool ElementAnimations::HasActiveAnimation() const { | 1113 bool ElementAnimations::HasActiveAnimation() const { |
1114 for (size_t i = 0; i < animations_.size(); ++i) { | 1114 for (size_t i = 0; i < animations_.size(); ++i) { |
1115 if (!animations_[i]->is_finished()) | 1115 if (!animations_[i]->is_finished()) |
1116 return true; | 1116 return true; |
1117 } | 1117 } |
1118 return false; | 1118 return false; |
1119 } | 1119 } |
1120 | 1120 |
1121 bool ElementAnimations::IsPotentiallyAnimatingProperty( | 1121 bool ElementAnimations::IsPotentiallyAnimatingProperty( |
1122 TargetProperty::Type target_property, | 1122 TargetProperty::Type target_property, |
1123 LayerTreeType tree_type) const { | 1123 ElementListType list_type) const { |
1124 for (size_t i = 0; i < animations_.size(); ++i) { | 1124 for (size_t i = 0; i < animations_.size(); ++i) { |
1125 if (!animations_[i]->is_finished() && | 1125 if (!animations_[i]->is_finished() && |
1126 animations_[i]->target_property() == target_property) { | 1126 animations_[i]->target_property() == target_property) { |
1127 if ((tree_type == LayerTreeType::ACTIVE && | 1127 if ((list_type == ElementListType::ACTIVE && |
1128 animations_[i]->affects_active_elements()) || | 1128 animations_[i]->affects_active_elements()) || |
1129 (tree_type == LayerTreeType::PENDING && | 1129 (list_type == ElementListType::PENDING && |
1130 animations_[i]->affects_pending_elements())) | 1130 animations_[i]->affects_pending_elements())) |
1131 return true; | 1131 return true; |
1132 } | 1132 } |
1133 } | 1133 } |
1134 return false; | 1134 return false; |
1135 } | 1135 } |
1136 | 1136 |
1137 bool ElementAnimations::IsCurrentlyAnimatingProperty( | 1137 bool ElementAnimations::IsCurrentlyAnimatingProperty( |
1138 TargetProperty::Type target_property, | 1138 TargetProperty::Type target_property, |
1139 LayerTreeType tree_type) const { | 1139 ElementListType list_type) const { |
1140 for (size_t i = 0; i < animations_.size(); ++i) { | 1140 for (size_t i = 0; i < animations_.size(); ++i) { |
1141 if (!animations_[i]->is_finished() && | 1141 if (!animations_[i]->is_finished() && |
1142 animations_[i]->InEffect(last_tick_time_) && | 1142 animations_[i]->InEffect(last_tick_time_) && |
1143 animations_[i]->target_property() == target_property) { | 1143 animations_[i]->target_property() == target_property) { |
1144 if ((tree_type == LayerTreeType::ACTIVE && | 1144 if ((list_type == ElementListType::ACTIVE && |
1145 animations_[i]->affects_active_elements()) || | 1145 animations_[i]->affects_active_elements()) || |
1146 (tree_type == LayerTreeType::PENDING && | 1146 (list_type == ElementListType::PENDING && |
1147 animations_[i]->affects_pending_elements())) | 1147 animations_[i]->affects_pending_elements())) |
1148 return true; | 1148 return true; |
1149 } | 1149 } |
1150 } | 1150 } |
1151 return false; | 1151 return false; |
1152 } | 1152 } |
1153 | 1153 |
1154 void ElementAnimations::PauseAnimation(int animation_id, | 1154 void ElementAnimations::PauseAnimation(int animation_id, |
1155 base::TimeDelta time_offset) { | 1155 base::TimeDelta time_offset) { |
1156 for (size_t i = 0; i < animations_.size(); ++i) { | 1156 for (size_t i = 0; i < animations_.size(); ++i) { |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1235 return nullptr; | 1235 return nullptr; |
1236 } | 1236 } |
1237 | 1237 |
1238 Animation* ElementAnimations::GetAnimationById(int animation_id) const { | 1238 Animation* ElementAnimations::GetAnimationById(int animation_id) const { |
1239 for (size_t i = 0; i < animations_.size(); ++i) | 1239 for (size_t i = 0; i < animations_.size(); ++i) |
1240 if (animations_[i]->id() == animation_id) | 1240 if (animations_[i]->id() == animation_id) |
1241 return animations_[i].get(); | 1241 return animations_[i].get(); |
1242 return nullptr; | 1242 return nullptr; |
1243 } | 1243 } |
1244 | 1244 |
1245 void ElementAnimations::OnFilterAnimated(LayerTreeType tree_type, | 1245 void ElementAnimations::OnFilterAnimated(ElementListType list_type, |
1246 const FilterOperations& filters) { | 1246 const FilterOperations& filters) { |
1247 DCHECK(element_id()); | 1247 DCHECK(element_id()); |
1248 DCHECK(animation_host()); | 1248 DCHECK(animation_host()); |
1249 DCHECK(animation_host()->mutator_host_client()); | 1249 DCHECK(animation_host()->mutator_host_client()); |
1250 animation_host()->mutator_host_client()->SetLayerFilterMutated( | 1250 animation_host()->mutator_host_client()->SetElementFilterMutated( |
1251 element_id(), tree_type, filters); | 1251 element_id(), list_type, filters); |
1252 } | 1252 } |
1253 | 1253 |
1254 void ElementAnimations::OnOpacityAnimated(LayerTreeType tree_type, | 1254 void ElementAnimations::OnOpacityAnimated(ElementListType list_type, |
1255 float opacity) { | 1255 float opacity) { |
1256 DCHECK(element_id()); | 1256 DCHECK(element_id()); |
1257 DCHECK(animation_host()); | 1257 DCHECK(animation_host()); |
1258 DCHECK(animation_host()->mutator_host_client()); | 1258 DCHECK(animation_host()->mutator_host_client()); |
1259 animation_host()->mutator_host_client()->SetLayerOpacityMutated( | 1259 animation_host()->mutator_host_client()->SetElementOpacityMutated( |
1260 element_id(), tree_type, opacity); | 1260 element_id(), list_type, opacity); |
1261 } | 1261 } |
1262 | 1262 |
1263 void ElementAnimations::OnTransformAnimated(LayerTreeType tree_type, | 1263 void ElementAnimations::OnTransformAnimated(ElementListType list_type, |
1264 const gfx::Transform& transform) { | 1264 const gfx::Transform& transform) { |
1265 DCHECK(element_id()); | 1265 DCHECK(element_id()); |
1266 DCHECK(animation_host()); | 1266 DCHECK(animation_host()); |
1267 DCHECK(animation_host()->mutator_host_client()); | 1267 DCHECK(animation_host()->mutator_host_client()); |
1268 animation_host()->mutator_host_client()->SetLayerTransformMutated( | 1268 animation_host()->mutator_host_client()->SetElementTransformMutated( |
1269 element_id(), tree_type, transform); | 1269 element_id(), list_type, transform); |
1270 } | 1270 } |
1271 | 1271 |
1272 void ElementAnimations::OnScrollOffsetAnimated( | 1272 void ElementAnimations::OnScrollOffsetAnimated( |
1273 LayerTreeType tree_type, | 1273 ElementListType list_type, |
1274 const gfx::ScrollOffset& scroll_offset) { | 1274 const gfx::ScrollOffset& scroll_offset) { |
1275 DCHECK(element_id()); | 1275 DCHECK(element_id()); |
1276 DCHECK(animation_host()); | 1276 DCHECK(animation_host()); |
1277 DCHECK(animation_host()->mutator_host_client()); | 1277 DCHECK(animation_host()->mutator_host_client()); |
1278 animation_host()->mutator_host_client()->SetLayerScrollOffsetMutated( | 1278 animation_host()->mutator_host_client()->SetElementScrollOffsetMutated( |
1279 element_id(), tree_type, scroll_offset); | 1279 element_id(), list_type, scroll_offset); |
1280 } | 1280 } |
1281 | 1281 |
1282 void ElementAnimations::OnAnimationWaitingForDeletion() { | 1282 void ElementAnimations::OnAnimationWaitingForDeletion() { |
1283 // TODO(loyso): Invalidate AnimationHost::SetNeedsPushProperties here. | 1283 // TODO(loyso): Invalidate AnimationHost::SetNeedsPushProperties here. |
1284 // But we always do PushProperties in AnimationHost for now. crbug.com/604280 | 1284 // But we always do PushProperties in AnimationHost for now. crbug.com/604280 |
1285 DCHECK(animation_host()); | 1285 DCHECK(animation_host()); |
1286 animation_host()->OnAnimationWaitingForDeletion(); | 1286 animation_host()->OnAnimationWaitingForDeletion(); |
1287 } | 1287 } |
1288 | 1288 |
1289 void ElementAnimations::OnTransformIsPotentiallyAnimatingChanged( | 1289 void ElementAnimations::OnTransformIsPotentiallyAnimatingChanged( |
1290 LayerTreeType tree_type, | 1290 ElementListType list_type, |
1291 bool is_animating) { | 1291 bool is_animating) { |
1292 DCHECK(element_id()); | 1292 DCHECK(element_id()); |
1293 DCHECK(animation_host()); | 1293 DCHECK(animation_host()); |
1294 DCHECK(animation_host()->mutator_host_client()); | 1294 DCHECK(animation_host()->mutator_host_client()); |
1295 animation_host() | 1295 animation_host() |
1296 ->mutator_host_client() | 1296 ->mutator_host_client() |
1297 ->LayerTransformIsPotentiallyAnimatingChanged(element_id(), tree_type, | 1297 ->ElementTransformIsPotentiallyAnimatingChanged(element_id(), list_type, |
1298 is_animating); | 1298 is_animating); |
1299 } | 1299 } |
1300 | 1300 |
1301 void ElementAnimations::NotifyPlayersAnimationStarted( | 1301 void ElementAnimations::NotifyPlayersAnimationStarted( |
1302 base::TimeTicks monotonic_time, | 1302 base::TimeTicks monotonic_time, |
1303 TargetProperty::Type target_property, | 1303 TargetProperty::Type target_property, |
1304 int group) { | 1304 int group) { |
1305 for (PlayersListNode* node = players_list_->head(); | 1305 for (PlayersListNode* node = players_list_->head(); |
1306 node != players_list_->end(); node = node->next()) { | 1306 node != players_list_->end(); node = node->next()) { |
1307 AnimationPlayer* player = node->value(); | 1307 AnimationPlayer* player = node->value(); |
1308 player->NotifyAnimationStarted(monotonic_time, target_property, group); | 1308 player->NotifyAnimationStarted(monotonic_time, target_property, group); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1351 if (animation_host()) { | 1351 if (animation_host()) { |
1352 DCHECK(animation_host()->mutator_host_client()); | 1352 DCHECK(animation_host()->mutator_host_client()); |
1353 return animation_host()->mutator_host_client()->GetScrollOffsetForAnimation( | 1353 return animation_host()->mutator_host_client()->GetScrollOffsetForAnimation( |
1354 element_id()); | 1354 element_id()); |
1355 } | 1355 } |
1356 | 1356 |
1357 return gfx::ScrollOffset(); | 1357 return gfx::ScrollOffset(); |
1358 } | 1358 } |
1359 | 1359 |
1360 } // namespace cc | 1360 } // namespace cc |
OLD | NEW |