static void add_quad(SkPoint pts[3], PLSVertices& vertices) { SkPoint normal = SkPoint::Make(pts[0].fY - pts[2].fY, pts[2].fX - pts[0].fX); normal.setLength(kBloatSize); SkScalar cross = (pts[1] - pts[0]).cross(pts[2] - pts[0]); if (cross < 0) { normal = -normal; } PLSVertex quad[kQuadNumVertices]; quad[0].fPos = pts[0] + normal; quad[1].fPos = pts[0] - normal; quad[2].fPos = pts[1] - normal; quad[3].fPos = pts[2] - normal; quad[4].fPos = pts[2] + normal; for (int i = 0; i < kQuadNumVertices; i++) { quad[i].fWinding = cross < 0 ? 1 : -1; if (cross > 0.0) { quad[i].fVert2 = pts[0]; quad[i].fVert3 = pts[2]; } else { quad[i].fVert2 = pts[2]; quad[i].fVert3 = pts[0]; } } GrPathUtils::QuadUVMatrix DevToUV(pts); DevToUV.apply<kQuadNumVertices, sizeof(PLSVertex), sizeof(SkPoint)>(quad); for (int i = 2; i < kQuadNumVertices; i++) { vertices.push_back(quad[0]); vertices.push_back(quad[i - 1]); vertices.push_back(quad[i]); } }
/* Used by bloat_tri; outsets a single point. */ static bool outset(SkPoint* p1, SkPoint line1, SkPoint line2) { // rotate the two line vectors 90 degrees to form the normals, and compute // the dot product of the normals SkScalar dotProd = line1.fY * line2.fY + line1.fX * line2.fX; SkScalar lengthSq = 1.0f / ((1.0f - dotProd) / 2.0f); if (lengthSq > kBloatLimit) { return false; } SkPoint bisector = line1 + line2; bisector.setLength(SkScalarSqrt(lengthSq) * kBloatSize); *p1 += bisector; return true; }