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

Unified Diff: tests/GeometryTest.cpp

Issue 1026633002: use Sk2s for EvalQuadTangent and ChopQuadAt (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 9 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
« src/core/SkGeometry.cpp ('K') | « src/core/SkGeometry.cpp ('k') | no next file » | 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 9be6000a0e2e0ec6cc2b8ab5c71e9635c96206a7..aba8dd224bf0e12e25697b55c46a4f741f24f0c6 100644
--- a/tests/GeometryTest.cpp
+++ b/tests/GeometryTest.cpp
@@ -34,6 +34,16 @@ static void testChopCubic(skiatest::Reporter* reporter) {
}
}
+static void check_pairs(skiatest::Reporter* reporter, int index, SkScalar t, const char name[],
+ SkScalar x0, SkScalar y0, SkScalar x1, SkScalar y1) {
+ bool eq = SkScalarNearlyEqual(x0, x1) && SkScalarNearlyEqual(y0, y1);
+ if (!eq) {
+ SkDebugf("%s [%d %g] p0 [%10.8f %10.8f] p1 [%10.8f %10.8f]\n",
+ name, index, t, x0, y0, x1, y1);
+ REPORTER_ASSERT(reporter, eq);
+ }
+}
+
static void test_evalquadat(skiatest::Reporter* reporter) {
SkRandom rand;
for (int i = 0; i < 1000; ++i) {
@@ -41,17 +51,27 @@ static void test_evalquadat(skiatest::Reporter* reporter) {
for (int j = 0; j < 3; ++j) {
pts[j].set(rand.nextSScalar1() * 100, rand.nextSScalar1() * 100);
}
- SkScalar t = 0;
const SkScalar dt = SK_Scalar1 / 128;
- for (int j = 0; j < 128; ++j) {
+ SkScalar t = dt;
+ for (int j = 1; j < 128; ++j) {
SkPoint r0;
SkEvalQuadAt(pts, t, &r0);
SkPoint r1 = SkEvalQuadAt(pts, t);
- bool eq = SkScalarNearlyEqual(r0.fX, r1.fX) && SkScalarNearlyEqual(r0.fY, r1.fY);
- if (!eq) {
- SkDebugf("[%d %g] p0 [%10.8f %10.8f] p1 [%10.8f %10.8f]\n", i, t, r0.fX, r0.fY, r1.fX, r1.fY);
- REPORTER_ASSERT(reporter, eq);
+ check_pairs(reporter, i, t, "quad-pos", r0.fX, r0.fY, r1.fX, r1.fY);
+
+ SkVector v0;
+ SkEvalQuadAt(pts, t, NULL, &v0);
+ SkVector v1 = SkEvalQuadTangentAt(pts, t);
+ check_pairs(reporter, i, t, "quad-tan", v0.fX, v0.fY, v1.fX, v1.fY);
+
+ SkPoint dst0[5], dst1[5];
+ SkChopQuadAt(pts, dst0, t);
+ SkChopQuadAt2(pts, dst1, t);
+ for (int k = 0; k < 5; ++k) {
+ check_pairs(reporter, i, t, "chop-quad",
+ dst0[k].fX, dst0[k].fY, dst1[k].fX, dst1[k].fY);
}
+
t += dt;
}
}
« src/core/SkGeometry.cpp ('K') | « src/core/SkGeometry.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698