2013-04-08 20:37:35 +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.
|
|
|
|
*/
|
2019-04-23 17:05:21 +00:00
|
|
|
#include "src/pathops/SkIntersections.h"
|
|
|
|
#include "src/pathops/SkPathOpsRect.h"
|
|
|
|
#include "src/pathops/SkReduceOrder.h"
|
|
|
|
#include "tests/PathOpsQuadIntersectionTestData.h"
|
|
|
|
#include "tests/Test.h"
|
2013-04-08 20:37:35 +00:00
|
|
|
|
2016-10-20 15:32:18 +00:00
|
|
|
static const QuadPts testSet[] = {
|
2013-04-08 20:37:35 +00:00
|
|
|
{{{1, 1}, {2, 2}, {1, 1.000003}}},
|
|
|
|
{{{1, 0}, {2, 6}, {3, 0}}}
|
|
|
|
};
|
|
|
|
|
2013-04-15 19:13:59 +00:00
|
|
|
static const size_t testSetCount = SK_ARRAY_COUNT(testSet);
|
2013-04-08 20:37:35 +00:00
|
|
|
|
|
|
|
static void oneOffTest(skiatest::Reporter* reporter) {
|
|
|
|
for (size_t index = 0; index < testSetCount; ++index) {
|
2016-10-20 15:32:18 +00:00
|
|
|
const QuadPts& q = testSet[index];
|
|
|
|
SkDQuad quad;
|
|
|
|
quad.debugSet(q.fPts);
|
2013-04-08 20:37:35 +00:00
|
|
|
SkReduceOrder reducer;
|
2013-11-25 14:18:21 +00:00
|
|
|
SkDEBUGCODE(int result = ) reducer.reduce(quad);
|
2013-04-08 20:37:35 +00:00
|
|
|
SkASSERT(result == 3);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void standardTestCases(skiatest::Reporter* reporter) {
|
|
|
|
size_t index;
|
|
|
|
SkReduceOrder reducer;
|
|
|
|
int order;
|
|
|
|
enum {
|
|
|
|
RunAll,
|
|
|
|
RunQuadraticLines,
|
|
|
|
RunQuadraticModLines,
|
|
|
|
RunNone
|
|
|
|
} run = RunAll;
|
|
|
|
int firstTestIndex = 0;
|
|
|
|
#if 0
|
|
|
|
run = RunQuadraticLines;
|
|
|
|
firstTestIndex = 1;
|
|
|
|
#endif
|
|
|
|
int firstQuadraticLineTest = run == RunAll ? 0 : run == RunQuadraticLines ? firstTestIndex
|
|
|
|
: SK_MaxS32;
|
|
|
|
int firstQuadraticModLineTest = run == RunAll ? 0 : run == RunQuadraticModLines ? firstTestIndex
|
|
|
|
: SK_MaxS32;
|
|
|
|
|
|
|
|
for (index = firstQuadraticLineTest; index < quadraticLines_count; ++index) {
|
2016-10-20 15:32:18 +00:00
|
|
|
const QuadPts& q = quadraticLines[index];
|
|
|
|
SkDQuad quad;
|
|
|
|
quad.debugSet(q.fPts);
|
2013-11-25 14:18:21 +00:00
|
|
|
order = reducer.reduce(quad);
|
2013-04-08 20:37:35 +00:00
|
|
|
if (order != 2) {
|
2013-10-11 18:50:45 +00:00
|
|
|
SkDebugf("[%d] line quad order=%d\n", (int) index, order);
|
2013-04-08 20:37:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
for (index = firstQuadraticModLineTest; index < quadraticModEpsilonLines_count; ++index) {
|
2016-10-20 15:32:18 +00:00
|
|
|
const QuadPts& q = quadraticModEpsilonLines[index];
|
|
|
|
SkDQuad quad;
|
|
|
|
quad.debugSet(q.fPts);
|
2013-11-25 14:18:21 +00:00
|
|
|
order = reducer.reduce(quad);
|
2014-11-13 14:58:52 +00:00
|
|
|
if (order != 2 && order != 3) { // FIXME: data probably is not good
|
2013-10-11 18:50:45 +00:00
|
|
|
SkDebugf("[%d] line mod quad order=%d\n", (int) index, order);
|
2013-04-08 20:37:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-01-02 21:45:03 +00:00
|
|
|
DEF_TEST(PathOpsReduceOrderQuad, reporter) {
|
2013-04-08 20:37:35 +00:00
|
|
|
oneOffTest(reporter);
|
|
|
|
standardTestCases(reporter);
|
|
|
|
}
|