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 "SkIntersections.h" | 7 #include "SkIntersections.h" |
8 #include "SkLineParameters.h" | 8 #include "SkLineParameters.h" |
9 #include "SkPathOpsCubic.h" | 9 #include "SkPathOpsCubic.h" |
10 #include "SkPathOpsQuad.h" | 10 #include "SkPathOpsQuad.h" |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 | 157 |
158 SkDVector SkDQuad::dxdyAtT(double t) const { | 158 SkDVector SkDQuad::dxdyAtT(double t) const { |
159 double a = t - 1; | 159 double a = t - 1; |
160 double b = 1 - 2 * t; | 160 double b = 1 - 2 * t; |
161 double c = t; | 161 double c = t; |
162 SkDVector result = { a * fPts[0].fX + b * fPts[1].fX + c * fPts[2].fX, | 162 SkDVector result = { a * fPts[0].fX + b * fPts[1].fX + c * fPts[2].fX, |
163 a * fPts[0].fY + b * fPts[1].fY + c * fPts[2].fY }; | 163 a * fPts[0].fY + b * fPts[1].fY + c * fPts[2].fY }; |
164 return result; | 164 return result; |
165 } | 165 } |
166 | 166 |
| 167 // OPTIMIZE: assert if caller passes in t == 0 / t == 1 ? |
167 SkDPoint SkDQuad::xyAtT(double t) const { | 168 SkDPoint SkDQuad::xyAtT(double t) const { |
168 double one_t = 1 - t; | 169 double one_t = 1 - t; |
169 double a = one_t * one_t; | 170 double a = one_t * one_t; |
170 double b = 2 * one_t * t; | 171 double b = 2 * one_t * t; |
171 double c = t * t; | 172 double c = t * t; |
172 SkDPoint result = { a * fPts[0].fX + b * fPts[1].fX + c * fPts[2].fX, | 173 SkDPoint result = { a * fPts[0].fX + b * fPts[1].fX + c * fPts[2].fX, |
173 a * fPts[0].fY + b * fPts[1].fY + c * fPts[2].fY }; | 174 a * fPts[0].fY + b * fPts[1].fY + c * fPts[2].fY }; |
174 return result; | 175 return result; |
175 } | 176 } |
176 | 177 |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
326 * c = C | 327 * c = C |
327 */ | 328 */ |
328 void SkDQuad::SetABC(const double* quad, double* a, double* b, double* c) { | 329 void SkDQuad::SetABC(const double* quad, double* a, double* b, double* c) { |
329 *a = quad[0]; // a = A | 330 *a = quad[0]; // a = A |
330 *b = 2 * quad[2]; // b = 2*B | 331 *b = 2 * quad[2]; // b = 2*B |
331 *c = quad[4]; // c = C | 332 *c = quad[4]; // c = C |
332 *b -= *c; // b = 2*B - C | 333 *b -= *c; // b = 2*B - C |
333 *a -= *b; // a = A - 2*B + C | 334 *a -= *b; // a = A - 2*B + C |
334 *b -= *c; // b = 2*B - 2*C | 335 *b -= *c; // b = 2*B - 2*C |
335 } | 336 } |
OLD | NEW |