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 365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
376 double ab = SkDInterp(src[0], src[2], t); | 376 double ab = SkDInterp(src[0], src[2], t); |
377 double bc = SkDInterp(src[2], src[4], t); | 377 double bc = SkDInterp(src[2], src[4], t); |
378 double cd = SkDInterp(src[4], src[6], t); | 378 double cd = SkDInterp(src[4], src[6], t); |
379 double abc = SkDInterp(ab, bc, t); | 379 double abc = SkDInterp(ab, bc, t); |
380 double bcd = SkDInterp(bc, cd, t); | 380 double bcd = SkDInterp(bc, cd, t); |
381 double abcd = SkDInterp(abc, bcd, t); | 381 double abcd = SkDInterp(abc, bcd, t); |
382 return abcd; | 382 return abcd; |
383 } | 383 } |
384 | 384 |
385 SkDCubic SkDCubic::subDivide(double t1, double t2) const { | 385 SkDCubic SkDCubic::subDivide(double t1, double t2) const { |
386 if (t1 == 0 && t2 == 1) { | 386 if (t1 == 0 || t2 == 1) { |
387 return *this; | 387 if (t1 == 0 && t2 == 1) { |
| 388 return *this; |
| 389 } |
| 390 SkDCubicPair pair = chopAt(t1 == 0 ? t2 : t1); |
| 391 SkDCubic dst = t1 == 0 ? pair.first() : pair.second(); |
| 392 return dst; |
388 } | 393 } |
389 SkDCubic dst; | 394 SkDCubic dst; |
390 double ax = dst[0].fX = interp_cubic_coords(&fPts[0].fX, t1); | 395 double ax = dst[0].fX = interp_cubic_coords(&fPts[0].fX, t1); |
391 double ay = dst[0].fY = interp_cubic_coords(&fPts[0].fY, t1); | 396 double ay = dst[0].fY = interp_cubic_coords(&fPts[0].fY, t1); |
392 double ex = interp_cubic_coords(&fPts[0].fX, (t1*2+t2)/3); | 397 double ex = interp_cubic_coords(&fPts[0].fX, (t1*2+t2)/3); |
393 double ey = interp_cubic_coords(&fPts[0].fY, (t1*2+t2)/3); | 398 double ey = interp_cubic_coords(&fPts[0].fY, (t1*2+t2)/3); |
394 double fx = interp_cubic_coords(&fPts[0].fX, (t1+t2*2)/3); | 399 double fx = interp_cubic_coords(&fPts[0].fX, (t1+t2*2)/3); |
395 double fy = interp_cubic_coords(&fPts[0].fY, (t1+t2*2)/3); | 400 double fy = interp_cubic_coords(&fPts[0].fY, (t1+t2*2)/3); |
396 double dx = dst[3].fX = interp_cubic_coords(&fPts[0].fX, t2); | 401 double dx = dst[3].fX = interp_cubic_coords(&fPts[0].fX, t2); |
397 double dy = dst[3].fY = interp_cubic_coords(&fPts[0].fY, t2); | 402 double dy = dst[3].fY = interp_cubic_coords(&fPts[0].fY, t2); |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
490 dst.pts[4].fY = (fPts[1].fY + 2 * fPts[2].fY + fPts[3].fY) / 4; | 495 dst.pts[4].fY = (fPts[1].fY + 2 * fPts[2].fY + fPts[3].fY) / 4; |
491 dst.pts[5].fX = (fPts[2].fX + fPts[3].fX) / 2; | 496 dst.pts[5].fX = (fPts[2].fX + fPts[3].fX) / 2; |
492 dst.pts[5].fY = (fPts[2].fY + fPts[3].fY) / 2; | 497 dst.pts[5].fY = (fPts[2].fY + fPts[3].fY) / 2; |
493 dst.pts[6] = fPts[3]; | 498 dst.pts[6] = fPts[3]; |
494 return dst; | 499 return dst; |
495 } | 500 } |
496 interp_cubic_coords(&fPts[0].fX, &dst.pts[0].fX, t); | 501 interp_cubic_coords(&fPts[0].fX, &dst.pts[0].fX, t); |
497 interp_cubic_coords(&fPts[0].fY, &dst.pts[0].fY, t); | 502 interp_cubic_coords(&fPts[0].fY, &dst.pts[0].fY, t); |
498 return dst; | 503 return dst; |
499 } | 504 } |
OLD | NEW |