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

Unified Diff: tests/PathOpsCubicIntersectionTest.cpp

Issue 1037573004: cumulative pathops patch (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fix pathopsinverse gm 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
« no previous file with comments | « tests/PathOpsBuilderTest.cpp ('k') | tests/PathOpsCubicIntersectionTestData.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/PathOpsCubicIntersectionTest.cpp
diff --git a/tests/PathOpsCubicIntersectionTest.cpp b/tests/PathOpsCubicIntersectionTest.cpp
index b6a9e5910af766af170a69c6e190ff87400518e6..598c7cc66b7dc3260e0731dfd9f818a0645b6182 100644
--- a/tests/PathOpsCubicIntersectionTest.cpp
+++ b/tests/PathOpsCubicIntersectionTest.cpp
@@ -6,6 +6,7 @@
*/
#include "PathOpsCubicIntersectionTestData.h"
#include "PathOpsTestCommon.h"
+#include "SkGeometry.h"
#include "SkIntersections.h"
#include "SkPathOpsRect.h"
#include "SkReduceOrder.h"
@@ -162,6 +163,60 @@ static const SkDCubic testSet[] = {
const int testSetCount = (int) SK_ARRAY_COUNT(testSet);
static const SkDCubic newTestSet[] = {
+{{{980.026001,1481.276}, {980.026001,1481.276}, {980.02594,1481.27576}, {980.025879,1481.27527}}},
+{{{980.025879,1481.27527}, {980.025452,1481.27222}, {980.023743,1481.26038}, {980.02179,1481.24072}}},
+
+{{{1.80943513,3.07782435}, {1.66686702,2.16806936}, {1.68301272,0}, {3,0}}},
+{{{0,1}, {0,3}, {3,2}, {5,2}}},
+
+{{{3.4386673,2.66977954}, {4.06668949,2.17046738}, {4.78887367,1.59629118}, {6,2}}},
+{{{1.71985495,3.49467373}, {2.11620402,2.7201426}, {2.91897964,1.15138781}, {6,3}}},
+
+{{{0,1}, {0.392703831,1.78540766}, {0.219947904,2.05676103}, {0.218561709,2.05630541}}},
+{{{0.218561709,2.05630541}, {0.216418028,2.05560064}, {0.624105453,1.40486407}, {4.16666651,1.00000012}}},
+
+{{{0, 1}, {3, 5}, {2, 1}, {3, 1}}},
+{{{1.01366711f, 2.21379328f}, {1.09074128f, 2.23241305f}, {1.60246587f, 0.451849401f}, {5, 3}}},
+
+{{{0, 1}, {0.541499972f, 3.16599989f}, {1.08299994f, 2.69299984f}, {2.10083938f, 1.80391729f}}},
+{{{0.806384504f, 2.85426903f}, {1.52740121f, 1.99355423f}, {2.81689167f, 0.454222918f}, {5, 1}}},
+
+{{{0, 1}, {1.90192389f, 2.90192389f}, {2.59807634f, 2.79422879f}, {3.1076951f, 2.71539044f}}},
+{{{2, 3}, {2.36602545f, 3.36602545f}, {2.330127f, 3.06217766f}, {2.28460979f, 2.67691422f}}},
+
+{{{0, 1}, {1.90192389f, 2.90192389f}, {2.59807634f, 2.79422879f}, {3.1076951f, 2.71539044f}}},
+{{{2.28460979f, 2.67691422f}, {2.20577145f, 2.00961876f}, {2.09807634f, 1.09807622f}, {4, 3}}},
+
+{{{0, 1}, {0.8211091160774231, 2.0948121547698975}, {0.91805583238601685, 2.515404224395752}, {0.91621249914169312, 2.5146586894989014}}},
+{{{0.91621249914169312, 2.5146586894989014}, {0.91132104396820068, 2.5126807689666748}, {0.21079301834106445, -0.45617169141769409}, {10.5, -1.6666665077209473}}},
+
+{{{42.6237564,68.9841232}, {32.449646,81.963089}, {14.7713947,103.565269}, {12.6310005,105.247002}}},
+{{{37.2640038,95.3540039}, {37.2640038,95.3540039}, {11.3710003,83.7339935}, {-25.0779991,124.912003}}},
+
+{{{0,1}, {4,5}, {6,0}, {1,0}}},
+{{{0,6}, {0,1}, {1,0}, {5,4}}},
+
+{{{0,1}, {4,6}, {5,1}, {6,2}}},
+{{{1,5}, {2,6}, {1,0}, {6,4}}},
+
+{{{322, 896.04803466796875}, {314.09201049804687, 833.4376220703125}, {260.24713134765625, 785}, {195, 785}}},
+{{{195, 785}, {265.14016723632812, 785}, {322, 842.30755615234375}, {322, 913}}},
+
+{{{1, 4}, {4, 5}, {3, 2}, {6, 3}}},
+{{{2, 3}, {3, 6}, {4, 1}, {5, 4}}},
+
+{{{67, 913}, {67, 917.388916015625}, {67.224380493164063, 921.72576904296875}, {67.662384033203125, 926}}},
+{{{194, 1041}, {123.85984039306641, 1041}, {67, 983.69244384765625}, {67, 913}}},
+
+{{{1,4}, {1,5}, {6,0}, {5,1}}},
+{{{0,6}, {1,5}, {4,1}, {5,1}}},
+
+{{{0,1}, {4,5}, {6,0}, {1,0}}},
+{{{0,6}, {0,1}, {1,0}, {5,4}}},
+
+{{{0,1}, {4,6}, {2,0}, {2,0}}},
+{{{0,2}, {0,2}, {1,0}, {6,4}}},
+
{{{980.9000244140625, 1474.3280029296875}, {980.9000244140625, 1474.3280029296875}, {978.89300537109375, 1471.95703125}, {981.791015625, 1469.487060546875}}},
{{{981.791015625, 1469.487060546875}, {981.791015625, 1469.4859619140625}, {983.3580322265625, 1472.72900390625}, {980.9000244140625, 1474.3280029296875}}},
@@ -306,7 +361,6 @@ static const SkDCubic newTestSet[] = {
};
const int newTestSetCount = (int) SK_ARRAY_COUNT(newTestSet);
-
static void oneOff(skiatest::Reporter* reporter, const SkDCubic& cubic1, const SkDCubic& cubic2,
bool coin) {
SkASSERT(ValidCubic(cubic1));
@@ -320,28 +374,19 @@ static void oneOff(skiatest::Reporter* reporter, const SkDCubic& cubic1, const S
cubic2[0].fX, cubic2[0].fY, cubic2[1].fX, cubic2[1].fY,
cubic2[2].fX, cubic2[2].fY, cubic2[3].fX, cubic2[3].fY);
#endif
- SkTArray<SkDQuad, true> quads1;
- CubicToQuads(cubic1, cubic1.calcPrecision(), quads1);
-#if ONE_OFF_DEBUG
- SkDebugf("computed quadratics set 1\n");
- for (int index = 0; index < quads1.count(); ++index) {
- const SkDQuad& q = quads1[index];
- SkDebugf(" {{%1.9g,%1.9g}, {%1.9g,%1.9g}, {%1.9g,%1.9g}},\n", q[0].fX, q[0].fY,
- q[1].fX, q[1].fY, q[2].fX, q[2].fY);
+ SkIntersections intersections;
+ intersections.intersect(cubic1, cubic2);
+#if DEBUG_T_SECT_DUMP == 3
+ SkDebugf("</div>\n\n");
+ SkDebugf("<script type=\"text/javascript\">\n\n");
+ SkDebugf("var testDivs = [\n");
+ for (int index = 1; index <= gDumpTSectNum; ++index) {
+ SkDebugf("sect%d,\n", index);
}
#endif
- SkTArray<SkDQuad, true> quads2;
- CubicToQuads(cubic2, cubic2.calcPrecision(), quads2);
-#if ONE_OFF_DEBUG
- SkDebugf("computed quadratics set 2\n");
- for (int index = 0; index < quads2.count(); ++index) {
- const SkDQuad& q = quads2[index];
- SkDebugf(" {{%1.9g,%1.9g}, {%1.9g,%1.9g}, {%1.9g,%1.9g}},\n", q[0].fX, q[0].fY,
- q[1].fX, q[1].fY, q[2].fX, q[2].fY);
+ if (coin && intersections.used() != 2) {
+ SkDebugf("");
}
-#endif
- SkIntersections intersections;
- intersections.intersect(cubic1, cubic2);
REPORTER_ASSERT(reporter, !coin || intersections.used() == 2);
double tt1, tt2;
SkDPoint xy1, xy2;
@@ -558,37 +603,30 @@ int selfSetCount = (int) SK_ARRAY_COUNT(selfSet);
static void selfOneOff(skiatest::Reporter* reporter, int index) {
const SkDCubic& cubic = selfSet[index];
-#if ONE_OFF_DEBUG
- int idx2;
- double max[3];
- int ts = cubic.findMaxCurvature(max);
- for (idx2 = 0; idx2 < ts; ++idx2) {
- SkDebugf("%s max[%d]=%1.9g (%1.9g, %1.9g)\n", __FUNCTION__, idx2,
- max[idx2], cubic.ptAtT(max[idx2]).fX, cubic.ptAtT(max[idx2]).fY);
- }
- SkTArray<double, true> ts1;
- SkTArray<SkDQuad, true> quads1;
- cubic.toQuadraticTs(cubic.calcPrecision(), &ts1);
- for (idx2 = 0; idx2 < ts1.count(); ++idx2) {
- SkDebugf("%s t[%d]=%1.9g\n", __FUNCTION__, idx2, ts1[idx2]);
+ SkPoint c[4];
+ for (int i = 0; i < 4; ++i) {
+ c[i] = cubic[i].asSkPoint();
}
- CubicToQuads(cubic, cubic.calcPrecision(), quads1);
- for (idx2 = 0; idx2 < quads1.count(); ++idx2) {
- const SkDQuad& q = quads1[idx2];
- SkDebugf(" {{{%1.9g,%1.9g}, {%1.9g,%1.9g}, {%1.9g,%1.9g}}},\n",
- q[0].fX, q[0].fY, q[1].fX, q[1].fY, q[2].fX, q[2].fY);
+ SkScalar loopT;
+ SkScalar d[3];
+ SkCubicType cubicType = SkClassifyCubic(c, d);
+ if (SkDCubic::ComplexBreak(c, &loopT) && cubicType == SkCubicType::kLoop_SkCubicType) {
+ SkIntersections i;
+ SkPoint twoCubics[7];
+ SkChopCubicAt(c, twoCubics, loopT);
+ SkDCubic chopped[2];
+ chopped[0].set(&twoCubics[0]);
+ chopped[1].set(&twoCubics[3]);
+ int result = i.intersect(chopped[0], chopped[1]);
+ REPORTER_ASSERT(reporter, result == 2);
+ REPORTER_ASSERT(reporter, i.used() == 2);
+ for (int index = 0; index < result; ++index) {
+ SkDPoint pt1 = chopped[0].ptAtT(i[0][index]);
+ SkDPoint pt2 = chopped[1].ptAtT(i[1][index]);
+ REPORTER_ASSERT(reporter, pt1.approximatelyEqual(pt2));
+ reporter->bumpTestCount();
+ }
}
- SkDebugf("\n");
-#endif
- SkIntersections i;
- int result = i.intersect(cubic);
- REPORTER_ASSERT(reporter, result == 1);
- REPORTER_ASSERT(reporter, i.used() == 1);
- REPORTER_ASSERT(reporter, !approximately_equal(i[0][0], i[1][0]));
- SkDPoint pt1 = cubic.ptAtT(i[0][0]);
- SkDPoint pt2 = cubic.ptAtT(i[1][0]);
- REPORTER_ASSERT(reporter, pt1.approximatelyEqual(pt2));
- reporter->bumpTestCount();
}
static void cubicIntersectionSelfTest(skiatest::Reporter* reporter) {
@@ -599,12 +637,12 @@ static void cubicIntersectionSelfTest(skiatest::Reporter* reporter) {
}
static const SkDCubic coinSet[] = {
+ {{{2, 3}, {0, 4}, {3, 2}, {5, 3}}},
+ {{{2, 3}, {0, 4}, {3, 2}, {5, 3}}},
+
{{{317, 711}, {322.52285766601562, 711}, {327, 715.4771728515625}, {327, 721}}},
{{{324.07107543945312, 713.928955078125}, {324.4051513671875, 714.26300048828125},
{324.71566772460937, 714.62060546875}, {325, 714.9990234375}}},
-
- {{{2, 3}, {0, 4}, {3, 2}, {5, 3}}},
- {{{2, 3}, {0, 4}, {3, 2}, {5, 3}}},
};
static int coinSetCount = (int) SK_ARRAY_COUNT(coinSet);
« no previous file with comments | « tests/PathOpsBuilderTest.cpp ('k') | tests/PathOpsCubicIntersectionTestData.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698