aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Stephen White <senorblanco@chromium.org>2018-06-28 09:36:49 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-06-28 14:07:47 +0000
commit3de40f8bee6db21e61ccabcb3f7130796c017a06 (patch)
treecbef03605d7d409b661e8fc22d65473af9934df6
parent82f1f744f89025b0fc1f2260035829ac0a45906b (diff)
GrTessellator: handle collinear final vertex.
If the last vertex in a contour is collinear with its neighbours, remove it (this edge case was missing). Otherwise, the simplify step may try to split it indefinitely. Bug: 851409 Change-Id: I7efa4e616cdc1508a73c7a9f3de9d3f571569af8 Reviewed-on: https://skia-review.googlesource.com/138106 Reviewed-by: Robert Phillips <robertphillips@google.com> Commit-Queue: Stephen White <senorblanco@chromium.org>
-rw-r--r--src/gpu/GrTessellator.cpp3
-rw-r--r--tests/TessellatingPathRendererTests.cpp12
2 files changed, 14 insertions, 1 deletions
diff --git a/src/gpu/GrTessellator.cpp b/src/gpu/GrTessellator.cpp
index d6a64cdd46..6cd54380e6 100644
--- a/src/gpu/GrTessellator.cpp
+++ b/src/gpu/GrTessellator.cpp
@@ -1279,13 +1279,14 @@ void sanitize_contours(VertexList* contours, int contourCnt, bool approximate) {
round(&v->fPoint);
}
Vertex* next = v->fNext;
+ Vertex* nextWrap = next ? next : contour->fHead;
if (coincident(prev->fPoint, v->fPoint)) {
LOG("vertex %g,%g coincident; removing\n", v->fPoint.fX, v->fPoint.fY);
contour->remove(v);
} else if (!v->fPoint.isFinite()) {
LOG("vertex %g,%g non-finite; removing\n", v->fPoint.fX, v->fPoint.fY);
contour->remove(v);
- } else if (next && Line(prev->fPoint, next->fPoint).dist(v->fPoint) == 0.0) {
+ } else if (Line(prev->fPoint, nextWrap->fPoint).dist(v->fPoint) == 0.0) {
LOG("vertex %g,%g collinear; removing\n", v->fPoint.fX, v->fPoint.fY);
contour->remove(v);
} else {
diff --git a/tests/TessellatingPathRendererTests.cpp b/tests/TessellatingPathRendererTests.cpp
index 0b30feecc0..a9913769df 100644
--- a/tests/TessellatingPathRendererTests.cpp
+++ b/tests/TessellatingPathRendererTests.cpp
@@ -560,6 +560,17 @@ static SkPath create_path_38() {
return path;
}
+// Reduction from crbug.com/851409.
+static SkPath create_path_39() {
+ SkPath path;
+ path.moveTo(2072553216, 0);
+ path.lineTo(2072553216, 1);
+ path.lineTo(2072553472, -13.5);
+ path.lineTo(2072553216, 0);
+ path.lineTo(2072553472, -6.5);
+ return path;
+}
+
static std::unique_ptr<GrFragmentProcessor> create_linear_gradient_processor(GrContext* ctx) {
SkPoint pts[2] = { {0, 0}, {1, 1} };
@@ -658,4 +669,5 @@ DEF_GPUTEST_FOR_ALL_CONTEXTS(TessellatingPathRendererTests, reporter, ctxInfo) {
test_path(ctx, rtc.get(), create_path_36());
test_path(ctx, rtc.get(), create_path_37());
test_path(ctx, rtc.get(), create_path_38(), SkMatrix(), GrAAType::kCoverage);
+ test_path(ctx, rtc.get(), create_path_39());
}