OLD | NEW |
---|---|
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2011 Google Inc. | 3 * Copyright 2011 Google Inc. |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 #include "Test.h" | 8 #include "Test.h" |
9 #include "SkDevice.h" | 9 #include "SkDevice.h" |
10 #include "SkTemplates.h" | 10 #include "SkTemplates.h" |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
119 rec.fRadius[1], | 119 rec.fRadius[1], |
120 rec.fColors, | 120 rec.fColors, |
121 rec.fPos, | 121 rec.fPos, |
122 rec.fColorCount, | 122 rec.fColorCount, |
123 rec.fTileMode)); | 123 rec.fTileMode)); |
124 | 124 |
125 SkShader::GradientInfo info; | 125 SkShader::GradientInfo info; |
126 rec.gradCheck(reporter, s, &info, SkShader::kConical_GradientType); | 126 rec.gradCheck(reporter, s, &info, SkShader::kConical_GradientType); |
127 REPORTER_ASSERT(reporter, !memcmp(info.fPoint, rec.fPoint, 2 * sizeof(SkPoin t))); | 127 REPORTER_ASSERT(reporter, !memcmp(info.fPoint, rec.fPoint, 2 * sizeof(SkPoin t))); |
128 REPORTER_ASSERT(reporter, !memcmp(info.fRadius, rec.fRadius, 2 * sizeof(SkSc alar))); | 128 REPORTER_ASSERT(reporter, !memcmp(info.fRadius, rec.fRadius, 2 * sizeof(SkSc alar))); |
129 REPORTER_ASSERT(reporter, !s->isOpaque()); | |
130 } | |
131 | |
132 // 2-point radial gradient should behave as opaque when it extends to the entire plane | |
133 static void conical_gradproc_opaque(skiatest::Reporter* reporter, const GradRec& rec) { | |
134 SkAutoTUnref<SkShader> s(SkGradientShader::CreateTwoPointConical(rec.fPoint[ 0], | |
135 rec.fRadius[0], | |
136 rec.fPoint[0], | |
137 rec.fRadius[1], | |
138 rec.fColors, | |
139 rec.fPos, | |
140 rec.fColorCount, | |
141 rec.fTileMode)); | |
142 REPORTER_ASSERT(reporter, s->isOpaque()); | |
143 } | |
144 | |
145 // 2nd circle center lies on edge of first circle should not be considered opaqu e | |
146 static void conical_gradproc_not_opaque(skiatest::Reporter* reporter, const Grad Rec& rec) { | |
147 SkAutoTUnref<SkShader> s(SkGradientShader::CreateTwoPointConical(rec.fPoint[ 1], | |
148 rec.fRadius[1], | |
Justin Novosad
2013/07/04 14:01:47
Unaligned indentation
| |
149 SkPoint::Make(rec.f Point[1].x() + rec.fRadius[1], rec.fPoint[1].y()), | |
Justin Novosad
2013/07/04 14:01:47
In skia we limit lines to 100 columns.
| |
150 rec.fRadius[0], | |
151 rec.fColors, | |
152 rec.fPos, | |
153 rec.fColorCount, | |
154 rec.fTileMode)); | |
155 REPORTER_ASSERT(reporter, !s->isOpaque()); | |
129 } | 156 } |
130 | 157 |
131 // Ensure that repeated color gradients behave like drawing a single color | 158 // Ensure that repeated color gradients behave like drawing a single color |
132 static void TestConstantGradient(skiatest::Reporter*) { | 159 static void TestConstantGradient(skiatest::Reporter*) { |
133 const SkPoint pts[] = { | 160 const SkPoint pts[] = { |
134 { 0, 0 }, | 161 { 0, 0 }, |
135 { SkIntToScalar(10), 0 } | 162 { SkIntToScalar(10), 0 } |
136 }; | 163 }; |
137 SkColor colors[] = { SK_ColorBLUE, SK_ColorBLUE }; | 164 SkColor colors[] = { SK_ColorBLUE, SK_ColorBLUE }; |
138 const SkScalar pos[] = { 0, SK_Scalar1 }; | 165 const SkScalar pos[] = { 0, SK_Scalar1 }; |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
178 rec.fTileMode = SkShader::kClamp_TileMode; | 205 rec.fTileMode = SkShader::kClamp_TileMode; |
179 | 206 |
180 static const GradProc gProcs[] = { | 207 static const GradProc gProcs[] = { |
181 none_gradproc, | 208 none_gradproc, |
182 color_gradproc, | 209 color_gradproc, |
183 linear_gradproc, | 210 linear_gradproc, |
184 radial_gradproc, | 211 radial_gradproc, |
185 radial2_gradproc, | 212 radial2_gradproc, |
186 sweep_gradproc, | 213 sweep_gradproc, |
187 conical_gradproc, | 214 conical_gradproc, |
215 conical_gradproc_opaque, | |
216 conical_gradproc_not_opaque, | |
188 }; | 217 }; |
189 | 218 |
190 for (size_t i = 0; i < SK_ARRAY_COUNT(gProcs); ++i) { | 219 for (size_t i = 0; i < SK_ARRAY_COUNT(gProcs); ++i) { |
191 gProcs[i](reporter, rec); | 220 gProcs[i](reporter, rec); |
192 } | 221 } |
193 } | 222 } |
194 | 223 |
195 static void TestGradients(skiatest::Reporter* reporter) { | 224 static void TestGradients(skiatest::Reporter* reporter) { |
196 TestGradientShaders(reporter); | 225 TestGradientShaders(reporter); |
197 TestConstantGradient(reporter); | 226 TestConstantGradient(reporter); |
198 } | 227 } |
199 #include "TestClassDef.h" | 228 #include "TestClassDef.h" |
200 DEFINE_TESTCLASS("Gradients", TestGradientsClass, TestGradients) | 229 DEFINE_TESTCLASS("Gradients", TestGradientsClass, TestGradients) |
OLD | NEW |