aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoregdaniel <egdaniel@google.com>2014-11-05 05:02:27 -0800
committerCommit bot <commit-bot@chromium.org>2014-11-05 05:02:27 -0800
commit21402e3851454e90329bad52893f29959da086f7 (patch)
tree06923683a74242ca885cf1c667974ea7fd1260db
parent9f2251c73ed6f417dd1057d487bf523e04488440 (diff)
downloadskia-21402e3851454e90329bad52893f29959da086f7.tar.gz
Bug fix for cull_line in SkDashPathEffect.
In cull_line we must also check if both points are the same. Otherwise we fail the assert in the else "SkASSERT(dy && !dx)". This is currently blocking the roll as it fails a webkit test. BUG=skia: Review URL: https://codereview.chromium.org/703783002
-rw-r--r--expectations/gm/ignored-tests.txt3
-rw-r--r--gm/dashing.cpp12
-rw-r--r--src/effects/SkDashPathEffect.cpp2
-rw-r--r--src/utils/SkDashPath.cpp2
4 files changed, 17 insertions, 2 deletions
diff --git a/expectations/gm/ignored-tests.txt b/expectations/gm/ignored-tests.txt
index 785194e00..a781c4d8f 100644
--- a/expectations/gm/ignored-tests.txt
+++ b/expectations/gm/ignored-tests.txt
@@ -73,3 +73,6 @@ polygons
pathopsinverse
rects
+#edgdaniel https://codereview.chromium.org/703783002/
+dashing
+
diff --git a/gm/dashing.cpp b/gm/dashing.cpp
index d6c1c97df..7e32bfaf9 100644
--- a/gm/dashing.cpp
+++ b/gm/dashing.cpp
@@ -34,6 +34,16 @@ static void show_giant_dash(SkCanvas* canvas) {
drawline(canvas, 1, 1, paint, SkIntToScalar(20 * 1000));
}
+static void show_zero_len_dash(SkCanvas* canvas) {
+ SkPaint paint;
+
+ drawline(canvas, 2, 2, paint, SkIntToScalar(0));
+ paint.setStyle(SkPaint::kStroke_Style);
+ paint.setStrokeWidth(SkIntToScalar(2));
+ canvas->translate(0, SkIntToScalar(20));
+ drawline(canvas, 4, 4, paint, SkIntToScalar(0));
+}
+
class DashingGM : public skiagm::GM {
public:
DashingGM() {}
@@ -81,6 +91,8 @@ protected:
}
show_giant_dash(canvas);
+ canvas->translate(0, SkIntToScalar(20));
+ show_zero_len_dash(canvas);
}
};
diff --git a/src/effects/SkDashPathEffect.cpp b/src/effects/SkDashPathEffect.cpp
index a05306619..412965e88 100644
--- a/src/effects/SkDashPathEffect.cpp
+++ b/src/effects/SkDashPathEffect.cpp
@@ -66,7 +66,7 @@ static bool cull_line(SkPoint* pts, const SkStrokeRec& rec,
SkScalar dx = pts[1].x() - pts[0].x();
SkScalar dy = pts[1].y() - pts[0].y();
- if (dx && dy) {
+ if ((dx && dy) || (!dx && !dy)) {
return false;
}
diff --git a/src/utils/SkDashPath.cpp b/src/utils/SkDashPath.cpp
index 02de98f1d..4b2b33d2c 100644
--- a/src/utils/SkDashPath.cpp
+++ b/src/utils/SkDashPath.cpp
@@ -119,7 +119,7 @@ static bool cull_path(const SkPath& srcPath, const SkStrokeRec& rec,
SkTSwap(minX, maxX);
}
- SkASSERT(minX < maxX);
+ SkASSERT(minX <= maxX);
if (maxX < bounds.fLeft || minX > bounds.fRight) {
return false;
}