aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/SkPathMeasure.cpp
diff options
context:
space:
mode:
authorGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-05-17 15:31:43 +0000
committerGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-05-17 15:31:43 +0000
commit5b94153a7b039a9269a8aabbe8f0da0e878e3978 (patch)
treebcbfe07821be1829145e921fc955ffb19d0c9762 /src/core/SkPathMeasure.cpp
parente8fcb5017cfcaf5b02d8a11e62073d6903aa02a5 (diff)
minor cleanups, in prep for more work on improving precision
git-svn-id: http://skia.googlecode.com/svn/trunk@3993 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/core/SkPathMeasure.cpp')
-rw-r--r--src/core/SkPathMeasure.cpp34
1 files changed, 10 insertions, 24 deletions
diff --git a/src/core/SkPathMeasure.cpp b/src/core/SkPathMeasure.cpp
index d09bf92c5c..887c0c18fb 100644
--- a/src/core/SkPathMeasure.cpp
+++ b/src/core/SkPathMeasure.cpp
@@ -51,17 +51,6 @@ static inline int tspan_big_enough(int tspan) {
return tspan >> 10;
}
-#if 0
-static inline bool tangents_too_curvy(const SkVector& tan0, SkVector& tan1) {
- static const SkScalar kFlatEnoughTangentDotProd = SK_Scalar1 * 99 / 100;
-
- SkASSERT(kFlatEnoughTangentDotProd > 0 &&
- kFlatEnoughTangentDotProd < SK_Scalar1);
-
- return SkPoint::DotProduct(tan0, tan1) < kFlatEnoughTangentDotProd;
-}
-#endif
-
// can't use tangents, since we need [0..1..................2] to be seen
// as definitely not a line (it is when drawn, but not parametrically)
// so we compare midpoints
@@ -259,15 +248,13 @@ void SkPathMeasure::buildSegments() {
#endif
}
-static void compute_pos_tan(const SkTDArray<SkPoint>& segmentPts, int ptIndex,
- int segType, SkScalar t, SkPoint* pos, SkVector* tangent) {
- const SkPoint* pts = &segmentPts[ptIndex];
-
+static void compute_pos_tan(const SkPoint pts[], int segType,
+ SkScalar t, SkPoint* pos, SkVector* tangent) {
switch (segType) {
case kLine_SegType:
if (pos) {
pos->set(SkScalarInterp(pts[0].fX, pts[1].fX, t),
- SkScalarInterp(pts[0].fY, pts[1].fY, t));
+ SkScalarInterp(pts[0].fY, pts[1].fY, t));
}
if (tangent) {
tangent->setNormalize(pts[1].fX - pts[0].fX, pts[1].fY - pts[0].fY);
@@ -290,8 +277,8 @@ static void compute_pos_tan(const SkTDArray<SkPoint>& segmentPts, int ptIndex,
}
}
-static void seg_to(const SkTDArray<SkPoint>& segmentPts, int ptIndex,
- int segType, SkScalar startT, SkScalar stopT, SkPath* dst) {
+static void seg_to(const SkPoint pts[], int segType,
+ SkScalar startT, SkScalar stopT, SkPath* dst) {
SkASSERT(startT >= 0 && startT <= SK_Scalar1);
SkASSERT(stopT >= 0 && stopT <= SK_Scalar1);
SkASSERT(startT <= stopT);
@@ -300,7 +287,6 @@ static void seg_to(const SkTDArray<SkPoint>& segmentPts, int ptIndex,
return;
}
- const SkPoint* pts = &segmentPts[ptIndex];
SkPoint tmp0[7], tmp1[7];
switch (segType) {
@@ -462,7 +448,7 @@ bool SkPathMeasure::getPosTan(SkScalar distance, SkPoint* pos,
SkScalar t;
const Segment* seg = this->distanceToSegment(distance, &t);
- compute_pos_tan(fPts, seg->fPtIndex, seg->fType, t, pos, tangent);
+ compute_pos_tan(&fPts[seg->fPtIndex], seg->fType, t, pos, tangent);
return true;
}
@@ -510,19 +496,19 @@ bool SkPathMeasure::getSegment(SkScalar startD, SkScalar stopD, SkPath* dst,
SkASSERT(seg <= stopSeg);
if (startWithMoveTo) {
- compute_pos_tan(fPts, seg->fPtIndex, seg->fType, startT, &p, NULL);
+ compute_pos_tan(&fPts[seg->fPtIndex], seg->fType, startT, &p, NULL);
dst->moveTo(p);
}
if (seg->fPtIndex == stopSeg->fPtIndex) {
- seg_to(fPts, seg->fPtIndex, seg->fType, startT, stopT, dst);
+ seg_to(&fPts[seg->fPtIndex], seg->fType, startT, stopT, dst);
} else {
do {
- seg_to(fPts, seg->fPtIndex, seg->fType, startT, SK_Scalar1, dst);
+ seg_to(&fPts[seg->fPtIndex], seg->fType, startT, SK_Scalar1, dst);
seg = SkPathMeasure::NextSegment(seg);
startT = 0;
} while (seg->fPtIndex < stopSeg->fPtIndex);
- seg_to(fPts, seg->fPtIndex, seg->fType, 0, stopT, dst);
+ seg_to(&fPts[seg->fPtIndex], seg->fType, 0, stopT, dst);
}
return true;
}