| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/transform_operations.h" | 5 #include "cc/animation/transform_operations.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <limits> | 9 #include <limits> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/memory/ptr_util.h" | 12 #include "base/memory/ptr_util.h" |
| 13 #include "cc/test/geometry_test_utils.h" | 13 #include "cc/test/geometry_test_utils.h" |
| 14 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
| 15 #include "ui/gfx/animation/tween.h" | 15 #include "ui/gfx/animation/tween.h" |
| 16 #include "ui/gfx/geometry/box_f.h" | 16 #include "ui/gfx/geometry/box_f.h" |
| 17 #include "ui/gfx/geometry/rect_conversions.h" | 17 #include "ui/gfx/geometry/rect_conversions.h" |
| 18 #include "ui/gfx/geometry/vector3d_f.h" | 18 #include "ui/gfx/geometry/vector3d_f.h" |
| 19 | 19 |
| 20 namespace cc { | 20 namespace cc { |
| 21 namespace { | 21 namespace { |
| 22 | 22 |
| 23 void ExpectTransformOperationEqual(const TransformOperation& lhs, |
| 24 const TransformOperation& rhs) { |
| 25 EXPECT_EQ(lhs.type, rhs.type); |
| 26 EXPECT_TRANSFORMATION_MATRIX_EQ(lhs.matrix, rhs.matrix); |
| 27 switch (lhs.type) { |
| 28 case TransformOperation::TRANSFORM_OPERATION_TRANSLATE: |
| 29 EXPECT_FLOAT_EQ(lhs.translate.x, rhs.translate.x); |
| 30 EXPECT_FLOAT_EQ(lhs.translate.y, rhs.translate.y); |
| 31 EXPECT_FLOAT_EQ(lhs.translate.z, rhs.translate.z); |
| 32 break; |
| 33 case TransformOperation::TRANSFORM_OPERATION_ROTATE: |
| 34 EXPECT_FLOAT_EQ(lhs.rotate.axis.x, rhs.rotate.axis.x); |
| 35 EXPECT_FLOAT_EQ(lhs.rotate.axis.y, rhs.rotate.axis.y); |
| 36 EXPECT_FLOAT_EQ(lhs.rotate.axis.z, rhs.rotate.axis.z); |
| 37 EXPECT_FLOAT_EQ(lhs.rotate.angle, rhs.rotate.angle); |
| 38 break; |
| 39 case TransformOperation::TRANSFORM_OPERATION_SCALE: |
| 40 EXPECT_FLOAT_EQ(lhs.scale.x, rhs.scale.x); |
| 41 EXPECT_FLOAT_EQ(lhs.scale.y, rhs.scale.y); |
| 42 EXPECT_FLOAT_EQ(lhs.scale.z, rhs.scale.z); |
| 43 break; |
| 44 case TransformOperation::TRANSFORM_OPERATION_SKEW: |
| 45 EXPECT_FLOAT_EQ(lhs.skew.x, rhs.skew.x); |
| 46 EXPECT_FLOAT_EQ(lhs.skew.y, rhs.skew.y); |
| 47 break; |
| 48 case TransformOperation::TRANSFORM_OPERATION_PERSPECTIVE: |
| 49 EXPECT_FLOAT_EQ(lhs.perspective_depth, rhs.perspective_depth); |
| 50 break; |
| 51 case TransformOperation::TRANSFORM_OPERATION_MATRIX: |
| 52 case TransformOperation::TRANSFORM_OPERATION_IDENTITY: |
| 53 break; |
| 54 } |
| 55 } |
| 56 |
| 23 TEST(TransformOperationTest, TransformTypesAreUnique) { | 57 TEST(TransformOperationTest, TransformTypesAreUnique) { |
| 24 std::vector<std::unique_ptr<TransformOperations>> transforms; | 58 std::vector<std::unique_ptr<TransformOperations>> transforms; |
| 25 | 59 |
| 26 std::unique_ptr<TransformOperations> to_add( | 60 std::unique_ptr<TransformOperations> to_add( |
| 27 base::MakeUnique<TransformOperations>()); | 61 base::MakeUnique<TransformOperations>()); |
| 28 to_add->AppendTranslate(1, 0, 0); | 62 to_add->AppendTranslate(1, 0, 0); |
| 29 transforms.push_back(std::move(to_add)); | 63 transforms.push_back(std::move(to_add)); |
| 30 | 64 |
| 31 to_add = base::MakeUnique<TransformOperations>(); | 65 to_add = base::MakeUnique<TransformOperations>(); |
| 32 to_add->AppendRotate(0, 0, 1, 2); | 66 to_add->AppendRotate(0, 0, 1, 2); |
| (...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 296 gfx::Transform translate_from; | 330 gfx::Transform translate_from; |
| 297 translate_from.Translate3d(dx1, dy1, dz1); | 331 translate_from.Translate3d(dx1, dy1, dz1); |
| 298 | 332 |
| 299 gfx::Transform scale_to; | 333 gfx::Transform scale_to; |
| 300 scale_to.Scale3d(sx2, sy2, sz2); | 334 scale_to.Scale3d(sx2, sy2, sz2); |
| 301 gfx::Transform translate_to; | 335 gfx::Transform translate_to; |
| 302 translate_to.Translate3d(dx2, dy2, dz2); | 336 translate_to.Translate3d(dx2, dy2, dz2); |
| 303 | 337 |
| 304 SkMScalar progress = 0.25f; | 338 SkMScalar progress = 0.25f; |
| 305 | 339 |
| 340 TransformOperations operations_expected; |
| 341 operations_expected.AppendScale( |
| 342 gfx::Tween::FloatValueBetween(progress, sx1, sx2), |
| 343 gfx::Tween::FloatValueBetween(progress, sy1, sy2), |
| 344 gfx::Tween::FloatValueBetween(progress, sz1, sz2)); |
| 345 |
| 346 operations_expected.AppendTranslate( |
| 347 gfx::Tween::FloatValueBetween(progress, dx1, dx2), |
| 348 gfx::Tween::FloatValueBetween(progress, dy1, dy2), |
| 349 gfx::Tween::FloatValueBetween(progress, dz1, dz2)); |
| 350 |
| 306 gfx::Transform blended_scale = scale_to; | 351 gfx::Transform blended_scale = scale_to; |
| 307 blended_scale.Blend(scale_from, progress); | 352 blended_scale.Blend(scale_from, progress); |
| 308 | 353 |
| 309 gfx::Transform blended_translate = translate_to; | 354 gfx::Transform blended_translate = translate_to; |
| 310 blended_translate.Blend(translate_from, progress); | 355 blended_translate.Blend(translate_from, progress); |
| 311 | 356 |
| 312 gfx::Transform expected = blended_scale; | 357 gfx::Transform expected = blended_scale; |
| 313 expected.PreconcatTransform(blended_translate); | 358 expected.PreconcatTransform(blended_translate); |
| 314 | 359 |
| 315 EXPECT_TRANSFORMATION_MATRIX_EQ( | 360 TransformOperations blended = operations_to.Blend(operations_from, progress); |
| 316 expected, operations_to.Blend(operations_from, progress)); | 361 |
| 362 EXPECT_TRANSFORMATION_MATRIX_EQ(expected, blended.Apply()); |
| 363 EXPECT_TRANSFORMATION_MATRIX_EQ(operations_expected.Apply(), blended.Apply()); |
| 364 EXPECT_EQ(operations_expected.size(), blended.size()); |
| 365 for (size_t i = 0; i < operations_expected.size(); ++i) { |
| 366 TransformOperation expected_op = operations_expected.at(i); |
| 367 TransformOperation blended_op = blended.at(i); |
| 368 SCOPED_TRACE(i); |
| 369 ExpectTransformOperationEqual(expected_op, blended_op); |
| 370 } |
| 371 |
| 372 // Create a mismatch, forcing matrix interpolation. |
| 373 operations_to.AppendMatrix(gfx::Transform()); |
| 374 |
| 375 blended = operations_to.Blend(operations_from, progress); |
| 376 |
| 377 expected = operations_to.Apply(); |
| 378 expected.Blend(operations_from.Apply(), progress); |
| 379 |
| 380 operations_expected = TransformOperations(); |
| 381 operations_expected.AppendMatrix(expected); |
| 382 |
| 383 EXPECT_TRANSFORMATION_MATRIX_EQ(expected, blended.Apply()); |
| 384 EXPECT_TRANSFORMATION_MATRIX_EQ(operations_expected.Apply(), blended.Apply()); |
| 385 EXPECT_EQ(operations_expected.size(), blended.size()); |
| 386 for (size_t i = 0; i < operations_expected.size(); ++i) { |
| 387 TransformOperation expected_op = operations_expected.at(i); |
| 388 TransformOperation blended_op = blended.at(i); |
| 389 SCOPED_TRACE(i); |
| 390 ExpectTransformOperationEqual(expected_op, blended_op); |
| 391 } |
| 317 } | 392 } |
| 318 | 393 |
| 319 static void CheckProgress(SkMScalar progress, | 394 static void CheckProgress(SkMScalar progress, |
| 320 const gfx::Transform& from_matrix, | 395 const gfx::Transform& from_matrix, |
| 321 const gfx::Transform& to_matrix, | 396 const gfx::Transform& to_matrix, |
| 322 const TransformOperations& from_transform, | 397 const TransformOperations& from_transform, |
| 323 const TransformOperations& to_transform) { | 398 const TransformOperations& to_transform) { |
| 324 gfx::Transform expected_matrix = to_matrix; | 399 gfx::Transform expected_matrix = to_matrix; |
| 325 expected_matrix.Blend(from_matrix, progress); | 400 expected_matrix.Blend(from_matrix, progress); |
| 326 EXPECT_TRANSFORMATION_MATRIX_EQ( | 401 EXPECT_TRANSFORMATION_MATRIX_EQ( |
| 327 expected_matrix, to_transform.Blend(from_transform, progress)); | 402 expected_matrix, to_transform.Blend(from_transform, progress).Apply()); |
| 328 } | 403 } |
| 329 | 404 |
| 330 TEST(TransformOperationTest, BlendProgress) { | 405 TEST(TransformOperationTest, BlendProgress) { |
| 331 SkMScalar sx = 2; | 406 SkMScalar sx = 2; |
| 332 SkMScalar sy = 4; | 407 SkMScalar sy = 4; |
| 333 SkMScalar sz = 8; | 408 SkMScalar sz = 8; |
| 334 TransformOperations operations_from; | 409 TransformOperations operations_from; |
| 335 operations_from.AppendScale(sx, sy, sz); | 410 operations_from.AppendScale(sx, sy, sz); |
| 336 | 411 |
| 337 gfx::Transform matrix_from; | 412 gfx::Transform matrix_from; |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 386 gfx::Transform to; | 461 gfx::Transform to; |
| 387 to.Translate3d(dx2, dy2, dz2); | 462 to.Translate3d(dx2, dy2, dz2); |
| 388 to.Scale3d(sx2, sy2, sz2); | 463 to.Scale3d(sx2, sy2, sz2); |
| 389 | 464 |
| 390 SkMScalar progress = 0.25f; | 465 SkMScalar progress = 0.25f; |
| 391 | 466 |
| 392 gfx::Transform expected = to; | 467 gfx::Transform expected = to; |
| 393 expected.Blend(from, progress); | 468 expected.Blend(from, progress); |
| 394 | 469 |
| 395 EXPECT_TRANSFORMATION_MATRIX_EQ( | 470 EXPECT_TRANSFORMATION_MATRIX_EQ( |
| 396 expected, operations_to.Blend(operations_from, progress)); | 471 expected, operations_to.Blend(operations_from, progress).Apply()); |
| 397 } | 472 } |
| 398 | 473 |
| 399 TEST(TransformOperationTest, LargeRotationsWithSameAxis) { | 474 TEST(TransformOperationTest, LargeRotationsWithSameAxis) { |
| 400 TransformOperations operations_from; | 475 TransformOperations operations_from; |
| 401 operations_from.AppendRotate(0, 0, 1, 0); | 476 operations_from.AppendRotate(0, 0, 1, 0); |
| 402 | 477 |
| 403 TransformOperations operations_to; | 478 TransformOperations operations_to; |
| 404 operations_to.AppendRotate(0, 0, 2, 360); | 479 operations_to.AppendRotate(0, 0, 2, 360); |
| 405 | 480 |
| 406 SkMScalar progress = 0.5f; | 481 SkMScalar progress = 0.5f; |
| 407 | 482 |
| 408 gfx::Transform expected; | 483 gfx::Transform expected; |
| 409 expected.RotateAbout(gfx::Vector3dF(0, 0, 1), 180); | 484 expected.RotateAbout(gfx::Vector3dF(0, 0, 1), 180); |
| 410 | 485 |
| 411 EXPECT_TRANSFORMATION_MATRIX_EQ( | 486 EXPECT_TRANSFORMATION_MATRIX_EQ( |
| 412 expected, operations_to.Blend(operations_from, progress)); | 487 expected, operations_to.Blend(operations_from, progress).Apply()); |
| 413 } | 488 } |
| 414 | 489 |
| 415 TEST(TransformOperationTest, LargeRotationsWithSameAxisInDifferentDirection) { | 490 TEST(TransformOperationTest, LargeRotationsWithSameAxisInDifferentDirection) { |
| 416 TransformOperations operations_from; | 491 TransformOperations operations_from; |
| 417 operations_from.AppendRotate(0, 0, 1, 180); | 492 operations_from.AppendRotate(0, 0, 1, 180); |
| 418 | 493 |
| 419 TransformOperations operations_to; | 494 TransformOperations operations_to; |
| 420 operations_to.AppendRotate(0, 0, -1, 180); | 495 operations_to.AppendRotate(0, 0, -1, 180); |
| 421 | 496 |
| 422 SkMScalar progress = 0.5f; | 497 SkMScalar progress = 0.5f; |
| 423 | 498 |
| 424 gfx::Transform expected; | 499 gfx::Transform expected; |
| 425 | 500 |
| 426 EXPECT_TRANSFORMATION_MATRIX_EQ( | 501 EXPECT_TRANSFORMATION_MATRIX_EQ( |
| 427 expected, operations_to.Blend(operations_from, progress)); | 502 expected, operations_to.Blend(operations_from, progress).Apply()); |
| 428 } | 503 } |
| 429 | 504 |
| 430 TEST(TransformOperationTest, LargeRotationsWithDifferentAxes) { | 505 TEST(TransformOperationTest, LargeRotationsWithDifferentAxes) { |
| 431 TransformOperations operations_from; | 506 TransformOperations operations_from; |
| 432 operations_from.AppendRotate(0, 0, 1, 175); | 507 operations_from.AppendRotate(0, 0, 1, 175); |
| 433 | 508 |
| 434 TransformOperations operations_to; | 509 TransformOperations operations_to; |
| 435 operations_to.AppendRotate(0, 1, 0, 175); | 510 operations_to.AppendRotate(0, 1, 0, 175); |
| 436 | 511 |
| 437 SkMScalar progress = 0.5f; | 512 SkMScalar progress = 0.5f; |
| 438 gfx::Transform matrix_from; | 513 gfx::Transform matrix_from; |
| 439 matrix_from.RotateAbout(gfx::Vector3dF(0, 0, 1), 175); | 514 matrix_from.RotateAbout(gfx::Vector3dF(0, 0, 1), 175); |
| 440 | 515 |
| 441 gfx::Transform matrix_to; | 516 gfx::Transform matrix_to; |
| 442 matrix_to.RotateAbout(gfx::Vector3dF(0, 1, 0), 175); | 517 matrix_to.RotateAbout(gfx::Vector3dF(0, 1, 0), 175); |
| 443 | 518 |
| 444 gfx::Transform expected = matrix_to; | 519 gfx::Transform expected = matrix_to; |
| 445 expected.Blend(matrix_from, progress); | 520 expected.Blend(matrix_from, progress); |
| 446 | 521 |
| 447 EXPECT_TRANSFORMATION_MATRIX_EQ( | 522 EXPECT_TRANSFORMATION_MATRIX_EQ( |
| 448 expected, operations_to.Blend(operations_from, progress)); | 523 expected, operations_to.Blend(operations_from, progress).Apply()); |
| 449 } | 524 } |
| 450 | 525 |
| 451 TEST(TransformOperationTest, RotationFromZeroDegDifferentAxes) { | 526 TEST(TransformOperationTest, RotationFromZeroDegDifferentAxes) { |
| 452 TransformOperations operations_from; | 527 TransformOperations operations_from; |
| 453 operations_from.AppendRotate(0, 0, 1, 0); | 528 operations_from.AppendRotate(0, 0, 1, 0); |
| 454 | 529 |
| 455 TransformOperations operations_to; | 530 TransformOperations operations_to; |
| 456 operations_to.AppendRotate(0, 1, 0, 450); | 531 operations_to.AppendRotate(0, 1, 0, 450); |
| 457 | 532 |
| 458 SkMScalar progress = 0.5f; | 533 SkMScalar progress = 0.5f; |
| 459 gfx::Transform expected; | 534 gfx::Transform expected; |
| 460 expected.RotateAbout(gfx::Vector3dF(0, 1, 0), 225); | 535 expected.RotateAbout(gfx::Vector3dF(0, 1, 0), 225); |
| 461 EXPECT_TRANSFORMATION_MATRIX_EQ( | 536 EXPECT_TRANSFORMATION_MATRIX_EQ( |
| 462 expected, operations_to.Blend(operations_from, progress)); | 537 expected, operations_to.Blend(operations_from, progress).Apply()); |
| 463 } | 538 } |
| 464 | 539 |
| 465 TEST(TransformOperationTest, RotationFromZeroDegSameAxes) { | 540 TEST(TransformOperationTest, RotationFromZeroDegSameAxes) { |
| 466 TransformOperations operations_from; | 541 TransformOperations operations_from; |
| 467 operations_from.AppendRotate(0, 0, 1, 0); | 542 operations_from.AppendRotate(0, 0, 1, 0); |
| 468 | 543 |
| 469 TransformOperations operations_to; | 544 TransformOperations operations_to; |
| 470 operations_to.AppendRotate(0, 0, 1, 450); | 545 operations_to.AppendRotate(0, 0, 1, 450); |
| 471 | 546 |
| 472 SkMScalar progress = 0.5f; | 547 SkMScalar progress = 0.5f; |
| 473 gfx::Transform expected; | 548 gfx::Transform expected; |
| 474 expected.RotateAbout(gfx::Vector3dF(0, 0, 1), 225); | 549 expected.RotateAbout(gfx::Vector3dF(0, 0, 1), 225); |
| 475 EXPECT_TRANSFORMATION_MATRIX_EQ( | 550 EXPECT_TRANSFORMATION_MATRIX_EQ( |
| 476 expected, operations_to.Blend(operations_from, progress)); | 551 expected, operations_to.Blend(operations_from, progress).Apply()); |
| 477 } | 552 } |
| 478 | 553 |
| 479 TEST(TransformOperationTest, RotationToZeroDegDifferentAxes) { | 554 TEST(TransformOperationTest, RotationToZeroDegDifferentAxes) { |
| 480 TransformOperations operations_from; | 555 TransformOperations operations_from; |
| 481 operations_from.AppendRotate(0, 1, 0, 450); | 556 operations_from.AppendRotate(0, 1, 0, 450); |
| 482 | 557 |
| 483 TransformOperations operations_to; | 558 TransformOperations operations_to; |
| 484 operations_to.AppendRotate(0, 0, 1, 0); | 559 operations_to.AppendRotate(0, 0, 1, 0); |
| 485 | 560 |
| 486 SkMScalar progress = 0.5f; | 561 SkMScalar progress = 0.5f; |
| 487 gfx::Transform expected; | 562 gfx::Transform expected; |
| 488 expected.RotateAbout(gfx::Vector3dF(0, 1, 0), 225); | 563 expected.RotateAbout(gfx::Vector3dF(0, 1, 0), 225); |
| 489 EXPECT_TRANSFORMATION_MATRIX_EQ( | 564 EXPECT_TRANSFORMATION_MATRIX_EQ( |
| 490 expected, operations_to.Blend(operations_from, progress)); | 565 expected, operations_to.Blend(operations_from, progress).Apply()); |
| 491 } | 566 } |
| 492 | 567 |
| 493 TEST(TransformOperationTest, RotationToZeroDegSameAxes) { | 568 TEST(TransformOperationTest, RotationToZeroDegSameAxes) { |
| 494 TransformOperations operations_from; | 569 TransformOperations operations_from; |
| 495 operations_from.AppendRotate(0, 0, 1, 450); | 570 operations_from.AppendRotate(0, 0, 1, 450); |
| 496 | 571 |
| 497 TransformOperations operations_to; | 572 TransformOperations operations_to; |
| 498 operations_to.AppendRotate(0, 0, 1, 0); | 573 operations_to.AppendRotate(0, 0, 1, 0); |
| 499 | 574 |
| 500 SkMScalar progress = 0.5f; | 575 SkMScalar progress = 0.5f; |
| 501 gfx::Transform expected; | 576 gfx::Transform expected; |
| 502 expected.RotateAbout(gfx::Vector3dF(0, 0, 1), 225); | 577 expected.RotateAbout(gfx::Vector3dF(0, 0, 1), 225); |
| 503 EXPECT_TRANSFORMATION_MATRIX_EQ( | 578 EXPECT_TRANSFORMATION_MATRIX_EQ( |
| 504 expected, operations_to.Blend(operations_from, progress)); | 579 expected, operations_to.Blend(operations_from, progress).Apply()); |
| 505 } | 580 } |
| 506 | 581 |
| 507 TEST(TransformOperationTest, BlendRotationFromIdentity) { | 582 TEST(TransformOperationTest, BlendRotationFromIdentity) { |
| 508 std::vector<std::unique_ptr<TransformOperations>> identity_operations = | 583 std::vector<std::unique_ptr<TransformOperations>> identity_operations = |
| 509 GetIdentityOperations(); | 584 GetIdentityOperations(); |
| 510 | 585 |
| 511 for (size_t i = 0; i < identity_operations.size(); ++i) { | 586 for (size_t i = 0; i < identity_operations.size(); ++i) { |
| 512 TransformOperations operations; | 587 TransformOperations operations; |
| 513 operations.AppendRotate(0, 0, 1, 90); | 588 operations.AppendRotate(0, 0, 1, 90); |
| 514 | 589 |
| 515 SkMScalar progress = 0.5f; | 590 SkMScalar progress = 0.5f; |
| 516 | 591 |
| 517 gfx::Transform expected; | 592 gfx::Transform expected; |
| 518 expected.RotateAbout(gfx::Vector3dF(0, 0, 1), 45); | 593 expected.RotateAbout(gfx::Vector3dF(0, 0, 1), 45); |
| 519 | 594 |
| 520 EXPECT_TRANSFORMATION_MATRIX_EQ( | 595 EXPECT_TRANSFORMATION_MATRIX_EQ( |
| 521 expected, operations.Blend(*identity_operations[i], progress)); | 596 expected, operations.Blend(*identity_operations[i], progress).Apply()); |
| 522 | 597 |
| 523 progress = -0.5f; | 598 progress = -0.5f; |
| 524 | 599 |
| 525 expected.MakeIdentity(); | 600 expected.MakeIdentity(); |
| 526 expected.RotateAbout(gfx::Vector3dF(0, 0, 1), -45); | 601 expected.RotateAbout(gfx::Vector3dF(0, 0, 1), -45); |
| 527 | 602 |
| 528 EXPECT_TRANSFORMATION_MATRIX_EQ( | 603 EXPECT_TRANSFORMATION_MATRIX_EQ( |
| 529 expected, operations.Blend(*identity_operations[i], progress)); | 604 expected, operations.Blend(*identity_operations[i], progress).Apply()); |
| 530 | 605 |
| 531 progress = 1.5f; | 606 progress = 1.5f; |
| 532 | 607 |
| 533 expected.MakeIdentity(); | 608 expected.MakeIdentity(); |
| 534 expected.RotateAbout(gfx::Vector3dF(0, 0, 1), 135); | 609 expected.RotateAbout(gfx::Vector3dF(0, 0, 1), 135); |
| 535 | 610 |
| 536 EXPECT_TRANSFORMATION_MATRIX_EQ( | 611 EXPECT_TRANSFORMATION_MATRIX_EQ( |
| 537 expected, operations.Blend(*identity_operations[i], progress)); | 612 expected, operations.Blend(*identity_operations[i], progress).Apply()); |
| 538 } | 613 } |
| 539 } | 614 } |
| 540 | 615 |
| 541 TEST(TransformOperationTest, BlendTranslationFromIdentity) { | 616 TEST(TransformOperationTest, BlendTranslationFromIdentity) { |
| 542 std::vector<std::unique_ptr<TransformOperations>> identity_operations = | 617 std::vector<std::unique_ptr<TransformOperations>> identity_operations = |
| 543 GetIdentityOperations(); | 618 GetIdentityOperations(); |
| 544 | 619 |
| 545 for (size_t i = 0; i < identity_operations.size(); ++i) { | 620 for (size_t i = 0; i < identity_operations.size(); ++i) { |
| 546 TransformOperations operations; | 621 TransformOperations operations; |
| 547 operations.AppendTranslate(2, 2, 2); | 622 operations.AppendTranslate(2, 2, 2); |
| 548 | 623 |
| 549 SkMScalar progress = 0.5f; | 624 SkMScalar progress = 0.5f; |
| 550 | 625 |
| 551 gfx::Transform expected; | 626 gfx::Transform expected; |
| 552 expected.Translate3d(1, 1, 1); | 627 expected.Translate3d(1, 1, 1); |
| 553 | 628 |
| 554 EXPECT_TRANSFORMATION_MATRIX_EQ( | 629 EXPECT_TRANSFORMATION_MATRIX_EQ( |
| 555 expected, operations.Blend(*identity_operations[i], progress)); | 630 expected, operations.Blend(*identity_operations[i], progress).Apply()); |
| 556 | 631 |
| 557 progress = -0.5f; | 632 progress = -0.5f; |
| 558 | 633 |
| 559 expected.MakeIdentity(); | 634 expected.MakeIdentity(); |
| 560 expected.Translate3d(-1, -1, -1); | 635 expected.Translate3d(-1, -1, -1); |
| 561 | 636 |
| 562 EXPECT_TRANSFORMATION_MATRIX_EQ( | 637 EXPECT_TRANSFORMATION_MATRIX_EQ( |
| 563 expected, operations.Blend(*identity_operations[i], progress)); | 638 expected, operations.Blend(*identity_operations[i], progress).Apply()); |
| 564 | 639 |
| 565 progress = 1.5f; | 640 progress = 1.5f; |
| 566 | 641 |
| 567 expected.MakeIdentity(); | 642 expected.MakeIdentity(); |
| 568 expected.Translate3d(3, 3, 3); | 643 expected.Translate3d(3, 3, 3); |
| 569 | 644 |
| 570 EXPECT_TRANSFORMATION_MATRIX_EQ( | 645 EXPECT_TRANSFORMATION_MATRIX_EQ( |
| 571 expected, operations.Blend(*identity_operations[i], progress)); | 646 expected, operations.Blend(*identity_operations[i], progress).Apply()); |
| 572 } | 647 } |
| 573 } | 648 } |
| 574 | 649 |
| 575 TEST(TransformOperationTest, BlendScaleFromIdentity) { | 650 TEST(TransformOperationTest, BlendScaleFromIdentity) { |
| 576 std::vector<std::unique_ptr<TransformOperations>> identity_operations = | 651 std::vector<std::unique_ptr<TransformOperations>> identity_operations = |
| 577 GetIdentityOperations(); | 652 GetIdentityOperations(); |
| 578 | 653 |
| 579 for (size_t i = 0; i < identity_operations.size(); ++i) { | 654 for (size_t i = 0; i < identity_operations.size(); ++i) { |
| 580 TransformOperations operations; | 655 TransformOperations operations; |
| 581 operations.AppendScale(3, 3, 3); | 656 operations.AppendScale(3, 3, 3); |
| 582 | 657 |
| 583 SkMScalar progress = 0.5f; | 658 SkMScalar progress = 0.5f; |
| 584 | 659 |
| 585 gfx::Transform expected; | 660 gfx::Transform expected; |
| 586 expected.Scale3d(2, 2, 2); | 661 expected.Scale3d(2, 2, 2); |
| 587 | 662 |
| 588 EXPECT_TRANSFORMATION_MATRIX_EQ( | 663 EXPECT_TRANSFORMATION_MATRIX_EQ( |
| 589 expected, operations.Blend(*identity_operations[i], progress)); | 664 expected, operations.Blend(*identity_operations[i], progress).Apply()); |
| 590 | 665 |
| 591 progress = -0.5f; | 666 progress = -0.5f; |
| 592 | 667 |
| 593 expected.MakeIdentity(); | 668 expected.MakeIdentity(); |
| 594 expected.Scale3d(0, 0, 0); | 669 expected.Scale3d(0, 0, 0); |
| 595 | 670 |
| 596 EXPECT_TRANSFORMATION_MATRIX_EQ( | 671 EXPECT_TRANSFORMATION_MATRIX_EQ( |
| 597 expected, operations.Blend(*identity_operations[i], progress)); | 672 expected, operations.Blend(*identity_operations[i], progress).Apply()); |
| 598 | 673 |
| 599 progress = 1.5f; | 674 progress = 1.5f; |
| 600 | 675 |
| 601 expected.MakeIdentity(); | 676 expected.MakeIdentity(); |
| 602 expected.Scale3d(4, 4, 4); | 677 expected.Scale3d(4, 4, 4); |
| 603 | 678 |
| 604 EXPECT_TRANSFORMATION_MATRIX_EQ( | 679 EXPECT_TRANSFORMATION_MATRIX_EQ( |
| 605 expected, operations.Blend(*identity_operations[i], progress)); | 680 expected, operations.Blend(*identity_operations[i], progress).Apply()); |
| 606 } | 681 } |
| 607 } | 682 } |
| 608 | 683 |
| 609 TEST(TransformOperationTest, BlendSkewFromEmpty) { | 684 TEST(TransformOperationTest, BlendSkewFromEmpty) { |
| 610 TransformOperations empty_operation; | 685 TransformOperations empty_operation; |
| 611 | 686 |
| 612 TransformOperations operations; | 687 TransformOperations operations; |
| 613 operations.AppendSkew(2, 2); | 688 operations.AppendSkew(2, 2); |
| 614 | 689 |
| 615 SkMScalar progress = 0.5f; | 690 SkMScalar progress = 0.5f; |
| 616 | 691 |
| 617 gfx::Transform expected; | 692 gfx::Transform expected; |
| 618 expected.Skew(1, 1); | 693 expected.Skew(1, 1); |
| 619 | 694 |
| 620 EXPECT_TRANSFORMATION_MATRIX_EQ(expected, | 695 EXPECT_TRANSFORMATION_MATRIX_EQ( |
| 621 operations.Blend(empty_operation, progress)); | 696 expected, operations.Blend(empty_operation, progress).Apply()); |
| 622 | 697 |
| 623 progress = -0.5f; | 698 progress = -0.5f; |
| 624 | 699 |
| 625 expected.MakeIdentity(); | 700 expected.MakeIdentity(); |
| 626 expected.Skew(-1, -1); | 701 expected.Skew(-1, -1); |
| 627 | 702 |
| 628 EXPECT_TRANSFORMATION_MATRIX_EQ(expected, | 703 EXPECT_TRANSFORMATION_MATRIX_EQ( |
| 629 operations.Blend(empty_operation, progress)); | 704 expected, operations.Blend(empty_operation, progress).Apply()); |
| 630 | 705 |
| 631 progress = 1.5f; | 706 progress = 1.5f; |
| 632 | 707 |
| 633 expected.MakeIdentity(); | 708 expected.MakeIdentity(); |
| 634 expected.Skew(3, 3); | 709 expected.Skew(3, 3); |
| 635 | 710 |
| 636 EXPECT_TRANSFORMATION_MATRIX_EQ(expected, | 711 EXPECT_TRANSFORMATION_MATRIX_EQ( |
| 637 operations.Blend(empty_operation, progress)); | 712 expected, operations.Blend(empty_operation, progress).Apply()); |
| 638 } | 713 } |
| 639 | 714 |
| 640 TEST(TransformOperationTest, BlendPerspectiveFromIdentity) { | 715 TEST(TransformOperationTest, BlendPerspectiveFromIdentity) { |
| 641 std::vector<std::unique_ptr<TransformOperations>> identity_operations = | 716 std::vector<std::unique_ptr<TransformOperations>> identity_operations = |
| 642 GetIdentityOperations(); | 717 GetIdentityOperations(); |
| 643 | 718 |
| 644 for (size_t i = 0; i < identity_operations.size(); ++i) { | 719 for (size_t i = 0; i < identity_operations.size(); ++i) { |
| 645 TransformOperations operations; | 720 TransformOperations operations; |
| 646 operations.AppendPerspective(1000); | 721 operations.AppendPerspective(1000); |
| 647 | 722 |
| 648 SkMScalar progress = 0.5f; | 723 SkMScalar progress = 0.5f; |
| 649 | 724 |
| 650 gfx::Transform expected; | 725 gfx::Transform expected; |
| 651 expected.ApplyPerspectiveDepth(2000); | 726 expected.ApplyPerspectiveDepth(2000); |
| 652 | 727 |
| 653 EXPECT_TRANSFORMATION_MATRIX_EQ( | 728 EXPECT_TRANSFORMATION_MATRIX_EQ( |
| 654 expected, operations.Blend(*identity_operations[i], progress)); | 729 expected, operations.Blend(*identity_operations[i], progress).Apply()); |
| 655 } | 730 } |
| 656 } | 731 } |
| 657 | 732 |
| 658 TEST(TransformOperationTest, BlendRotationToIdentity) { | 733 TEST(TransformOperationTest, BlendRotationToIdentity) { |
| 659 std::vector<std::unique_ptr<TransformOperations>> identity_operations = | 734 std::vector<std::unique_ptr<TransformOperations>> identity_operations = |
| 660 GetIdentityOperations(); | 735 GetIdentityOperations(); |
| 661 | 736 |
| 662 for (size_t i = 0; i < identity_operations.size(); ++i) { | 737 for (size_t i = 0; i < identity_operations.size(); ++i) { |
| 663 TransformOperations operations; | 738 TransformOperations operations; |
| 664 operations.AppendRotate(0, 0, 1, 90); | 739 operations.AppendRotate(0, 0, 1, 90); |
| 665 | 740 |
| 666 SkMScalar progress = 0.5f; | 741 SkMScalar progress = 0.5f; |
| 667 | 742 |
| 668 gfx::Transform expected; | 743 gfx::Transform expected; |
| 669 expected.RotateAbout(gfx::Vector3dF(0, 0, 1), 45); | 744 expected.RotateAbout(gfx::Vector3dF(0, 0, 1), 45); |
| 670 | 745 |
| 671 EXPECT_TRANSFORMATION_MATRIX_EQ( | 746 EXPECT_TRANSFORMATION_MATRIX_EQ( |
| 672 expected, identity_operations[i]->Blend(operations, progress)); | 747 expected, identity_operations[i]->Blend(operations, progress).Apply()); |
| 673 } | 748 } |
| 674 } | 749 } |
| 675 | 750 |
| 676 TEST(TransformOperationTest, BlendTranslationToIdentity) { | 751 TEST(TransformOperationTest, BlendTranslationToIdentity) { |
| 677 std::vector<std::unique_ptr<TransformOperations>> identity_operations = | 752 std::vector<std::unique_ptr<TransformOperations>> identity_operations = |
| 678 GetIdentityOperations(); | 753 GetIdentityOperations(); |
| 679 | 754 |
| 680 for (size_t i = 0; i < identity_operations.size(); ++i) { | 755 for (size_t i = 0; i < identity_operations.size(); ++i) { |
| 681 TransformOperations operations; | 756 TransformOperations operations; |
| 682 operations.AppendTranslate(2, 2, 2); | 757 operations.AppendTranslate(2, 2, 2); |
| 683 | 758 |
| 684 SkMScalar progress = 0.5f; | 759 SkMScalar progress = 0.5f; |
| 685 | 760 |
| 686 gfx::Transform expected; | 761 gfx::Transform expected; |
| 687 expected.Translate3d(1, 1, 1); | 762 expected.Translate3d(1, 1, 1); |
| 688 | 763 |
| 689 EXPECT_TRANSFORMATION_MATRIX_EQ( | 764 EXPECT_TRANSFORMATION_MATRIX_EQ( |
| 690 expected, identity_operations[i]->Blend(operations, progress)); | 765 expected, identity_operations[i]->Blend(operations, progress).Apply()); |
| 691 } | 766 } |
| 692 } | 767 } |
| 693 | 768 |
| 694 TEST(TransformOperationTest, BlendScaleToIdentity) { | 769 TEST(TransformOperationTest, BlendScaleToIdentity) { |
| 695 std::vector<std::unique_ptr<TransformOperations>> identity_operations = | 770 std::vector<std::unique_ptr<TransformOperations>> identity_operations = |
| 696 GetIdentityOperations(); | 771 GetIdentityOperations(); |
| 697 | 772 |
| 698 for (size_t i = 0; i < identity_operations.size(); ++i) { | 773 for (size_t i = 0; i < identity_operations.size(); ++i) { |
| 699 TransformOperations operations; | 774 TransformOperations operations; |
| 700 operations.AppendScale(3, 3, 3); | 775 operations.AppendScale(3, 3, 3); |
| 701 | 776 |
| 702 SkMScalar progress = 0.5f; | 777 SkMScalar progress = 0.5f; |
| 703 | 778 |
| 704 gfx::Transform expected; | 779 gfx::Transform expected; |
| 705 expected.Scale3d(2, 2, 2); | 780 expected.Scale3d(2, 2, 2); |
| 706 | 781 |
| 707 EXPECT_TRANSFORMATION_MATRIX_EQ( | 782 EXPECT_TRANSFORMATION_MATRIX_EQ( |
| 708 expected, identity_operations[i]->Blend(operations, progress)); | 783 expected, identity_operations[i]->Blend(operations, progress).Apply()); |
| 709 } | 784 } |
| 710 } | 785 } |
| 711 | 786 |
| 712 TEST(TransformOperationTest, BlendSkewToEmpty) { | 787 TEST(TransformOperationTest, BlendSkewToEmpty) { |
| 713 TransformOperations empty_operation; | 788 TransformOperations empty_operation; |
| 714 | 789 |
| 715 TransformOperations operations; | 790 TransformOperations operations; |
| 716 operations.AppendSkew(2, 2); | 791 operations.AppendSkew(2, 2); |
| 717 | 792 |
| 718 SkMScalar progress = 0.5f; | 793 SkMScalar progress = 0.5f; |
| 719 | 794 |
| 720 gfx::Transform expected; | 795 gfx::Transform expected; |
| 721 expected.Skew(1, 1); | 796 expected.Skew(1, 1); |
| 722 | 797 |
| 723 EXPECT_TRANSFORMATION_MATRIX_EQ(expected, | 798 EXPECT_TRANSFORMATION_MATRIX_EQ( |
| 724 empty_operation.Blend(operations, progress)); | 799 expected, empty_operation.Blend(operations, progress).Apply()); |
| 725 } | 800 } |
| 726 | 801 |
| 727 TEST(TransformOperationTest, BlendPerspectiveToIdentity) { | 802 TEST(TransformOperationTest, BlendPerspectiveToIdentity) { |
| 728 std::vector<std::unique_ptr<TransformOperations>> identity_operations = | 803 std::vector<std::unique_ptr<TransformOperations>> identity_operations = |
| 729 GetIdentityOperations(); | 804 GetIdentityOperations(); |
| 730 | 805 |
| 731 for (size_t i = 0; i < identity_operations.size(); ++i) { | 806 for (size_t i = 0; i < identity_operations.size(); ++i) { |
| 732 TransformOperations operations; | 807 TransformOperations operations; |
| 733 operations.AppendPerspective(1000); | 808 operations.AppendPerspective(1000); |
| 734 | 809 |
| 735 SkMScalar progress = 0.5f; | 810 SkMScalar progress = 0.5f; |
| 736 | 811 |
| 737 gfx::Transform expected; | 812 gfx::Transform expected; |
| 738 expected.ApplyPerspectiveDepth(2000); | 813 expected.ApplyPerspectiveDepth(2000); |
| 739 | 814 |
| 740 EXPECT_TRANSFORMATION_MATRIX_EQ( | 815 EXPECT_TRANSFORMATION_MATRIX_EQ( |
| 741 expected, identity_operations[i]->Blend(operations, progress)); | 816 expected, identity_operations[i]->Blend(operations, progress).Apply()); |
| 742 } | 817 } |
| 743 } | 818 } |
| 744 | 819 |
| 745 TEST(TransformOperationTest, ExtrapolatePerspectiveBlending) { | 820 TEST(TransformOperationTest, ExtrapolatePerspectiveBlending) { |
| 746 TransformOperations operations1; | 821 TransformOperations operations1; |
| 747 operations1.AppendPerspective(1000); | 822 operations1.AppendPerspective(1000); |
| 748 | 823 |
| 749 TransformOperations operations2; | 824 TransformOperations operations2; |
| 750 operations2.AppendPerspective(500); | 825 operations2.AppendPerspective(500); |
| 751 | 826 |
| 752 gfx::Transform expected; | 827 gfx::Transform expected; |
| 753 expected.ApplyPerspectiveDepth(400); | 828 expected.ApplyPerspectiveDepth(400); |
| 754 | 829 |
| 755 EXPECT_TRANSFORMATION_MATRIX_EQ( | 830 EXPECT_TRANSFORMATION_MATRIX_EQ(expected, |
| 756 expected, operations1.Blend(operations2, -0.5)); | 831 operations1.Blend(operations2, -0.5).Apply()); |
| 757 | 832 |
| 758 expected.MakeIdentity(); | 833 expected.MakeIdentity(); |
| 759 expected.ApplyPerspectiveDepth(2000); | 834 expected.ApplyPerspectiveDepth(2000); |
| 760 | 835 |
| 761 EXPECT_TRANSFORMATION_MATRIX_EQ( | 836 EXPECT_TRANSFORMATION_MATRIX_EQ(expected, |
| 762 expected, operations1.Blend(operations2, 1.5)); | 837 operations1.Blend(operations2, 1.5).Apply()); |
| 763 } | 838 } |
| 764 | 839 |
| 765 TEST(TransformOperationTest, ExtrapolateMatrixBlending) { | 840 TEST(TransformOperationTest, ExtrapolateMatrixBlending) { |
| 766 gfx::Transform transform1; | 841 gfx::Transform transform1; |
| 767 transform1.Translate3d(1, 1, 1); | 842 transform1.Translate3d(1, 1, 1); |
| 768 TransformOperations operations1; | 843 TransformOperations operations1; |
| 769 operations1.AppendMatrix(transform1); | 844 operations1.AppendMatrix(transform1); |
| 770 | 845 |
| 771 gfx::Transform transform2; | 846 gfx::Transform transform2; |
| 772 transform2.Translate3d(3, 3, 3); | 847 transform2.Translate3d(3, 3, 3); |
| 773 TransformOperations operations2; | 848 TransformOperations operations2; |
| 774 operations2.AppendMatrix(transform2); | 849 operations2.AppendMatrix(transform2); |
| 775 | 850 |
| 776 gfx::Transform expected; | 851 gfx::Transform expected; |
| 777 EXPECT_TRANSFORMATION_MATRIX_EQ( | 852 EXPECT_TRANSFORMATION_MATRIX_EQ(expected, |
| 778 expected, operations1.Blend(operations2, 1.5)); | 853 operations1.Blend(operations2, 1.5).Apply()); |
| 779 | 854 |
| 780 expected.Translate3d(4, 4, 4); | 855 expected.Translate3d(4, 4, 4); |
| 781 EXPECT_TRANSFORMATION_MATRIX_EQ( | 856 EXPECT_TRANSFORMATION_MATRIX_EQ(expected, |
| 782 expected, operations1.Blend(operations2, -0.5)); | 857 operations1.Blend(operations2, -0.5).Apply()); |
| 783 } | 858 } |
| 784 | 859 |
| 785 TEST(TransformOperationTest, BlendedBoundsWhenTypesDoNotMatch) { | 860 TEST(TransformOperationTest, BlendedBoundsWhenTypesDoNotMatch) { |
| 786 TransformOperations operations_from; | 861 TransformOperations operations_from; |
| 787 operations_from.AppendScale(2.0, 4.0, 8.0); | 862 operations_from.AppendScale(2.0, 4.0, 8.0); |
| 788 operations_from.AppendTranslate(1.0, 2.0, 3.0); | 863 operations_from.AppendTranslate(1.0, 2.0, 3.0); |
| 789 | 864 |
| 790 TransformOperations operations_to; | 865 TransformOperations operations_to; |
| 791 operations_to.AppendTranslate(10.0, 20.0, 30.0); | 866 operations_to.AppendTranslate(10.0, 20.0, 30.0); |
| 792 operations_to.AppendScale(4.0, 8.0, 16.0); | 867 operations_to.AppendScale(4.0, 8.0, 16.0); |
| (...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1060 gfx::BoxF bounds; | 1135 gfx::BoxF bounds; |
| 1061 EXPECT_TRUE( | 1136 EXPECT_TRUE( |
| 1062 to.BlendedBoundsForBox(box, from, min_progress, max_progress, &bounds)); | 1137 to.BlendedBoundsForBox(box, from, min_progress, max_progress, &bounds)); |
| 1063 | 1138 |
| 1064 bool first_time = true; | 1139 bool first_time = true; |
| 1065 gfx::BoxF empirical_bounds; | 1140 gfx::BoxF empirical_bounds; |
| 1066 static const size_t kNumSteps = 10; | 1141 static const size_t kNumSteps = 10; |
| 1067 for (size_t step = 0; step < kNumSteps; ++step) { | 1142 for (size_t step = 0; step < kNumSteps; ++step) { |
| 1068 float t = step / (kNumSteps - 1.f); | 1143 float t = step / (kNumSteps - 1.f); |
| 1069 t = gfx::Tween::FloatValueBetween(t, min_progress, max_progress); | 1144 t = gfx::Tween::FloatValueBetween(t, min_progress, max_progress); |
| 1070 gfx::Transform partial_transform = to.Blend(from, t); | 1145 gfx::Transform partial_transform = to.Blend(from, t).Apply(); |
| 1071 gfx::BoxF transformed = box; | 1146 gfx::BoxF transformed = box; |
| 1072 partial_transform.TransformBox(&transformed); | 1147 partial_transform.TransformBox(&transformed); |
| 1073 | 1148 |
| 1074 if (first_time) { | 1149 if (first_time) { |
| 1075 empirical_bounds = transformed; | 1150 empirical_bounds = transformed; |
| 1076 first_time = false; | 1151 first_time = false; |
| 1077 } else { | 1152 } else { |
| 1078 empirical_bounds.Union(transformed); | 1153 empirical_bounds.Union(transformed); |
| 1079 } | 1154 } |
| 1080 } | 1155 } |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1195 to_transform.ApplyPerspectiveDepth(1000); | 1270 to_transform.ApplyPerspectiveDepth(1000); |
| 1196 | 1271 |
| 1197 static const int steps = 20; | 1272 static const int steps = 20; |
| 1198 for (int i = 0; i < steps; ++i) { | 1273 for (int i = 0; i < steps; ++i) { |
| 1199 double progress = static_cast<double>(i) / (steps - 1); | 1274 double progress = static_cast<double>(i) / (steps - 1); |
| 1200 | 1275 |
| 1201 gfx::Transform blended_matrix = to_transform; | 1276 gfx::Transform blended_matrix = to_transform; |
| 1202 EXPECT_TRUE(blended_matrix.Blend(from_transform, progress)); | 1277 EXPECT_TRUE(blended_matrix.Blend(from_transform, progress)); |
| 1203 | 1278 |
| 1204 gfx::Transform blended_transform = | 1279 gfx::Transform blended_transform = |
| 1205 to_operations.Blend(from_operations, progress); | 1280 to_operations.Blend(from_operations, progress).Apply(); |
| 1206 | 1281 |
| 1207 EXPECT_TRANSFORMATION_MATRIX_EQ(blended_matrix, blended_transform); | 1282 EXPECT_TRANSFORMATION_MATRIX_EQ(blended_matrix, blended_transform); |
| 1208 } | 1283 } |
| 1209 } | 1284 } |
| 1210 | 1285 |
| 1211 TEST(TransformOperationTest, BlendedBoundsForPerspective) { | 1286 TEST(TransformOperationTest, BlendedBoundsForPerspective) { |
| 1212 struct { | 1287 struct { |
| 1213 float from_depth; | 1288 float from_depth; |
| 1214 float to_depth; | 1289 float to_depth; |
| 1215 } perspective_depths[] = { | 1290 } perspective_depths[] = { |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1279 operations_to.AppendRotate(0.0, 1.0, 0.0, 135.0); | 1354 operations_to.AppendRotate(0.0, 1.0, 0.0, 135.0); |
| 1280 | 1355 |
| 1281 gfx::BoxF box(0, 0, 0, 1, 1, 1); | 1356 gfx::BoxF box(0, 0, 0, 1, 1, 1); |
| 1282 gfx::BoxF bounds; | 1357 gfx::BoxF bounds; |
| 1283 | 1358 |
| 1284 SkMScalar min_progress = 0.0f; | 1359 SkMScalar min_progress = 0.0f; |
| 1285 SkMScalar max_progress = 1.0f; | 1360 SkMScalar max_progress = 1.0f; |
| 1286 EXPECT_TRUE(operations_to.BlendedBoundsForBox( | 1361 EXPECT_TRUE(operations_to.BlendedBoundsForBox( |
| 1287 box, operations_from, min_progress, max_progress, &bounds)); | 1362 box, operations_from, min_progress, max_progress, &bounds)); |
| 1288 gfx::Transform blended_transform = | 1363 gfx::Transform blended_transform = |
| 1289 operations_to.Blend(operations_from, max_progress); | 1364 operations_to.Blend(operations_from, max_progress).Apply(); |
| 1290 gfx::Point3F blended_point(0.9f, 0.9f, 0.0f); | 1365 gfx::Point3F blended_point(0.9f, 0.9f, 0.0f); |
| 1291 blended_transform.TransformPoint(&blended_point); | 1366 blended_transform.TransformPoint(&blended_point); |
| 1292 gfx::BoxF expanded_bounds = bounds; | 1367 gfx::BoxF expanded_bounds = bounds; |
| 1293 expanded_bounds.ExpandTo(blended_point); | 1368 expanded_bounds.ExpandTo(blended_point); |
| 1294 EXPECT_EQ(bounds.ToString(), expanded_bounds.ToString()); | 1369 EXPECT_EQ(bounds.ToString(), expanded_bounds.ToString()); |
| 1295 } | 1370 } |
| 1296 | 1371 |
| 1297 TEST(TransformOperationTest, BlendedBoundsForSequence) { | 1372 TEST(TransformOperationTest, BlendedBoundsForSequence) { |
| 1298 TransformOperations operations_from; | 1373 TransformOperations operations_from; |
| 1299 operations_from.AppendTranslate(1.0, -5.0, 1.0); | 1374 operations_from.AppendTranslate(1.0, -5.0, 1.0); |
| (...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1509 TransformOperations operations16; | 1584 TransformOperations operations16; |
| 1510 gfx::Transform skew_transform; | 1585 gfx::Transform skew_transform; |
| 1511 skew_transform.Skew(50.f, 60.f); | 1586 skew_transform.Skew(50.f, 60.f); |
| 1512 operations16.AppendMatrix(skew_transform); | 1587 operations16.AppendMatrix(skew_transform); |
| 1513 EXPECT_TRUE(operations16.ScaleComponent(&scale)); | 1588 EXPECT_TRUE(operations16.ScaleComponent(&scale)); |
| 1514 EXPECT_EQ(2.f, scale); | 1589 EXPECT_EQ(2.f, scale); |
| 1515 } | 1590 } |
| 1516 | 1591 |
| 1517 } // namespace | 1592 } // namespace |
| 1518 } // namespace cc | 1593 } // namespace cc |
| OLD | NEW |