2012-08-27 14:11:33 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2012 Google Inc.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
|
|
|
*/
|
2012-02-03 22:07:47 +00:00
|
|
|
#include "CurveIntersection.h"
|
2012-01-25 18:57:23 +00:00
|
|
|
#include "Intersection_Tests.h"
|
|
|
|
#include "QuadraticIntersection_TestData.h"
|
|
|
|
#include "TestUtilities.h"
|
|
|
|
|
2012-05-18 20:50:33 +00:00
|
|
|
static const Quadratic testSet[] = {
|
|
|
|
{{1, 1}, {2, 2}, {1, 1.000003}},
|
|
|
|
{{1, 0}, {2, 6}, {3, 0}}
|
|
|
|
};
|
|
|
|
|
|
|
|
static const size_t testSetCount = sizeof(testSet) / sizeof(testSet[0]);
|
|
|
|
|
|
|
|
|
|
|
|
static void oneOffTest() {
|
|
|
|
SkDebugf("%s FLT_EPSILON=%1.9g\n", __FUNCTION__, FLT_EPSILON);
|
2012-06-01 18:20:10 +00:00
|
|
|
for (size_t index = 0; index < testSetCount; ++index) {
|
2012-05-18 20:50:33 +00:00
|
|
|
const Quadratic& quad = testSet[index];
|
|
|
|
Quadratic reduce;
|
2013-03-13 20:29:41 +00:00
|
|
|
SkDEBUGCODE(int result = ) reduceOrder(quad, reduce, kReduceOrder_TreatAsFill);
|
|
|
|
SkASSERT(result == 3);
|
2012-05-18 20:50:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void standardTestCases() {
|
2012-01-25 18:57:23 +00:00
|
|
|
size_t index;
|
|
|
|
Quadratic reduce;
|
|
|
|
int order;
|
|
|
|
enum {
|
|
|
|
RunAll,
|
|
|
|
RunQuadraticLines,
|
|
|
|
RunQuadraticModLines,
|
|
|
|
RunNone
|
|
|
|
} run = RunAll;
|
|
|
|
int firstTestIndex = 0;
|
|
|
|
#if 0
|
|
|
|
run = RunQuadraticLines;
|
|
|
|
firstTestIndex = 1;
|
|
|
|
#endif
|
2013-01-29 20:28:49 +00:00
|
|
|
int firstQuadraticLineTest = run == RunAll ? 0 : run == RunQuadraticLines ? firstTestIndex : SK_MaxS32;
|
|
|
|
int firstQuadraticModLineTest = run == RunAll ? 0 : run == RunQuadraticModLines ? firstTestIndex : SK_MaxS32;
|
2012-01-25 18:57:23 +00:00
|
|
|
|
|
|
|
for (index = firstQuadraticLineTest; index < quadraticLines_count; ++index) {
|
|
|
|
const Quadratic& quad = quadraticLines[index];
|
2013-02-17 01:41:25 +00:00
|
|
|
order = reduceOrder(quad, reduce, kReduceOrder_TreatAsFill);
|
2012-01-25 18:57:23 +00:00
|
|
|
if (order != 2) {
|
|
|
|
printf("[%d] line quad order=%d\n", (int) index, order);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for (index = firstQuadraticModLineTest; index < quadraticModEpsilonLines_count; ++index) {
|
|
|
|
const Quadratic& quad = quadraticModEpsilonLines[index];
|
2013-02-17 01:41:25 +00:00
|
|
|
order = reduceOrder(quad, reduce, kReduceOrder_TreatAsFill);
|
2012-01-25 18:57:23 +00:00
|
|
|
if (order != 3) {
|
|
|
|
printf("[%d] line mod quad order=%d\n", (int) index, order);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-05-18 20:50:33 +00:00
|
|
|
|
|
|
|
void QuadraticReduceOrder_Test() {
|
|
|
|
oneOffTest();
|
|
|
|
standardTestCases();
|
|
|
|
}
|