OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2011 Google Inc. | 3 * Copyright 2011 Google Inc. |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 #include "GrAAHairLinePathRenderer.h" | 9 #include "GrAAHairLinePathRenderer.h" |
10 | 10 |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 | 151 |
152 SkScalar dsqd = p[1].distanceToLineBetweenSqd(p[0], p[2]); | 152 SkScalar dsqd = p[1].distanceToLineBetweenSqd(p[0], p[2]); |
153 if (dsqd < gDegenerateToLineTolSqd) { | 153 if (dsqd < gDegenerateToLineTolSqd) { |
154 return -1; | 154 return -1; |
155 } | 155 } |
156 | 156 |
157 if (p[2].distanceToLineBetweenSqd(p[1], p[0]) < gDegenerateToLineTolSqd) { | 157 if (p[2].distanceToLineBetweenSqd(p[1], p[0]) < gDegenerateToLineTolSqd) { |
158 return -1; | 158 return -1; |
159 } | 159 } |
160 | 160 |
161 static const int kMaxSub = 4; | |
162 // tolerance of triangle height in pixels | 161 // tolerance of triangle height in pixels |
163 // tuned on windows Quadro FX 380 / Z600 | 162 // tuned on windows Quadro FX 380 / Z600 |
164 // trade off of fill vs cpu time on verts | 163 // trade off of fill vs cpu time on verts |
165 // maybe different when do this using gpu (geo or tess shaders) | 164 // maybe different when do this using gpu (geo or tess shaders) |
166 static const SkScalar gSubdivTol = 175 * SK_Scalar1; | 165 static const SkScalar gSubdivTol = 175 * SK_Scalar1; |
167 | 166 |
168 if (dsqd <= SkScalarMul(gSubdivTol, gSubdivTol)) { | 167 if (dsqd <= SkScalarMul(gSubdivTol, gSubdivTol)) { |
169 return 0; | 168 return 0; |
170 } else { | 169 } else { |
| 170 static const int kMaxSub = 4; |
171 // subdividing the quad reduces d by 4. so we want x = log4(d/tol) | 171 // subdividing the quad reduces d by 4. so we want x = log4(d/tol) |
172 // = log4(d*d/tol*tol)/2 | 172 // = log4(d*d/tol*tol)/2 |
173 // = log2(d*d/tol*tol) | 173 // = log2(d*d/tol*tol) |
174 | 174 |
175 #ifdef SK_SCALAR_IS_FLOAT | 175 #ifdef SK_SCALAR_IS_FLOAT |
176 // +1 since we're ignoring the mantissa contribution. | 176 // +1 since we're ignoring the mantissa contribution. |
177 int log = get_float_exp(dsqd/(gSubdivTol*gSubdivTol)) + 1; | 177 int log = get_float_exp(dsqd/(gSubdivTol*gSubdivTol)) + 1; |
178 log = GrMin(GrMax(0, log), kMaxSub); | 178 log = GrMin(GrMax(0, log), kMaxSub); |
179 return log; | 179 return log; |
180 #else | 180 #else |
(...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
627 target->drawIndexed(kTriangles_GrPrimitiveType, | 627 target->drawIndexed(kTriangles_GrPrimitiveType, |
628 4 * lineCnt + kVertsPerQuad*quads, // startV | 628 4 * lineCnt + kVertsPerQuad*quads, // startV |
629 0, // startI | 629 0, // startI |
630 kVertsPerQuad*n, // vCount | 630 kVertsPerQuad*n, // vCount |
631 kIdxsPerQuad*n); // iCount | 631 kIdxsPerQuad*n); // iCount |
632 quads += n; | 632 quads += n; |
633 } | 633 } |
634 drawState->setVertexEdgeType(oldEdgeType); | 634 drawState->setVertexEdgeType(oldEdgeType); |
635 return true; | 635 return true; |
636 } | 636 } |
OLD | NEW |