diff options
author | reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2012-04-20 15:10:32 +0000 |
---|---|---|
committer | reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2012-04-20 15:10:32 +0000 |
commit | fab1ddd3a8893db58b2ce0afd28ecc73412ee871 (patch) | |
tree | 7a3dfc4e59baf0e3e51507d3f48bc1cebfd71ca2 /src/core | |
parent | d6195f956fdccef865224520a624e3fd968573d0 (diff) |
only add pathmeasure segment if the accumulated length was actually changed,
and not based on if the local length was > 0. This is necessary since
assert(delta > 0); // true
prevDistance = distance;
distance += delta;
assert(distance > prevDistance); // not always true
Fixes https://bugs.webkit.org/show_bug.cgi?id=78979
git-svn-id: http://skia.googlecode.com/svn/trunk@3739 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/SkPathMeasure.cpp | 52 |
1 files changed, 33 insertions, 19 deletions
diff --git a/src/core/SkPathMeasure.cpp b/src/core/SkPathMeasure.cpp index 04d19c2ac5..0d4dcd4121 100644 --- a/src/core/SkPathMeasure.cpp +++ b/src/core/SkPathMeasure.cpp @@ -147,11 +147,16 @@ SkScalar SkPathMeasure::compute_cubic_segs(const SkPoint pts[4], void SkPathMeasure::buildSegments() { SkPoint pts[4]; int ptIndex = fFirstPtIndex; - SkScalar d, distance = 0; + SkScalar distance = 0; bool isClosed = fForceClosed; bool firstMoveTo = ptIndex < 0; Segment* seg; + /* Note: + * as we accumulate distance, we have to check that the result of += + * actually made it larger, since a very small delta might be > 0, but + * still have no effect on distance (if distance >>> delta). + */ fSegments.reset(); bool done = false; do { @@ -166,32 +171,41 @@ void SkPathMeasure::buildSegments() { firstMoveTo = false; break; - case SkPath::kLine_Verb: - d = SkPoint::Distance(pts[0], pts[1]); + case SkPath::kLine_Verb: { + SkScalar d = SkPoint::Distance(pts[0], pts[1]); SkASSERT(d >= 0); + SkScalar prevD = distance; distance += d; - seg = fSegments.append(); - seg->fDistance = distance; - seg->fPtIndex = ptIndex; - seg->fType = kLine_SegType; - seg->fTValue = kMaxTValue; - fPts.append(1, pts + 1); - ptIndex++; - break; + if (distance > prevD) { + seg = fSegments.append(); + seg->fDistance = distance; + seg->fPtIndex = ptIndex; + seg->fType = kLine_SegType; + seg->fTValue = kMaxTValue; + fPts.append(1, pts + 1); + ptIndex++; + } + } break; - case SkPath::kQuad_Verb: + case SkPath::kQuad_Verb: { + SkScalar prevD = distance; distance = this->compute_quad_segs(pts, distance, 0, kMaxTValue, ptIndex); - fPts.append(2, pts + 1); - ptIndex += 2; - break; + if (distance > prevD) { + fPts.append(2, pts + 1); + ptIndex += 2; + } + } break; - case SkPath::kCubic_Verb: + case SkPath::kCubic_Verb: { + SkScalar prevD = distance; distance = this->compute_cubic_segs(pts, distance, 0, kMaxTValue, ptIndex); - fPts.append(3, pts + 1); - ptIndex += 3; - break; + if (distance > prevD) { + fPts.append(3, pts + 1); + ptIndex += 3; + } + } break; case SkPath::kClose_Verb: isClosed = true; |