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

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

Issue 2257423002: Some assert fixes for running the Fuzzer sample in GPU mode. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 4 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/GrBlurUtils.cpp ('k') | no next file » | 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 26 matching lines...) Expand all
37 static const SkScalar gMinCurveTol = 0.0001f; 37 static const SkScalar gMinCurveTol = 0.0001f;
38 38
39 uint32_t GrPathUtils::quadraticPointCount(const SkPoint points[], 39 uint32_t GrPathUtils::quadraticPointCount(const SkPoint 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 (!SkScalarIsFinite(d)) {
48 return MAX_POINTS_PER_CURVE;
49 } else if (d <= tol) {
48 return 1; 50 return 1;
49 } else { 51 } else {
50 // Each time we subdivide, d should be cut in 4. So we need to 52 // Each time we subdivide, d should be cut in 4. So we need to
51 // subdivide x = log4(d/tol) times. x subdivisions creates 2^(x) 53 // subdivide x = log4(d/tol) times. x subdivisions creates 2^(x)
52 // points. 54 // points.
53 // 2^(log4(x)) = sqrt(x); 55 // 2^(log4(x)) = sqrt(x);
54 SkScalar divSqrt = SkScalarSqrt(d / tol); 56 SkScalar divSqrt = SkScalarSqrt(d / tol);
55 if (((SkScalar)SK_MaxS32) <= divSqrt) { 57 if (((SkScalar)SK_MaxS32) <= divSqrt) {
56 return MAX_POINTS_PER_CURVE; 58 return MAX_POINTS_PER_CURVE;
57 } else { 59 } else {
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 SkScalar tol) { 99 SkScalar tol) {
98 if (tol < gMinCurveTol) { 100 if (tol < gMinCurveTol) {
99 tol = gMinCurveTol; 101 tol = gMinCurveTol;
100 } 102 }
101 SkASSERT(tol > 0); 103 SkASSERT(tol > 0);
102 104
103 SkScalar d = SkTMax( 105 SkScalar d = SkTMax(
104 points[1].distanceToLineSegmentBetweenSqd(points[0], points[3]), 106 points[1].distanceToLineSegmentBetweenSqd(points[0], points[3]),
105 points[2].distanceToLineSegmentBetweenSqd(points[0], points[3])); 107 points[2].distanceToLineSegmentBetweenSqd(points[0], points[3]));
106 d = SkScalarSqrt(d); 108 d = SkScalarSqrt(d);
107 if (d <= tol) { 109 if (!SkScalarIsFinite(d)) {
110 return MAX_POINTS_PER_CURVE;
111 } else if (d <= tol) {
108 return 1; 112 return 1;
109 } else { 113 } else {
110 SkScalar divSqrt = SkScalarSqrt(d / tol); 114 SkScalar divSqrt = SkScalarSqrt(d / tol);
111 if (((SkScalar)SK_MaxS32) <= divSqrt) { 115 if (((SkScalar)SK_MaxS32) <= divSqrt) {
112 return MAX_POINTS_PER_CURVE; 116 return MAX_POINTS_PER_CURVE;
113 } else { 117 } else {
114 int temp = SkScalarCeilToInt(SkScalarSqrt(d / tol)); 118 int temp = SkScalarCeilToInt(SkScalarSqrt(d / tol));
115 int pow2 = GrNextPow2(temp); 119 int pow2 = GrNextPow2(temp);
116 // Because of NaNs & INFs we can wind up with a degenerate temp 120 // Because of NaNs & INFs we can wind up with a degenerate temp
117 // such that pow2 comes out negative. Also, our point generator 121 // such that pow2 comes out negative. Also, our point generator
(...skipping 695 matching lines...) Expand 10 before | Expand all | Expand 10 after
813 set_loop_klm(d, controlK, controlL, controlM); 817 set_loop_klm(d, controlK, controlL, controlM);
814 } else if (kCusp_SkCubicType == cType) { 818 } else if (kCusp_SkCubicType == cType) {
815 SkASSERT(0.f == d[0]); 819 SkASSERT(0.f == d[0]);
816 set_cusp_klm(d, controlK, controlL, controlM); 820 set_cusp_klm(d, controlK, controlL, controlM);
817 } else if (kQuadratic_SkCubicType == cType) { 821 } else if (kQuadratic_SkCubicType == cType) {
818 set_quadratic_klm(d, controlK, controlL, controlM); 822 set_quadratic_klm(d, controlK, controlL, controlM);
819 } 823 }
820 824
821 calc_cubic_klm(p, controlK, controlL, controlM, klm, &klm[3], &klm[6]); 825 calc_cubic_klm(p, controlK, controlL, controlM, klm, &klm[3], &klm[6]);
822 } 826 }
OLDNEW
« no previous file with comments | « src/gpu/GrBlurUtils.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698