1 /*
2 * Copyright 2011 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8 #include "src/gpu/ganesh/geometry/GrPathUtils.h"
9
10 #include "include/gpu/GrTypes.h"
11 #include "src/base/SkMathPriv.h"
12 #include "src/base/SkUtils.h"
13 #include "src/core/SkPointPriv.h"
14 #include "src/gpu/tessellate/WangsFormula.h"
15
16 static const SkScalar kMinCurveTol = 0.0001f;
17
tolerance_to_wangs_precision(float srcTol)18 static float tolerance_to_wangs_precision(float srcTol) {
19 // You should have called scaleToleranceToSrc, which guarantees this
20 SkASSERT(srcTol >= kMinCurveTol);
21
22 // The GrPathUtil API defines tolerance as the max distance the linear segment can be from
23 // the real curve. Wang's formula guarantees the linear segments will be within 1/precision
24 // of the true curve, so precision = 1/srcTol
25 return 1.f / srcTol;
26 }
27
max_bezier_vertices(uint32_t chopCount)28 uint32_t max_bezier_vertices(uint32_t chopCount) {
29 static constexpr uint32_t kMaxChopsPerCurve = 10;
30 static_assert((1 << kMaxChopsPerCurve) == GrPathUtils::kMaxPointsPerCurve);
31 return 1 << std::min(chopCount, kMaxChopsPerCurve);
32 }
33
scaleToleranceToSrc(SkScalar devTol,const SkMatrix & viewM,const SkRect & pathBounds)34 SkScalar GrPathUtils::scaleToleranceToSrc(SkScalar devTol,
35 const SkMatrix& viewM,
36 const SkRect& pathBounds) {
37 // In order to tesselate the path we get a bound on how much the matrix can
38 // scale when mapping to screen coordinates.
39 SkScalar stretch = viewM.getMaxScale();
40
41 if (stretch < 0) {
42 // take worst case mapRadius amoung four corners.
43 // (less than perfect)
44 for (int i = 0; i < 4; ++i) {
45 SkMatrix mat;
46 mat.setTranslate((i % 2) ? pathBounds.fLeft : pathBounds.fRight,
47 (i < 2) ? pathBounds.fTop : pathBounds.fBottom);
48 mat.postConcat(viewM);
49 stretch = std::max(stretch, mat.mapRadius(SK_Scalar1));
50 }
51 }
52 SkScalar srcTol = 0;
53 if (stretch <= 0) {
54 // We have degenerate bounds or some degenerate matrix. Thus we set the tolerance to be the
55 // max of the path pathBounds width and height.
56 srcTol = std::max(pathBounds.width(), pathBounds.height());
57 } else {
58 srcTol = devTol / stretch;
59 }
60 if (srcTol < kMinCurveTol) {
61 srcTol = kMinCurveTol;
62 }
63 return srcTol;
64 }
65
quadraticPointCount(const SkPoint points[],SkScalar tol)66 uint32_t GrPathUtils::quadraticPointCount(const SkPoint points[], SkScalar tol) {
67 return max_bezier_vertices(skgpu::wangs_formula::quadratic_log2(
68 tolerance_to_wangs_precision(tol), points));
69 }
70
generateQuadraticPoints(const SkPoint & p0,const SkPoint & p1,const SkPoint & p2,SkScalar tolSqd,SkPoint ** points,uint32_t pointsLeft)71 uint32_t GrPathUtils::generateQuadraticPoints(const SkPoint& p0,
72 const SkPoint& p1,
73 const SkPoint& p2,
74 SkScalar tolSqd,
75 SkPoint** points,
76 uint32_t pointsLeft) {
77 if (pointsLeft < 2 ||
78 (SkPointPriv::DistanceToLineSegmentBetweenSqd(p1, p0, p2)) < tolSqd) {
79 (*points)[0] = p2;
80 *points += 1;
81 return 1;
82 }
83
84 SkPoint q[] = {
85 { SkScalarAve(p0.fX, p1.fX), SkScalarAve(p0.fY, p1.fY) },
86 { SkScalarAve(p1.fX, p2.fX), SkScalarAve(p1.fY, p2.fY) },
87 };
88 SkPoint r = { SkScalarAve(q[0].fX, q[1].fX), SkScalarAve(q[0].fY, q[1].fY) };
89
90 pointsLeft >>= 1;
91 uint32_t a = generateQuadraticPoints(p0, q[0], r, tolSqd, points, pointsLeft);
92 uint32_t b = generateQuadraticPoints(r, q[1], p2, tolSqd, points, pointsLeft);
93 return a + b;
94 }
95
cubicPointCount(const SkPoint points[],SkScalar tol)96 uint32_t GrPathUtils::cubicPointCount(const SkPoint points[], SkScalar tol) {
97 return max_bezier_vertices(skgpu::wangs_formula::cubic_log2(
98 tolerance_to_wangs_precision(tol), points));
99 }
100
generateCubicPoints(const SkPoint & p0,const SkPoint & p1,const SkPoint & p2,const SkPoint & p3,SkScalar tolSqd,SkPoint ** points,uint32_t pointsLeft)101 uint32_t GrPathUtils::generateCubicPoints(const SkPoint& p0,
102 const SkPoint& p1,
103 const SkPoint& p2,
104 const SkPoint& p3,
105 SkScalar tolSqd,
106 SkPoint** points,
107 uint32_t pointsLeft) {
108 if (pointsLeft < 2 ||
109 (SkPointPriv::DistanceToLineSegmentBetweenSqd(p1, p0, p3) < tolSqd &&
110 SkPointPriv::DistanceToLineSegmentBetweenSqd(p2, p0, p3) < tolSqd)) {
111 (*points)[0] = p3;
112 *points += 1;
113 return 1;
114 }
115 SkPoint q[] = {
116 { SkScalarAve(p0.fX, p1.fX), SkScalarAve(p0.fY, p1.fY) },
117 { SkScalarAve(p1.fX, p2.fX), SkScalarAve(p1.fY, p2.fY) },
118 { SkScalarAve(p2.fX, p3.fX), SkScalarAve(p2.fY, p3.fY) }
119 };
120 SkPoint r[] = {
121 { SkScalarAve(q[0].fX, q[1].fX), SkScalarAve(q[0].fY, q[1].fY) },
122 { SkScalarAve(q[1].fX, q[2].fX), SkScalarAve(q[1].fY, q[2].fY) }
123 };
124 SkPoint s = { SkScalarAve(r[0].fX, r[1].fX), SkScalarAve(r[0].fY, r[1].fY) };
125 pointsLeft >>= 1;
126 uint32_t a = generateCubicPoints(p0, q[0], r[0], s, tolSqd, points, pointsLeft);
127 uint32_t b = generateCubicPoints(s, r[1], q[2], p3, tolSqd, points, pointsLeft);
128 return a + b;
129 }
130
set(const SkPoint qPts[3])131 void GrPathUtils::QuadUVMatrix::set(const SkPoint qPts[3]) {
132 // We want M such that M * xy_pt = uv_pt
133 // We know M * control_pts = [0 1/2 1]
134 // [0 0 1]
135 // [1 1 1]
136 // And control_pts = [x0 x1 x2]
137 // [y0 y1 y2]
138 // [1 1 1 ]
139 // We invert the control pt matrix and post concat to both sides to get M.
140 // Using the known form of the control point matrix and the result, we can
141 // optimize and improve precision.
142
143 double x0 = qPts[0].fX;
144 double y0 = qPts[0].fY;
145 double x1 = qPts[1].fX;
146 double y1 = qPts[1].fY;
147 double x2 = qPts[2].fX;
148 double y2 = qPts[2].fY;
149
150 // pre-calculate some adjugate matrix factors for determinant
151 double a2 = x1*y2-x2*y1;
152 double a5 = x2*y0-x0*y2;
153 double a8 = x0*y1-x1*y0;
154 double det = a2 + a5 + a8;
155
156 if (!sk_float_isfinite(det)
157 || SkScalarNearlyZero((float)det, SK_ScalarNearlyZero * SK_ScalarNearlyZero)) {
158 // The quad is degenerate. Hopefully this is rare. Find the pts that are
159 // farthest apart to compute a line (unless it is really a pt).
160 SkScalar maxD = SkPointPriv::DistanceToSqd(qPts[0], qPts[1]);
161 int maxEdge = 0;
162 SkScalar d = SkPointPriv::DistanceToSqd(qPts[1], qPts[2]);
163 if (d > maxD) {
164 maxD = d;
165 maxEdge = 1;
166 }
167 d = SkPointPriv::DistanceToSqd(qPts[2], qPts[0]);
168 if (d > maxD) {
169 maxD = d;
170 maxEdge = 2;
171 }
172 // We could have a tolerance here, not sure if it would improve anything
173 if (maxD > 0) {
174 // Set the matrix to give (u = 0, v = distance_to_line)
175 SkVector lineVec = qPts[(maxEdge + 1)%3] - qPts[maxEdge];
176 // when looking from the point 0 down the line we want positive
177 // distances to be to the left. This matches the non-degenerate
178 // case.
179 lineVec = SkPointPriv::MakeOrthog(lineVec, SkPointPriv::kLeft_Side);
180 // first row
181 fM[0] = 0;
182 fM[1] = 0;
183 fM[2] = 0;
184 // second row
185 fM[3] = lineVec.fX;
186 fM[4] = lineVec.fY;
187 fM[5] = -lineVec.dot(qPts[maxEdge]);
188 } else {
189 // It's a point. It should cover zero area. Just set the matrix such
190 // that (u, v) will always be far away from the quad.
191 fM[0] = 0; fM[1] = 0; fM[2] = 100.f;
192 fM[3] = 0; fM[4] = 0; fM[5] = 100.f;
193 }
194 } else {
195 double scale = 1.0/det;
196
197 // compute adjugate matrix
198 double a3, a4, a6, a7;
199 a3 = y2-y0;
200 a4 = x0-x2;
201
202 a6 = y0-y1;
203 a7 = x1-x0;
204
205 // this performs the uv_pts*adjugate(control_pts) multiply,
206 // then does the scale by 1/det afterwards to improve precision
207 fM[0] = (float)((0.5*a3 + a6)*scale);
208 fM[1] = (float)((0.5*a4 + a7)*scale);
209 fM[2] = (float)((0.5*a5 + a8)*scale);
210 fM[3] = (float)(a6*scale);
211 fM[4] = (float)(a7*scale);
212 fM[5] = (float)(a8*scale);
213 }
214 }
215
216 ////////////////////////////////////////////////////////////////////////////////
217
218 // k = (y2 - y0, x0 - x2, x2*y0 - x0*y2)
219 // l = (y1 - y0, x0 - x1, x1*y0 - x0*y1) * 2*w
220 // m = (y2 - y1, x1 - x2, x2*y1 - x1*y2) * 2*w
getConicKLM(const SkPoint p[3],const SkScalar weight,SkMatrix * out)221 void GrPathUtils::getConicKLM(const SkPoint p[3], const SkScalar weight, SkMatrix* out) {
222 SkMatrix& klm = *out;
223 const SkScalar w2 = 2.f * weight;
224 klm[0] = p[2].fY - p[0].fY;
225 klm[1] = p[0].fX - p[2].fX;
226 klm[2] = p[2].fX * p[0].fY - p[0].fX * p[2].fY;
227
228 klm[3] = w2 * (p[1].fY - p[0].fY);
229 klm[4] = w2 * (p[0].fX - p[1].fX);
230 klm[5] = w2 * (p[1].fX * p[0].fY - p[0].fX * p[1].fY);
231
232 klm[6] = w2 * (p[2].fY - p[1].fY);
233 klm[7] = w2 * (p[1].fX - p[2].fX);
234 klm[8] = w2 * (p[2].fX * p[1].fY - p[1].fX * p[2].fY);
235
236 // scale the max absolute value of coeffs to 10
237 SkScalar scale = 0.f;
238 for (int i = 0; i < 9; ++i) {
239 scale = std::max(scale, SkScalarAbs(klm[i]));
240 }
241 SkASSERT(scale > 0.f);
242 scale = 10.f / scale;
243 for (int i = 0; i < 9; ++i) {
244 klm[i] *= scale;
245 }
246 }
247
248 ////////////////////////////////////////////////////////////////////////////////
249
250 namespace {
251
252 // a is the first control point of the cubic.
253 // ab is the vector from a to the second control point.
254 // dc is the vector from the fourth to the third control point.
255 // d is the fourth control point.
256 // p is the candidate quadratic control point.
257 // this assumes that the cubic doesn't inflect and is simple
is_point_within_cubic_tangents(const SkPoint & a,const SkVector & ab,const SkVector & dc,const SkPoint & d,SkPathFirstDirection dir,const SkPoint p)258 bool is_point_within_cubic_tangents(const SkPoint& a,
259 const SkVector& ab,
260 const SkVector& dc,
261 const SkPoint& d,
262 SkPathFirstDirection dir,
263 const SkPoint p) {
264 SkVector ap = p - a;
265 SkScalar apXab = ap.cross(ab);
266 if (SkPathFirstDirection::kCW == dir) {
267 if (apXab > 0) {
268 return false;
269 }
270 } else {
271 SkASSERT(SkPathFirstDirection::kCCW == dir);
272 if (apXab < 0) {
273 return false;
274 }
275 }
276
277 SkVector dp = p - d;
278 SkScalar dpXdc = dp.cross(dc);
279 if (SkPathFirstDirection::kCW == dir) {
280 if (dpXdc < 0) {
281 return false;
282 }
283 } else {
284 SkASSERT(SkPathFirstDirection::kCCW == dir);
285 if (dpXdc > 0) {
286 return false;
287 }
288 }
289 return true;
290 }
291
convert_noninflect_cubic_to_quads(const SkPoint p[4],SkScalar toleranceSqd,SkTArray<SkPoint,true> * quads,int sublevel=0,bool preserveFirstTangent=true,bool preserveLastTangent=true)292 void convert_noninflect_cubic_to_quads(const SkPoint p[4],
293 SkScalar toleranceSqd,
294 SkTArray<SkPoint, true>* quads,
295 int sublevel = 0,
296 bool preserveFirstTangent = true,
297 bool preserveLastTangent = true) {
298 // Notation: Point a is always p[0]. Point b is p[1] unless p[1] == p[0], in which case it is
299 // p[2]. Point d is always p[3]. Point c is p[2] unless p[2] == p[3], in which case it is p[1].
300 SkVector ab = p[1] - p[0];
301 SkVector dc = p[2] - p[3];
302
303 if (SkPointPriv::LengthSqd(ab) < SK_ScalarNearlyZero) {
304 if (SkPointPriv::LengthSqd(dc) < SK_ScalarNearlyZero) {
305 SkPoint* degQuad = quads->push_back_n(3);
306 degQuad[0] = p[0];
307 degQuad[1] = p[0];
308 degQuad[2] = p[3];
309 return;
310 }
311 ab = p[2] - p[0];
312 }
313 if (SkPointPriv::LengthSqd(dc) < SK_ScalarNearlyZero) {
314 dc = p[1] - p[3];
315 }
316
317 static const SkScalar kLengthScale = 3 * SK_Scalar1 / 2;
318 static const int kMaxSubdivs = 10;
319
320 ab.scale(kLengthScale);
321 dc.scale(kLengthScale);
322
323 // c0 and c1 are extrapolations along vectors ab and dc.
324 SkPoint c0 = p[0] + ab;
325 SkPoint c1 = p[3] + dc;
326
327 SkScalar dSqd = sublevel > kMaxSubdivs ? 0 : SkPointPriv::DistanceToSqd(c0, c1);
328 if (dSqd < toleranceSqd) {
329 SkPoint newC;
330 if (preserveFirstTangent == preserveLastTangent) {
331 // We used to force a split when both tangents need to be preserved and c0 != c1.
332 // This introduced a large performance regression for tiny paths for no noticeable
333 // quality improvement. However, we aren't quite fulfilling our contract of guaranteeing
334 // the two tangent vectors and this could introduce a missed pixel in
335 // AAHairlinePathRenderer.
336 newC = (c0 + c1) * 0.5f;
337 } else if (preserveFirstTangent) {
338 newC = c0;
339 } else {
340 newC = c1;
341 }
342
343 SkPoint* pts = quads->push_back_n(3);
344 pts[0] = p[0];
345 pts[1] = newC;
346 pts[2] = p[3];
347 return;
348 }
349 SkPoint choppedPts[7];
350 SkChopCubicAtHalf(p, choppedPts);
351 convert_noninflect_cubic_to_quads(
352 choppedPts + 0, toleranceSqd, quads, sublevel + 1, preserveFirstTangent, false);
353 convert_noninflect_cubic_to_quads(
354 choppedPts + 3, toleranceSqd, quads, sublevel + 1, false, preserveLastTangent);
355 }
356
convert_noninflect_cubic_to_quads_with_constraint(const SkPoint p[4],SkScalar toleranceSqd,SkPathFirstDirection dir,SkTArray<SkPoint,true> * quads,int sublevel=0)357 void convert_noninflect_cubic_to_quads_with_constraint(const SkPoint p[4],
358 SkScalar toleranceSqd,
359 SkPathFirstDirection dir,
360 SkTArray<SkPoint, true>* quads,
361 int sublevel = 0) {
362 // Notation: Point a is always p[0]. Point b is p[1] unless p[1] == p[0], in which case it is
363 // p[2]. Point d is always p[3]. Point c is p[2] unless p[2] == p[3], in which case it is p[1].
364
365 SkVector ab = p[1] - p[0];
366 SkVector dc = p[2] - p[3];
367
368 if (SkPointPriv::LengthSqd(ab) < SK_ScalarNearlyZero) {
369 if (SkPointPriv::LengthSqd(dc) < SK_ScalarNearlyZero) {
370 SkPoint* degQuad = quads->push_back_n(3);
371 degQuad[0] = p[0];
372 degQuad[1] = p[0];
373 degQuad[2] = p[3];
374 return;
375 }
376 ab = p[2] - p[0];
377 }
378 if (SkPointPriv::LengthSqd(dc) < SK_ScalarNearlyZero) {
379 dc = p[1] - p[3];
380 }
381
382 // When the ab and cd tangents are degenerate or nearly parallel with vector from d to a the
383 // constraint that the quad point falls between the tangents becomes hard to enforce and we are
384 // likely to hit the max subdivision count. However, in this case the cubic is approaching a
385 // line and the accuracy of the quad point isn't so important. We check if the two middle cubic
386 // control points are very close to the baseline vector. If so then we just pick quadratic
387 // points on the control polygon.
388
389 SkVector da = p[0] - p[3];
390 bool doQuads = SkPointPriv::LengthSqd(dc) < SK_ScalarNearlyZero ||
391 SkPointPriv::LengthSqd(ab) < SK_ScalarNearlyZero;
392 if (!doQuads) {
393 SkScalar invDALengthSqd = SkPointPriv::LengthSqd(da);
394 if (invDALengthSqd > SK_ScalarNearlyZero) {
395 invDALengthSqd = SkScalarInvert(invDALengthSqd);
396 // cross(ab, da)^2/length(da)^2 == sqd distance from b to line from d to a.
397 // same goes for point c using vector cd.
398 SkScalar detABSqd = ab.cross(da);
399 detABSqd = SkScalarSquare(detABSqd);
400 SkScalar detDCSqd = dc.cross(da);
401 detDCSqd = SkScalarSquare(detDCSqd);
402 if (detABSqd * invDALengthSqd < toleranceSqd &&
403 detDCSqd * invDALengthSqd < toleranceSqd) {
404 doQuads = true;
405 }
406 }
407 }
408 if (doQuads) {
409 SkPoint b = p[0] + ab;
410 SkPoint c = p[3] + dc;
411 SkPoint mid = b + c;
412 mid.scale(SK_ScalarHalf);
413 // Insert two quadratics to cover the case when ab points away from d and/or dc
414 // points away from a.
415 if (SkVector::DotProduct(da, dc) < 0 || SkVector::DotProduct(ab, da) > 0) {
416 SkPoint* qpts = quads->push_back_n(6);
417 qpts[0] = p[0];
418 qpts[1] = b;
419 qpts[2] = mid;
420 qpts[3] = mid;
421 qpts[4] = c;
422 qpts[5] = p[3];
423 } else {
424 SkPoint* qpts = quads->push_back_n(3);
425 qpts[0] = p[0];
426 qpts[1] = mid;
427 qpts[2] = p[3];
428 }
429 return;
430 }
431
432 static const SkScalar kLengthScale = 3 * SK_Scalar1 / 2;
433 static const int kMaxSubdivs = 10;
434
435 ab.scale(kLengthScale);
436 dc.scale(kLengthScale);
437
438 // c0 and c1 are extrapolations along vectors ab and dc.
439 SkVector c0 = p[0] + ab;
440 SkVector c1 = p[3] + dc;
441
442 SkScalar dSqd = sublevel > kMaxSubdivs ? 0 : SkPointPriv::DistanceToSqd(c0, c1);
443 if (dSqd < toleranceSqd) {
444 SkPoint cAvg = (c0 + c1) * 0.5f;
445 bool subdivide = false;
446
447 if (!is_point_within_cubic_tangents(p[0], ab, dc, p[3], dir, cAvg)) {
448 // choose a new cAvg that is the intersection of the two tangent lines.
449 ab = SkPointPriv::MakeOrthog(ab);
450 SkScalar z0 = -ab.dot(p[0]);
451 dc = SkPointPriv::MakeOrthog(dc);
452 SkScalar z1 = -dc.dot(p[3]);
453 cAvg.fX = ab.fY * z1 - z0 * dc.fY;
454 cAvg.fY = z0 * dc.fX - ab.fX * z1;
455 SkScalar z = ab.fX * dc.fY - ab.fY * dc.fX;
456 z = SkScalarInvert(z);
457 cAvg.fX *= z;
458 cAvg.fY *= z;
459 if (sublevel <= kMaxSubdivs) {
460 SkScalar d0Sqd = SkPointPriv::DistanceToSqd(c0, cAvg);
461 SkScalar d1Sqd = SkPointPriv::DistanceToSqd(c1, cAvg);
462 // We need to subdivide if d0 + d1 > tolerance but we have the sqd values. We know
463 // the distances and tolerance can't be negative.
464 // (d0 + d1)^2 > toleranceSqd
465 // d0Sqd + 2*d0*d1 + d1Sqd > toleranceSqd
466 SkScalar d0d1 = SkScalarSqrt(d0Sqd * d1Sqd);
467 subdivide = 2 * d0d1 + d0Sqd + d1Sqd > toleranceSqd;
468 }
469 }
470 if (!subdivide) {
471 SkPoint* pts = quads->push_back_n(3);
472 pts[0] = p[0];
473 pts[1] = cAvg;
474 pts[2] = p[3];
475 return;
476 }
477 }
478 SkPoint choppedPts[7];
479 SkChopCubicAtHalf(p, choppedPts);
480 convert_noninflect_cubic_to_quads_with_constraint(
481 choppedPts + 0, toleranceSqd, dir, quads, sublevel + 1);
482 convert_noninflect_cubic_to_quads_with_constraint(
483 choppedPts + 3, toleranceSqd, dir, quads, sublevel + 1);
484 }
485 } // namespace
486
convertCubicToQuads(const SkPoint p[4],SkScalar tolScale,SkTArray<SkPoint,true> * quads)487 void GrPathUtils::convertCubicToQuads(const SkPoint p[4],
488 SkScalar tolScale,
489 SkTArray<SkPoint, true>* quads) {
490 if (!p[0].isFinite() || !p[1].isFinite() || !p[2].isFinite() || !p[3].isFinite()) {
491 return;
492 }
493 if (!SkScalarIsFinite(tolScale)) {
494 return;
495 }
496 SkPoint chopped[10];
497 int count = SkChopCubicAtInflections(p, chopped);
498
499 const SkScalar tolSqd = SkScalarSquare(tolScale);
500
501 for (int i = 0; i < count; ++i) {
502 SkPoint* cubic = chopped + 3*i;
503 convert_noninflect_cubic_to_quads(cubic, tolSqd, quads);
504 }
505 }
506
convertCubicToQuadsConstrainToTangents(const SkPoint p[4],SkScalar tolScale,SkPathFirstDirection dir,SkTArray<SkPoint,true> * quads)507 void GrPathUtils::convertCubicToQuadsConstrainToTangents(const SkPoint p[4],
508 SkScalar tolScale,
509 SkPathFirstDirection dir,
510 SkTArray<SkPoint, true>* quads) {
511 if (!p[0].isFinite() || !p[1].isFinite() || !p[2].isFinite() || !p[3].isFinite()) {
512 return;
513 }
514 if (!SkScalarIsFinite(tolScale)) {
515 return;
516 }
517 SkPoint chopped[10];
518 int count = SkChopCubicAtInflections(p, chopped);
519
520 const SkScalar tolSqd = SkScalarSquare(tolScale);
521
522 for (int i = 0; i < count; ++i) {
523 SkPoint* cubic = chopped + 3*i;
524 convert_noninflect_cubic_to_quads_with_constraint(cubic, tolSqd, dir, quads);
525 }
526 }
527