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

Unified Diff: tests/PathOpsAngleTest.cpp

Issue 14865019: path ops work in progress (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 7 years, 7 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 | « src/pathops/SkPathOpsDebug.h ('k') | tests/PathOpsOpTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/PathOpsAngleTest.cpp
===================================================================
--- tests/PathOpsAngleTest.cpp (revision 9111)
+++ tests/PathOpsAngleTest.cpp (working copy)
@@ -10,14 +10,22 @@
static const SkPoint cubics[][4] = {
{{0, 1}, {2, 6}, {4, 2}, {5, 3}},
{{10, 234}, {10, 229.581726f}, {13.5817204f, 226}, {18, 226}},
+ {{132, 11419}, {130.89543151855469f, 11419}, {130, 11418.1044921875f}, {130, 11417}},
+ {{130.04275512695312f, 11417.4130859375f}, {130.23307800292969f, 11418.3193359375f},
+ {131.03709411621094f, 11419}, {132, 11419}},
+ {{0,1}, {0,5}, {4,1}, {6,4}},
};
static const SkPoint quads[][3] = {
{{12.3423996f, 228.342407f}, {10, 230.686295f}, {10, 234}},
+ {{304.24319458007812f,591.75677490234375f}, {306,593.51470947265625f}, {306,596}},
};
static const SkPoint lines[][2] = {
{{6, 2}, {2, 4}},
+ {{306,617}, {306,590}},
+ {{306,596}, {306,617}},
+ {{6,4}, {0,1}},
};
struct SortSet {
@@ -25,8 +33,16 @@
int ptCount;
double tStart;
double tEnd;
+ SkPoint endPt;
};
+static const SortSet set6[] = {
+ {lines[3], 2, 0.407407407, 0.554627832},
+ {cubics[4], 4, 0.666666667, 0.548022446},
+ {lines[3], 2, 0.407407407, 0},
+ {cubics[4], 4, 0.666666667, 1},
+};
+
static const SortSet set1[] = {
{cubics[0], 4, 0.66666987081928919, 0.875},
{lines[0], 2, 0.574070336, 0.388888889},
@@ -34,6 +50,11 @@
{lines[0], 2, 0.574070336, 0.9140625},
};
+static const SortSet set1a[] = {
+ {cubics[0], 4, 0.666666667, 0.405037112, {4.58007812f,2.83203125f}},
+ {lines[0], 2, 0.574074074, 0.9140625, {4.44444466f,2.77777767f}},
+};
+
static const SortSet set2[] = {
{cubics[0], 4, 0.666666667, 0.875},
{lines[0], 2, 0.574074074, 0.388888889},
@@ -46,26 +67,57 @@
{quads[0], 3, 1, 0},
};
+static const SortSet set4[] = {
+ {cubics[2], 4, 0.812114222, 1},
+ {cubics[3], 4, 0.0684734759, 0},
+};
+
+static const SortSet set5[] = {
+ {lines[1], 2, 0.777777778, 1},
+ {quads[1], 3, 1, 4.34137342e-06},
+ {lines[2], 2, 0, 1},
+};
+
+static const SortSet set5a[] = {
+ {lines[1], 2, 0.777777778, 1, {306,590}},
+ {quads[1], 3, 1, 4.34137342e-06, {304.243195f,591.756775f}},
+ {lines[2], 2, 0, 1, {306,617}},
+};
+
struct SortSetTests {
const SortSet* set;
size_t count;
+ SkPoint startPt;
};
static const SortSetTests tests[] = {
+ { set5, SK_ARRAY_COUNT(set5) },
+ { set6, SK_ARRAY_COUNT(set6) },
+ { set5a, SK_ARRAY_COUNT(set5a), {306,596} },
+ { set1a, SK_ARRAY_COUNT(set1a), {3.70370364f,3.14814806f} },
+ { set4, SK_ARRAY_COUNT(set4) },
{ set3, SK_ARRAY_COUNT(set3) },
{ set2, SK_ARRAY_COUNT(set2) },
{ set1, SK_ARRAY_COUNT(set1) },
};
static void setup(const SortSet* set, const size_t idx, SkPoint const ** data,
- SkOpSegment* seg, int* ts) {
+ SkOpSegment* seg, int* ts, const SkPoint& startPt) {
SkPoint start, end;
*data = set[idx].ptData;
+ bool useIntersectPt = startPt.fX != 0 || startPt.fY != 0;
+ if (useIntersectPt) {
+ start = startPt;
+ end = set[idx].endPt;
+ }
switch(set[idx].ptCount) {
case 2: {
seg->addLine(*data, false, false);
SkDLine dLine;
dLine.set(set[idx].ptData);
+ if (useIntersectPt) {
+ break;
+ }
start = dLine.xyAtT(set[idx].tStart).asSkPoint();
end = dLine.xyAtT(set[idx].tEnd).asSkPoint();
} break;
@@ -73,6 +125,9 @@
seg->addQuad(*data, false, false);
SkDQuad dQuad;
dQuad.set(set[idx].ptData);
+ if (useIntersectPt) {
+ break;
+ }
start = dQuad.xyAtT(set[idx].tStart).asSkPoint();
end = dQuad.xyAtT(set[idx].tEnd).asSkPoint();
} break;
@@ -80,6 +135,9 @@
seg->addCubic(*data, false, false);
SkDCubic dCubic;
dCubic.set(set[idx].ptData);
+ if (useIntersectPt) {
+ break;
+ }
start = dCubic.xyAtT(set[idx].tStart).asSkPoint();
end = dCubic.xyAtT(set[idx].tEnd).asSkPoint();
} break;
@@ -88,13 +146,13 @@
double tEnd = set[idx].tEnd;
seg->addT(NULL, start, tStart);
seg->addT(NULL, end, tEnd);
- double tLeft = tStart < tEnd ? 0 : 1;
- if (tStart != tLeft && tEnd != tLeft) {
- seg->addT(NULL, set[idx].ptData[0], tLeft);
+ // double tLeft = tStart < tEnd ? 0 : 1;
+ if (tStart != 0 && tEnd != 0) {
+ seg->addT(NULL, set[idx].ptData[0], 0);
}
- double tRight = tStart < tEnd ? 1 : 0;
- if (tStart != tRight && tEnd != tRight) {
- seg->addT(NULL, set[idx].ptData[set[idx].ptCount - 1], tRight);
+ // double tRight = tStart < tEnd ? 1 : 0;
+ if (tStart != 1 && tEnd != 1) {
+ seg->addT(NULL, set[idx].ptData[set[idx].ptCount - 1], 1);
}
int tIndex = 0;
do {
@@ -118,9 +176,9 @@
int lesserTs[2], greaterTs[2];
const SkPoint* lesserData, * greaterData;
const SortSet* set = test.set;
- setup(set, idxL, &lesserData, &lesser, lesserTs);
+ setup(set, idxL, &lesserData, &lesser, lesserTs, test.startPt);
size_t idxG = idxL + 1;
- setup(set, idxG, &greaterData, &greater, greaterTs);
+ setup(set, idxG, &greaterData, &greater, greaterTs, test.startPt);
SkOpAngle first, second;
first.set(lesserData, (SkPath::Verb) (set[idxL].ptCount - 1), &lesser,
lesserTs[0], lesserTs[1], lesser.spans());
@@ -130,8 +188,10 @@
if (!compare) {
SkDebugf("%s test[%d]: lesser[%d] > greater[%d]\n", __FUNCTION__,
index, idxL, idxG);
+ compare = first < second;
}
REPORTER_ASSERT(reporter, compare);
+ reporter->bumpTestCount();
}
}
}
« no previous file with comments | « src/pathops/SkPathOpsDebug.h ('k') | tests/PathOpsOpTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698