| 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 <algorithm> | 5 #include <algorithm> |
| 6 | 6 |
| 7 #include "cc/animation/keyframed_animation_curve.h" | 7 #include "cc/animation/keyframed_animation_curve.h" |
| 8 #include "ui/gfx/animation/tween.h" | 8 #include "ui/gfx/animation/tween.h" |
| 9 #include "ui/gfx/box_f.h" | 9 #include "ui/gfx/box_f.h" |
| 10 | 10 |
| (...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 359 | 359 |
| 360 bool KeyframedTransformAnimationCurve::IsTranslation() const { | 360 bool KeyframedTransformAnimationCurve::IsTranslation() const { |
| 361 for (size_t i = 0; i < keyframes_.size(); ++i) { | 361 for (size_t i = 0; i < keyframes_.size(); ++i) { |
| 362 if (!keyframes_[i]->Value().IsTranslation() && | 362 if (!keyframes_[i]->Value().IsTranslation() && |
| 363 !keyframes_[i]->Value().IsIdentity()) | 363 !keyframes_[i]->Value().IsIdentity()) |
| 364 return false; | 364 return false; |
| 365 } | 365 } |
| 366 return true; | 366 return true; |
| 367 } | 367 } |
| 368 | 368 |
| 369 bool KeyframedTransformAnimationCurve::MaximumScale(float* max_scale) const { | 369 bool KeyframedTransformAnimationCurve::MaximumTargetScale( |
| 370 bool forward_direction, |
| 371 float* max_scale) const { |
| 370 DCHECK_GE(keyframes_.size(), 2ul); | 372 DCHECK_GE(keyframes_.size(), 2ul); |
| 371 *max_scale = 0.f; | 373 *max_scale = 0.f; |
| 372 for (size_t i = 1; i < keyframes_.size(); ++i) { | |
| 373 float min_progress = 0.f; | |
| 374 float max_progress = 1.f; | |
| 375 if (keyframes_[i - 1]->timing_function()) | |
| 376 keyframes_[i - 1]->timing_function()->Range(&min_progress, &max_progress); | |
| 377 | 374 |
| 378 float max_scale_for_segment = 0.f; | 375 // If |forward_direction| is true, then skip the first frame, otherwise |
| 379 if (!keyframes_[i]->Value().MaximumScale(keyframes_[i - 1]->Value(), | 376 // skip the last frame, since that is the original position in the animation. |
| 380 min_progress, | 377 size_t start = 1; |
| 381 max_progress, | 378 size_t end = keyframes_.size(); |
| 382 &max_scale_for_segment)) | 379 if (!forward_direction) { |
| 380 --start; |
| 381 --end; |
| 382 } |
| 383 |
| 384 for (size_t i = start; i < end; ++i) { |
| 385 gfx::Vector3dF target_scale_for_segment; |
| 386 if (!keyframes_[i]->Value().ScaleComponent(&target_scale_for_segment)) |
| 383 return false; | 387 return false; |
| 384 | 388 float max_scale_for_segment = |
| 385 *max_scale = std::max(*max_scale, max_scale_for_segment); | 389 fmaxf(std::abs(target_scale_for_segment.x()), |
| 390 fmaxf(std::abs(target_scale_for_segment.y()), |
| 391 std::abs(target_scale_for_segment.z()))); |
| 392 *max_scale = fmaxf(*max_scale, max_scale_for_segment); |
| 386 } | 393 } |
| 387 return true; | 394 return true; |
| 388 } | 395 } |
| 389 | 396 |
| 390 scoped_ptr<KeyframedFilterAnimationCurve> KeyframedFilterAnimationCurve:: | 397 scoped_ptr<KeyframedFilterAnimationCurve> KeyframedFilterAnimationCurve:: |
| 391 Create() { | 398 Create() { |
| 392 return make_scoped_ptr(new KeyframedFilterAnimationCurve); | 399 return make_scoped_ptr(new KeyframedFilterAnimationCurve); |
| 393 } | 400 } |
| 394 | 401 |
| 395 KeyframedFilterAnimationCurve::KeyframedFilterAnimationCurve() {} | 402 KeyframedFilterAnimationCurve::KeyframedFilterAnimationCurve() {} |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 434 bool KeyframedFilterAnimationCurve::HasFilterThatMovesPixels() const { | 441 bool KeyframedFilterAnimationCurve::HasFilterThatMovesPixels() const { |
| 435 for (size_t i = 0; i < keyframes_.size(); ++i) { | 442 for (size_t i = 0; i < keyframes_.size(); ++i) { |
| 436 if (keyframes_[i]->Value().HasFilterThatMovesPixels()) { | 443 if (keyframes_[i]->Value().HasFilterThatMovesPixels()) { |
| 437 return true; | 444 return true; |
| 438 } | 445 } |
| 439 } | 446 } |
| 440 return false; | 447 return false; |
| 441 } | 448 } |
| 442 | 449 |
| 443 } // namespace cc | 450 } // namespace cc |
| OLD | NEW |