Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(7)

Side by Side Diff: tests/GradientTest.cpp

Issue 2234663002: Prevent degenerate linear gradient instantiation (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: add a regression test Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/effects/gradients/SkGradientShader.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2011 Google Inc. 2 * Copyright 2011 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "SkCanvas.h" 8 #include "SkCanvas.h"
9 #include "SkColorPriv.h" 9 #include "SkColorPriv.h"
10 #include "SkColorShader.h" 10 #include "SkColorShader.h"
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 surface->getCanvas()->scale(100, 100); 246 surface->getCanvas()->scale(100, 100);
247 surface->getCanvas()->drawPaint(p); 247 surface->getCanvas()->drawPaint(p);
248 248
249 const SkPoint pts2[] = { SkPoint::Make(10000.99f, 1000000), SkPoint::Make(10 001, 1000001) }; 249 const SkPoint pts2[] = { SkPoint::Make(10000.99f, 1000000), SkPoint::Make(10 001, 1000001) };
250 p.setShader(SkGradientShader::MakeLinear(pts2, colors, nullptr, 2, SkShader: :kClamp_TileMode)); 250 p.setShader(SkGradientShader::MakeLinear(pts2, colors, nullptr, 2, SkShader: :kClamp_TileMode));
251 surface->getCanvas()->drawPaint(p); 251 surface->getCanvas()->drawPaint(p);
252 252
253 // Passes if we don't trigger asserts. 253 // Passes if we don't trigger asserts.
254 } 254 }
255 255
256 // http://crbug.com/636194
257 static void text_degenerate_linear(skiatest::Reporter*) {
258 SkPaint p;
259 const SkColor colors[] = { SK_ColorRED, SK_ColorGREEN };
260 const SkPoint pts[] = {
261 SkPoint::Make(-46058024627067344430605278824628224.0f, 0),
262 SkPoint::Make(SK_ScalarMax, 0)
263 };
264
265 p.setShader(SkGradientShader::MakeLinear(pts, colors, nullptr, 2, SkShader:: kClamp_TileMode));
266 sk_sp<SkSurface> surface(SkSurface::MakeRasterN32Premul(50, 50));
267 surface->getCanvas()->drawPaint(p);
268
269 // Passes if we don't trigger asserts.
270 }
271
256 DEF_TEST(Gradient, reporter) { 272 DEF_TEST(Gradient, reporter) {
257 TestGradientShaders(reporter); 273 TestGradientShaders(reporter);
258 TestConstantGradient(reporter); 274 TestConstantGradient(reporter);
259 test_big_grad(reporter); 275 test_big_grad(reporter);
260 test_nearly_vertical(reporter); 276 test_nearly_vertical(reporter);
261 test_linear_fuzz(reporter); 277 test_linear_fuzz(reporter);
262 test_two_point_conical_zero_radius(reporter); 278 test_two_point_conical_zero_radius(reporter);
263 test_clamping_overflow(reporter); 279 test_clamping_overflow(reporter);
280 text_degenerate_linear(reporter);
264 } 281 }
OLDNEW
« no previous file with comments | « src/effects/gradients/SkGradientShader.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698