OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 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 | 7 |
8 #include "GrPathUtils.h" | 8 #include "GrPathUtils.h" |
9 | 9 |
10 #include "GrPoint.h" | 10 #include "GrPoint.h" |
(...skipping 16 matching lines...) Expand all Loading... |
27 (i < 2) ? pathBounds.fTop : pathBounds.fBottom); | 27 (i < 2) ? pathBounds.fTop : pathBounds.fBottom); |
28 mat.postConcat(viewM); | 28 mat.postConcat(viewM); |
29 stretch = SkMaxScalar(stretch, mat.mapRadius(SK_Scalar1)); | 29 stretch = SkMaxScalar(stretch, mat.mapRadius(SK_Scalar1)); |
30 } | 30 } |
31 } | 31 } |
32 srcTol = SkScalarDiv(srcTol, stretch); | 32 srcTol = SkScalarDiv(srcTol, stretch); |
33 return srcTol; | 33 return srcTol; |
34 } | 34 } |
35 | 35 |
36 static const int MAX_POINTS_PER_CURVE = 1 << 10; | 36 static const int MAX_POINTS_PER_CURVE = 1 << 10; |
37 static const SkScalar gMinCurveTol = SkFloatToScalar(0.0001f); | 37 static const SkScalar gMinCurveTol = 0.0001f; |
38 | 38 |
39 uint32_t GrPathUtils::quadraticPointCount(const GrPoint points[], | 39 uint32_t GrPathUtils::quadraticPointCount(const GrPoint points[], |
40 SkScalar tol) { | 40 SkScalar tol) { |
41 if (tol < gMinCurveTol) { | 41 if (tol < gMinCurveTol) { |
42 tol = gMinCurveTol; | 42 tol = gMinCurveTol; |
43 } | 43 } |
44 SkASSERT(tol > 0); | 44 SkASSERT(tol > 0); |
45 | 45 |
46 SkScalar d = points[1].distanceToLineSegmentBetween(points[0], points[2]); | 46 SkScalar d = points[1].distanceToLineSegmentBetween(points[0], points[2]); |
47 if (d <= tol) { | 47 if (d <= tol) { |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
243 } else { | 243 } else { |
244 // It's a point. It should cover zero area. Just set the matrix such | 244 // It's a point. It should cover zero area. Just set the matrix such |
245 // that (u, v) will always be far away from the quad. | 245 // that (u, v) will always be far away from the quad. |
246 fM[0] = 0; fM[1] = 0; fM[2] = 100.f; | 246 fM[0] = 0; fM[1] = 0; fM[2] = 100.f; |
247 fM[3] = 0; fM[4] = 0; fM[5] = 100.f; | 247 fM[3] = 0; fM[4] = 0; fM[5] = 100.f; |
248 } | 248 } |
249 } else { | 249 } else { |
250 m.postConcat(UVpts); | 250 m.postConcat(UVpts); |
251 | 251 |
252 // The matrix should not have perspective. | 252 // The matrix should not have perspective. |
253 SkDEBUGCODE(static const SkScalar gTOL = SkFloatToScalar(1.f / 100.f)); | 253 SkDEBUGCODE(static const SkScalar gTOL = 1.f / 100.f); |
254 SkASSERT(SkScalarAbs(m.get(SkMatrix::kMPersp0)) < gTOL); | 254 SkASSERT(SkScalarAbs(m.get(SkMatrix::kMPersp0)) < gTOL); |
255 SkASSERT(SkScalarAbs(m.get(SkMatrix::kMPersp1)) < gTOL); | 255 SkASSERT(SkScalarAbs(m.get(SkMatrix::kMPersp1)) < gTOL); |
256 | 256 |
257 // It may not be normalized to have 1.0 in the bottom right | 257 // It may not be normalized to have 1.0 in the bottom right |
258 float m33 = m.get(SkMatrix::kMPersp2); | 258 float m33 = m.get(SkMatrix::kMPersp2); |
259 if (1.f != m33) { | 259 if (1.f != m33) { |
260 m33 = 1.f / m33; | 260 m33 = 1.f / m33; |
261 fM[0] = m33 * m.get(SkMatrix::kMScaleX); | 261 fM[0] = m33 * m.get(SkMatrix::kMScaleX); |
262 fM[1] = m33 * m.get(SkMatrix::kMSkewX); | 262 fM[1] = m33 * m.get(SkMatrix::kMSkewX); |
263 fM[2] = m33 * m.get(SkMatrix::kMTransX); | 263 fM[2] = m33 * m.get(SkMatrix::kMTransX); |
(...skipping 567 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
831 set_loop_klm(d, controlK, controlL, controlM); | 831 set_loop_klm(d, controlK, controlL, controlM); |
832 } else if (kCusp_CubicType == cType) { | 832 } else if (kCusp_CubicType == cType) { |
833 SkASSERT(0.f == d[0]); | 833 SkASSERT(0.f == d[0]); |
834 set_cusp_klm(d, controlK, controlL, controlM); | 834 set_cusp_klm(d, controlK, controlL, controlM); |
835 } else if (kQuadratic_CubicType == cType) { | 835 } else if (kQuadratic_CubicType == cType) { |
836 set_quadratic_klm(d, controlK, controlL, controlM); | 836 set_quadratic_klm(d, controlK, controlL, controlM); |
837 } | 837 } |
838 | 838 |
839 calc_cubic_klm(p, controlK, controlL, controlM, klm, &klm[3], &klm[6]); | 839 calc_cubic_klm(p, controlK, controlL, controlM, klm, &klm[3], &klm[6]); |
840 } | 840 } |
OLD | NEW |