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

Unified 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, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/core/SkRRect.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/RoundRectTest.cpp
diff --git a/tests/RoundRectTest.cpp b/tests/RoundRectTest.cpp
index 0a528a65357f8f83fb4e18036b63841f49bf4a93..261ec67ca0963cc313db4d1c178bec6505d69e47 100644
--- a/tests/RoundRectTest.cpp
+++ b/tests/RoundRectTest.cpp
@@ -582,6 +582,35 @@ static void test_round_rect_transform(skiatest::Reporter* reporter) {
}
}
+// Test out the case where an oval already off in space is translated/scaled
+// further off into space - yielding numerical issues when the rect & radii
+// are transformed separatly
+// BUG=skia:2696
+static void test_issue_2696(skiatest::Reporter* reporter) {
+ SkRRect rrect;
+ SkRect r = { 28443.8594f, 53.1428604f, 28446.7148f, 56.0000038f };
+ rrect.setOval(r);
+
+ SkMatrix xform;
+ xform.setAll(2.44f, 0.0f, 485411.7f,
+ 0.0f, 2.44f, -438.7f,
+ 0.0f, 0.0f, 1.0f);
+ SkRRect dst;
+
+ bool success = rrect.transform(xform, &dst);
+ REPORTER_ASSERT(reporter, success);
+
+ SkScalar halfWidth = SkScalarHalf(dst.width());
+ SkScalar halfHeight = SkScalarHalf(dst.height());
+
+ for (int i = 0; i < 4; ++i) {
+ REPORTER_ASSERT(reporter,
+ SkScalarNearlyEqual(dst.radii((SkRRect::Corner)i).fX, halfWidth));
+ REPORTER_ASSERT(reporter,
+ SkScalarNearlyEqual(dst.radii((SkRRect::Corner)i).fY, halfHeight));
+ }
+}
+
DEF_TEST(RoundRect, reporter) {
test_round_rect_basic(reporter);
test_round_rect_rects(reporter);
@@ -591,4 +620,5 @@ DEF_TEST(RoundRect, reporter) {
test_inset(reporter);
test_round_rect_contains_rect(reporter);
test_round_rect_transform(reporter);
+ test_issue_2696(reporter);
}
« 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