Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(985)

Unified Diff: src/utils/SkCurveMeasure.cpp

Issue 2229403004: Fastpath lines in SkCurveMeasure (Closed) Base URL: https://skia.googlesource.com/skia.git@curvemeasure_use_geometry
Patch Set: Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698