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

Unified Diff: tests/GradientTest.cpp

Issue 886473003: add more checks for computing clamp counts, remove dead code (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: update comment on overflow test Created 5 years, 11 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 e6fd7b99fdc4680a36861c2477827643dc640e19..f530b3e263bb285d1b82b6ab0087d9b5a4ac4cad 100644
--- a/tests/GradientTest.cpp
+++ b/tests/GradientTest.cpp
@@ -12,6 +12,30 @@
#include "SkTemplates.h"
#include "Test.h"
+// https://code.google.com/p/chromium/issues/detail?id=448299
+// Giant (inverse) matrix causes overflow when converting/computing using 32.32
+// Before the fix, we would assert (and then crash).
+static void test_big_grad(skiatest::Reporter* reporter) {
+ const SkColor colors[] = { SK_ColorRED, SK_ColorBLUE };
+ const SkPoint pts[] = {{ 15, 14.7112684f }, { 0.709064007f, 12.6108112f }};
+ SkShader* s = SkGradientShader::CreateLinear(pts, colors, NULL, 2, SkShader::kClamp_TileMode);
+ SkPaint paint;
+ paint.setShader(s)->unref();
+
+ SkBitmap bm;
+ bm.allocN32Pixels(2000, 1);
+ SkCanvas c(bm);
+
+ const SkScalar affine[] = {
+ 1.06608627e-06f, 4.26434525e-07f, 6.2855f, 2.6611f, 273.4393f, 244.0046f
+ };
+ SkMatrix matrix;
+ matrix.setAffine(affine);
+ c.concat(matrix);
+
+ c.drawPaint(paint);
+}
+
struct GradRec {
int fColorCount;
const SkColor* fColors;
@@ -192,4 +216,5 @@ static void TestGradientShaders(skiatest::Reporter* reporter) {
DEF_TEST(Gradient, reporter) {
TestGradientShaders(reporter);
TestConstantGradient(reporter);
+ test_big_grad(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