Apply fix from #3739 to quads and cubics as well
Fixes http://code.google.com/p/chromium/issues/detail?id=125249
Review URL: https://codereview.appspot.com/6137046
git-svn-id: http://skia.googlecode.com/svn/trunk@3786 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/core/SkPathMeasure.cpp b/src/core/SkPathMeasure.cpp
index 0d4dcd4..d09bf92 100644
--- a/src/core/SkPathMeasure.cpp
+++ b/src/core/SkPathMeasure.cpp
@@ -108,8 +108,12 @@
} else {
SkScalar d = SkPoint::Distance(pts[0], pts[2]);
SkASSERT(d >= 0);
- if (!SkScalarNearlyZero(d)) {
- distance += d;
+ if (SkScalarNearlyZero(d)) {
+ d = 0;
+ }
+ SkScalar prevD = distance;
+ distance += d;
+ if (distance > prevD) {
Segment* seg = fSegments.append();
seg->fDistance = distance;
seg->fPtIndex = ptIndex;
@@ -132,8 +136,12 @@
} else {
SkScalar d = SkPoint::Distance(pts[0], pts[3]);
SkASSERT(d >= 0);
- if (!SkScalarNearlyZero(d)) {
- distance += d;
+ if (SkScalarNearlyZero(d)) {
+ d = 0;
+ }
+ SkScalar prevD = distance;
+ distance += d;
+ if (distance > prevD) {
Segment* seg = fSegments.append();
seg->fDistance = distance;
seg->fPtIndex = ptIndex;
@@ -156,6 +164,8 @@
* 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).
+ *
+ * We do this check below, and in compute_quad_segs and compute_cubic_segs
*/
fSegments.reset();
bool done = false;