From de1837bb96b0f72dad7482786d6e577013d4a85b Mon Sep 17 00:00:00 2001 From: "reed@google.com" Date: Mon, 21 May 2012 16:47:43 +0000 Subject: [PATCH] remove bogus nearlyzero checks Review URL: https://codereview.appspot.com/6213060 git-svn-id: http://skia.googlecode.com/svn/trunk@4014 2bbb7eff-a529-9590-31e7-b0007b416f81 --- gm/dashing.cpp | 16 ++++++++++++++-- src/core/SkPathMeasure.cpp | 12 ++---------- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/gm/dashing.cpp b/gm/dashing.cpp index 2fdda4fae0..196b401495 100644 --- a/gm/dashing.cpp +++ b/gm/dashing.cpp @@ -10,7 +10,8 @@ #include "SkPaint.h" #include "SkDashPathEffect.h" -static void drawline(SkCanvas* canvas, int on, int off, const SkPaint& paint) { +static void drawline(SkCanvas* canvas, int on, int off, const SkPaint& paint, + SkScalar finalX = SkIntToScalar(600)) { SkPaint p(paint); const SkScalar intervals[] = { @@ -19,7 +20,16 @@ static void drawline(SkCanvas* canvas, int on, int off, const SkPaint& paint) { }; p.setPathEffect(new SkDashPathEffect(intervals, 2, 0))->unref(); - canvas->drawLine(0, 0, SkIntToScalar(600), 0, p); + canvas->drawLine(0, 0, finalX, 0, p); +} + +// earlier bug stopped us from drawing very long single-segment dashes, because +// SkPathMeasure was skipping very small delta-T values (nearlyzero). This is +// now fixes, so this giant dash should appear. +static void show_giant_dash(SkCanvas* canvas) { + SkPaint paint; + + drawline(canvas, 1, 1, paint, SkIntToScalar(20 * 1000)); } class DashingGM : public skiagm::GM { @@ -64,6 +74,8 @@ protected: } } } + + show_giant_dash(canvas); } }; diff --git a/src/core/SkPathMeasure.cpp b/src/core/SkPathMeasure.cpp index 887c0c18fb..b591aacb94 100644 --- a/src/core/SkPathMeasure.cpp +++ b/src/core/SkPathMeasure.cpp @@ -96,10 +96,6 @@ SkScalar SkPathMeasure::compute_quad_segs(const SkPoint pts[3], distance = this->compute_quad_segs(&tmp[2], distance, halft, maxt, ptIndex); } else { SkScalar d = SkPoint::Distance(pts[0], pts[2]); - SkASSERT(d >= 0); - if (SkScalarNearlyZero(d)) { - d = 0; - } SkScalar prevD = distance; distance += d; if (distance > prevD) { @@ -124,10 +120,6 @@ SkScalar SkPathMeasure::compute_cubic_segs(const SkPoint pts[4], distance = this->compute_cubic_segs(&tmp[3], distance, halft, maxt, ptIndex); } else { SkScalar d = SkPoint::Distance(pts[0], pts[3]); - SkASSERT(d >= 0); - if (SkScalarNearlyZero(d)) { - d = 0; - } SkScalar prevD = distance; distance += d; if (distance > prevD) { @@ -283,8 +275,8 @@ static void seg_to(const SkPoint pts[], int segType, SkASSERT(stopT >= 0 && stopT <= SK_Scalar1); SkASSERT(startT <= stopT); - if (SkScalarNearlyZero(stopT - startT)) { - return; + if (startT == stopT) { + return; // should we report this, to undo a moveTo? } SkPoint tmp0[7], tmp1[7]; -- 2.34.1