OLD | NEW |
1 | |
2 /* | 1 /* |
3 * Copyright 2011 Google Inc. | 2 * Copyright 2011 Google Inc. |
4 * | 3 * |
5 * 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 |
6 * found in the LICENSE file. | 5 * found in the LICENSE file. |
7 */ | 6 */ |
8 | 7 |
| 8 #include "GrPathUtils.h" |
9 | 9 |
10 #include "GrPathUtils.h" | |
11 #include "GrPoint.h" | 10 #include "GrPoint.h" |
12 #include "SkGeometry.h" | 11 #include "SkGeometry.h" |
13 | 12 |
14 SkScalar GrPathUtils::scaleToleranceToSrc(SkScalar devTol, | 13 SkScalar GrPathUtils::scaleToleranceToSrc(SkScalar devTol, |
15 const SkMatrix& viewM, | 14 const SkMatrix& viewM, |
16 const GrRect& pathBounds) { | 15 const SkRect& pathBounds) { |
17 // 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 |
18 // stretch when mapping to screen coordinates. | 17 // stretch when mapping to screen coordinates. |
19 SkScalar stretch = viewM.getMaxStretch(); | 18 SkScalar stretch = viewM.getMaxStretch(); |
20 SkScalar srcTol = devTol; | 19 SkScalar srcTol = devTol; |
21 | 20 |
22 if (stretch < 0) { | 21 if (stretch < 0) { |
23 // take worst case mapRadius amoung four corners. | 22 // take worst case mapRadius amoung four corners. |
24 // (less than perfect) | 23 // (less than perfect) |
25 for (int i = 0; i < 4; ++i) { | 24 for (int i = 0; i < 4; ++i) { |
26 SkMatrix mat; | 25 SkMatrix mat; |
(...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
470 // base tolerance is 1 pixel. | 469 // base tolerance is 1 pixel. |
471 static const SkScalar kTolerance = SK_Scalar1; | 470 static const SkScalar kTolerance = SK_Scalar1; |
472 const SkScalar tolSqd = SkScalarSquare(SkScalarMul(tolScale, kTolerance)); | 471 const SkScalar tolSqd = SkScalarSquare(SkScalarMul(tolScale, kTolerance)); |
473 | 472 |
474 for (int i = 0; i < count; ++i) { | 473 for (int i = 0; i < count; ++i) { |
475 SkPoint* cubic = chopped + 3*i; | 474 SkPoint* cubic = chopped + 3*i; |
476 convert_noninflect_cubic_to_quads(cubic, tolSqd, constrainWithinTangents
, dir, quads); | 475 convert_noninflect_cubic_to_quads(cubic, tolSqd, constrainWithinTangents
, dir, quads); |
477 } | 476 } |
478 | 477 |
479 } | 478 } |
OLD | NEW |