OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2006 The Android Open Source Project | 2 * Copyright 2006 The Android Open Source Project |
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 | 7 |
8 #include "SkGeometry.h" | 8 #include "SkGeometry.h" |
9 #include "SkMatrix.h" | 9 #include "SkMatrix.h" |
10 #include "Sk2x.h" | 10 #include "Sk2x.h" |
(...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
472 dst[12] = src[6]; | 472 dst[12] = src[6]; |
473 } | 473 } |
474 | 474 |
475 void SkChopCubicAt(const SkPoint src[4], SkPoint dst[7], SkScalar t) { | 475 void SkChopCubicAt(const SkPoint src[4], SkPoint dst[7], SkScalar t) { |
476 SkASSERT(t > 0 && t < SK_Scalar1); | 476 SkASSERT(t > 0 && t < SK_Scalar1); |
477 | 477 |
478 interp_cubic_coords(&src[0].fX, &dst[0].fX, t); | 478 interp_cubic_coords(&src[0].fX, &dst[0].fX, t); |
479 interp_cubic_coords(&src[0].fY, &dst[0].fY, t); | 479 interp_cubic_coords(&src[0].fY, &dst[0].fY, t); |
480 } | 480 } |
481 | 481 |
| 482 void SkChopCubicAt2(const SkPoint src[4], SkPoint dst[7], SkScalar t) { |
| 483 SkASSERT(t > 0 && t < SK_Scalar1); |
| 484 |
| 485 Sk2s p0 = from_point(src[0]); |
| 486 Sk2s p1 = from_point(src[1]); |
| 487 Sk2s p2 = from_point(src[2]); |
| 488 Sk2s p3 = from_point(src[3]); |
| 489 Sk2s tt(t); |
| 490 |
| 491 Sk2s ab = interp(p0, p1, tt); |
| 492 Sk2s bc = interp(p1, p2, tt); |
| 493 Sk2s cd = interp(p2, p3, tt); |
| 494 Sk2s abc = interp(ab, bc, tt); |
| 495 Sk2s bcd = interp(bc, cd, tt); |
| 496 Sk2s abcd = interp(abc, bcd, tt); |
| 497 |
| 498 dst[0] = src[0]; |
| 499 dst[1] = to_point(ab); |
| 500 dst[2] = to_point(abc); |
| 501 dst[3] = to_point(abcd); |
| 502 dst[4] = to_point(bcd); |
| 503 dst[5] = to_point(cd); |
| 504 dst[6] = src[3]; |
| 505 } |
| 506 |
482 /* http://code.google.com/p/skia/issues/detail?id=32 | 507 /* http://code.google.com/p/skia/issues/detail?id=32 |
483 | 508 |
484 This test code would fail when we didn't check the return result of | 509 This test code would fail when we didn't check the return result of |
485 valid_unit_divide in SkChopCubicAt(... tValues[], int roots). The reason is | 510 valid_unit_divide in SkChopCubicAt(... tValues[], int roots). The reason is |
486 that after the first chop, the parameters to valid_unit_divide are equal | 511 that after the first chop, the parameters to valid_unit_divide are equal |
487 (thanks to finite float precision and rounding in the subtracts). Thus | 512 (thanks to finite float precision and rounding in the subtracts). Thus |
488 even though the 2nd tValue looks < 1.0, after we renormalize it, we end | 513 even though the 2nd tValue looks < 1.0, after we renormalize it, we end |
489 up with 1.0, hence the need to check and just return the last cubic as | 514 up with 1.0, hence the need to check and just return the last cubic as |
490 a degenerate clump of 4 points in the sampe place. | 515 a degenerate clump of 4 points in the sampe place. |
491 | 516 |
(...skipping 1122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1614 matrix.preScale(SK_Scalar1, -SK_Scalar1); | 1639 matrix.preScale(SK_Scalar1, -SK_Scalar1); |
1615 } | 1640 } |
1616 if (userMatrix) { | 1641 if (userMatrix) { |
1617 matrix.postConcat(*userMatrix); | 1642 matrix.postConcat(*userMatrix); |
1618 } | 1643 } |
1619 for (int i = 0; i < conicCount; ++i) { | 1644 for (int i = 0; i < conicCount; ++i) { |
1620 matrix.mapPoints(dst[i].fPts, 3); | 1645 matrix.mapPoints(dst[i].fPts, 3); |
1621 } | 1646 } |
1622 return conicCount; | 1647 return conicCount; |
1623 } | 1648 } |
OLD | NEW |