23static bool controls_inside(
const SkDCubic& cubic) {
24 return between(cubic[0].fX, cubic[1].fX, cubic[3].fX)
25 &&
between(cubic[0].fX, cubic[2].fX, cubic[3].fX)
26 &&
between(cubic[0].fY, cubic[1].fY, cubic[3].fY)
27 &&
between(cubic[0].fY, cubic[2].fY, cubic[3].fY);
30static bool tiny(
const SkDCubic& cubic) {
31 int index, minX, maxX, minY, maxY;
32 minX = maxX = minY = maxY = 0;
33 for (index = 1; index < 4; ++index) {
34 if (cubic[minX].fX > cubic[index].fX) {
37 if (cubic[minY].fY > cubic[index].fY) {
40 if (cubic[maxX].fX < cubic[index].fX) {
43 if (cubic[maxY].fY < cubic[index].fY) {
53 if (!tiny(cubicPair.
first()) && !controls_inside(cubicPair.
first())) {
54 find_tight_bounds(cubicPair.
first(), bounds);
59 if (!tiny(cubicPair.
second()) && !controls_inside(cubicPair.
second())) {
60 find_tight_bounds(cubicPair.
second(), bounds);
75 RunNotPointDegenerates,
87 int firstTestIndex = 0;
89 run = RunComputedLines;
92 int firstPointDegeneratesTest =
run == RunAll ? 0 :
run == RunPointDegenerates
94 int firstNotPointDegeneratesTest =
run == RunAll ? 0 :
run == RunNotPointDegenerates
96 int firstLinesTest =
run == RunAll ? 0 :
run == RunLines ? firstTestIndex :
SK_MaxS32;
97 int firstNotLinesTest =
run == RunAll ? 0 :
run == RunNotLines ? firstTestIndex :
SK_MaxS32;
98 int firstModEpsilonTest =
run == RunAll ? 0 :
run == RunModEpsilonLines
100 int firstLessEpsilonTest =
run == RunAll ? 0 :
run == RunLessEpsilonLines
102 int firstNegEpsilonTest =
run == RunAll ? 0 :
run == RunNegEpsilonLines
104 int firstQuadraticPointTest =
run == RunAll ? 0 :
run == RunQuadraticPoints
106 int firstQuadraticLineTest =
run == RunAll ? 0 :
run == RunQuadraticLines
108 int firstQuadraticModLineTest =
run == RunAll ? 0 :
run == RunQuadraticModLines
111 int firstComputedLinesTest =
run == RunAll ? 0 :
run == RunComputedLines
117 cubic.debugSet(c.
fPts);
121 SkDebugf(
"[%d] pointDegenerates order=%d\n",
static_cast<int>(index), order);
128 cubic.debugSet(c.
fPts);
132 SkDebugf(
"[%d] notPointDegenerates order=%d\n",
static_cast<int>(index), order);
137 for (index = firstLinesTest; index <
lines_count; ++index) {
140 cubic.debugSet(c.
fPts);
144 SkDebugf(
"[%d] lines order=%d\n",
static_cast<int>(index), order);
148 for (index = firstNotLinesTest; index <
notLines_count; ++index) {
151 cubic.debugSet(c.
fPts);
155 SkDebugf(
"[%d] notLines order=%d\n",
static_cast<int>(index), order);
162 cubic.debugSet(c.
fPts);
166 SkDebugf(
"[%d] line mod by epsilon order=%d\n",
static_cast<int>(index), order);
173 cubic.debugSet(c.
fPts);
177 SkDebugf(
"[%d] line less by epsilon/2 order=%d\n",
static_cast<int>(index), order);
185 cubic.debugSet(c.
fPts);
189 SkDebugf(
"[%d] line neg by epsilon/2 order=%d\n",
static_cast<int>(index), order);
201 SkDebugf(
"[%d] point quad order=%d\n",
static_cast<int>(index), order);
213 SkDebugf(
"[%d] line quad order=%d\n",
static_cast<int>(index), order);
225 SkDebugf(
"[%d] line mod quad order=%d\n",
static_cast<int>(index), order);
232 for (index = firstComputedLinesTest; index <
lines_count; ++index) {
235 bool controlsInside = controls_inside(cubic);
237 SkReduceOrder::kStroke_Style);
238 if (order == 2 && reducer.
fLine[0] == reducer.
fLine[1]) {
239 SkDebugf(
"[%d] line computed ends match order=%d\n",
static_cast<int>(index), order);
242 if (controlsInside) {
243 if ( (reducer.
fLine[0].fX != cubic[0].fX && reducer.
fLine[0].fX != cubic[3].fX)
244 || (reducer.
fLine[0].fY != cubic[0].fY && reducer.
fLine[0].fY != cubic[3].fY)
245 || (reducer.
fLine[1].fX != cubic[0].fX && reducer.
fLine[1].fX != cubic[3].fX)
246 || (reducer.
fLine[1].fY != cubic[0].fY && reducer.
fLine[1].fY != cubic[3].fY)) {
247 SkDebugf(
"[%d] line computed ends order=%d\n",
static_cast<int>(index), order);
253 SkDRect bounds = {DBL_MAX, DBL_MAX, -DBL_MAX, -DBL_MAX};
254 find_tight_bounds(cubic, bounds);
263 SkDebugf(
"[%d] line computed tight bounds order=%d\n",
static_cast<int>(index), order);
const size_t quadraticLines_count
const QuadPts quadraticModEpsilonLines[]
const size_t quadraticPoints_count
const size_t quadraticModEpsilonLines_count
const QuadPts quadraticPoints[]
const QuadPts quadraticLines[]
bool ValidCubic(const SkDCubic &cubic)
bool ValidQuad(const SkDQuad &quad)
void SK_SPI SkDebugf(const char format[],...) SK_PRINTF_LIKE(1
static bool between(SkScalar a, SkScalar b, SkScalar c)
static constexpr int32_t SK_MaxS32
bool AlmostEqualUlps(const SkPoint &pt1, const SkPoint &pt2)
bool approximately_equal(double x, double y)
#define DEF_TEST(name, reporter)
#define REPORTER_ASSERT(r, cond,...)
const CubicPts negEpsilonLines[]
const size_t modEpsilonLines_count
const CubicPts lessEpsilonLines[]
const size_t notPointDegenerates_count
const CubicPts notPointDegenerates[]
const size_t lessEpsilonLines_count
const size_t negEpsilonLines_count
const CubicPts pointDegenerates[]
const CubicPts notLines[]
const CubicPts modEpsilonLines[]
const size_t notLines_count
const size_t pointDegenerates_count
Optional< SkRect > bounds
SkDPoint fPts[kPointCount]
SkDPoint fPts[kPointCount]
void debugSet(const SkDPoint *pts)
SkDCubic debugToCubic() const
int reduce(const SkDCubic &cubic, Quadratics)