Lines Matching defs:cubic
52 // note that three points in a line doesn't simplify a cubic
103 static int coincident_line(const SkDCubic& cubic, SkDCubic& reduction) {
104 reduction[0] = reduction[1] = cubic[0];
112 static int vertical_line(const SkDCubic& cubic, SkDCubic& reduction) {
113 reduction[0] = cubic[0];
114 reduction[1] = cubic[3];
118 static int horizontal_line(const SkDCubic& cubic, SkDCubic& reduction) {
119 reduction[0] = cubic[0];
120 reduction[1] = cubic[3];
125 static int check_quadratic(const SkDCubic& cubic, SkDCubic& reduction) {
126 double dx10 = cubic[1].fX - cubic[0].fX;
127 double dx23 = cubic[2].fX - cubic[3].fX;
128 double midX = cubic[0].fX + dx10 * 3 / 2;
129 double sideAx = midX - cubic[3].fX;
135 double dy10 = cubic[1].fY - cubic[0].fY;
136 double dy23 = cubic[2].fY - cubic[3].fY;
137 double midY = cubic[0].fY + dy10 * 3 / 2;
138 double sideAy = midY - cubic[3].fY;
144 reduction[0] = cubic[0];
147 reduction[2] = cubic[3];
151 static int check_linear(const SkDCubic& cubic,
153 if (!cubic.isLinear(0, 3)) {
157 reduction[0] = cubic[0];
158 reduction[1] = cubic[3];
163 http://objectmix.com/graphics/132906-fast-precision-driven-cubic-quadratic-piecewise-degree-reduction-algos-2-a.html
165 Given points c1, c2, c3 and c4 of a cubic Bezier, the points of the
185 // note that three points in a line doesn't simplify a cubic
188 int SkReduceOrder::reduce(const SkDCubic& cubic, Quadratics allowQuadratics) {
194 if (cubic[minX].fX > cubic[index].fX) {
197 if (cubic[minY].fY > cubic[index].fY) {
200 if (cubic[maxX].fX < cubic[index].fX) {
203 if (cubic[maxY].fY < cubic[index].fY) {
208 double cx = cubic[index].fX;
209 double cy = cubic[index].fY;
211 std::max(fabs(cubic[minX].fX), fabs(cubic[minY].fY))));
218 if (approximately_equal_half(cx * inv, cubic[minX].fX * inv)) {
221 if (approximately_equal_half(cy * inv, cubic[minY].fY * inv)) {
227 return coincident_line(cubic, fCubic);
229 return vertical_line(cubic, fCubic);
232 return horizontal_line(cubic, fCubic);
234 int result = check_linear(cubic, minX, maxX, minY, maxY, fCubic);
239 && (result = check_quadratic(cubic, fCubic))) {
242 fCubic = cubic;
273 SkDCubic cubic;
274 cubic.set(a);
276 int order = reducer.reduce(cubic, kAllow_Quadratics);
277 if (order == 2 || order == 3) { // cubic became line or quad