void Path::apply(void* info, PathApplierFunction function) const { SkPath::Iter iter(*m_path, false); SkPoint pts[4]; PathElement pathElement; FloatPoint pathPoints[3]; for (;;) { switch (iter.next(pts)) { case SkPath::kMove_Verb: pathElement.type = PathElementMoveToPoint; pathElement.points = convertPathPoints(pathPoints, &pts[0], 1); break; case SkPath::kLine_Verb: pathElement.type = PathElementAddLineToPoint; pathElement.points = convertPathPoints(pathPoints, &pts[1], 1); break; case SkPath::kQuad_Verb: pathElement.type = PathElementAddQuadCurveToPoint; pathElement.points = convertPathPoints(pathPoints, &pts[1], 2); break; case SkPath::kCubic_Verb: pathElement.type = PathElementAddCurveToPoint; pathElement.points = convertPathPoints(pathPoints, &pts[1], 3); break; case SkPath::kClose_Verb: pathElement.type = PathElementCloseSubpath; pathElement.points = convertPathPoints(pathPoints, 0, 0); break; case SkPath::kDone_Verb: return; } function(info, &pathElement); } }
void Path::apply(void* info, PathApplierFunction function) const { SkPath::RawIter iter(m_path); SkPoint pts[4]; PathElement pathElement; FloatPoint pathPoints[3]; for (;;) { switch (iter.next(pts)) { case SkPath::kMove_Verb: pathElement.type = PathElementMoveToPoint; pathElement.points = convertPathPoints(pathPoints, &pts[0], 1); break; case SkPath::kLine_Verb: pathElement.type = PathElementAddLineToPoint; pathElement.points = convertPathPoints(pathPoints, &pts[1], 1); break; case SkPath::kQuad_Verb: pathElement.type = PathElementAddQuadCurveToPoint; pathElement.points = convertPathPoints(pathPoints, &pts[1], 2); break; case SkPath::kCubic_Verb: pathElement.type = PathElementAddCurveToPoint; pathElement.points = convertPathPoints(pathPoints, &pts[1], 3); break; case SkPath::kClose_Verb: pathElement.type = PathElementCloseSubpath; pathElement.points = convertPathPoints(pathPoints, 0, 0); break; case SkPath::kDone_Verb: return; default: // place-holder for kConic_Verb, when that lands from skia break; } function(info, &pathElement); } }
void Path::apply(void* info, PathApplierFunction function) const { SkPath::RawIter iter(m_path); SkPoint pts[4]; PathElement pathElement; FloatPoint pathPoints[3]; for (;;) { switch (iter.next(pts)) { case SkPath::kMove_Verb: pathElement.type = PathElementMoveToPoint; pathElement.points = convertPathPoints(pathPoints, &pts[0], 1); break; case SkPath::kLine_Verb: pathElement.type = PathElementAddLineToPoint; pathElement.points = convertPathPoints(pathPoints, &pts[1], 1); break; case SkPath::kQuad_Verb: pathElement.type = PathElementAddQuadCurveToPoint; pathElement.points = convertPathPoints(pathPoints, &pts[1], 2); break; case SkPath::kCubic_Verb: pathElement.type = PathElementAddCurveToPoint; pathElement.points = convertPathPoints(pathPoints, &pts[1], 3); break; case SkPath::kConic_Verb: { // Approximate with quads. Use two for now, increase if more precision // is needed. const int kPow2 = 1; const unsigned quadCount = 1 << kPow2; SkPoint quads[1 + 2 * quadCount]; SkPath::ConvertConicToQuads(pts[0], pts[1], pts[2], iter.conicWeight(), quads, kPow2); pathElement.type = PathElementAddQuadCurveToPoint; for (unsigned i = 0; i < quadCount; ++i) { pathElement.points = convertPathPoints(pathPoints, &quads[1 + 2 * i], 2); function(info, &pathElement); } continue; } case SkPath::kClose_Verb: pathElement.type = PathElementCloseSubpath; pathElement.points = convertPathPoints(pathPoints, 0, 0); break; case SkPath::kDone_Verb: return; } function(info, &pathElement); } }