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

Side by Side 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, 10 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/SkLinearGradient.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 "SkColorShader.h" 9 #include "SkColorShader.h"
10 #include "SkGradientShader.h" 10 #include "SkGradientShader.h"
11 #include "SkShader.h" 11 #include "SkShader.h"
12 #include "SkTemplates.h" 12 #include "SkTemplates.h"
13 #include "Test.h" 13 #include "Test.h"
14 14
15 // https://code.google.com/p/chromium/issues/detail?id=448299
16 // Giant (inverse) matrix causes overflow when converting/computing using 32.32
17 // Before the fix, we would assert (and then crash).
18 static void test_big_grad(skiatest::Reporter* reporter) {
19 const SkColor colors[] = { SK_ColorRED, SK_ColorBLUE };
20 const SkPoint pts[] = {{ 15, 14.7112684f }, { 0.709064007f, 12.6108112f }};
21 SkShader* s = SkGradientShader::CreateLinear(pts, colors, NULL, 2, SkShader: :kClamp_TileMode);
22 SkPaint paint;
23 paint.setShader(s)->unref();
24
25 SkBitmap bm;
26 bm.allocN32Pixels(2000, 1);
27 SkCanvas c(bm);
28
29 const SkScalar affine[] = {
30 1.06608627e-06f, 4.26434525e-07f, 6.2855f, 2.6611f, 273.4393f, 244.0046f
31 };
32 SkMatrix matrix;
33 matrix.setAffine(affine);
34 c.concat(matrix);
35
36 c.drawPaint(paint);
37 }
38
15 struct GradRec { 39 struct GradRec {
16 int fColorCount; 40 int fColorCount;
17 const SkColor* fColors; 41 const SkColor* fColors;
18 const SkScalar* fPos; 42 const SkScalar* fPos;
19 const SkPoint* fPoint; // 2 43 const SkPoint* fPoint; // 2
20 const SkScalar* fRadius; // 2 44 const SkScalar* fRadius; // 2
21 SkShader::TileMode fTileMode; 45 SkShader::TileMode fTileMode;
22 46
23 void gradCheck(skiatest::Reporter* reporter, SkShader* shader, 47 void gradCheck(skiatest::Reporter* reporter, SkShader* shader,
24 SkShader::GradientInfo* info, 48 SkShader::GradientInfo* info,
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 }; 209 };
186 210
187 for (size_t i = 0; i < SK_ARRAY_COUNT(gProcs); ++i) { 211 for (size_t i = 0; i < SK_ARRAY_COUNT(gProcs); ++i) {
188 gProcs[i](reporter, rec); 212 gProcs[i](reporter, rec);
189 } 213 }
190 } 214 }
191 215
192 DEF_TEST(Gradient, reporter) { 216 DEF_TEST(Gradient, reporter) {
193 TestGradientShaders(reporter); 217 TestGradientShaders(reporter);
194 TestConstantGradient(reporter); 218 TestConstantGradient(reporter);
219 test_big_grad(reporter);
195 } 220 }
OLDNEW
« 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