ArcLengthIntegrator::ArcLengthIntegrator(const SkPoint* pts, SkSegType segType) : fSegType(segType) { switch (fSegType) { case kQuad_SegType: { float Ax = pts[0].x(); float Bx = pts[1].x(); float Cx = pts[2].x(); float Ay = pts[0].y(); float By = pts[1].y(); float Cy = pts[2].y(); // precompute coefficients for derivative Sk8f(2*(Ax - 2*Bx + Cx)).store(&xCoeff[0]); Sk8f(2*(Bx - Ax)).store(&xCoeff[1]); Sk8f(2*(Ay - 2*By + Cy)).store(&yCoeff[0]); Sk8f(2*(By - Ay)).store(&yCoeff[1]); } break; case kCubic_SegType: { float Ax = pts[0].x(); float Bx = pts[1].x(); float Cx = pts[2].x(); float Dx = pts[3].x(); float Ay = pts[0].y(); float By = pts[1].y(); float Cy = pts[2].y(); float Dy = pts[3].y(); // precompute coefficients for derivative Sk8f(3*(-Ax + 3*(Bx - Cx) + Dx)).store(&xCoeff[0]); Sk8f(6*(Ax - 2*Bx + Cx)).store(&xCoeff[1]); Sk8f(3*(-Ax + Bx)).store(&xCoeff[2]); Sk8f(3*(-Ay + 3*(By - Cy) + Dy)).store(&yCoeff[0]); Sk8f(6*(Ay - 2*By + Cy)).store(&yCoeff[1]); Sk8f(3*(-Ay + By)).store(&yCoeff[2]); } break; case kConic_SegType: UNIMPLEMENTED; break; default: UNIMPLEMENTED; } }
ArcLengthIntegrator::ArcLengthIntegrator(const SkPoint* pts, SkSegType segType) : fSegType(segType) { switch (fSegType) { case kQuad_SegType: { float Ax = pts[0].x(); float Bx = pts[1].x(); float Cx = pts[2].x(); float Ay = pts[0].y(); float By = pts[1].y(); float Cy = pts[2].y(); // precompute coefficients for derivative xCoeff[0] = Sk8f(2.0f*(Ax - 2*Bx + Cx)); xCoeff[1] = Sk8f(2.0f*(Bx - Ax)); yCoeff[0] = Sk8f(2.0f*(Ay - 2*By + Cy)); yCoeff[1] = Sk8f(2.0f*(By - Ay)); } break; case kLine_SegType: { // the length of the derivative of a line is constant // we put in in both coeff arrays for consistency's sake SkScalar length = (pts[1] - pts[0]).length(); xCoeff[0] = Sk8f(length); yCoeff[0] = Sk8f(length); } break; case kCubic_SegType: { float Ax = pts[0].x(); float Bx = pts[1].x(); float Cx = pts[2].x(); float Dx = pts[3].x(); float Ay = pts[0].y(); float By = pts[1].y(); float Cy = pts[2].y(); float Dy = pts[3].y(); // precompute coefficients for derivative xCoeff[0] = Sk8f(3.0f*(-Ax + 3.0f*(Bx - Cx) + Dx)); xCoeff[1] = Sk8f(3.0f*(2.0f*(Ax - 2.0f*Bx + Cx))); xCoeff[2] = Sk8f(3.0f*(-Ax + Bx)); yCoeff[0] = Sk8f(3.0f*(-Ay + 3.0f*(By - Cy) + Dy)); yCoeff[1] = Sk8f(3.0f * -Ay + By + 2.0f*(Ay - 2.0f*By + Cy)); yCoeff[2] = Sk8f(3.0f*(-Ay + By)); } break; case kConic_SegType: UNIMPLEMENTED; break; default: UNIMPLEMENTED; } }