From ea49523b5f47fb795a9d65bc5b88229089b75dc7 Mon Sep 17 00:00:00 2001 From: Stephen White Date: Tue, 3 Apr 2018 11:28:15 -0400 Subject: [PATCH] GrTessellator: fix for points that become infinite on stroking. stroke -> Inf -> NaN -> assert. BUG=skia:7775 Change-Id: I086883bce90d1d473cff87f67e954718ea3181f6 Reviewed-on: https://skia-review.googlesource.com/118145 Commit-Queue: Stephen White Reviewed-by: Robert Phillips --- src/gpu/GrTessellator.cpp | 4 ++++ tests/TessellatingPathRendererTests.cpp | 13 +++++++++++++ 2 files changed, 17 insertions(+) diff --git a/src/gpu/GrTessellator.cpp b/src/gpu/GrTessellator.cpp index b8ec6551c9..5136f23c42 100644 --- a/src/gpu/GrTessellator.cpp +++ b/src/gpu/GrTessellator.cpp @@ -2015,6 +2015,10 @@ void stroke_boundary(EdgeList* boundary, VertexList* innerMesh, VertexList* oute } innerPoint1 = innerPoint2 = innerPoint; } + if (!innerPoint1.isFinite() || !innerPoint2.isFinite() || + !outerPoint1.isFinite() || !outerPoint2.isFinite()) { + continue; + } LOG("inner (%g, %g), (%g, %g), ", innerPoint1.fX, innerPoint1.fY, innerPoint2.fX, innerPoint2.fY); LOG("outer (%g, %g), (%g, %g)\n", diff --git a/tests/TessellatingPathRendererTests.cpp b/tests/TessellatingPathRendererTests.cpp index 035b3fe323..8fefc9b56e 100644 --- a/tests/TessellatingPathRendererTests.cpp +++ b/tests/TessellatingPathRendererTests.cpp @@ -460,6 +460,18 @@ static SkPath create_path_30() { return path; } +// A path with vertices which become infinite on AA stroking. Should not crash or assert. +static SkPath create_path_31() { + SkPath path; + path.moveTo(2.0257809259190991347e+36, -1244080640); + path.conicTo(2.0257809259190991347e+36, -1244080640, + 2.0257809259190991347e+36, 0.10976474732160568237, 0.70710676908493041992); + path.lineTo(-10036566016, -1954718402215936); + path.conicTo(-1.1375507718551896064e+20, -1954721086570496, + 10036566016, -1954721086570496, 0.70710676908493041992); + return path; +} + static std::unique_ptr create_linear_gradient_processor(GrContext* ctx) { SkPoint pts[2] = { {0, 0}, {1, 1} }; @@ -551,5 +563,6 @@ DEF_GPUTEST_FOR_ALL_CONTEXTS(TessellatingPathRendererTests, reporter, ctxInfo) { test_path(ctx, rtc.get(), create_path_28(), SkMatrix(), GrAAType::kCoverage); test_path(ctx, rtc.get(), create_path_29()); test_path(ctx, rtc.get(), create_path_30()); + test_path(ctx, rtc.get(), create_path_31(), SkMatrix(), GrAAType::kCoverage); } #endif