| Index: src/utils/SkCurveMeasure.cpp
|
| diff --git a/src/utils/SkCurveMeasure.cpp b/src/utils/SkCurveMeasure.cpp
|
| index 823f56adcff9388f8e7f82980afee91bfa1c2e5d..2a74a49c22e6fd41d1541bdcbe3ad1b37422285a 100644
|
| --- a/src/utils/SkCurveMeasure.cpp
|
| +++ b/src/utils/SkCurveMeasure.cpp
|
| @@ -77,10 +77,6 @@ static inline Sk8f evaluateDerivativeLength(const Sk8f& ts,
|
| x = xCoeff[0]*ts + xCoeff[1];
|
| y = yCoeff[0]*ts + yCoeff[1];
|
| break;
|
| - case kLine_SegType:
|
| - // length of line derivative is constant
|
| - // and we precompute it in the constructor
|
| - return xCoeff[0];
|
| case kCubic_SegType:
|
| x = (xCoeff[0]*ts + xCoeff[1])*ts + xCoeff[2];
|
| y = (yCoeff[0]*ts + yCoeff[1])*ts + yCoeff[2];
|
| @@ -117,14 +113,6 @@ ArcLengthIntegrator::ArcLengthIntegrator(const SkPoint* pts, SkSegType segType)
|
| 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();
|
| @@ -183,6 +171,7 @@ SkCurveMeasure::SkCurveMeasure(const SkPoint* pts, SkSegType segType)
|
| case SkSegType::kLine_SegType:
|
| fPts[0] = pts[0];
|
| fPts[1] = pts[1];
|
| + fLength = (fPts[1] - fPts[0]).length();
|
| break;
|
| case SkSegType::kCubic_SegType:
|
| for (size_t i = 0; i < 4; i++) {
|
| @@ -198,7 +187,9 @@ SkCurveMeasure::SkCurveMeasure(const SkPoint* pts, SkSegType segType)
|
| UNIMPLEMENTED;
|
| break;
|
| }
|
| - fIntegrator = ArcLengthIntegrator(fPts, fSegType);
|
| + if (kLine_SegType != segType) {
|
| + fIntegrator = ArcLengthIntegrator(fPts, fSegType);
|
| + }
|
| }
|
|
|
| SkScalar SkCurveMeasure::getLength() {
|
| @@ -227,6 +218,9 @@ SkScalar SkCurveMeasure::getTime(SkScalar targetLength) {
|
| if (SkScalarNearlyEqual(targetLength, currentLength)) {
|
| return 1.0f;
|
| }
|
| + if (kLine_SegType == fSegType) {
|
| + return targetLength / currentLength;
|
| + }
|
|
|
| // initial estimate of t is percentage of total length
|
| SkScalar currentT = targetLength / currentLength;
|
|
|