OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "SkMatrix.h" | 8 #include "SkMatrix.h" |
9 #include "SkRRect.h" | 9 #include "SkRRect.h" |
10 #include "Test.h" | 10 #include "Test.h" |
(...skipping 675 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
686 SkIntToScalar(27), SkIntToScalar(34) }; | 686 SkIntToScalar(27), SkIntToScalar(34) }; |
687 SkVector radii[4] = { { 0, SkIntToScalar(1) }, | 687 SkVector radii[4] = { { 0, SkIntToScalar(1) }, |
688 { SkIntToScalar(2), SkIntToScalar(3) }, | 688 { SkIntToScalar(2), SkIntToScalar(3) }, |
689 { SkIntToScalar(4), SkIntToScalar(5) }, | 689 { SkIntToScalar(4), SkIntToScalar(5) }, |
690 { SkIntToScalar(6), SkIntToScalar(7) } }; | 690 { SkIntToScalar(6), SkIntToScalar(7) } }; |
691 rrect.setRectRadii(r, radii); | 691 rrect.setRectRadii(r, radii); |
692 test_transform_helper(reporter, rrect); | 692 test_transform_helper(reporter, rrect); |
693 } | 693 } |
694 } | 694 } |
695 | 695 |
696 // Test out the case where an oval already off in space is translated/scaled | 696 // Test out the case where an oval already off in space is translated/scaled |
697 // further off into space - yielding numerical issues when the rect & radii | 697 // further off into space - yielding numerical issues when the rect & radii |
698 // are transformed separatly | 698 // are transformed separatly |
699 // BUG=skia:2696 | 699 // BUG=skia:2696 |
700 static void test_issue_2696(skiatest::Reporter* reporter) { | 700 static void test_issue_2696(skiatest::Reporter* reporter) { |
701 SkRRect rrect; | 701 SkRRect rrect; |
702 SkRect r = { 28443.8594f, 53.1428604f, 28446.7148f, 56.0000038f }; | 702 SkRect r = { 28443.8594f, 53.1428604f, 28446.7148f, 56.0000038f }; |
703 rrect.setOval(r); | 703 rrect.setOval(r); |
704 | 704 |
705 SkMatrix xform; | 705 SkMatrix xform; |
706 xform.setAll(2.44f, 0.0f, 485411.7f, | 706 xform.setAll(2.44f, 0.0f, 485411.7f, |
707 0.0f, 2.44f, -438.7f, | 707 0.0f, 2.44f, -438.7f, |
708 0.0f, 0.0f, 1.0f); | 708 0.0f, 0.0f, 1.0f); |
709 SkRRect dst; | 709 SkRRect dst; |
710 | 710 |
711 bool success = rrect.transform(xform, &dst); | 711 bool success = rrect.transform(xform, &dst); |
712 REPORTER_ASSERT(reporter, success); | 712 REPORTER_ASSERT(reporter, success); |
713 | 713 |
714 SkScalar halfWidth = SkScalarHalf(dst.width()); | 714 SkScalar halfWidth = SkScalarHalf(dst.width()); |
715 SkScalar halfHeight = SkScalarHalf(dst.height()); | 715 SkScalar halfHeight = SkScalarHalf(dst.height()); |
716 | 716 |
717 for (int i = 0; i < 4; ++i) { | 717 for (int i = 0; i < 4; ++i) { |
718 REPORTER_ASSERT(reporter, | 718 REPORTER_ASSERT(reporter, |
719 SkScalarNearlyEqual(dst.radii((SkRRect::Corner)i).fX, ha
lfWidth)); | 719 SkScalarNearlyEqual(dst.radii((SkRRect::Corner)i).fX, ha
lfWidth)); |
720 REPORTER_ASSERT(reporter, | 720 REPORTER_ASSERT(reporter, |
721 SkScalarNearlyEqual(dst.radii((SkRRect::Corner)i).fY, ha
lfHeight)); | 721 SkScalarNearlyEqual(dst.radii((SkRRect::Corner)i).fY, ha
lfHeight)); |
722 } | 722 } |
723 } | 723 } |
724 | 724 |
725 DEF_TEST(RoundRect, reporter) { | 725 DEF_TEST(RoundRect, reporter) { |
726 test_round_rect_basic(reporter); | 726 test_round_rect_basic(reporter); |
727 test_round_rect_rects(reporter); | 727 test_round_rect_rects(reporter); |
728 test_round_rect_ovals(reporter); | 728 test_round_rect_ovals(reporter); |
729 test_round_rect_general(reporter); | 729 test_round_rect_general(reporter); |
730 test_round_rect_iffy_parameters(reporter); | 730 test_round_rect_iffy_parameters(reporter); |
731 test_inset(reporter); | 731 test_inset(reporter); |
732 test_round_rect_contains_rect(reporter); | 732 test_round_rect_contains_rect(reporter); |
733 test_round_rect_transform(reporter); | 733 test_round_rect_transform(reporter); |
734 test_issue_2696(reporter); | 734 test_issue_2696(reporter); |
735 test_tricky_radii(reporter); | 735 test_tricky_radii(reporter); |
736 test_empty_crbug_458524(reporter); | 736 test_empty_crbug_458524(reporter); |
737 test_empty(reporter); | 737 test_empty(reporter); |
738 } | 738 } |
OLD | NEW |