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

Unified Diff: tests/GradientTest.cpp

Issue 2010843002: Fix int32 overflow in LinearGradientContext::shade4_dx_clamp (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: Created 4 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/effects/gradients/SkLinearGradient.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/GradientTest.cpp
diff --git a/tests/GradientTest.cpp b/tests/GradientTest.cpp
index ac55d9934efc2a39b8cb2c3bdd464b95ad5d1a8f..7add42d875b93804539f78a42977b081ce9ce2af 100644
--- a/tests/GradientTest.cpp
+++ b/tests/GradientTest.cpp
@@ -234,6 +234,25 @@ static void test_two_point_conical_zero_radius(skiatest::Reporter* reporter) {
REPORTER_ASSERT(reporter, SkGetPackedR32(centerPMColor) == 0);
}
+// http://crbug.com/599458
+static void test_clamping_overflow(skiatest::Reporter*) {
+ SkPaint p;
+ const SkColor colors[] = { SK_ColorRED, SK_ColorGREEN };
+ const SkPoint pts1[] = { SkPoint::Make(1001, 1000001), SkPoint::Make(1000.99f, 1000000) };
+
+ p.setShader(SkGradientShader::MakeLinear(pts1, colors, nullptr, 2, SkShader::kClamp_TileMode));
+
+ sk_sp<SkSurface> surface(SkSurface::MakeRasterN32Premul(50, 50));
+ surface->getCanvas()->scale(100, 100);
+ surface->getCanvas()->drawPaint(p);
+
+ const SkPoint pts2[] = { SkPoint::Make(10000.99f, 1000000), SkPoint::Make(10001, 1000001) };
+ p.setShader(SkGradientShader::MakeLinear(pts2, colors, nullptr, 2, SkShader::kClamp_TileMode));
+ surface->getCanvas()->drawPaint(p);
+
+ // Passes if we don't trigger asserts.
+}
+
DEF_TEST(Gradient, reporter) {
TestGradientShaders(reporter);
TestConstantGradient(reporter);
@@ -241,4 +260,5 @@ DEF_TEST(Gradient, reporter) {
test_nearly_vertical(reporter);
test_linear_fuzz(reporter);
test_two_point_conical_zero_radius(reporter);
+ test_clamping_overflow(reporter);
}
« no previous file with comments | « src/effects/gradients/SkLinearGradient.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698