Index: tests/GeometryTest.cpp |
diff --git a/tests/GeometryTest.cpp b/tests/GeometryTest.cpp |
index 5151b70805efe39eb31df6443a67f052f12712de..9be6000a0e2e0ec6cc2b8ab5c71e9635c96206a7 100644 |
--- a/tests/GeometryTest.cpp |
+++ b/tests/GeometryTest.cpp |
@@ -7,6 +7,7 @@ |
#include "SkGeometry.h" |
#include "Test.h" |
+#include "SkRandom.h" |
static bool nearly_equal(const SkPoint& a, const SkPoint& b) { |
return SkScalarNearlyEqual(a.fX, b.fX) && SkScalarNearlyEqual(a.fY, b.fY); |
@@ -33,6 +34,29 @@ static void testChopCubic(skiatest::Reporter* reporter) { |
} |
} |
+static void test_evalquadat(skiatest::Reporter* reporter) { |
+ SkRandom rand; |
+ for (int i = 0; i < 1000; ++i) { |
+ SkPoint pts[3]; |
+ 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) { |
+ 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); |
+ } |
+ t += dt; |
+ } |
+ } |
+} |
+ |
DEF_TEST(Geometry, reporter) { |
SkPoint pts[3], dst[5]; |
@@ -58,4 +82,5 @@ DEF_TEST(Geometry, reporter) { |
} |
testChopCubic(reporter); |
+ test_evalquadat(reporter); |
} |