aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/PathOpsAngleTest.cpp
diff options
context:
space:
mode:
authorGravatar Cary Clark <caryclark@google.com>2017-01-18 11:00:57 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-01-20 17:35:30 +0000
commitd2eb581ebc8f8009e80cccccd74d5b341ef5bd5b (patch)
treeb7e839cf44743ce6d8119ad527ebaae5e2c1ea6d /tests/PathOpsAngleTest.cpp
parentf833215420847565b4c9945aebdc2e7ae182937f (diff)
offset angle check edge in common
When curves cross, their intersection points may be nearby, but not exactly the same. Sort the angles formed by the crossing curves when all angles don't have the same origin. This sets up the framework to solve test case that currently fail (e.g., joel6) but does not fix all related test cases (e.g., joel9). All older existing test cases, including extended tests, pass. Rework the test framework to better report when tests expected to produce failing results now pass. Add new point and vector operations to support offset angles. TBR=reed@google.com BUG=skia:6041 Change-Id: I67c651ded0a25e99ad93d55d6a35109b3ee3698e Reviewed-on: https://skia-review.googlesource.com/6624 Commit-Queue: Cary Clark <caryclark@google.com> Reviewed-by: Cary Clark <caryclark@google.com>
Diffstat (limited to 'tests/PathOpsAngleTest.cpp')
-rw-r--r--tests/PathOpsAngleTest.cpp61
1 files changed, 61 insertions, 0 deletions
diff --git a/tests/PathOpsAngleTest.cpp b/tests/PathOpsAngleTest.cpp
index d5285c8fbc..a598aea949 100644
--- a/tests/PathOpsAngleTest.cpp
+++ b/tests/PathOpsAngleTest.cpp
@@ -478,6 +478,67 @@ DEF_TEST(PathOpsAngleAfter, reporter) {
}
}
+static void offset_start(SkOpAngle* angle, const SkPoint* line, bool offsetStart) {
+ SkDPoint* pt = angle->debugFirstPt();
+ if (!offsetStart) {
+ pt->fX = pt->fY = 0;
+ return;
+ }
+ pt->fX = line[1].fX * 0.001f;
+ pt->fY = line[1].fY * 0.001f;
+}
+
+// test if offset line edges return the same results as edges without offsets
+DEF_TEST(PathOpsOffsetLineAngle, reporter) {
+ static SkPoint radialLines[][2] = {
+ { {0, 0}, { 2, -1} }, { {0, 0}, { 2, -2} }, { {0, 0}, { 1, -2} }, { {0, 0}, { 0, -2} },
+ { {0, 0}, {-1, -2} }, { {0, 0}, {-2, -2} }, { {0, 0}, {-2, -1} }, { {0, 0}, {-2, 0} },
+ { {0, 0}, {-2, 1} }, { {0, 0}, {-2, 2} }, { {0, 0}, {-1, 2} }, { {0, 0}, { 0, 2} },
+ { {0, 0}, { 1, 2} }, { {0, 0}, { 2, 2} }, { {0, 0}, { 2, 1} }, { {0, 0}, { 2, 0} },
+ };
+ SkChunkAlloc allocator(4096);
+ SkOpContourHead contour;
+ SkOpGlobalState state(&contour, &allocator SkDEBUGPARAMS(false) SkDEBUGPARAMS(nullptr));
+ contour.init(&state, false, false);
+ for (int lh = 0; lh < 16; ++lh) {
+ for (int mid = 0; mid < 16; ++mid) {
+ if (lh == mid) {
+ continue;
+ }
+ for (int rh = 0; rh < 16; ++rh) {
+ if (lh == rh || mid == rh) {
+ continue;
+ }
+ allocator.reset();
+ contour.reset();
+ contour.addLine(radialLines[lh]);
+ contour.addLine(radialLines[mid]);
+ contour.addLine(radialLines[rh]);
+ SkOpSegment* seg1 = contour.first();
+ seg1->debugAddAngle(0, 1);
+ SkOpSegment* seg2 = seg1->next();
+ seg2->debugAddAngle(0, 1);
+ SkOpSegment* seg3 = seg2->next();
+ seg3->debugAddAngle(0, 1);
+ SkOpAngle* angle1 = seg1->debugLastAngle();
+ SkOpAngle* angle2 = seg2->debugLastAngle();
+ SkOpAngle* angle3 = seg3->debugLastAngle();
+ PathOpsAngleTester::SetNext(*angle1, *angle3);
+ /* int expected = */ PathOpsAngleTester::After(*angle2, *angle1);
+ for (int test = 1; test <= 8; ++test) {
+ offset_start(angle1, radialLines[lh], test & 1);
+ offset_start(angle2, radialLines[mid], test & 2);
+ offset_start(angle3, radialLines[rh], test & 4);
+ /* int found = */ PathOpsAngleTester::After(*angle2, *angle1);
+#if 0 // this test fails; haven't explored if this is a real bug or not
+ REPORTER_ASSERT(reporter, expected == found);
+#endif
+ }
+ }
+ }
+ }
+}
+
void SkOpSegment::debugAddAngle(double startT, double endT) {
SkOpPtT* startPtT = startT == 0 ? fHead.ptT() : startT == 1 ? fTail.ptT()
: this->addT(startT);