OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "cc/animation/layer_animation_controller.h" | 5 #include "cc/animation/layer_animation_controller.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <vector> |
8 | 9 |
9 #include "cc/animation/animation.h" | 10 #include "cc/animation/animation.h" |
10 #include "cc/animation/animation_delegate.h" | 11 #include "cc/animation/animation_delegate.h" |
11 #include "cc/animation/animation_registrar.h" | 12 #include "cc/animation/animation_registrar.h" |
12 #include "cc/animation/keyframed_animation_curve.h" | 13 #include "cc/animation/keyframed_animation_curve.h" |
13 #include "cc/animation/layer_animation_value_observer.h" | 14 #include "cc/animation/layer_animation_value_observer.h" |
14 #include "cc/animation/layer_animation_value_provider.h" | 15 #include "cc/animation/layer_animation_value_provider.h" |
15 #include "cc/animation/scroll_offset_animation_curve.h" | 16 #include "cc/animation/scroll_offset_animation_curve.h" |
16 #include "cc/base/scoped_ptr_algorithm.h" | 17 #include "cc/base/scoped_ptr_algorithm.h" |
17 #include "cc/output/filter_operations.h" | 18 #include "cc/output/filter_operations.h" |
(...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
487 | 488 |
488 const TransformAnimationCurve* transform_animation_curve = | 489 const TransformAnimationCurve* transform_animation_curve = |
489 animations_[i]->curve()->ToTransformAnimationCurve(); | 490 animations_[i]->curve()->ToTransformAnimationCurve(); |
490 if (!transform_animation_curve->IsTranslation()) | 491 if (!transform_animation_curve->IsTranslation()) |
491 return false; | 492 return false; |
492 } | 493 } |
493 | 494 |
494 return true; | 495 return true; |
495 } | 496 } |
496 | 497 |
497 bool LayerAnimationController::MaximumScale(float* max_scale) const { | 498 bool LayerAnimationController::MaximumTargetScale(float* max_scale) const { |
498 *max_scale = 0.f; | 499 *max_scale = 0.f; |
499 for (size_t i = 0; i < animations_.size(); ++i) { | 500 for (size_t i = 0; i < animations_.size(); ++i) { |
500 if (animations_[i]->is_finished() || | 501 if (animations_[i]->is_finished() || |
501 animations_[i]->target_property() != Animation::Transform) | 502 animations_[i]->target_property() != Animation::Transform) |
502 continue; | 503 continue; |
503 | 504 |
| 505 bool forward_direction = true; |
| 506 switch (animations_[i]->direction()) { |
| 507 case Animation::Normal: |
| 508 case Animation::Alternate: |
| 509 forward_direction = animations_[i]->playback_rate() >= 0.0; |
| 510 break; |
| 511 case Animation::Reverse: |
| 512 case Animation::AlternateReverse: |
| 513 forward_direction = animations_[i]->playback_rate() < 0.0; |
| 514 break; |
| 515 } |
| 516 |
504 const TransformAnimationCurve* transform_animation_curve = | 517 const TransformAnimationCurve* transform_animation_curve = |
505 animations_[i]->curve()->ToTransformAnimationCurve(); | 518 animations_[i]->curve()->ToTransformAnimationCurve(); |
506 float animation_scale = 0.f; | 519 float animation_scale = 0.f; |
507 if (!transform_animation_curve->MaximumScale(&animation_scale)) | 520 if (!transform_animation_curve->MaximumTargetScale(forward_direction, |
| 521 &animation_scale)) |
508 return false; | 522 return false; |
509 *max_scale = std::max(*max_scale, animation_scale); | 523 *max_scale = std::max(*max_scale, animation_scale); |
510 } | 524 } |
511 | 525 |
512 return true; | 526 return true; |
513 } | 527 } |
514 | 528 |
515 void LayerAnimationController::PushNewAnimationsToImplThread( | 529 void LayerAnimationController::PushNewAnimationsToImplThread( |
516 LayerAnimationController* controller_impl) const { | 530 LayerAnimationController* controller_impl) const { |
517 // Any new animations owned by the main thread's controller are cloned and | 531 // Any new animations owned by the main thread's controller are cloned and |
(...skipping 496 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1014 value_observers_); | 1028 value_observers_); |
1015 LayerAnimationValueObserver* obs; | 1029 LayerAnimationValueObserver* obs; |
1016 while ((obs = it.GetNext()) != nullptr) | 1030 while ((obs = it.GetNext()) != nullptr) |
1017 if (obs->IsActive()) | 1031 if (obs->IsActive()) |
1018 return true; | 1032 return true; |
1019 } | 1033 } |
1020 return false; | 1034 return false; |
1021 } | 1035 } |
1022 | 1036 |
1023 } // namespace cc | 1037 } // namespace cc |
OLD | NEW |