| 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 437 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 448 SkDCubic sub = subDivide(t1, t2); | 448 SkDCubic sub = subDivide(t1, t2); |
| 449 dst[0] = sub[1] + (a - sub[0]); | 449 dst[0] = sub[1] + (a - sub[0]); |
| 450 dst[1] = sub[2] + (d - sub[3]); | 450 dst[1] = sub[2] + (d - sub[3]); |
| 451 #endif | 451 #endif |
| 452 if (t1 == 0 || t2 == 0) { | 452 if (t1 == 0 || t2 == 0) { |
| 453 align(0, 1, t1 == 0 ? &dst[0] : &dst[1]); | 453 align(0, 1, t1 == 0 ? &dst[0] : &dst[1]); |
| 454 } | 454 } |
| 455 if (t1 == 1 || t2 == 1) { | 455 if (t1 == 1 || t2 == 1) { |
| 456 align(3, 2, t1 == 1 ? &dst[0] : &dst[1]); | 456 align(3, 2, t1 == 1 ? &dst[0] : &dst[1]); |
| 457 } | 457 } |
| 458 if (precisely_subdivide_equal(dst[0].fX, a.fX)) { | 458 if (AlmostBequalUlps(dst[0].fX, a.fX)) { |
| 459 dst[0].fX = a.fX; | 459 dst[0].fX = a.fX; |
| 460 } | 460 } |
| 461 if (precisely_subdivide_equal(dst[0].fY, a.fY)) { | 461 if (AlmostBequalUlps(dst[0].fY, a.fY)) { |
| 462 dst[0].fY = a.fY; | 462 dst[0].fY = a.fY; |
| 463 } | 463 } |
| 464 if (precisely_subdivide_equal(dst[1].fX, d.fX)) { | 464 if (AlmostBequalUlps(dst[1].fX, d.fX)) { |
| 465 dst[1].fX = d.fX; | 465 dst[1].fX = d.fX; |
| 466 } | 466 } |
| 467 if (precisely_subdivide_equal(dst[1].fY, d.fY)) { | 467 if (AlmostBequalUlps(dst[1].fY, d.fY)) { |
| 468 dst[1].fY = d.fY; | 468 dst[1].fY = d.fY; |
| 469 } | 469 } |
| 470 } | 470 } |
| 471 | 471 |
| 472 /* classic one t subdivision */ | 472 /* classic one t subdivision */ |
| 473 static void interp_cubic_coords(const double* src, double* dst, double t) { | 473 static void interp_cubic_coords(const double* src, double* dst, double t) { |
| 474 double ab = SkDInterp(src[0], src[2], t); | 474 double ab = SkDInterp(src[0], src[2], t); |
| 475 double bc = SkDInterp(src[2], src[4], t); | 475 double bc = SkDInterp(src[2], src[4], t); |
| 476 double cd = SkDInterp(src[4], src[6], t); | 476 double cd = SkDInterp(src[4], src[6], t); |
| 477 double abc = SkDInterp(ab, bc, t); | 477 double abc = SkDInterp(ab, bc, t); |
| (...skipping 23 matching lines...) Expand all 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 |