OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 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 "SkIntersections.h" | 7 #include "SkIntersections.h" |
8 #include "SkLineParameters.h" | 8 #include "SkLineParameters.h" |
9 #include "SkPathOpsConic.h" | 9 #include "SkPathOpsConic.h" |
10 #include "SkPathOpsCubic.h" | 10 #include "SkPathOpsCubic.h" |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 cy = conic_eval_numerator(&fPts[0].fY, fWeight, t2); | 146 cy = conic_eval_numerator(&fPts[0].fY, fWeight, t2); |
147 cz = conic_eval_denominator(fWeight, t2); | 147 cz = conic_eval_denominator(fWeight, t2); |
148 } else { | 148 } else { |
149 cx = fPts[0].fX; | 149 cx = fPts[0].fX; |
150 cy = fPts[0].fY; | 150 cy = fPts[0].fY; |
151 cz = 1; | 151 cz = 1; |
152 } | 152 } |
153 double bx = 2 * dx - (ax + cx) / 2; | 153 double bx = 2 * dx - (ax + cx) / 2; |
154 double by = 2 * dy - (ay + cy) / 2; | 154 double by = 2 * dy - (ay + cy) / 2; |
155 double bz = 2 * dz - (az + cz) / 2; | 155 double bz = 2 * dz - (az + cz) / 2; |
156 SkDConic dst = {{{{ax / az, ay / az}, {bx / bz, by / bz}, {cx / cz, cy / cz}
}}, 0 }; | 156 SkDConic dst = {{{{ax / az, ay / az}, {bx / bz, by / bz}, {cx / cz, cy / cz}
}}, |
157 SkDPoint dMidAC = { (dst.fPts[0].fX + dst.fPts[2].fX) / 2, | 157 SkDoubleToScalar(bz / sqrt(az * cz)) }; |
158 (dst.fPts[0].fY + dst.fPts[2].fY) / 2 }; | |
159 SkDPoint dMid = { dx / dz, dy / dz }; | |
160 SkDVector dWNumer = dMidAC - dMid; | |
161 SkDVector dWDenom = dMid - dst.fPts[1]; | |
162 dst.fWeight = dWNumer.length() / dWDenom.length(); | |
163 return dst; | 158 return dst; |
164 } | 159 } |
165 | 160 |
166 SkDPoint SkDConic::subDivide(const SkDPoint& a, const SkDPoint& c, double t1, do
uble t2, | 161 SkDPoint SkDConic::subDivide(const SkDPoint& a, const SkDPoint& c, double t1, do
uble t2, |
167 SkScalar* weight) const { | 162 SkScalar* weight) const { |
168 SkDConic chopped = this->subDivide(t1, t2); | 163 SkDConic chopped = this->subDivide(t1, t2); |
169 *weight = chopped.fWeight; | 164 *weight = chopped.fWeight; |
170 return chopped[1]; | 165 return chopped[1]; |
171 } | 166 } |
OLD | NEW |