diff --git a/gm/concavepaths.cpp b/gm/concavepaths.cpp index c371615f2f..890f6c0855 100644 --- a/gm/concavepaths.cpp +++ b/gm/concavepaths.cpp @@ -62,6 +62,40 @@ void test_fake_bowtie(SkCanvas* canvas, const SkPaint& paint) { canvas->restore(); } +// Bowtie with a smaller right hand lobe. The outer vertex of the left hand +// lobe intrudes into the interior of the right hand lobe. +void test_intruding_vertex(SkCanvas* canvas, const SkPaint& paint) { + SkPath path; + canvas->save(); + canvas->translate(400, 0); + path.setIsVolatile(true); + path.moveTo(20, 20); + path.lineTo(50, 50); + path.lineTo(68, 20); + path.lineTo(68, 80); + path.lineTo(50, 50); + path.lineTo(20, 80); + canvas->drawPath(path, paint); + canvas->restore(); +} + +// A shape with an edge that becomes inverted on AA stroking and that also contains +// a repeated start/end vertex. +void test_inversion_repeat_vertex(SkCanvas* canvas, const SkPaint& paint) { + SkPath path; + canvas->save(); + canvas->translate(400, 100); + path.setIsVolatile(true); + path.moveTo(80, 50); + path.lineTo(40, 80); + path.lineTo(60, 20); + path.lineTo(20, 20); + path.lineTo(39.99f, 80); + path.lineTo(80, 50); + canvas->drawPath(path, paint); + canvas->restore(); +} + // Fish test (intersection/concave) void test_fish(SkCanvas* canvas, const SkPaint& paint) { SkPath path; @@ -360,7 +394,7 @@ void test_coincident_edges_4(SkCanvas* canvas, const SkPaint& paint) { }; -DEF_SIMPLE_GM(concavepaths, canvas, 400, 600) { +DEF_SIMPLE_GM(concavepaths, canvas, 500, 600) { SkPaint paint; paint.setAntiAlias(true); @@ -370,10 +404,12 @@ DEF_SIMPLE_GM(concavepaths, canvas, 400, 600) { test_reverse_concave(canvas, paint); test_bowtie(canvas, paint); test_fake_bowtie(canvas, paint); + test_intruding_vertex(canvas, paint); test_fish(canvas, paint); test_fast_forward(canvas, paint); test_hole(canvas, paint); test_star(canvas, paint); + test_inversion_repeat_vertex(canvas, paint); test_stairstep(canvas, paint); test_stairstep2(canvas, paint); test_overlapping(canvas, paint); diff --git a/src/gpu/GrTessellator.cpp b/src/gpu/GrTessellator.cpp index 2d844f6448..22ce864197 100644 --- a/src/gpu/GrTessellator.cpp +++ b/src/gpu/GrTessellator.cpp @@ -1149,6 +1149,9 @@ Vertex* check_for_intersection(Edge* edge, Edge* other, EdgeList* activeEdges, C void sanitize_contours(Vertex** contours, int contourCnt, bool approximate) { for (int i = 0; i < contourCnt; ++i) { SkASSERT(contours[i]); + if (approximate) { + round(&contours[i]->fPrev->fPoint); + } for (Vertex* v = contours[i];;) { if (approximate) { round(&v->fPoint); @@ -1162,7 +1165,7 @@ void sanitize_contours(Vertex** contours, int contourCnt, bool approximate) { v->fPrev->fNext = v->fNext; v->fNext->fPrev = v->fPrev; if (contours[i] == v) { - contours[i] = v->fNext; + contours[i] = v->fPrev; } v = v->fPrev; } else {