Lines Matching refs:Cubic
51 // note that three points in a line doesn't simplify a cubic
100 static int coincident_line(const SkDCubic& cubic, SkDCubic& reduction) {
101 reduction[0] = reduction[1] = cubic[0];
109 static int vertical_line(const SkDCubic& cubic, SkDCubic& reduction) {
110 reduction[0] = cubic[0];
111 reduction[1] = cubic[3];
115 static int horizontal_line(const SkDCubic& cubic, SkDCubic& reduction) {
116 reduction[0] = cubic[0];
117 reduction[1] = cubic[3];
122 static int check_quadratic(const SkDCubic& cubic, SkDCubic& reduction) {
123 double dx10 = cubic[1].fX - cubic[0].fX;
124 double dx23 = cubic[2].fX - cubic[3].fX;
125 double midX = cubic[0].fX + dx10 * 3 / 2;
126 double sideAx = midX - cubic[3].fX;
132 double dy10 = cubic[1].fY - cubic[0].fY;
133 double dy23 = cubic[2].fY - cubic[3].fY;
134 double midY = cubic[0].fY + dy10 * 3 / 2;
135 double sideAy = midY - cubic[3].fY;
141 reduction[0] = cubic[0];
144 reduction[2] = cubic[3];
148 static int check_linear(const SkDCubic& cubic,
150 if (!cubic.isLinear(0, 3)) {
154 reduction[0] = cubic[0];
155 reduction[1] = cubic[3];
160 http://objectmix.com/graphics/132906-fast-precision-driven-cubic-quadratic-piecewise-degree-reduction-algos-2-a.html
162 Given points c1, c2, c3 and c4 of a cubic Bezier, the points of the
182 // note that three points in a line doesn't simplify a cubic
185 int SkReduceOrder::reduce(const SkDCubic& cubic, Quadratics allowQuadratics) {
191 if (cubic[minX].fX > cubic[index].fX) {
194 if (cubic[minY].fY > cubic[index].fY) {
197 if (cubic[maxX].fX < cubic[index].fX) {
200 if (cubic[maxY].fY < cubic[index].fY) {
205 double cx = cubic[index].fX;
206 double cy = cubic[index].fY;
208 SkTMax(fabs(cubic[minX].fX), fabs(cubic[minY].fY))));
215 if (approximately_equal_half(cx * inv, cubic[minX].fX * inv)) {
218 if (approximately_equal_half(cy * inv, cubic[minY].fY * inv)) {
224 return coincident_line(cubic, fCubic);
226 return vertical_line(cubic, fCubic);
229 return horizontal_line(cubic, fCubic);
231 int result = check_linear(cubic, minX, maxX, minY, maxY, fCubic);
236 && (result = check_quadratic(cubic, fCubic))) {
239 fCubic = cubic;
264 SkPath::Verb SkReduceOrder::Cubic(const SkPoint a[4], SkPoint* reducePts) {
270 SkDCubic cubic;
271 cubic.set(a);
273 int order = reducer.reduce(cubic, kAllow_Quadratics);
274 if (order == 2 || order == 3) { // cubic became line or quad