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" |
11 #include "SkGeometry.h" | 11 #include "SkGeometry.h" |
12 | 12 |
13 SkScalar GrPathUtils::scaleToleranceToSrc(SkScalar devTol, | 13 SkScalar GrPathUtils::scaleToleranceToSrc(SkScalar devTol, |
14 const SkMatrix& viewM, | 14 const SkMatrix& viewM, |
15 const SkRect& pathBounds) { | 15 const SkRect& pathBounds) { |
16 // In order to tesselate the path we get a bound on how much the matrix can | 16 // In order to tesselate the path we get a bound on how much the matrix can |
17 // stretch when mapping to screen coordinates. | 17 // scale when mapping to screen coordinates. |
18 SkScalar stretch = viewM.getMaxStretch(); | 18 SkScalar stretch = viewM.getMaxScale(); |
19 SkScalar srcTol = devTol; | 19 SkScalar srcTol = devTol; |
20 | 20 |
21 if (stretch < 0) { | 21 if (stretch < 0) { |
22 // take worst case mapRadius amoung four corners. | 22 // take worst case mapRadius amoung four corners. |
23 // (less than perfect) | 23 // (less than perfect) |
24 for (int i = 0; i < 4; ++i) { | 24 for (int i = 0; i < 4; ++i) { |
25 SkMatrix mat; | 25 SkMatrix mat; |
26 mat.setTranslate((i % 2) ? pathBounds.fLeft : pathBounds.fRight, | 26 mat.setTranslate((i % 2) ? pathBounds.fLeft : pathBounds.fRight, |
27 (i < 2) ? pathBounds.fTop : pathBounds.fBottom); | 27 (i < 2) ? pathBounds.fTop : pathBounds.fBottom); |
28 mat.postConcat(viewM); | 28 mat.postConcat(viewM); |
(...skipping 830 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
859 set_loop_klm(d, controlK, controlL, controlM); | 859 set_loop_klm(d, controlK, controlL, controlM); |
860 } else if (kCusp_CubicType == cType) { | 860 } else if (kCusp_CubicType == cType) { |
861 SkASSERT(0.f == d[0]); | 861 SkASSERT(0.f == d[0]); |
862 set_cusp_klm(d, controlK, controlL, controlM); | 862 set_cusp_klm(d, controlK, controlL, controlM); |
863 } else if (kQuadratic_CubicType == cType) { | 863 } else if (kQuadratic_CubicType == cType) { |
864 set_quadratic_klm(d, controlK, controlL, controlM); | 864 set_quadratic_klm(d, controlK, controlL, controlM); |
865 } | 865 } |
866 | 866 |
867 calc_cubic_klm(p, controlK, controlL, controlM, klm, &klm[3], &klm[6]); | 867 calc_cubic_klm(p, controlK, controlL, controlM, klm, &klm[3], &klm[6]); |
868 } | 868 } |
OLD | NEW |