aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests
diff options
context:
space:
mode:
authorGravatar caryclark <caryclark@google.com>2016-09-26 05:36:58 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-09-26 05:36:58 -0700
commit6c3b9cdcb047afe963c7bcf34834ba2ecccacc33 (patch)
treed32c7f96607e4ca588a258e8cadd8202b2271aa6 /tests
parenteafe9d1577f7a9feb19af9773bf835e5d657bec1 (diff)
fix tiger b
The tiger tests have uncovered numerous bugs. This CL fixes the last of them. If a pair of curves do not intersect, but have one or both ends very close to the opposite curve, consider that an intersection. TBR=reed@google.com BUG=skia:5131 GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2356363003 Review-Url: https://codereview.chromium.org/2356363003
Diffstat (limited to 'tests')
-rw-r--r--tests/PathOpsConicQuadIntersectionTest.cpp69
-rw-r--r--tests/PathOpsCubicIntersectionTest.cpp4
-rw-r--r--tests/PathOpsSimplifyTest.cpp4
-rw-r--r--tests/PathOpsTSectDebug.h6
4 files changed, 76 insertions, 7 deletions
diff --git a/tests/PathOpsConicQuadIntersectionTest.cpp b/tests/PathOpsConicQuadIntersectionTest.cpp
new file mode 100644
index 0000000000..5996cf804c
--- /dev/null
+++ b/tests/PathOpsConicQuadIntersectionTest.cpp
@@ -0,0 +1,69 @@
+/*
+ * Copyright 2015 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+#include "PathOpsTestCommon.h"
+#include "SkIntersections.h"
+#include "SkPathOpsConic.h"
+#include "SkPathOpsQuad.h"
+#include "SkReduceOrder.h"
+#include "Test.h"
+
+static struct conicQuad {
+ SkDConic conic;
+ SkDQuad quad;
+} conicQuadTests[] = {
+ {{{{{494.348663,224.583771}, {494.365143,224.633194}, {494.376404,224.684067}}}, 0.998645842f},
+ {{{494.30481,224.474213}, {494.334961,224.538284}, {494.355774,224.605927}}}},
+
+ {{{{{494.348663,224.583771}, {494.365143,224.633194}, {494.376404,224.684067}}}, 0.998645842f},
+ {{{494.355774f, 224.605927f}, {494.363708f, 224.631714f}, {494.370148f, 224.657471f}}}},
+};
+
+static const int conicQuadTests_count = (int) SK_ARRAY_COUNT(conicQuadTests);
+
+static void conicQuadIntersection(skiatest::Reporter* reporter, int index) {
+ const SkDConic& conic = conicQuadTests[index].conic;
+ SkASSERT(ValidConic(conic));
+ const SkDQuad& quad = conicQuadTests[index].quad;
+ SkASSERT(ValidQuad(quad));
+ SkReduceOrder reduce1;
+ SkReduceOrder reduce2;
+ int order1 = reduce2.reduce(conic.fPts);
+ int order2 = reduce1.reduce(quad);
+ if (order2 != 3) {
+ SkDebugf("[%d] conic order=%d\n", index, order1);
+ REPORTER_ASSERT(reporter, 0);
+ }
+ if (order1 != 3) {
+ SkDebugf("[%d] quad order=%d\n", index, order2);
+ REPORTER_ASSERT(reporter, 0);
+ }
+ SkIntersections i;
+ int roots = i.intersect(conic, quad);
+ for (int pt = 0; pt < roots; ++pt) {
+ double tt1 = i[0][pt];
+ SkDPoint xy1 = conic.ptAtT(tt1);
+ double tt2 = i[1][pt];
+ SkDPoint xy2 = quad.ptAtT(tt2);
+ if (!xy1.approximatelyEqual(xy2)) {
+ SkDebugf("%s [%d,%d] x!= t1=%g (%g,%g) t2=%g (%g,%g)\n",
+ __FUNCTION__, index, pt, tt1, xy1.fX, xy1.fY, tt2, xy2.fX, xy2.fY);
+ }
+ REPORTER_ASSERT(reporter, xy1.approximatelyEqual(xy2));
+ }
+ reporter->bumpTestCount();
+}
+
+DEF_TEST(PathOpsConicQuadIntersection, reporter) {
+ for (int index = 0; index < conicQuadTests_count; ++index) {
+ conicQuadIntersection(reporter, index);
+ reporter->bumpTestCount();
+ }
+}
+
+DEF_TEST(PathOpsConicQuadIntersectionOneOff, reporter) {
+ conicQuadIntersection(reporter, 1);
+}
diff --git a/tests/PathOpsCubicIntersectionTest.cpp b/tests/PathOpsCubicIntersectionTest.cpp
index 9bf60b7e39..07852bca9a 100644
--- a/tests/PathOpsCubicIntersectionTest.cpp
+++ b/tests/PathOpsCubicIntersectionTest.cpp
@@ -404,10 +404,10 @@ static void oneOff(skiatest::Reporter* reporter, const SkDCubic& cubic1, const S
SkDebugf("sect%d,\n", index);
}
#endif
- if (coin && intersections.used() != 2) {
+ if (coin && intersections.used() < 2) {
SkDebugf("");
}
- REPORTER_ASSERT(reporter, !coin || intersections.used() == 2);
+ REPORTER_ASSERT(reporter, !coin || intersections.used() >= 2);
double tt1, tt2;
SkDPoint xy1, xy2;
for (int pt3 = 0; pt3 < intersections.used(); ++pt3) {
diff --git a/tests/PathOpsSimplifyTest.cpp b/tests/PathOpsSimplifyTest.cpp
index 55f0447bae..2e469854fa 100644
--- a/tests/PathOpsSimplifyTest.cpp
+++ b/tests/PathOpsSimplifyTest.cpp
@@ -5331,7 +5331,7 @@ static void tiger8b_h_1(skiatest::Reporter* reporter, const char* filename) {
#if DEBUG_UNDER_DEVELOPMENT // tiger
return;
#endif
- uint64_t testlines = 0x000000201304b4a3; // best so far: 0x000000201304b4a3
+ uint64_t testlines = 0x000000000f27b9e3; // best so far: 0x000000201304b4a3
tiger8b_x(reporter, filename, testlines);
}
@@ -5870,7 +5870,7 @@ static void testQuads73(skiatest::Reporter* reporter, const char* filename) {
}
static void (*skipTest)(skiatest::Reporter* , const char* filename) = 0;
-static void (*firstTest)(skiatest::Reporter* , const char* filename) = 0;
+static void (*firstTest)(skiatest::Reporter* , const char* filename) = tiger8b_h_1;
static void (*stopTest)(skiatest::Reporter* , const char* filename) = 0;
static TestDesc tests[] = {
diff --git a/tests/PathOpsTSectDebug.h b/tests/PathOpsTSectDebug.h
index 4e04db794b..e18e0f89e6 100644
--- a/tests/PathOpsTSectDebug.h
+++ b/tests/PathOpsTSectDebug.h
@@ -9,16 +9,16 @@
template<typename TCurve, typename OppCurve>
char SkTCoincident<TCurve, OppCurve>::dumpIsCoincidentStr() const {
- if (!!fCoincident != fCoincident) {
+ if (!!fMatch != fMatch) {
return '?';
}
- return fCoincident ? '*' : 0;
+ return fMatch ? '*' : 0;
}
template<typename TCurve, typename OppCurve>
void SkTCoincident<TCurve, OppCurve>::dump() const {
SkDebugf("t=%1.9g pt=(%1.9g,%1.9g)%s\n", fPerpT, fPerpPt.fX, fPerpPt.fY,
- fCoincident ? " coincident" : "");
+ fMatch ? " match" : "");
}
template<typename TCurve, typename OppCurve>