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

Side by Side Diff: tests/GradientTest.cpp

Issue 1316233002: Style Change: NULL->nullptr (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 2015-08-27 (Thursday) 10:25:06 EDT Created 5 years, 3 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 | « tests/GrTextureMipMapInvalidationTest.cpp ('k') | tests/HashTest.cpp » ('j') | 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 15 // https://code.google.com/p/chromium/issues/detail?id=448299
16 // Giant (inverse) matrix causes overflow when converting/computing using 32.32 16 // Giant (inverse) matrix causes overflow when converting/computing using 32.32
17 // Before the fix, we would assert (and then crash). 17 // Before the fix, we would assert (and then crash).
18 static void test_big_grad(skiatest::Reporter* reporter) { 18 static void test_big_grad(skiatest::Reporter* reporter) {
19 const SkColor colors[] = { SK_ColorRED, SK_ColorBLUE }; 19 const SkColor colors[] = { SK_ColorRED, SK_ColorBLUE };
20 const SkPoint pts[] = {{ 15, 14.7112684f }, { 0.709064007f, 12.6108112f }}; 20 const SkPoint pts[] = {{ 15, 14.7112684f }, { 0.709064007f, 12.6108112f }};
21 SkShader* s = SkGradientShader::CreateLinear(pts, colors, NULL, 2, SkShader: :kClamp_TileMode); 21 SkShader* s = SkGradientShader::CreateLinear(pts, colors, nullptr, 2, SkShad er::kClamp_TileMode);
22 SkPaint paint; 22 SkPaint paint;
23 paint.setShader(s)->unref(); 23 paint.setShader(s)->unref();
24 24
25 SkBitmap bm; 25 SkBitmap bm;
26 bm.allocN32Pixels(2000, 1); 26 bm.allocN32Pixels(2000, 1);
27 SkCanvas c(bm); 27 SkCanvas c(bm);
28 28
29 const SkScalar affine[] = { 29 const SkScalar affine[] = {
30 1.06608627e-06f, 4.26434525e-07f, 6.2855f, 2.6611f, 273.4393f, 244.0046f 30 1.06608627e-06f, 4.26434525e-07f, 6.2855f, 2.6611f, 273.4393f, 244.0046f
31 }; 31 };
(...skipping 28 matching lines...) Expand all
60 !memcmp(info->fColors, fColors, fColorCount * sizeof(SkC olor))); 60 !memcmp(info->fColors, fColors, fColorCount * sizeof(SkC olor)));
61 REPORTER_ASSERT(reporter, 61 REPORTER_ASSERT(reporter,
62 !memcmp(info->fColorOffsets, fPos, fColorCount * sizeof( SkScalar))); 62 !memcmp(info->fColorOffsets, fPos, fColorCount * sizeof( SkScalar)));
63 REPORTER_ASSERT(reporter, fTileMode == info->fTileMode); 63 REPORTER_ASSERT(reporter, fTileMode == info->fTileMode);
64 } 64 }
65 }; 65 };
66 66
67 67
68 static void none_gradproc(skiatest::Reporter* reporter, const GradRec&) { 68 static void none_gradproc(skiatest::Reporter* reporter, const GradRec&) {
69 SkAutoTUnref<SkShader> s(SkShader::CreateEmptyShader()); 69 SkAutoTUnref<SkShader> s(SkShader::CreateEmptyShader());
70 REPORTER_ASSERT(reporter, SkShader::kNone_GradientType == s->asAGradient(NUL L)); 70 REPORTER_ASSERT(reporter, SkShader::kNone_GradientType == s->asAGradient(nul lptr));
71 } 71 }
72 72
73 static void color_gradproc(skiatest::Reporter* reporter, const GradRec& rec) { 73 static void color_gradproc(skiatest::Reporter* reporter, const GradRec& rec) {
74 SkAutoTUnref<SkShader> s(new SkColorShader(rec.fColors[0])); 74 SkAutoTUnref<SkShader> s(new SkColorShader(rec.fColors[0]));
75 REPORTER_ASSERT(reporter, SkShader::kColor_GradientType == s->asAGradient(NU LL)); 75 REPORTER_ASSERT(reporter, SkShader::kColor_GradientType == s->asAGradient(nu llptr));
76 76
77 SkShader::GradientInfo info; 77 SkShader::GradientInfo info;
78 info.fColors = NULL; 78 info.fColors = nullptr;
79 info.fColorCount = 0; 79 info.fColorCount = 0;
80 s->asAGradient(&info); 80 s->asAGradient(&info);
81 REPORTER_ASSERT(reporter, 1 == info.fColorCount); 81 REPORTER_ASSERT(reporter, 1 == info.fColorCount);
82 } 82 }
83 83
84 static void linear_gradproc(skiatest::Reporter* reporter, const GradRec& rec) { 84 static void linear_gradproc(skiatest::Reporter* reporter, const GradRec& rec) {
85 SkAutoTUnref<SkShader> s(SkGradientShader::CreateLinear(rec.fPoint, 85 SkAutoTUnref<SkShader> s(SkGradientShader::CreateLinear(rec.fPoint,
86 rec.fColors, 86 rec.fColors,
87 rec.fPos, 87 rec.fPos,
88 rec.fColorCount, 88 rec.fColorCount,
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 for (size_t i = 0; i < SK_ARRAY_COUNT(gProcs); ++i) { 194 for (size_t i = 0; i < SK_ARRAY_COUNT(gProcs); ++i) {
195 gProcs[i](reporter, rec); 195 gProcs[i](reporter, rec);
196 } 196 }
197 } 197 }
198 198
199 DEF_TEST(Gradient, reporter) { 199 DEF_TEST(Gradient, reporter) {
200 TestGradientShaders(reporter); 200 TestGradientShaders(reporter);
201 TestConstantGradient(reporter); 201 TestConstantGradient(reporter);
202 test_big_grad(reporter); 202 test_big_grad(reporter);
203 } 203 }
OLDNEW
« no previous file with comments | « tests/GrTextureMipMapInvalidationTest.cpp ('k') | tests/HashTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698