pathB.close();
</div>
+<div id="testQuadratic94">
+ SkPath path;
+ path.moveTo(0, 0);
+ path.lineTo(8, 8);
+ path.quadTo(8, 4, 4, 4);
+ path.quadTo(4, 0, 0, 0);
+ path.close();
+ testSimplify(reporter, path);
+</div>
+
+<div id="testQuadratic95">
+ SkPath path;
+ path.moveTo(8, 8);
+ path.lineTo(0, 0);
+ path.quadTo(4, 0, 4, 4);
+ path.quadTo(8, 4, 8, 8);
+ path.close();
+ testSimplify(reporter, path);
+</div>
+
+<div id="testQuadratic96">
+ SkPath path;
+ path.moveTo(8, 0);
+ path.lineTo(0, 8);
+ path.quadTo(0, 4, 4, 4);
+ path.quadTo(4, 0, 8, 0);
+ path.close();
+ testSimplify(reporter, path);
+</div>
+
+<div id="testQuadratic97">
+ SkPath path;
+ path.moveTo(0, 8);
+ path.lineTo(8, 0);
+ path.quadTo(4, 0, 4, 4);
+ path.quadTo(0, 4, 0, 8);
+ path.close();
+ testSimplify(reporter, path);
+</div>
+
</div>
<script type="text/javascript">
var testDivs = [
+ testQuadratic97,
+ testQuadratic96,
+ testQuadratic95,
+ testQuadratic94,
testLine16,
cubicOp63d,
cubicOp62d,
'type': 'executable',
'suppress_wildcard': '1',
'include_dirs' : [
- '../include/pathops',
'../src/core',
'../src/effects',
'../src/lazy',
- '../src/pathops',
'../src/pdf',
'../src/pipe/utils',
'../src/utils',
{
'sources': [
+ '../tests/PathOpsAngleTest.cpp',
'../tests/PathOpsBoundsTest.cpp',
'../tests/PathOpsCubicIntersectionTest.cpp',
'../tests/PathOpsCubicIntersectionTestData.cpp',
char tab[] = " ";
if (tLimits1[0][0] >= t1Start && tLimits1[0][1] <= t1
&& tLimits1[1][0] >= t2Start && tLimits1[1][1] <= t2) {
- SkDCubic cSub1 = cubic1.subDivide(t1Start, t1);
- SkDCubic cSub2 = cubic2.subDivide(t2Start, t2);
SkDebugf("%.*s %s t1=(%1.9g,%1.9g) t2=(%1.9g,%1.9g)", i.depth()*2, tab,
__FUNCTION__, t1Start, t1, t2Start, t2);
SkIntersections xlocals;
}
for (int n = 0; n < 3; ++n) {
double test = (q2[n].fY - origY) * adj - (q2[n].fX - origX) * opp;
+ if (test * sign > 0 && precisely_zero(test)) {
+ SkDebugf("*** very teeny\n");
+ }
if (test * sign > 0) {
goto tryNextHalfPlane;
}
SkDQuad hull = q1.subDivide(t1s, t1e);
SkDLine line = {{hull[2], hull[0]}};
const SkDLine* testLines[] = { &line, (const SkDLine*) &hull[0], (const SkDLine*) &hull[1] };
- size_t testCount = sizeof(testLines) / sizeof(testLines[0]);
+ size_t testCount = SK_ARRAY_COUNT(testLines);
SkTDArray<double> tsFound;
for (size_t index = 0; index < testCount; ++index) {
SkIntersections rootTs;
class SkOpAngle {
public:
bool operator<(const SkOpAngle& rh) const;
+
double dx() const {
return fTangent1.dx();
}
bool lengthen();
bool reverseLengthen();
+
void set(const SkPoint* orig, SkPath::Verb verb, const SkOpSegment* segment,
int start, int end, const SkTDArray<SkOpSpan>& spans);
void setSpans();
+
SkOpSegment* segment() const {
return const_cast<SkOpSegment*>(fSegment);
}
int oppoSign = oppSign(firstAngle);
int oppWindSum = oppLastSum - oppoSign;
#define WIND_AS_STRING(x) char x##Str[12]; if (!valid_wind(x)) strcpy(x##Str, "?"); \
- else snprintf(x##Str, sizeof(x##Str), "%d", x)
+ else SK_SNPRINTF(x##Str, sizeof(x##Str), "%d", x)
WIND_AS_STRING(contourWinding);
WIND_AS_STRING(oppContourWinding);
SkDebugf("%s %s contourWinding=%s oppContourWinding=%s sign=%d\n", fun, __FUNCTION__,
opp ? windSumStr : oppWindSumStr);
}
SkDebugf(" done=%d tiny=%d opp=%d\n", mSpan.fDone, mSpan.fTiny, opp);
-#if false && DEBUG_ANGLE
+#if 0 && DEBUG_ANGLE
angle.debugShow(segment.xyAtT(&sSpan));
#endif
++index;
return fTs[tIndex];
}
+ // OPTIMIZATION: mark as debugging only if used solely by tests
+ const SkTDArray<SkOpSpan>& spans() const {
+ return fTs;
+ }
+
int spanSign(const SkOpAngle* angle) const {
SkASSERT(angle->segment() == this);
return spanSign(angle->start(), angle->end());
#ifdef SK_RELEASE
#define FORCE_RELEASE 1
#else
-#define FORCE_RELEASE 1 // set force release to 1 for multiple thread -- no debugging
+#define FORCE_RELEASE 0 // set force release to 1 for multiple thread -- no debugging
#endif
#define ONE_OFF_DEBUG 0
bool approximatelyEqual(const SkPoint& a) const {
double denom = SkTMax<double>(fabs(fX), SkTMax<double>(fabs(fY),
- SkScalarToDouble(SkTMax<SkScalar>(fabs(a.fX), fabs(a.fY)))));
+ SkScalarToDouble(SkTMax<SkScalar>(fabsf(a.fX), fabsf(a.fY)))));
if (denom == 0) {
return true;
}
--- /dev/null
+/*
+ * Copyright 2013 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+#include "SkOpSegment.h"
+#include "Test.h"
+
+static const SkPoint cubics[][4] = {
+ {{0, 1}, {2, 6}, {4, 2}, {5, 3}}
+};
+
+static const SkPoint lines[][2] = {
+ {{6, 2}, {2, 4}}
+};
+
+struct SortSet {
+ const SkPoint* ptData;
+ int ptCount;
+ double tStart;
+ double tEnd;
+};
+
+static const SortSet set1[] = {
+ {lines[0], 2, 0.54070336, 0.388888889},
+ {cubics[0], 4, 0.666669871, 0.405037112},
+ {lines[0], 2, 0.54070336, 0.9140625},
+ {cubics[0], 4, 0.666669871, 0.875},
+};
+
+static const SortSet set2[] = {
+ {lines[0], 2, 0.574074074, 0.388888889},
+ {cubics[0], 4, 0.666666667, 0.405037112},
+ {lines[0], 2, 0.574074074, 0.9140625},
+ {cubics[0], 4, 0.666666667, 0.875},
+};
+
+struct SortSetTests {
+ const SortSet* set;
+ size_t count;
+};
+
+static const SortSetTests tests[] = {
+ { set1, SK_ARRAY_COUNT(set1) },
+ { set2, SK_ARRAY_COUNT(set2) }
+};
+
+static void setup(const SortSet* set, const size_t idx, SkPoint const ** data,
+ SkPoint* reverse, SkOpSegment* seg) {
+ SkPoint start, end;
+ if (set[idx].ptCount == 2) {
+ if (set[idx].tStart < set[idx].tEnd) {
+ *data = set[idx].ptData;
+ } else {
+ reverse[0] = set[idx].ptData[1];
+ reverse[1] = set[idx].ptData[0];
+ *data = reverse;
+ }
+ seg->addLine(*data, false, false);
+ SkDLine dLine;
+ dLine.set(set[idx].ptData);
+ start = dLine.xyAtT(set[idx].tStart).asSkPoint();
+ end = dLine.xyAtT(set[idx].tEnd).asSkPoint();
+ } else if (set[idx].ptCount == 4) {
+ if (set[idx].tStart < set[idx].tEnd) {
+ *data = set[idx].ptData;
+ } else {
+ reverse[0] = set[idx].ptData[3];
+ reverse[1] = set[idx].ptData[2];
+ reverse[2] = set[idx].ptData[1];
+ reverse[3] = set[idx].ptData[0];
+ *data = reverse;
+ }
+ seg->addCubic(*data, false, false);
+ SkDCubic dCubic;
+ dCubic.set(set[idx].ptData);
+ start = dCubic.xyAtT(set[idx].tStart).asSkPoint();
+ end = dCubic.xyAtT(set[idx].tEnd).asSkPoint();
+ }
+ seg->addT(NULL, start, set[idx].tStart);
+ seg->addT(NULL, end, set[idx].tEnd);
+ seg->addT(NULL, set[idx].ptData[0], 0);
+ seg->addT(NULL, set[idx].ptData[set[idx].ptCount - 1], 1);
+}
+
+static void PathOpsAngleTest(skiatest::Reporter* reporter) {
+ for (size_t index = 0; index < SK_ARRAY_COUNT(tests); ++index) {
+ const SortSetTests& test = tests[index];
+ for (size_t idxL = 0; idxL < test.count - 1; ++idxL) {
+ SkOpSegment lesser, greater;
+ SkPoint lesserReverse[4], greaterReverse[4];
+ const SkPoint* lesserData, * greaterData;
+ const SortSet* set = test.set;
+ setup(set, idxL, &lesserData, lesserReverse, &lesser);
+ size_t idxG = idxL + 1;
+ setup(set, idxG, &greaterData, greaterReverse, &greater);
+ SkOpAngle first, second;
+ first.set(lesserData, (SkPath::Verb) (set[idxL].ptCount - 1), &lesser,
+ 0, 1, lesser.spans());
+ first.setSpans();
+ second.set(greaterData, (SkPath::Verb) (set[idxG].ptCount - 1), &greater,
+ 0, 1, greater.spans());
+ second.setSpans();
+ bool compare = first < second;
+ if (!compare) {
+ SkDebugf("%s test[%d]: lesser[%d] > greater[%d]\n", __FUNCTION__,
+ index, idxL, idxG);
+ }
+ REPORTER_ASSERT(reporter, compare);
+ }
+ }
+}
+
+#include "TestClassDef.h"
+DEFINE_TESTCLASS_SHORT(PathOpsAngleTest)
{{2, 0, 4, 1}, {4, 1, 5, 2}}, // touching just on a corner is OK
};
-static const size_t sectTestsCount = sizeof(sectTests) / sizeof(sectTests[0]);
+static const size_t sectTestsCount = SK_ARRAY_COUNT(sectTests);
static const SkRect noSectTests[][2] = {
{{2, 0, 4, 1}, {5, 0, 6, 1}},
{{2, 0, 4, 1}, {3, 2, 5, 2}},
};
-static const size_t noSectTestsCount = sizeof(noSectTests) / sizeof(noSectTests[0]);
+static const size_t noSectTestsCount = SK_ARRAY_COUNT(noSectTests);
static const SkRect reallyEmpty[] = {
{0, 0, 0, 0},
{1, 2, 3, SK_ScalarNaN},
};
-static const size_t emptyTestsCount = sizeof(reallyEmpty) / sizeof(reallyEmpty[0]);
+static const size_t emptyTestsCount = SK_ARRAY_COUNT(reallyEmpty);
static const SkRect notReallyEmpty[] = {
{0, 0, 1, 0},
{0, 0, 1, 1},
};
-static const size_t notEmptyTestsCount = sizeof(notReallyEmpty) / sizeof(notReallyEmpty[0]);
+static const size_t notEmptyTestsCount = SK_ARRAY_COUNT(notReallyEmpty);
-static void OpBoundsTest(skiatest::Reporter* reporter) {
+static void PathOpsBoundsTest(skiatest::Reporter* reporter) {
for (size_t index = 0; index < sectTestsCount; ++index) {
const SkPathOpsBounds& bounds1 = static_cast<const SkPathOpsBounds&>(sectTests[index][0]);
const SkPathOpsBounds& bounds2 = static_cast<const SkPathOpsBounds&>(sectTests[index][1]);
}
#include "TestClassDef.h"
-DEFINE_TESTCLASS("PathOpsBounds", PathOpsBoundsClass, OpBoundsTest)
+DEFINE_TESTCLASS_SHORT(PathOpsBoundsTest)
{56.4860195, 60.529264}}},
};
-const size_t testSetCount = sizeof(testSet) / sizeof(testSet[0]);
+const size_t testSetCount = SK_ARRAY_COUNT(testSet);
static const SkDCubic newTestSet[] = {
{{{0, 1}, {1, 5}, {1, 0}, {1, 0}}},
{{{0, 3}, {0, 1}, {2, 0}, {1, 0}}},
};
-const size_t newTestSetCount = sizeof(newTestSet) / sizeof(newTestSet[0]);
+const size_t newTestSetCount = SK_ARRAY_COUNT(newTestSet);
static void oneOff(skiatest::Reporter* reporter, const SkDCubic& cubic1, const SkDCubic& cubic2) {
#if ONE_OFF_DEBUG
{{{6.71, 3.14}, {7.99, 2.75}, {8.27, 1.96}, {6.35, 3.57}}},
{{{12.81, 7.27}, {7.22, 6.98}, {12.49, 8.97}, {11.42, 6.18}}},
};
- size_t selfSetCount = sizeof(selfSet) / sizeof(selfSet[0]);
+ size_t selfSetCount = SK_ARRAY_COUNT(selfSet);
size_t firstFail = 1;
for (size_t index = firstFail; index < selfSetCount; ++index) {
const SkDCubic& cubic = selfSet[index];
}
}
-static void TestCubicIntersection(skiatest::Reporter* reporter) {
+static void PathOpsCubicIntersectionTest(skiatest::Reporter* reporter) {
oneOffTest(reporter);
oneOffTests(reporter);
cubicIntersectionSelfTest(reporter);
}
#include "TestClassDef.h"
-DEFINE_TESTCLASS("PathOpsCubicIntersectionTest", CubicIntersectionTestClass, TestCubicIntersection)
+DEFINE_TESTCLASS_SHORT(PathOpsCubicIntersectionTest)
{{{1, 1}, {2, 2}, {2, 2+N}, {1, 1}}},
};
-const size_t pointDegenerates_count = sizeof(pointDegenerates) / sizeof(pointDegenerates[0]);
+const size_t pointDegenerates_count = SK_ARRAY_COUNT(pointDegenerates);
const SkDCubic notPointDegenerates[] = {
{{{1 + FLT_EPSILON * 2, 1}, {1, FLT_EPSILON * 2}, {1, 1}, {1, 1}}},
};
const size_t notPointDegenerates_count =
- sizeof(notPointDegenerates) / sizeof(notPointDegenerates[0]);
+ SK_ARRAY_COUNT(notPointDegenerates);
// from http://www.truetex.com/bezint.htm
const SkDCubic tests[][2] = {
}
};
-const size_t tests_count = sizeof(tests) / sizeof(tests[0]);
+const size_t tests_count = SK_ARRAY_COUNT(tests);
const SkDCubic lines[] = {
{{{0, 0}, {0, 0}, {0, 0}, {1, 0}}}, // 0: horizontal
{{{2, 2}, {4, 4}, {3, 3}, {1, 1}}},
};
-const size_t lines_count = sizeof(lines) / sizeof(lines[0]);
+const size_t lines_count = SK_ARRAY_COUNT(lines);
// 'not a line' tries to fool the line detection code
const SkDCubic notLines[] = {
{{{0, 1}, {1, 0}, {0, 0}, {0, 0}}},
};
-const size_t notLines_count = sizeof(notLines) / sizeof(notLines[0]);
+const size_t notLines_count = SK_ARRAY_COUNT(notLines);
static const double E = FLT_EPSILON * 2;
static const double F = FLT_EPSILON * 3;
{{{2, 2}, {4, 4}, {3, 3}, {1, 1+E}}},
};
-const size_t modEpsilonLines_count = sizeof(modEpsilonLines) / sizeof(modEpsilonLines[0]);
+const size_t modEpsilonLines_count = SK_ARRAY_COUNT(modEpsilonLines);
const SkDCubic lessEpsilonLines[] = {
{{{0, D}, {0, 0}, {0, 0}, {1, 0}}}, // horizontal
{{{2, 2}, {4, 4}, {3, 3}, {1, 1+D}}},
};
-const size_t lessEpsilonLines_count = sizeof(lessEpsilonLines) / sizeof(lessEpsilonLines[0]);
+const size_t lessEpsilonLines_count = SK_ARRAY_COUNT(lessEpsilonLines);
const SkDCubic negEpsilonLines[] = {
{{{0, N}, {0, 0}, {0, 0}, {1, 0}}}, // horizontal
{{{2, 2}, {4, 4}, {3, 3}, {1, 1+N}}},
};
-const size_t negEpsilonLines_count = sizeof(negEpsilonLines) / sizeof(negEpsilonLines[0]);
+const size_t negEpsilonLines_count = SK_ARRAY_COUNT(negEpsilonLines);
{{{{0, 0}, {0, 1}, {0, 1}, {1, 1}}}, {{{0, 1}, {1, 0}}}},
};
-static const size_t lineCubicTests_count = sizeof(lineCubicTests) / sizeof(lineCubicTests[0]);
+static const size_t lineCubicTests_count = SK_ARRAY_COUNT(lineCubicTests);
-static void CubicLineIntersectionTest(skiatest::Reporter* reporter) {
+static void PathOpsCubicLineIntersectionTest(skiatest::Reporter* reporter) {
for (size_t index = 0; index < lineCubicTests_count; ++index) {
int iIndex = static_cast<int>(index);
const SkDCubic& cubic = lineCubicTests[index].cubic;
}
#include "TestClassDef.h"
-DEFINE_TESTCLASS("PathOpsCubicLineIntersection", CubicLineIntersectionTestClass, \
- CubicLineIntersectionTest)
+DEFINE_TESTCLASS_SHORT(PathOpsCubicLineIntersectionTest)
}
}
-static void CubicReduceOrderTest(skiatest::Reporter* reporter) {
+static void PathOpsReduceOrderCubicTest(skiatest::Reporter* reporter) {
size_t index;
SkReduceOrder reducer;
int order;
}
#include "TestClassDef.h"
-DEFINE_TESTCLASS("PathOpsReduceOrderCubic", ReduceOrderCubicTestClass, CubicReduceOrderTest)
+DEFINE_TESTCLASS_SHORT(PathOpsReduceOrderCubicTest)
{1.4974754310666936, 68.069569937917208}, {45.261946574441133, 17.536076632112298}}},
};
-static size_t localsCount = sizeof(locals) / sizeof(locals[0]);
+static size_t localsCount = SK_ARRAY_COUNT(locals);
#define DEBUG_CRASH 0
#define TEST_AVERAGE_END_POINTS 0 // must take const off to test
oneOff(reporter, 0);
}
-static void TestCubicToQuads(skiatest::Reporter* reporter) {
+static void PathOpsCubicToQuadsTest(skiatest::Reporter* reporter) {
CubicToQuads_Test(reporter);
CubicsToQuadratics_OneOffTest(reporter);
CubicsToQuadratics_OneOffTests(reporter);
}
#include "TestClassDef.h"
-DEFINE_TESTCLASS("PathOpsCubicToQuads", PathOpsCubicToQuads, TestCubicToQuads)
+DEFINE_TESTCLASS_SHORT(PathOpsCubicToQuadsTest)
{{{3, 0}, {2, 1}, {3, 2}, {1, 1}}},
};
-static const size_t tests_count = sizeof(tests) / sizeof(tests[0]);
+static const size_t tests_count = SK_ARRAY_COUNT(tests);
-static void DCubicTest(skiatest::Reporter* reporter) {
+static void PathOpsDCubicTest(skiatest::Reporter* reporter) {
for (size_t index = 0; index < tests_count; ++index) {
const SkDCubic& cubic = tests[index];
bool result = cubic.clockwise();
}
#include "TestClassDef.h"
-DEFINE_TESTCLASS("PathOpsDCubic", PathOpsDCubic, DCubicTest)
+DEFINE_TESTCLASS_SHORT(PathOpsDCubicTest)
{2, 1}
};
-static const size_t tests_count = sizeof(tests) / sizeof(tests[0]);
+static const size_t tests_count = SK_ARRAY_COUNT(tests);
-static void DLineTest(skiatest::Reporter* reporter) {
+static void PathOpsLineUtilitiesTest(skiatest::Reporter* reporter) {
for (size_t index = 0; index < tests_count; ++index) {
const SkDLine& line = tests[index];
SkDLine line2;
}
#include "TestClassDef.h"
-DEFINE_TESTCLASS("PathOpsLineUtilities", PathOpsLineUtilitiesClass, DLineTest)
+DEFINE_TESTCLASS_SHORT(PathOpsLineUtilitiesTest)
{2, 2}
};
-static const size_t tests_count = sizeof(tests) / sizeof(tests[0]);
+static const size_t tests_count = SK_ARRAY_COUNT(tests);
-static void DPointTest(skiatest::Reporter* reporter) {
+static void PathOpsDPointTest(skiatest::Reporter* reporter) {
for (size_t index = 0; index < tests_count; ++index) {
const SkDPoint& pt = tests[index];
SkDPoint p = pt;
}
#include "TestClassDef.h"
-DEFINE_TESTCLASS("PathOpsDPoint", PathOpsDPointClass, DPointTest)
+DEFINE_TESTCLASS_SHORT(PathOpsDPointTest)
{1.1, 0.5},
};
-static const size_t tests_count = sizeof(tests) / sizeof(tests[0]);
+static const size_t tests_count = SK_ARRAY_COUNT(tests);
-static void DQuadTest(skiatest::Reporter* reporter) {
+static void PathOpsDQuadTest(skiatest::Reporter* reporter) {
for (size_t index = 0; index < tests_count; ++index) {
const SkDQuad& quad = tests[index];
bool result = quad.pointInHull(inPoint[index]);
}
#include "TestClassDef.h"
-DEFINE_TESTCLASS("PathOpsDQuad", PathOpsDQuadClass, DQuadTest)
+DEFINE_TESTCLASS_SHORT(PathOpsDQuadTest)
{{{3, 0}, {2, 1}, {3, 2}, {1, 1}}},
};
-static const size_t lineTests_count = sizeof(lineTests) / sizeof(lineTests[0]);
-static const size_t quadTests_count = sizeof(quadTests) / sizeof(quadTests[0]);
-static const size_t cubicTests_count = sizeof(cubicTests) / sizeof(cubicTests[0]);
+static const size_t lineTests_count = SK_ARRAY_COUNT(lineTests);
+static const size_t quadTests_count = SK_ARRAY_COUNT(quadTests);
+static const size_t cubicTests_count = SK_ARRAY_COUNT(cubicTests);
-static void DRectTest(skiatest::Reporter* reporter) {
+static void PathOpsDRectTest(skiatest::Reporter* reporter) {
size_t index;
SkDRect rect, rect2;
for (index = 0; index < lineTests_count; ++index) {
}
#include "TestClassDef.h"
-DEFINE_TESTCLASS("PathOpsDRect", PathOpsDRectClass, DRectTest)
+DEFINE_TESTCLASS_SHORT(PathOpsDRectTest)
{2.5, 2},
};
-static const size_t tests_count = sizeof(tests) / sizeof(tests[0]);
+static const size_t tests_count = SK_ARRAY_COUNT(tests);
-static void TriangleUtilitiesTest(skiatest::Reporter* reporter) {
+static void PathOpsTriangleUtilitiesTest(skiatest::Reporter* reporter) {
for (size_t index = 0; index < tests_count; ++index) {
const SkDTriangle& triangle = tests[index];
bool result = triangle.contains(inPoint[index]);
}
#include "TestClassDef.h"
-DEFINE_TESTCLASS("PathOpsTriangleUtilities", PathOpsTriangleUtilitiesClass, TriangleUtilitiesTest)
+DEFINE_TESTCLASS_SHORT(PathOpsTriangleUtilitiesTest)
{2, 2}
};
-static const size_t tests_count = sizeof(tests) / sizeof(tests[0]);
+static const size_t tests_count = SK_ARRAY_COUNT(tests);
-static void DVectorTest(skiatest::Reporter* reporter) {
+static void PathOpsDVectorTest(skiatest::Reporter* reporter) {
for (size_t index = 0; index < tests_count - 1; ++index) {
SkDVector v1 = tests[index + 1] - tests[index];
SkDVector v2 = tests[index] - tests[index + 1];
}
#include "TestClassDef.h"
-DEFINE_TESTCLASS("PathOpsDVector", PathOpsDVectorClass, DVectorTest)
+DEFINE_TESTCLASS_SHORT(PathOpsDVectorTest)
static void showPathOpPath(const SkPath& one, const SkPath& two, const SkPath& a, const SkPath& b,
const SkPath& scaledOne, const SkPath& scaledTwo, const SkPathOp shapeOp,
const SkMatrix& scale) {
- SkASSERT((unsigned) shapeOp < sizeof(opStrs) / sizeof(opStrs[0]));
+ SkASSERT((unsigned) shapeOp < SK_ARRAY_COUNT(opStrs));
showPath(a, "minuend:");
SkDebugf("op: %s\n", opStrs[shapeOp]);
showPath(b, "subtrahend:");
void outputProgress(char* ramStr, const char* pathStr, SkPathOp op) {
const char testFunction[] = "testOp(path);";
- SkASSERT(op < sizeof(opSuffixes) / sizeof(opSuffixes[0]));
+ SkASSERT((size_t) op < SK_ARRAY_COUNT(opSuffixes));
const char* nameSuffix = opSuffixes[op];
SkMemoryWStream rRamStream(ramStr, PATH_STR_SIZE);
outputToStream(pathStr, NULL, nameSuffix, testFunction, true, rRamStream);
{{{166.86960700313026, 112.6965477747386}, {166.86925794355412, 112.69656471103423}}}}
};
-static const size_t tests_count = sizeof(tests) / sizeof(tests[0]);
+static const size_t tests_count = SK_ARRAY_COUNT(tests);
static const SkDLine noIntersect[][2] = {
{{{{0, 0}, {1, 0}}}, {{{3, 0}, {2, 0}}}},
{{{{1, 1}, {2, 2}}}, {{{4, 4}, {3, 3}}}},
};
-static const size_t noIntersect_count = sizeof(noIntersect) / sizeof(noIntersect[0]);
+static const size_t noIntersect_count = SK_ARRAY_COUNT(noIntersect);
-static void TestLineIntersection(skiatest::Reporter* reporter) {
+static void PathOpsLineIntersectionTest(skiatest::Reporter* reporter) {
size_t index;
for (index = 0; index < tests_count; ++index) {
const SkDLine& line1 = tests[index][0];
}
#include "TestClassDef.h"
-DEFINE_TESTCLASS("PathOpsLineIntersection", LineIntersectionTestClass, TestLineIntersection)
+DEFINE_TESTCLASS_SHORT(PathOpsLineIntersectionTest)
{1.5894571940104115e-07, 7.9472859700520577e-08},
};
-static const size_t tests_count = sizeof(tests) / sizeof(tests[0]);
+static const size_t tests_count = SK_ARRAY_COUNT(tests);
-static void LineParameterTest(skiatest::Reporter* reporter) {
+static void PathOpsLineParametersTest(skiatest::Reporter* reporter) {
for (size_t index = 0; index < tests_count; ++index) {
SkLineParameters lineParameters;
const SkDCubic& cubic = tests[index];
}
#include "TestClassDef.h"
-DEFINE_TESTCLASS("PathOpsLineParameters", PathOpsLineParametersClass, LineParameterTest)
+DEFINE_TESTCLASS_SHORT(PathOpsLineParametersTest)
}
}
-static void TestOpCubicsThreaded(skiatest::Reporter* reporter)
+static void PathOpsOpCubicsThreadedTest(skiatest::Reporter* reporter)
{
int threadCount = initializeTests("cubicOp");
PathOpsThreadedTestRunner testRunner(reporter, threadCount);
}
#include "TestClassDef.h"
-DEFINE_TESTCLASS("PathOpsOpCubicsThreaded", OpCubicsThreadedTestClass, \
- TestOpCubicsThreaded)
+DEFINE_TESTCLASS_SHORT(PathOpsOpCubicsThreadedTest)
}
}
-static void TestPathOpsRectsThreaded(skiatest::Reporter* reporter) {
+static void PathOpsRectsThreadedTest(skiatest::Reporter* reporter) {
int threadCount = initializeTests("testOp");
PathOpsThreadedTestRunner testRunner(reporter, threadCount);
for (int a = 0; a < 6; ++a) { // outermost
}
#include "TestClassDef.h"
-DEFINE_TESTCLASS("PathOpsRectsThreaded", OpRectsThreadedTestClass, \
- TestPathOpsRectsThreaded)
+DEFINE_TESTCLASS_SHORT(PathOpsRectsThreadedTest)
TEST(cubicOp1d),
};
-static const size_t testCount = sizeof(tests) / sizeof(tests[0]);
+static const size_t testCount = SK_ARRAY_COUNT(tests);
static struct TestDesc subTests[] = {
TEST(cubicOp43d),
TEST(cubicOp40d),
};
-static const size_t subTestCount = sizeof(subTests) / sizeof(subTests[0]);
+static const size_t subTestCount = SK_ARRAY_COUNT(subTests);
static void (*firstSubTest)(skiatest::Reporter* ) = 0;
static bool runReverse = false;
static void (*stopTest)(skiatest::Reporter* ) = 0;
-static void OpTest(skiatest::Reporter* reporter) {
+static void PathOpsOpTest(skiatest::Reporter* reporter) {
#ifdef SK_DEBUG
gDebugMaxWindSum = 4;
gDebugMaxWindValue = 4;
}
#include "TestClassDef.h"
-DEFINE_TESTCLASS("PathOpsOpTest", PathOpsOpClass, OpTest)
+DEFINE_TESTCLASS_SHORT(PathOpsOpTest)
{{{8, 8}, {9, 9}, {10, 8}}}
};
-const size_t testSetCount = sizeof(testSet) / sizeof(testSet[0]);
+const size_t testSetCount = SK_ARRAY_COUNT(testSet);
static void oneOffTest1(skiatest::Reporter* reporter, size_t outer, size_t inner) {
const SkDQuad& quad1 = testSet[outer];
{{{8, -10}, {10, 10}, {8, 8}}},
};
-const size_t coincidentTestSetCount = sizeof(coincidentTestSet) / sizeof(coincidentTestSet[0]);
+const size_t coincidentTestSetCount = SK_ARRAY_COUNT(coincidentTestSet);
static void coincidentTest(skiatest::Reporter* reporter) {
for (size_t testIndex = 0; testIndex < coincidentTestSetCount - 1; testIndex += 2) {
intersectionFinder(0, 1);
}
-static void TestQuadIntersection(skiatest::Reporter* reporter) {
+static void PathOpsQuadIntersectionTest(skiatest::Reporter* reporter) {
oneOffTests(reporter);
coincidentTest(reporter);
standardTestCases(reporter);
#include "TestClassDef.h"
-DEFINE_TESTCLASS("PathOpsQuadIntersection", QuadIntersectionTestClass, TestQuadIntersection)
+DEFINE_TESTCLASS_SHORT(PathOpsQuadIntersectionTest)
{{{1, 1}, {2, 2}, {1, 1}}},
};
-const size_t quadraticPoints_count = sizeof(quadraticPoints) / sizeof(quadraticPoints[0]);
+const size_t quadraticPoints_count = SK_ARRAY_COUNT(quadraticPoints);
const SkDQuad quadraticLines[] = {
{{{0, 0}, {0, 0}, {1, 0}}},
{{{2, 2}, {4, 4}, {3, 3}}},
};
-const size_t quadraticLines_count = sizeof(quadraticLines) / sizeof(quadraticLines[0]);
+const size_t quadraticLines_count = SK_ARRAY_COUNT(quadraticLines);
static const double F = FLT_EPSILON * 3;
static const double H = FLT_EPSILON * 4;
};
const size_t quadraticModEpsilonLines_count =
- sizeof(quadraticModEpsilonLines) / sizeof(quadraticModEpsilonLines[0]);
+ SK_ARRAY_COUNT(quadraticModEpsilonLines);
const SkDQuad quadraticTests[][2] = {
{ // one intersection
}
};
-const size_t quadraticTests_count = sizeof(quadraticTests) / sizeof(quadraticTests[0]);
+const size_t quadraticTests_count = SK_ARRAY_COUNT(quadraticTests);
{{{{0, 0}, {0, 1}, {1, 1}}}, {{{0, 1}, {1, 0}}}, 1, {{.25, .75}, {0, 0}} },
};
-static size_t lineQuadTests_count = sizeof(lineQuadTests) / sizeof(lineQuadTests[0]);
+static size_t lineQuadTests_count = SK_ARRAY_COUNT(lineQuadTests);
static int doIntersect(SkIntersections& intersections, const SkDQuad& quad, const SkDLine& line,
bool& flipped) {
{{{406.207703, 121.298294}, {348.781738, 123.864815}}}}
};
-static size_t oneOffs_count = sizeof(oneOffs) / sizeof(oneOffs[0]);
+static size_t oneOffs_count = SK_ARRAY_COUNT(oneOffs);
static void testOneOffs(skiatest::Reporter* reporter) {
SkIntersections intersections;
}
}
-static void TestQuadLineIntersection(skiatest::Reporter* reporter) {
+static void PathOpsQuadLineIntersectionTest(skiatest::Reporter* reporter) {
testOneOffs(reporter);
for (size_t index = 0; index < lineQuadTests_count; ++index) {
int iIndex = static_cast<int>(index);
}
#include "TestClassDef.h"
-DEFINE_TESTCLASS("PathOpsQuadLineIntersection", QuadLineIntersectionTestClass, \
- TestQuadLineIntersection)
+DEFINE_TESTCLASS_SHORT(PathOpsQuadLineIntersectionTest)
}
}
-static void TestQuadLineIntersectionThreaded(skiatest::Reporter* reporter)
+static void PathOpsQuadLineIntersectionThreadedTest(skiatest::Reporter* reporter)
{
int threadCount = initializeTests("testQuadLineIntersect");
PathOpsThreadedTestRunner testRunner(reporter, threadCount);
}
#include "TestClassDef.h"
-DEFINE_TESTCLASS("PathOpsQuadLineIntersectionThreaded", QuadLineIntersectionThreadedTestClass, \
- TestQuadLineIntersectionThreaded)
+DEFINE_TESTCLASS_SHORT(PathOpsQuadLineIntersectionThreadedTest)
{{{0, 0}, {1, 0}, {1, 1}}},
};
-static const size_t quadratics_count = sizeof(quadratics) / sizeof(quadratics[0]);
+static const size_t quadratics_count = SK_ARRAY_COUNT(quadratics);
-static void TestQuadraticCoincidence(skiatest::Reporter* reporter) {
+static void PathOpsQuadImplicitTest(skiatest::Reporter* reporter) {
// split large quadratic
// compare original, parts, to see if the are coincident
for (size_t index = 0; index < quadratics_count; ++index) {
const SkDQuad* quads[] = {
&test, &midThird, &split.first(), &split.second()
};
- size_t quadsCount = sizeof(quads) / sizeof(quads[0]);
+ size_t quadsCount = SK_ARRAY_COUNT(quads);
for (size_t one = 0; one < quadsCount; ++one) {
for (size_t two = 0; two < quadsCount; ++two) {
for (size_t inner = 0; inner < 3; inner += 2) {
}
#include "TestClassDef.h"
-DEFINE_TESTCLASS("PathOpsQuadImplicit", QuadImplicitTestClass, TestQuadraticCoincidence)
+DEFINE_TESTCLASS_SHORT(PathOpsQuadImplicitTest)
{{{1, 0}, {2, 6}, {3, 0}}}
};
-static const size_t testSetCount = sizeof(testSet) / sizeof(testSet[0]);
+static const size_t testSetCount = SK_ARRAY_COUNT(testSet);
static void oneOffTest(skiatest::Reporter* reporter) {
for (size_t index = 0; index < testSetCount; ++index) {
}
}
-static void QuadReduceOrderTest(skiatest::Reporter* reporter) {
+static void PathOpsReduceOrderQuadTest(skiatest::Reporter* reporter) {
oneOffTest(reporter);
standardTestCases(reporter);
}
#include "TestClassDef.h"
-DEFINE_TESTCLASS("PathOpsReduceOrderQuad", ReduceOrderQuadTestClass, QuadReduceOrderTest)
+DEFINE_TESTCLASS_SHORT(PathOpsReduceOrderQuadTest)
}
}
-static void TestSimplifyDegeneratesThreaded(skiatest::Reporter* reporter) {
+static void PathOpsSimplifyDegeneratesThreadedTest(skiatest::Reporter* reporter) {
int threadCount = initializeTests("testDegenerates");
PathOpsThreadedTestRunner testRunner(reporter, threadCount);
for (int a = 0; a < 16; ++a) {
}
#include "TestClassDef.h"
-DEFINE_TESTCLASS("PathOpsSimplifyDegeneratesThreaded", SimplifyDegeneratesThreadedTestClass, \
- TestSimplifyDegeneratesThreaded)
+DEFINE_TESTCLASS_SHORT(PathOpsSimplifyDegeneratesThreadedTest)
}
}
-static void TestSimplifyQuadsThreaded(skiatest::Reporter* reporter)
+static void PathOpsSimplifyQuadsThreadedTest(skiatest::Reporter* reporter)
{
int threadCount = initializeTests("testQuads");
PathOpsThreadedTestRunner testRunner(reporter, threadCount);
}
#include "TestClassDef.h"
-DEFINE_TESTCLASS("PathOpsSimplifyQuadsThreaded", SimplifyQuadsThreadedTestClass, \
- TestSimplifyQuadsThreaded)
+DEFINE_TESTCLASS_SHORT(PathOpsSimplifyQuadsThreadedTest)
}
}
-static void TestSimplifyQuadralateralsThreaded(skiatest::Reporter* reporter)
-{
+static void PathOpsSimplifyQuadralateralsThreadedTest(skiatest::Reporter* reporter) {
int threadCount = initializeTests("testQuadralaterals");
PathOpsThreadedTestRunner testRunner(reporter, threadCount);
for (int a = 0; a < 16; ++a) {
}
#include "TestClassDef.h"
-DEFINE_TESTCLASS("SimplifyQuadralateralsThreaded", SimplifyQuadralateralsThreadedTestClass, \
- TestSimplifyQuadralateralsThreaded)
+DEFINE_TESTCLASS_SHORT(PathOpsSimplifyQuadralateralsThreadedTest)
}
}
-static void TestSimplifyRectsThreaded(skiatest::Reporter* reporter)
+static void PathOpsSimplifyRectsThreadedTest(skiatest::Reporter* reporter)
{
int threadCount = initializeTests("testLine");
PathOpsThreadedTestRunner testRunner(reporter, threadCount);
}
#include "TestClassDef.h"
-DEFINE_TESTCLASS("PathOpsSimplifyRectsThreaded",SimplifyRectsThreadedTestClass, \
- TestSimplifyRectsThreaded)
+DEFINE_TESTCLASS_SHORT(PathOpsSimplifyRectsThreadedTest)
testSimplify(reporter, path);
}
+static void testQuadratic94(skiatest::Reporter* reporter) {
+ SkPath path;
+ path.moveTo(0, 0);
+ path.lineTo(8, 8);
+ path.quadTo(8, 4, 4, 4);
+ path.quadTo(4, 0, 0, 0);
+ path.close();
+ testSimplify(reporter, path);
+}
+
+static void testQuadratic95(skiatest::Reporter* reporter) {
+ SkPath path;
+ path.moveTo(8, 8);
+ path.lineTo(0, 0);
+ path.quadTo(4, 0, 4, 4);
+ path.quadTo(8, 4, 8, 8);
+ path.close();
+ testSimplify(reporter, path);
+}
+
+static void testQuadratic96(skiatest::Reporter* reporter) {
+ SkPath path;
+ path.moveTo(8, 0);
+ path.lineTo(0, 8);
+ path.quadTo(0, 4, 4, 4);
+ path.quadTo(4, 0, 8, 0);
+ path.close();
+ testSimplify(reporter, path);
+}
+
+static void testQuadratic97(skiatest::Reporter* reporter) {
+ SkPath path;
+ path.moveTo(0, 8);
+ path.lineTo(8, 0);
+ path.quadTo(4, 0, 4, 4);
+ path.quadTo(0, 4, 0, 8);
+ path.close();
+ testSimplify(reporter, path);
+}
+
static void (*firstTest)(skiatest::Reporter* ) = 0;
static TestDesc tests[] = {
+ TEST(testQuadratic97),
+ TEST(testQuadratic96),
+ TEST(testQuadratic95),
+ TEST(testQuadratic94),
TEST(testQuadralateral2),
TEST(testQuad1), // FIXME: fails, need to investigate
TEST(testCubic2),
TEST(testLine1),
};
-static const size_t testCount = sizeof(tests) / sizeof(tests[0]);
+static const size_t testCount = SK_ARRAY_COUNT(tests);
static TestDesc subTests[] = {
TEST(testLine3),
TEST(testLine1),
};
-static const size_t subTestCount = sizeof(subTests) / sizeof(subTests[0]);
+static const size_t subTestCount = SK_ARRAY_COUNT(subTests);
static void (*firstSubTest)(skiatest::Reporter* ) = 0;
static bool runReverse = false;
static void (*stopTest)(skiatest::Reporter* ) = 0;
-static void SimplifyTest(skiatest::Reporter* reporter) {
+static void PathOpsSimplifyTest(skiatest::Reporter* reporter) {
#ifdef SK_DEBUG
gDebugMaxWindSum = 4;
gDebugMaxWindValue = 4;
}
#include "TestClassDef.h"
-DEFINE_TESTCLASS("PathOpsSimplifyTest", PathOpsSimplifyClass, SimplifyTest)
+DEFINE_TESTCLASS_SHORT(PathOpsSimplifyTest)
}
}
-static void TestSimplifyTrianglesThreaded(skiatest::Reporter* reporter) {
+static void PathOpsSimplifyTrianglesThreadedTest(skiatest::Reporter* reporter) {
int threadCount = initializeTests("testTriangles");
PathOpsThreadedTestRunner testRunner(reporter, threadCount);
for (int a = 0; a < 15; ++a) {
}
#include "TestClassDef.h"
-DEFINE_TESTCLASS("SimplifyTrianglesThreaded", SimplifyTrianglesThreadedTestClass, \
- TestSimplifyTrianglesThreaded)
+DEFINE_TESTCLASS_SHORT(PathOpsSimplifyTrianglesThreadedTest)
void MyTestFunction(skiatest::Reporter*)
*/
+// FIXME: replace all three param callers with the short one param version
+#define DEFINE_TESTCLASS_SHORT(function) \
+ namespace skiatest { \
+ class function##Class : public Test { \
+ public: \
+ static Test* Factory(void*) { return SkNEW(function##Class); } \
+ protected: \
+ virtual void onGetName(SkString* name) SK_OVERRIDE { name->set(#function); } \
+ virtual void onRun(Reporter* reporter) SK_OVERRIDE { function(reporter); } \
+ }; \
+ static TestRegistry gReg_##function##Class(function##Class::Factory); \
+ }
+
#define DEFINE_TESTCLASS(uiname, classname, function) \
namespace skiatest { \
class classname : public Test { \