OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 #include "SkLineParameters.h" | 7 #include "SkLineParameters.h" |
8 #include "SkPathOpsCubic.h" | 8 #include "SkPathOpsCubic.h" |
9 #include "SkPathOpsLine.h" | 9 #include "SkPathOpsLine.h" |
10 #include "SkPathOpsQuad.h" | 10 #include "SkPathOpsQuad.h" |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 | 122 |
123 int SkDCubic::RootsReal(double A, double B, double C, double D, double s[3]) { | 123 int SkDCubic::RootsReal(double A, double B, double C, double D, double s[3]) { |
124 #ifdef SK_DEBUG | 124 #ifdef SK_DEBUG |
125 // create a string mathematica understands | 125 // create a string mathematica understands |
126 // GDB set print repe 15 # if repeated digits is a bother | 126 // GDB set print repe 15 # if repeated digits is a bother |
127 // set print elements 400 # if line doesn't fit | 127 // set print elements 400 # if line doesn't fit |
128 char str[1024]; | 128 char str[1024]; |
129 sk_bzero(str, sizeof(str)); | 129 sk_bzero(str, sizeof(str)); |
130 SK_SNPRINTF(str, sizeof(str), "Solve[%1.19g x^3 + %1.19g x^2 + %1.19g x + %1
.19g == 0, x]", | 130 SK_SNPRINTF(str, sizeof(str), "Solve[%1.19g x^3 + %1.19g x^2 + %1.19g x + %1
.19g == 0, x]", |
131 A, B, C, D); | 131 A, B, C, D); |
132 mathematica_ize(str, sizeof(str)); | 132 SkPathOpsDebug::MathematicaIze(str, sizeof(str)); |
133 #if ONE_OFF_DEBUG && ONE_OFF_DEBUG_MATHEMATICA | 133 #if ONE_OFF_DEBUG && ONE_OFF_DEBUG_MATHEMATICA |
134 SkDebugf("%s\n", str); | 134 SkDebugf("%s\n", str); |
135 #endif | 135 #endif |
136 #endif | 136 #endif |
137 if (approximately_zero(A) | 137 if (approximately_zero(A) |
138 && approximately_zero_when_compared_to(A, B) | 138 && approximately_zero_when_compared_to(A, B) |
139 && approximately_zero_when_compared_to(A, C) | 139 && approximately_zero_when_compared_to(A, C) |
140 && approximately_zero_when_compared_to(A, D)) { // we're just a qua
dratic | 140 && approximately_zero_when_compared_to(A, D)) { // we're just a qua
dratic |
141 return SkDQuad::RootsReal(B, C, D, s); | 141 return SkDQuad::RootsReal(B, C, D, s); |
142 } | 142 } |
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
501 dst.pts[4].fY = (fPts[1].fY + 2 * fPts[2].fY + fPts[3].fY) / 4; | 501 dst.pts[4].fY = (fPts[1].fY + 2 * fPts[2].fY + fPts[3].fY) / 4; |
502 dst.pts[5].fX = (fPts[2].fX + fPts[3].fX) / 2; | 502 dst.pts[5].fX = (fPts[2].fX + fPts[3].fX) / 2; |
503 dst.pts[5].fY = (fPts[2].fY + fPts[3].fY) / 2; | 503 dst.pts[5].fY = (fPts[2].fY + fPts[3].fY) / 2; |
504 dst.pts[6] = fPts[3]; | 504 dst.pts[6] = fPts[3]; |
505 return dst; | 505 return dst; |
506 } | 506 } |
507 interp_cubic_coords(&fPts[0].fX, &dst.pts[0].fX, t); | 507 interp_cubic_coords(&fPts[0].fX, &dst.pts[0].fX, t); |
508 interp_cubic_coords(&fPts[0].fY, &dst.pts[0].fY, t); | 508 interp_cubic_coords(&fPts[0].fY, &dst.pts[0].fY, t); |
509 return dst; | 509 return dst; |
510 } | 510 } |
| 511 |
| 512 #ifdef SK_DEBUG |
| 513 void SkDCubic::dump() { |
| 514 SkDebugf("{{"); |
| 515 int index = 0; |
| 516 do { |
| 517 fPts[index].dump(); |
| 518 SkDebugf(", "); |
| 519 } while (++index < 3); |
| 520 fPts[index].dump(); |
| 521 SkDebugf("}}\n"); |
| 522 } |
| 523 #endif |
OLD | NEW |