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

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

Issue 1911283002: CC Animation: Erase ElementAnimations::ObserverType. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@mergelac
Patch Set: Prefer forward declarations. 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 357 matching lines...) Expand 10 before | Expand all | Expand 10 after
368 ->ToFilterAnimationCurve() 368 ->ToFilterAnimationCurve()
369 ->HasFilterThatMovesPixels()) 369 ->HasFilterThatMovesPixels())
370 return true; 370 return true;
371 } 371 }
372 372
373 return false; 373 return false;
374 } 374 }
375 375
376 bool ElementAnimations::HasTransformAnimationThatInflatesBounds() const { 376 bool ElementAnimations::HasTransformAnimationThatInflatesBounds() const {
377 return IsCurrentlyAnimatingProperty(TargetProperty::TRANSFORM, 377 return IsCurrentlyAnimatingProperty(TargetProperty::TRANSFORM,
378 ObserverType::ACTIVE) || 378 LayerTreeType::ACTIVE) ||
379 IsCurrentlyAnimatingProperty(TargetProperty::TRANSFORM, 379 IsCurrentlyAnimatingProperty(TargetProperty::TRANSFORM,
380 ObserverType::PENDING); 380 LayerTreeType::PENDING);
381 } 381 }
382 382
383 bool ElementAnimations::FilterAnimationBoundsForBox(const gfx::BoxF& box, 383 bool ElementAnimations::FilterAnimationBoundsForBox(const gfx::BoxF& box,
384 gfx::BoxF* bounds) const { 384 gfx::BoxF* bounds) const {
385 // TODO(avallee): Implement. 385 // TODO(avallee): Implement.
386 return false; 386 return false;
387 } 387 }
388 388
389 bool ElementAnimations::TransformAnimationBoundsForBox( 389 bool ElementAnimations::TransformAnimationBoundsForBox(
390 const gfx::BoxF& box, 390 const gfx::BoxF& box,
(...skipping 35 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 ObserverType observer_type) const { 436 LayerTreeType observer_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 == ObserverType::ACTIVE && 442 if ((observer_type == LayerTreeType::ACTIVE &&
443 !animations_[i]->affects_active_observers()) || 443 !animations_[i]->affects_active_observers()) ||
444 (observer_type == ObserverType::PENDING && 444 (observer_type == LayerTreeType::PENDING &&
445 !animations_[i]->affects_pending_observers())) 445 !animations_[i]->affects_pending_observers()))
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(ObserverType observer_type, 472 bool ElementAnimations::AnimationStartScale(LayerTreeType observer_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 == ObserverType::ACTIVE && 480 if ((observer_type == LayerTreeType::ACTIVE &&
481 !animations_[i]->affects_active_observers()) || 481 !animations_[i]->affects_active_observers()) ||
482 (observer_type == ObserverType::PENDING && 482 (observer_type == LayerTreeType::PENDING &&
483 !animations_[i]->affects_pending_observers())) 483 !animations_[i]->affects_pending_observers()))
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(ObserverType observer_type, 509 bool ElementAnimations::MaximumTargetScale(LayerTreeType observer_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 == ObserverType::ACTIVE && 517 if ((observer_type == LayerTreeType::ACTIVE &&
518 !animations_[i]->affects_active_observers()) || 518 !animations_[i]->affects_active_observers()) ||
519 (observer_type == ObserverType::PENDING && 519 (observer_type == LayerTreeType::PENDING &&
520 !animations_[i]->affects_pending_observers())) 520 !animations_[i]->affects_pending_observers()))
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:
(...skipping 584 matching lines...) Expand 10 before | Expand all | Expand 10 after
1114 bool ElementAnimations::HasActiveAnimation() const { 1114 bool ElementAnimations::HasActiveAnimation() const {
1115 for (size_t i = 0; i < animations_.size(); ++i) { 1115 for (size_t i = 0; i < animations_.size(); ++i) {
1116 if (!animations_[i]->is_finished()) 1116 if (!animations_[i]->is_finished())
1117 return true; 1117 return true;
1118 } 1118 }
1119 return false; 1119 return false;
1120 } 1120 }
1121 1121
1122 bool ElementAnimations::IsPotentiallyAnimatingProperty( 1122 bool ElementAnimations::IsPotentiallyAnimatingProperty(
1123 TargetProperty::Type target_property, 1123 TargetProperty::Type target_property,
1124 ObserverType observer_type) const { 1124 LayerTreeType observer_type) const {
1125 for (size_t i = 0; i < animations_.size(); ++i) { 1125 for (size_t i = 0; i < animations_.size(); ++i) {
1126 if (!animations_[i]->is_finished() && 1126 if (!animations_[i]->is_finished() &&
1127 animations_[i]->target_property() == target_property) { 1127 animations_[i]->target_property() == target_property) {
1128 if ((observer_type == ObserverType::ACTIVE && 1128 if ((observer_type == LayerTreeType::ACTIVE &&
1129 animations_[i]->affects_active_observers()) || 1129 animations_[i]->affects_active_observers()) ||
1130 (observer_type == ObserverType::PENDING && 1130 (observer_type == LayerTreeType::PENDING &&
1131 animations_[i]->affects_pending_observers())) 1131 animations_[i]->affects_pending_observers()))
1132 return true; 1132 return true;
1133 } 1133 }
1134 } 1134 }
1135 return false; 1135 return false;
1136 } 1136 }
1137 1137
1138 bool ElementAnimations::IsCurrentlyAnimatingProperty( 1138 bool ElementAnimations::IsCurrentlyAnimatingProperty(
1139 TargetProperty::Type target_property, 1139 TargetProperty::Type target_property,
1140 ObserverType observer_type) const { 1140 LayerTreeType observer_type) const {
1141 for (size_t i = 0; i < animations_.size(); ++i) { 1141 for (size_t i = 0; i < animations_.size(); ++i) {
1142 if (!animations_[i]->is_finished() && 1142 if (!animations_[i]->is_finished() &&
1143 animations_[i]->InEffect(last_tick_time_) && 1143 animations_[i]->InEffect(last_tick_time_) &&
1144 animations_[i]->target_property() == target_property) { 1144 animations_[i]->target_property() == target_property) {
1145 if ((observer_type == ObserverType::ACTIVE && 1145 if ((observer_type == LayerTreeType::ACTIVE &&
1146 animations_[i]->affects_active_observers()) || 1146 animations_[i]->affects_active_observers()) ||
1147 (observer_type == ObserverType::PENDING && 1147 (observer_type == LayerTreeType::PENDING &&
1148 animations_[i]->affects_pending_observers())) 1148 animations_[i]->affects_pending_observers()))
1149 return true; 1149 return true;
1150 } 1150 }
1151 } 1151 }
1152 return false; 1152 return false;
1153 } 1153 }
1154 1154
1155 void ElementAnimations::PauseAnimation(int animation_id, 1155 void ElementAnimations::PauseAnimation(int animation_id,
1156 base::TimeDelta time_offset) { 1156 base::TimeDelta time_offset) {
1157 for (size_t i = 0; i < animations_.size(); ++i) { 1157 for (size_t i = 0; i < animations_.size(); ++i) {
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
1352 if (animation_host()) { 1352 if (animation_host()) {
1353 DCHECK(animation_host()->mutator_host_client()); 1353 DCHECK(animation_host()->mutator_host_client());
1354 return animation_host()->mutator_host_client()->GetScrollOffsetForAnimation( 1354 return animation_host()->mutator_host_client()->GetScrollOffsetForAnimation(
1355 layer_id()); 1355 layer_id());
1356 } 1356 }
1357 1357
1358 return gfx::ScrollOffset(); 1358 return gfx::ScrollOffset();
1359 } 1359 }
1360 1360
1361 } // namespace cc 1361 } // 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