Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(324)

Side by Side Diff: src/gpu/GrPathUtils.cpp

Issue 1138263002: Revert of stop calling SkScalarDiv (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/gpu/GrOvalRenderer.cpp ('k') | src/gpu/effects/GrDashingEffect.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "GrTypes.h" 10 #include "GrTypes.h"
(...skipping 11 matching lines...) Expand all
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);
29 stretch = SkMaxScalar(stretch, mat.mapRadius(SK_Scalar1)); 29 stretch = SkMaxScalar(stretch, mat.mapRadius(SK_Scalar1));
30 } 30 }
31 } 31 }
32 return srcTol / stretch; 32 srcTol = SkScalarDiv(srcTol, stretch);
33 return srcTol;
33 } 34 }
34 35
35 static const int MAX_POINTS_PER_CURVE = 1 << 10; 36 static const int MAX_POINTS_PER_CURVE = 1 << 10;
36 static const SkScalar gMinCurveTol = 0.0001f; 37 static const SkScalar gMinCurveTol = 0.0001f;
37 38
38 uint32_t GrPathUtils::quadraticPointCount(const SkPoint points[], 39 uint32_t GrPathUtils::quadraticPointCount(const SkPoint points[],
39 SkScalar tol) { 40 SkScalar tol) {
40 if (tol < gMinCurveTol) { 41 if (tol < gMinCurveTol) {
41 tol = gMinCurveTol; 42 tol = gMinCurveTol;
42 } 43 }
43 SkASSERT(tol > 0); 44 SkASSERT(tol > 0);
44 45
45 SkScalar d = points[1].distanceToLineSegmentBetween(points[0], points[2]); 46 SkScalar d = points[1].distanceToLineSegmentBetween(points[0], points[2]);
46 if (d <= tol) { 47 if (d <= tol) {
47 return 1; 48 return 1;
48 } else { 49 } else {
49 // Each time we subdivide, d should be cut in 4. So we need to 50 // Each time we subdivide, d should be cut in 4. So we need to
50 // subdivide x = log4(d/tol) times. x subdivisions creates 2^(x) 51 // subdivide x = log4(d/tol) times. x subdivisions creates 2^(x)
51 // points. 52 // points.
52 // 2^(log4(x)) = sqrt(x); 53 // 2^(log4(x)) = sqrt(x);
53 SkScalar divSqrt = SkScalarSqrt(d / tol); 54 SkScalar divSqrt = SkScalarSqrt(SkScalarDiv(d, tol));
54 if (((SkScalar)SK_MaxS32) <= divSqrt) { 55 if (((SkScalar)SK_MaxS32) <= divSqrt) {
55 return MAX_POINTS_PER_CURVE; 56 return MAX_POINTS_PER_CURVE;
56 } else { 57 } else {
57 int temp = SkScalarCeilToInt(divSqrt); 58 int temp = SkScalarCeilToInt(divSqrt);
58 int pow2 = GrNextPow2(temp); 59 int pow2 = GrNextPow2(temp);
59 // Because of NaNs & INFs we can wind up with a degenerate temp 60 // Because of NaNs & INFs we can wind up with a degenerate temp
60 // such that pow2 comes out negative. Also, our point generator 61 // such that pow2 comes out negative. Also, our point generator
61 // will always output at least one pt. 62 // will always output at least one pt.
62 if (pow2 < 1) { 63 if (pow2 < 1) {
63 pow2 = 1; 64 pow2 = 1;
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 } 100 }
100 SkASSERT(tol > 0); 101 SkASSERT(tol > 0);
101 102
102 SkScalar d = SkTMax( 103 SkScalar d = SkTMax(
103 points[1].distanceToLineSegmentBetweenSqd(points[0], points[3]), 104 points[1].distanceToLineSegmentBetweenSqd(points[0], points[3]),
104 points[2].distanceToLineSegmentBetweenSqd(points[0], points[3])); 105 points[2].distanceToLineSegmentBetweenSqd(points[0], points[3]));
105 d = SkScalarSqrt(d); 106 d = SkScalarSqrt(d);
106 if (d <= tol) { 107 if (d <= tol) {
107 return 1; 108 return 1;
108 } else { 109 } else {
109 SkScalar divSqrt = SkScalarSqrt(d / tol); 110 SkScalar divSqrt = SkScalarSqrt(SkScalarDiv(d, tol));
110 if (((SkScalar)SK_MaxS32) <= divSqrt) { 111 if (((SkScalar)SK_MaxS32) <= divSqrt) {
111 return MAX_POINTS_PER_CURVE; 112 return MAX_POINTS_PER_CURVE;
112 } else { 113 } else {
113 int temp = SkScalarCeilToInt(SkScalarSqrt(d / tol)); 114 int temp = SkScalarCeilToInt(SkScalarSqrt(SkScalarDiv(d, tol)));
114 int pow2 = GrNextPow2(temp); 115 int pow2 = GrNextPow2(temp);
115 // Because of NaNs & INFs we can wind up with a degenerate temp 116 // Because of NaNs & INFs we can wind up with a degenerate temp
116 // such that pow2 comes out negative. Also, our point generator 117 // such that pow2 comes out negative. Also, our point generator
117 // will always output at least one pt. 118 // will always output at least one pt.
118 if (pow2 < 1) { 119 if (pow2 < 1) {
119 pow2 = 1; 120 pow2 = 1;
120 } 121 }
121 return SkTMin(pow2, MAX_POINTS_PER_CURVE); 122 return SkTMin(pow2, MAX_POINTS_PER_CURVE);
122 } 123 }
123 } 124 }
(...skipping 683 matching lines...) Expand 10 before | Expand all | Expand 10 after
807 set_loop_klm(d, controlK, controlL, controlM); 808 set_loop_klm(d, controlK, controlL, controlM);
808 } else if (kCusp_SkCubicType == cType) { 809 } else if (kCusp_SkCubicType == cType) {
809 SkASSERT(0.f == d[0]); 810 SkASSERT(0.f == d[0]);
810 set_cusp_klm(d, controlK, controlL, controlM); 811 set_cusp_klm(d, controlK, controlL, controlM);
811 } else if (kQuadratic_SkCubicType == cType) { 812 } else if (kQuadratic_SkCubicType == cType) {
812 set_quadratic_klm(d, controlK, controlL, controlM); 813 set_quadratic_klm(d, controlK, controlL, controlM);
813 } 814 }
814 815
815 calc_cubic_klm(p, controlK, controlL, controlM, klm, &klm[3], &klm[6]); 816 calc_cubic_klm(p, controlK, controlL, controlM, klm, &klm[3], &klm[6]);
816 } 817 }
OLDNEW
« no previous file with comments | « src/gpu/GrOvalRenderer.cpp ('k') | src/gpu/effects/GrDashingEffect.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698