staticint check_linear(const SkDQuad& quad, int minX, int maxX, int minY, int maxY, SkDQuad& reduction) { if (!quad.isLinear(0, 2)) { return0;
} // four are colinear: return line formed by outside
reduction[0] = quad[0];
reduction[1] = quad[2]; return reductionLineCount(reduction);
}
// reduce to a quadratic or smaller // look for identical points // look for all four points in a line // note that three points in a line doesn't simplify a cubic // look for approximation with single quadratic // save approximation with multiple quadratics for later int SkReduceOrder::reduce(const SkDQuad& quad) { int index, minX, maxX, minY, maxY; int minXSet, minYSet;
minX = maxX = minY = maxY = 0;
minXSet = minYSet = 0; for (index = 1; index < 3; ++index) { if (quad[minX].fX > quad[index].fX) {
minX = index;
} if (quad[minY].fY > quad[index].fY) {
minY = index;
} if (quad[maxX].fX < quad[index].fX) {
maxX = index;
} if (quad[maxY].fY < quad[index].fY) {
maxY = index;
}
} for (index = 0; index < 3; ++index) { if (AlmostEqualUlps(quad[index].fX, quad[minX].fX)) {
minXSet |= 1 << index;
} if (AlmostEqualUlps(quad[index].fY, quad[minY].fY)) {
minYSet |= 1 << index;
}
} if ((minXSet & 0x05) == 0x5 && (minYSet & 0x05) == 0x5) { // test for degenerate // this quad starts and ends at the same place, so never contributes // to the fill return coincident_line(quad, fQuad);
} if (minXSet == 0x7) { // test for vertical line return vertical_line(quad, fQuad);
} if (minYSet == 0x7) { // test for horizontal line return horizontal_line(quad, fQuad);
} int result = check_linear(quad, minX, maxX, minY, maxY, fQuad); if (result) { return result;
}
fQuad = quad; return3;
}
staticint check_linear(const SkDCubic& cubic, int minX, int maxX, int minY, int maxY, SkDCubic& reduction) { if (!cubic.isLinear(0, 3)) { return0;
} // four are colinear: return line formed by outside
reduction[0] = cubic[0];
reduction[1] = cubic[3]; return reductionLineCount(reduction);
}
/* food for thought: http://objectmix.com/graphics/132906-fast-precision-driven-cubic-quadratic-piecewise-degree-reduction-algos-2-a.html
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.