diff options
-rw-r--r-- | src/effects/gradients/SkGradientShader.cpp | 2 | ||||
-rw-r--r-- | tests/GradientTest.cpp | 17 |
2 files changed, 18 insertions, 1 deletions
diff --git a/src/effects/gradients/SkGradientShader.cpp b/src/effects/gradients/SkGradientShader.cpp index 710bde826e..820c5b225d 100644 --- a/src/effects/gradients/SkGradientShader.cpp +++ b/src/effects/gradients/SkGradientShader.cpp @@ -790,7 +790,7 @@ sk_sp<SkShader> SkGradientShader::MakeLinear(const SkPoint pts[2], SkShader::TileMode mode, uint32_t flags, const SkMatrix* localMatrix) { - if (!pts) { + if (!pts || !SkScalarIsFinite((pts[1] - pts[0]).length())) { return nullptr; } if (!valid_grad(colors, pos, colorCount, mode)) { diff --git a/tests/GradientTest.cpp b/tests/GradientTest.cpp index 7add42d875..3ed2f518cc 100644 --- a/tests/GradientTest.cpp +++ b/tests/GradientTest.cpp @@ -253,6 +253,22 @@ static void test_clamping_overflow(skiatest::Reporter*) { // Passes if we don't trigger asserts. } +// http://crbug.com/636194 +static void text_degenerate_linear(skiatest::Reporter*) { + SkPaint p; + const SkColor colors[] = { SK_ColorRED, SK_ColorGREEN }; + const SkPoint pts[] = { + SkPoint::Make(-46058024627067344430605278824628224.0f, 0), + SkPoint::Make(SK_ScalarMax, 0) + }; + + p.setShader(SkGradientShader::MakeLinear(pts, colors, nullptr, 2, SkShader::kClamp_TileMode)); + sk_sp<SkSurface> surface(SkSurface::MakeRasterN32Premul(50, 50)); + surface->getCanvas()->drawPaint(p); + + // Passes if we don't trigger asserts. +} + DEF_TEST(Gradient, reporter) { TestGradientShaders(reporter); TestConstantGradient(reporter); @@ -261,4 +277,5 @@ DEF_TEST(Gradient, reporter) { test_linear_fuzz(reporter); test_two_point_conical_zero_radius(reporter); test_clamping_overflow(reporter); + text_degenerate_linear(reporter); } |