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

Unified Diff: tests/GeometryTest.cpp

Issue 2142393003: handle large conic weights (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: another double warning Created 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/core/SkGeometry.cpp ('k') | tests/PathTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/GeometryTest.cpp
diff --git a/tests/GeometryTest.cpp b/tests/GeometryTest.cpp
index 17e46448570ec45ff43faf92cfbef15deb16100a..b3bbb51bc0122ac1b81395ac2ad06ea68c9fa896 100644
--- a/tests/GeometryTest.cpp
+++ b/tests/GeometryTest.cpp
@@ -145,6 +145,45 @@ static void test_conic_tangents(skiatest::Reporter* reporter) {
}
}
+static void test_this_conic_to_quad(skiatest::Reporter* r, const SkPoint pts[3], SkScalar w) {
+ SkAutoConicToQuads quadder;
+ const SkPoint* qpts = quadder.computeQuads(pts, w, 0.25);
+ const int qcount = quadder.countQuads();
+ const int pcount = qcount * 2 + 1;
+
+ REPORTER_ASSERT(r, SkPointsAreFinite(qpts, pcount));
+}
+
+/**
+ * We need to ensure that when a conic is approximated by quads, that we always return finite
+ * values in the quads.
+ *
+ * Inspired by crbug_627414
+ */
+static void test_conic_to_quads(skiatest::Reporter* reporter) {
+ const SkPoint triples[] = {
+ { 0, 0 }, { 1, 0 }, { 1, 1 },
+ { 3.58732e-43f, 2.72084f }, { 3.00392f, 3.00392f },
+ { 0, 0 }, { 100000, 0 }, { 100000, 100000 },
+ { 0, 0 }, { 1e30f, 0 }, { 1e30f, 1e30f },
+ };
+ const int N = sizeof(triples) / sizeof(SkPoint);
+
+ for (int i = 0; i < N; i += 3) {
+ const SkPoint* pts = &triples[i];
+
+ SkRect bounds;
+ bounds.set(pts, 3);
+
+ SkScalar w = 1e30f;
+ do {
+ w *= 2;
+ test_this_conic_to_quad(reporter, pts, w);
+ } while (SkScalarIsFinite(w));
+ test_this_conic_to_quad(reporter, pts, SK_ScalarNaN);
+ }
+}
+
static void test_cubic_tangents(skiatest::Reporter* reporter) {
SkPoint pts[] = {
{ 10, 20}, {10, 20}, {20, 30}, {30, 40},
@@ -193,4 +232,5 @@ DEF_TEST(Geometry, reporter) {
test_cubic_tangents(reporter);
test_quad_tangents(reporter);
test_conic_tangents(reporter);
+ test_conic_to_quads(reporter);
}
« no previous file with comments | « src/core/SkGeometry.cpp ('k') | tests/PathTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698