diff options
author | Florin Malita <fmalita@chromium.org> | 2017-04-18 13:47:15 -0400 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-04-19 17:33:08 +0000 |
commit | 03013084aac29967ee0559efce817b39234f4aa6 (patch) | |
tree | ae9232cf9ab36cbd548060cfe323af15a68a7aab /tests/GradientTest.cpp | |
parent | a4432dd418ca9ea31938ad645b1b231340bc29da (diff) |
Fix SkATan2_255 fuzzer crash
Test for degenerate values after computing the ratio, instead of
attempting to catch all tricky cases upfront.
BUG=skia:6511
Change-Id: I8e3421675994dd68a1eff1af3f1456917dd1f9e1
Reviewed-on: https://skia-review.googlesource.com/13726
Reviewed-by: Herb Derby <herb@google.com>
Commit-Queue: Florin Malita <fmalita@chromium.org>
Diffstat (limited to 'tests/GradientTest.cpp')
-rw-r--r-- | tests/GradientTest.cpp | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/tests/GradientTest.cpp b/tests/GradientTest.cpp index ec2753dc96..732bfbc22b 100644 --- a/tests/GradientTest.cpp +++ b/tests/GradientTest.cpp @@ -480,6 +480,51 @@ static void test_linear_fuzzer(skiatest::Reporter*) { } } +static void test_sweep_fuzzer(skiatest::Reporter*) { + static const SkColor gColors0[] = { 0x30303030, 0x30303030, 0x30303030 }; + static const SkScalar gPos0[] = { -47919293023455565225163489280.0f, 0, 1 }; + static const SkScalar gMatrix0[9] = { + 1.12116716e-13f, 0 , 8.50489682e+16f, + 4.1917041e-41f , 3.51369881e-23f, -2.54344271e-26f, + 9.61111907e+17f, -3.35263808e-29f, -1.35659403e+14f + }; + static const struct { + SkPoint fCenter; + const SkColor* fColors; + const SkScalar* fPos; + int fCount; + const SkScalar* fGlobalMatrix; + } gConfigs[] = { + { + { 0, 0 }, + gColors0, + gPos0, + SK_ARRAY_COUNT(gColors0), + gMatrix0 + }, + }; + + sk_sp<SkSurface> surface = SkSurface::MakeRasterN32Premul(100, 100); + SkCanvas* canvas = surface->getCanvas(); + SkPaint paint; + + for (const auto& config : gConfigs) { + paint.setShader(SkGradientShader::MakeSweep(config.fCenter.x(), + config.fCenter.y(), + config.fColors, + config.fPos, + config.fCount)); + + SkAutoCanvasRestore acr(canvas, false); + if (config.fGlobalMatrix) { + SkMatrix m; + m.set9(config.fGlobalMatrix); + canvas->save(); + canvas->concat(m); + } + canvas->drawPaint(paint); + } +} DEF_TEST(Gradient, reporter) { TestGradientShaders(reporter); @@ -493,4 +538,5 @@ DEF_TEST(Gradient, reporter) { test_clamping_overflow(reporter); test_degenerate_linear(reporter); test_linear_fuzzer(reporter); + test_sweep_fuzzer(reporter); } |