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

Side by Side Diff: tests/RoundRectTest.cpp

Issue 354913004: Fix RRect transform bug (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Add unit test Created 6 years, 5 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 | « src/core/SkRRect.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 564 matching lines...) Expand 10 before | Expand all | Expand 10 after
575 SkIntToScalar(27), SkIntToScalar(34) }; 575 SkIntToScalar(27), SkIntToScalar(34) };
576 SkVector radii[4] = { { 0, SkIntToScalar(1) }, 576 SkVector radii[4] = { { 0, SkIntToScalar(1) },
577 { SkIntToScalar(2), SkIntToScalar(3) }, 577 { SkIntToScalar(2), SkIntToScalar(3) },
578 { SkIntToScalar(4), SkIntToScalar(5) }, 578 { SkIntToScalar(4), SkIntToScalar(5) },
579 { SkIntToScalar(6), SkIntToScalar(7) } }; 579 { SkIntToScalar(6), SkIntToScalar(7) } };
580 rrect.setRectRadii(r, radii); 580 rrect.setRectRadii(r, radii);
581 test_transform_helper(reporter, rrect); 581 test_transform_helper(reporter, rrect);
582 } 582 }
583 } 583 }
584 584
585 // Test out the case where an oval already off in space is translated/scaled
586 // further off into space - yielding numerical issues when the rect & radii
587 // are transformed separatly
588 // BUG=skia:2696
589 static void test_issue_2696(skiatest::Reporter* reporter) {
590 SkRRect rrect;
591 SkRect r = { 28443.8594f, 53.1428604f, 28446.7148f, 56.0000038f };
592 rrect.setOval(r);
593
594 SkMatrix xform;
595 xform.setAll(2.44f, 0.0f, 485411.7f,
596 0.0f, 2.44f, -438.7f,
597 0.0f, 0.0f, 1.0f);
598 SkRRect dst;
599
600 bool success = rrect.transform(xform, &dst);
601 REPORTER_ASSERT(reporter, success);
602
603 SkScalar halfWidth = SkScalarHalf(dst.width());
604 SkScalar halfHeight = SkScalarHalf(dst.height());
605
606 for (int i = 0; i < 4; ++i) {
607 REPORTER_ASSERT(reporter,
608 SkScalarNearlyEqual(dst.radii((SkRRect::Corner)i).fX, ha lfWidth));
609 REPORTER_ASSERT(reporter,
610 SkScalarNearlyEqual(dst.radii((SkRRect::Corner)i).fY, ha lfHeight));
611 }
612 }
613
585 DEF_TEST(RoundRect, reporter) { 614 DEF_TEST(RoundRect, reporter) {
586 test_round_rect_basic(reporter); 615 test_round_rect_basic(reporter);
587 test_round_rect_rects(reporter); 616 test_round_rect_rects(reporter);
588 test_round_rect_ovals(reporter); 617 test_round_rect_ovals(reporter);
589 test_round_rect_general(reporter); 618 test_round_rect_general(reporter);
590 test_round_rect_iffy_parameters(reporter); 619 test_round_rect_iffy_parameters(reporter);
591 test_inset(reporter); 620 test_inset(reporter);
592 test_round_rect_contains_rect(reporter); 621 test_round_rect_contains_rect(reporter);
593 test_round_rect_transform(reporter); 622 test_round_rect_transform(reporter);
623 test_issue_2696(reporter);
594 } 624 }
OLDNEW
« no previous file with comments | « src/core/SkRRect.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698