OLD | NEW |
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" |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 rec.fPos, | 100 rec.fPos, |
101 rec.fColorCount, | 101 rec.fColorCount, |
102 rec.fTileMode)); | 102 rec.fTileMode)); |
103 | 103 |
104 SkShader::GradientInfo info; | 104 SkShader::GradientInfo info; |
105 rec.gradCheck(reporter, s, &info, SkShader::kRadial_GradientType); | 105 rec.gradCheck(reporter, s, &info, SkShader::kRadial_GradientType); |
106 REPORTER_ASSERT(reporter, info.fPoint[0] == rec.fPoint[0]); | 106 REPORTER_ASSERT(reporter, info.fPoint[0] == rec.fPoint[0]); |
107 REPORTER_ASSERT(reporter, info.fRadius[0] == rec.fRadius[0]); | 107 REPORTER_ASSERT(reporter, info.fRadius[0] == rec.fRadius[0]); |
108 } | 108 } |
109 | 109 |
110 static void radial2_gradproc(skiatest::Reporter* reporter, const GradRec& rec) { | |
111 SkAutoTUnref<SkShader> s(SkGradientShader::CreateTwoPointRadial(rec.fPoint[0
], | |
112 rec.fRadius[0], | |
113 rec.fPoint[1], | |
114 rec.fRadius[1], | |
115 rec.fColors, | |
116 rec.fPos, | |
117 rec.fColorCount, | |
118 rec.fTileMode)); | |
119 | |
120 SkShader::GradientInfo info; | |
121 rec.gradCheck(reporter, s, &info, SkShader::kRadial2_GradientType); | |
122 REPORTER_ASSERT(reporter, !memcmp(info.fPoint, rec.fPoint, 2 * sizeof(SkPoin
t))); | |
123 REPORTER_ASSERT(reporter, !memcmp(info.fRadius, rec.fRadius, 2 * sizeof(SkSc
alar))); | |
124 } | |
125 | |
126 static void sweep_gradproc(skiatest::Reporter* reporter, const GradRec& rec) { | 110 static void sweep_gradproc(skiatest::Reporter* reporter, const GradRec& rec) { |
127 SkAutoTUnref<SkShader> s(SkGradientShader::CreateSweep(rec.fPoint[0].fX, | 111 SkAutoTUnref<SkShader> s(SkGradientShader::CreateSweep(rec.fPoint[0].fX, |
128 rec.fPoint[0].fY, | 112 rec.fPoint[0].fY, |
129 rec.fColors, | 113 rec.fColors, |
130 rec.fPos, | 114 rec.fPos, |
131 rec.fColorCount)); | 115 rec.fColorCount)); |
132 | 116 |
133 SkShader::GradientInfo info; | 117 SkShader::GradientInfo info; |
134 rec.gradCheck(reporter, s, &info, SkShader::kSweep_GradientType); | 118 rec.gradCheck(reporter, s, &info, SkShader::kSweep_GradientType); |
135 REPORTER_ASSERT(reporter, info.fPoint[0] == rec.fPoint[0]); | 119 REPORTER_ASSERT(reporter, info.fPoint[0] == rec.fPoint[0]); |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 rec.fPos = gPos; | 180 rec.fPos = gPos; |
197 rec.fPoint = gPts; | 181 rec.fPoint = gPts; |
198 rec.fRadius = gRad; | 182 rec.fRadius = gRad; |
199 rec.fTileMode = SkShader::kClamp_TileMode; | 183 rec.fTileMode = SkShader::kClamp_TileMode; |
200 | 184 |
201 static const GradProc gProcs[] = { | 185 static const GradProc gProcs[] = { |
202 none_gradproc, | 186 none_gradproc, |
203 color_gradproc, | 187 color_gradproc, |
204 linear_gradproc, | 188 linear_gradproc, |
205 radial_gradproc, | 189 radial_gradproc, |
206 radial2_gradproc, | |
207 sweep_gradproc, | 190 sweep_gradproc, |
208 conical_gradproc, | 191 conical_gradproc, |
209 }; | 192 }; |
210 | 193 |
211 for (size_t i = 0; i < SK_ARRAY_COUNT(gProcs); ++i) { | 194 for (size_t i = 0; i < SK_ARRAY_COUNT(gProcs); ++i) { |
212 gProcs[i](reporter, rec); | 195 gProcs[i](reporter, rec); |
213 } | 196 } |
214 } | 197 } |
215 | 198 |
216 DEF_TEST(Gradient, reporter) { | 199 DEF_TEST(Gradient, reporter) { |
217 TestGradientShaders(reporter); | 200 TestGradientShaders(reporter); |
218 TestConstantGradient(reporter); | 201 TestConstantGradient(reporter); |
219 test_big_grad(reporter); | 202 test_big_grad(reporter); |
220 } | 203 } |
OLD | NEW |