alt SkEvalQuadAt that returns its answer, using Sk2f
BUG=skia:
Review URL: https://codereview.chromium.org/1011493003
diff --git a/tests/GeometryTest.cpp b/tests/GeometryTest.cpp
index 5151b70..9be6000 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 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 @@
}
testChopCubic(reporter);
+ test_evalquadat(reporter);
}