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 "SkNx.h" | 10 #include "SkNx.h" |
(...skipping 898 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
909 if (dst) { | 909 if (dst) { |
910 if (count == 0) { | 910 if (count == 0) { |
911 memcpy(dst, src, 4 * sizeof(SkPoint)); | 911 memcpy(dst, src, 4 * sizeof(SkPoint)); |
912 } else { | 912 } else { |
913 SkChopCubicAt(src, dst, tValues, count); | 913 SkChopCubicAt(src, dst, tValues, count); |
914 } | 914 } |
915 } | 915 } |
916 return count + 1; | 916 return count + 1; |
917 } | 917 } |
918 | 918 |
| 919 #include "../pathops/SkPathOpsCubic.h" |
| 920 |
| 921 typedef int (SkDCubic::*InterceptProc)(double intercept, double roots[3]) const; |
| 922 |
| 923 static bool cubic_dchop_at_intercept(const SkPoint src[4], SkScalar intercept, S
kPoint dst[7], |
| 924 InterceptProc method) { |
| 925 SkDCubic cubic; |
| 926 double roots[3]; |
| 927 int count = (cubic.set(src).*method)(intercept, roots); |
| 928 if (count > 0) { |
| 929 SkDCubicPair pair = cubic.chopAt(roots[0]); |
| 930 for (int i = 0; i < 7; ++i) { |
| 931 dst[i] = pair.pts[i].asSkPoint(); |
| 932 } |
| 933 return true; |
| 934 } |
| 935 return false; |
| 936 } |
| 937 |
| 938 bool SkChopMonoCubicAtY(SkPoint src[4], SkScalar y, SkPoint dst[7]) { |
| 939 return cubic_dchop_at_intercept(src, y, dst, &SkDCubic::horizontalIntersect)
; |
| 940 } |
| 941 |
| 942 bool SkChopMonoCubicAtX(SkPoint src[4], SkScalar x, SkPoint dst[7]) { |
| 943 return cubic_dchop_at_intercept(src, x, dst, &SkDCubic::verticalIntersect); |
| 944 } |
| 945 |
919 /////////////////////////////////////////////////////////////////////////////// | 946 /////////////////////////////////////////////////////////////////////////////// |
920 | 947 |
921 /* Find t value for quadratic [a, b, c] = d. | 948 /* Find t value for quadratic [a, b, c] = d. |
922 Return 0 if there is no solution within [0, 1) | 949 Return 0 if there is no solution within [0, 1) |
923 */ | 950 */ |
924 static SkScalar quad_solve(SkScalar a, SkScalar b, SkScalar c, SkScalar d) { | 951 static SkScalar quad_solve(SkScalar a, SkScalar b, SkScalar c, SkScalar d) { |
925 // At^2 + Bt + C = d | 952 // At^2 + Bt + C = d |
926 SkScalar A = a - 2 * b + c; | 953 SkScalar A = a - 2 * b + c; |
927 SkScalar B = 2 * (b - a); | 954 SkScalar B = 2 * (b - a); |
928 SkScalar C = a - d; | 955 SkScalar C = a - d; |
(...skipping 621 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1550 matrix.preScale(SK_Scalar1, -SK_Scalar1); | 1577 matrix.preScale(SK_Scalar1, -SK_Scalar1); |
1551 } | 1578 } |
1552 if (userMatrix) { | 1579 if (userMatrix) { |
1553 matrix.postConcat(*userMatrix); | 1580 matrix.postConcat(*userMatrix); |
1554 } | 1581 } |
1555 for (int i = 0; i < conicCount; ++i) { | 1582 for (int i = 0; i < conicCount; ++i) { |
1556 matrix.mapPoints(dst[i].fPts, 3); | 1583 matrix.mapPoints(dst[i].fPts, 3); |
1557 } | 1584 } |
1558 return conicCount; | 1585 return conicCount; |
1559 } | 1586 } |
OLD | NEW |