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

Unified Diff: tests/GeometryTest.cpp

Issue 1011493003: alt SkEvalQuadAt that returns its answer, using Sk2f (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
« bench/GeometryBench.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 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);
}
« bench/GeometryBench.cpp ('K') | « src/core/SkGeometry.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698