OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2016 Google Inc. | 2 * Copyright 2016 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 <initializer_list> | 8 #include <initializer_list> |
9 #include <functional> | 9 #include <functional> |
10 #include "Test.h" | 10 #include "Test.h" |
(...skipping 14 matching lines...) Expand all Loading... |
25 key->reset(size); | 25 key->reset(size); |
26 shape.writeUnstyledKey(key->begin()); | 26 shape.writeUnstyledKey(key->begin()); |
27 return true; | 27 return true; |
28 } | 28 } |
29 | 29 |
30 namespace { | 30 namespace { |
31 | 31 |
32 class TestCase { | 32 class TestCase { |
33 public: | 33 public: |
34 template <typename GEO> | 34 template <typename GEO> |
35 TestCase(const GEO& geo, const SkPaint& paint) : fBase(geo, paint) { | 35 TestCase(const GEO& geo, const SkPaint& paint, skiatest::Reporter* r) : fBas
e(geo, paint) { |
36 this->init(); | 36 this->init(r); |
37 } | 37 } |
38 | 38 |
39 struct SelfExpectations { | 39 struct SelfExpectations { |
40 bool fPEHasEffect; | 40 bool fPEHasEffect; |
41 bool fPEHasValidKey; | 41 bool fPEHasValidKey; |
42 bool fStrokeApplies; | 42 bool fStrokeApplies; |
43 }; | 43 }; |
44 | 44 |
45 void testExpectations(skiatest::Reporter* reporter, SelfExpectations expecta
tions) const; | 45 void testExpectations(skiatest::Reporter* reporter, SelfExpectations expecta
tions) const; |
46 | 46 |
(...skipping 10 matching lines...) Expand all Loading... |
57 const GrShape& appliedPathEffectShape() const { return fAppliedPE; } | 57 const GrShape& appliedPathEffectShape() const { return fAppliedPE; } |
58 const GrShape& appliedFullStyleShape() const { return fAppliedFull; } | 58 const GrShape& appliedFullStyleShape() const { return fAppliedFull; } |
59 | 59 |
60 // The returned array's count will be 0 if the key shape has no key. | 60 // The returned array's count will be 0 if the key shape has no key. |
61 const Key& baseKey() const { return fBaseKey; } | 61 const Key& baseKey() const { return fBaseKey; } |
62 const Key& appliedPathEffectKey() const { return fAppliedPEKey; } | 62 const Key& appliedPathEffectKey() const { return fAppliedPEKey; } |
63 const Key& appliedFullStyleKey() const { return fAppliedFullKey; } | 63 const Key& appliedFullStyleKey() const { return fAppliedFullKey; } |
64 const Key& appliedPathEffectThenStrokeKey() const { return fAppliedPEThenStr
okeKey; } | 64 const Key& appliedPathEffectThenStrokeKey() const { return fAppliedPEThenStr
okeKey; } |
65 | 65 |
66 private: | 66 private: |
67 void init() { | 67 void init(skiatest::Reporter* r) { |
68 fAppliedPE = fBase.applyPathEffect(); | 68 fAppliedPE = fBase.applyStyle(GrStyle::Apply::kPathEffectOnly)
; |
69 fAppliedPEThenStroke = fAppliedPE.applyFullStyle(); | 69 fAppliedPEThenStroke = fAppliedPE.applyStyle(GrStyle::Apply::kPathEffect
AndStrokeRec); |
70 fAppliedFull = fBase.applyFullStyle(); | 70 fAppliedFull = fBase.applyStyle(GrStyle::Apply::kPathEffectAndSt
rokeRec); |
71 | 71 |
72 make_key(&fBaseKey, fBase); | 72 make_key(&fBaseKey, fBase); |
73 make_key(&fAppliedPEKey, fAppliedPE); | 73 make_key(&fAppliedPEKey, fAppliedPE); |
74 make_key(&fAppliedPEThenStrokeKey, fAppliedPEThenStroke); | 74 make_key(&fAppliedPEThenStrokeKey, fAppliedPEThenStroke); |
75 make_key(&fAppliedFullKey, fAppliedFull); | 75 make_key(&fAppliedFullKey, fAppliedFull); |
| 76 |
| 77 // Applying the path effect and then the stroke should always be the sam
e as applying |
| 78 // both in one go. |
| 79 REPORTER_ASSERT(r, fAppliedPEThenStrokeKey == fAppliedFullKey); |
| 80 SkPath a, b; |
| 81 fAppliedPEThenStroke.asPath(&a); |
| 82 fAppliedFull.asPath(&b); |
| 83 REPORTER_ASSERT(r, a == b); |
| 84 |
| 85 // Check that the same path is produced when style is applied by GrShape
and GrStyle. |
| 86 SkPath preStyle; |
| 87 SkPath postPathEffect; |
| 88 SkPath postAllStyle; |
| 89 |
| 90 fBase.asPath(&preStyle); |
| 91 SkStrokeRec postPathEffectStrokeRec(SkStrokeRec::kFill_InitStyle); |
| 92 if (fBase.style().applyPathEffectToPath(&postPathEffect, &postPathEffect
StrokeRec, |
| 93 preStyle)) { |
| 94 SkPath testPath; |
| 95 fAppliedPE.asPath(&testPath); |
| 96 REPORTER_ASSERT(r, testPath == postPathEffect); |
| 97 REPORTER_ASSERT(r, |
| 98 postPathEffectStrokeRec.hasEqualEffect(fAppliedPE.st
yle().strokeRec())); |
| 99 } |
| 100 SkStrokeRec::InitStyle fillOrHairline; |
| 101 if (fBase.style().applyToPath(&postAllStyle, &fillOrHairline, preStyle))
{ |
| 102 SkPath testPath; |
| 103 fAppliedFull.asPath(&testPath); |
| 104 REPORTER_ASSERT(r, testPath == postAllStyle); |
| 105 if (fillOrHairline == SkStrokeRec::kFill_InitStyle) { |
| 106 REPORTER_ASSERT(r, fAppliedFull.style().isSimpleFill()); |
| 107 } else { |
| 108 REPORTER_ASSERT(r, fAppliedFull.style().isSimpleHairline()); |
| 109 } |
| 110 } |
76 } | 111 } |
77 | 112 |
78 GrShape fBase; | 113 GrShape fBase; |
79 GrShape fAppliedPE; | 114 GrShape fAppliedPE; |
80 GrShape fAppliedPEThenStroke; | 115 GrShape fAppliedPEThenStroke; |
81 GrShape fAppliedFull; | 116 GrShape fAppliedFull; |
82 | 117 |
83 Key fBaseKey; | 118 Key fBaseKey; |
84 Key fAppliedPEKey; | 119 Key fAppliedPEKey; |
85 Key fAppliedPEThenStrokeKey; | 120 Key fAppliedPEThenStrokeKey; |
86 Key fAppliedFullKey; | 121 Key fAppliedFullKey; |
87 | 122 |
88 }; | 123 }; |
89 | 124 |
90 void TestCase::testExpectations(skiatest::Reporter* reporter, SelfExpectations e
xpectations) const { | 125 void TestCase::testExpectations(skiatest::Reporter* reporter, SelfExpectations e
xpectations) const { |
91 // Applying the path effect and then the stroke should always be the same as
applying | |
92 // both in one go. | |
93 REPORTER_ASSERT(reporter, fAppliedPEThenStrokeKey == fAppliedFullKey); | |
94 SkPath a, b; | |
95 fAppliedPEThenStroke.asPath(&a); | |
96 fAppliedFull.asPath(&b); | |
97 REPORTER_ASSERT(reporter, a == b); | |
98 // The base's key should always be valid (unless the path is volatile) | 126 // The base's key should always be valid (unless the path is volatile) |
99 REPORTER_ASSERT(reporter, fBaseKey.count()); | 127 REPORTER_ASSERT(reporter, fBaseKey.count()); |
100 if (expectations.fPEHasEffect) { | 128 if (expectations.fPEHasEffect) { |
101 REPORTER_ASSERT(reporter, fBaseKey != fAppliedPEKey); | 129 REPORTER_ASSERT(reporter, fBaseKey != fAppliedPEKey); |
102 REPORTER_ASSERT(reporter, expectations.fPEHasValidKey == SkToBool(fAppli
edPEKey.count())); | 130 REPORTER_ASSERT(reporter, expectations.fPEHasValidKey == SkToBool(fAppli
edPEKey.count())); |
103 REPORTER_ASSERT(reporter, fBaseKey != fAppliedFullKey); | 131 REPORTER_ASSERT(reporter, fBaseKey != fAppliedFullKey); |
104 REPORTER_ASSERT(reporter, expectations.fPEHasValidKey == SkToBool(fAppli
edFullKey.count())); | 132 REPORTER_ASSERT(reporter, expectations.fPEHasValidKey == SkToBool(fAppli
edFullKey.count())); |
105 if (expectations.fStrokeApplies && expectations.fPEHasValidKey) { | 133 if (expectations.fStrokeApplies && expectations.fPEHasValidKey) { |
106 REPORTER_ASSERT(reporter, fAppliedPEKey != fAppliedFullKey); | 134 REPORTER_ASSERT(reporter, fAppliedPEKey != fAppliedFullKey); |
107 REPORTER_ASSERT(reporter, SkToBool(fAppliedFullKey.count())); | 135 REPORTER_ASSERT(reporter, SkToBool(fAppliedFullKey.count())); |
108 } | 136 } |
109 } else { | 137 } else { |
110 REPORTER_ASSERT(reporter, fBaseKey == fAppliedPEKey); | 138 REPORTER_ASSERT(reporter, fBaseKey == fAppliedPEKey); |
| 139 SkPath a, b; |
111 fBase.asPath(&a); | 140 fBase.asPath(&a); |
112 fAppliedPE.asPath(&b); | 141 fAppliedPE.asPath(&b); |
113 REPORTER_ASSERT(reporter, a == b); | 142 REPORTER_ASSERT(reporter, a == b); |
114 if (expectations.fStrokeApplies) { | 143 if (expectations.fStrokeApplies) { |
115 REPORTER_ASSERT(reporter, fBaseKey != fAppliedFullKey); | 144 REPORTER_ASSERT(reporter, fBaseKey != fAppliedFullKey); |
116 } else { | 145 } else { |
117 REPORTER_ASSERT(reporter, fBaseKey == fAppliedFullKey); | 146 REPORTER_ASSERT(reporter, fBaseKey == fAppliedFullKey); |
118 } | 147 } |
119 } | 148 } |
120 } | 149 } |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 return SkDashPathEffect::Make(kNullIntervals, SK_ARRAY_COUNT(kNullIntervals)
, 0.f); | 205 return SkDashPathEffect::Make(kNullIntervals, SK_ARRAY_COUNT(kNullIntervals)
, 0.f); |
177 } | 206 } |
178 | 207 |
179 template<typename GEO> | 208 template<typename GEO> |
180 static void test_basic(skiatest::Reporter* reporter, const GEO& geo) { | 209 static void test_basic(skiatest::Reporter* reporter, const GEO& geo) { |
181 sk_sp<SkPathEffect> dashPE = make_dash(); | 210 sk_sp<SkPathEffect> dashPE = make_dash(); |
182 | 211 |
183 TestCase::SelfExpectations expectations; | 212 TestCase::SelfExpectations expectations; |
184 SkPaint fill; | 213 SkPaint fill; |
185 | 214 |
186 TestCase fillCase(geo, fill); | 215 TestCase fillCase(geo, fill, reporter); |
187 expectations.fPEHasEffect = false; | 216 expectations.fPEHasEffect = false; |
188 expectations.fPEHasValidKey = false; | 217 expectations.fPEHasValidKey = false; |
189 expectations.fStrokeApplies = false; | 218 expectations.fStrokeApplies = false; |
190 fillCase.testExpectations(reporter, expectations); | 219 fillCase.testExpectations(reporter, expectations); |
191 // Test that another GrShape instance built from the same primitive is the s
ame. | 220 // Test that another GrShape instance built from the same primitive is the s
ame. |
192 TestCase(geo, fill).compare(reporter, fillCase, TestCase::kAllSame_Compariso
nExpecation); | 221 TestCase(geo, fill, reporter).compare(reporter, fillCase, |
| 222 TestCase::kAllSame_ComparisonExpecatio
n); |
193 | 223 |
194 SkPaint stroke2RoundBevel; | 224 SkPaint stroke2RoundBevel; |
195 stroke2RoundBevel.setStyle(SkPaint::kStroke_Style); | 225 stroke2RoundBevel.setStyle(SkPaint::kStroke_Style); |
196 stroke2RoundBevel.setStrokeCap(SkPaint::kRound_Cap); | 226 stroke2RoundBevel.setStrokeCap(SkPaint::kRound_Cap); |
197 stroke2RoundBevel.setStrokeJoin(SkPaint::kBevel_Join); | 227 stroke2RoundBevel.setStrokeJoin(SkPaint::kBevel_Join); |
198 stroke2RoundBevel.setStrokeWidth(2.f); | 228 stroke2RoundBevel.setStrokeWidth(2.f); |
199 TestCase stroke2RoundBevelCase(geo, stroke2RoundBevel); | 229 TestCase stroke2RoundBevelCase(geo, stroke2RoundBevel, reporter); |
200 expectations.fPEHasValidKey = true; | 230 expectations.fPEHasValidKey = true; |
201 expectations.fPEHasEffect = false; | 231 expectations.fPEHasEffect = false; |
202 expectations.fStrokeApplies = true; | 232 expectations.fStrokeApplies = true; |
203 stroke2RoundBevelCase.testExpectations(reporter, expectations); | 233 stroke2RoundBevelCase.testExpectations(reporter, expectations); |
204 TestCase(geo, stroke2RoundBevel).compare(reporter, stroke2RoundBevelCase, | 234 TestCase(geo, stroke2RoundBevel, reporter).compare(reporter, stroke2RoundBev
elCase, |
205 TestCase::kAllSame_ComparisonExpeca
tion); | 235 TestCase::kAllSame_Compar
isonExpecation); |
206 | 236 |
207 SkPaint stroke2RoundBevelDash = stroke2RoundBevel; | 237 SkPaint stroke2RoundBevelDash = stroke2RoundBevel; |
208 stroke2RoundBevelDash.setPathEffect(make_dash()); | 238 stroke2RoundBevelDash.setPathEffect(make_dash()); |
209 TestCase stroke2RoundBevelDashCase(geo, stroke2RoundBevelDash); | 239 TestCase stroke2RoundBevelDashCase(geo, stroke2RoundBevelDash, reporter); |
210 expectations.fPEHasValidKey = true; | 240 expectations.fPEHasValidKey = true; |
211 expectations.fPEHasEffect = true; | 241 expectations.fPEHasEffect = true; |
212 expectations.fStrokeApplies = true; | 242 expectations.fStrokeApplies = true; |
213 stroke2RoundBevelDashCase.testExpectations(reporter, expectations); | 243 stroke2RoundBevelDashCase.testExpectations(reporter, expectations); |
214 TestCase(geo, stroke2RoundBevelDash).compare(reporter, stroke2RoundBevelDash
Case, | 244 TestCase(geo, stroke2RoundBevelDash, reporter).compare(reporter, stroke2Roun
dBevelDashCase, |
215 TestCase::kAllSame_ComparisonEx
pecation); | 245 TestCase::kAllSame_Co
mparisonExpecation); |
216 | 246 |
217 fillCase.compare(reporter, stroke2RoundBevelCase, | 247 fillCase.compare(reporter, stroke2RoundBevelCase, |
218 TestCase::kSameUpToStroke_ComparisonExpecation); | 248 TestCase::kSameUpToStroke_ComparisonExpecation); |
219 fillCase.compare(reporter, stroke2RoundBevelDashCase, | 249 fillCase.compare(reporter, stroke2RoundBevelDashCase, |
220 TestCase::kSameUpToPE_ComparisonExpecation); | 250 TestCase::kSameUpToPE_ComparisonExpecation); |
221 stroke2RoundBevelCase.compare(reporter, stroke2RoundBevelDashCase, | 251 stroke2RoundBevelCase.compare(reporter, stroke2RoundBevelDashCase, |
222 TestCase::kSameUpToPE_ComparisonExpecation); | 252 TestCase::kSameUpToPE_ComparisonExpecation); |
223 | 253 |
224 SkPaint hairline; | 254 SkPaint hairline; |
225 hairline.setStyle(SkPaint::kStroke_Style); | 255 hairline.setStyle(SkPaint::kStroke_Style); |
226 hairline.setStrokeWidth(0.f); | 256 hairline.setStrokeWidth(0.f); |
227 TestCase hairlineCase(geo, hairline); | 257 TestCase hairlineCase(geo, hairline, reporter); |
228 // Since hairline style doesn't change the SkPath data, it is keyed identica
lly to fill. | 258 // Since hairline style doesn't change the SkPath data, it is keyed identica
lly to fill. |
229 hairlineCase.compare(reporter, fillCase, TestCase::kAllSame_ComparisonExpeca
tion); | 259 hairlineCase.compare(reporter, fillCase, TestCase::kAllSame_ComparisonExpeca
tion); |
230 } | 260 } |
231 | 261 |
232 template <typename GEO, typename T> | 262 template <typename GEO, typename T> |
233 static void test_stroke_param(skiatest::Reporter* reporter, const GEO& geo, | 263 static void test_stroke_param(skiatest::Reporter* reporter, const GEO& geo, |
234 std::function<void(SkPaint*, T)> setter, T a, T b)
{ | 264 std::function<void(SkPaint*, T)> setter, T a, T b)
{ |
235 // Set the stroke width so that we don't get hairline. However, call the fun
ction second so that | 265 // Set the stroke width so that we don't get hairline. However, call the fun
ction second so that |
236 // it can override. | 266 // it can override. |
237 SkPaint strokeA; | 267 SkPaint strokeA; |
238 strokeA.setStyle(SkPaint::kStroke_Style); | 268 strokeA.setStyle(SkPaint::kStroke_Style); |
239 strokeA.setStrokeWidth(2.f); | 269 strokeA.setStrokeWidth(2.f); |
240 setter(&strokeA, a); | 270 setter(&strokeA, a); |
241 SkPaint strokeB; | 271 SkPaint strokeB; |
242 strokeB.setStyle(SkPaint::kStroke_Style); | 272 strokeB.setStyle(SkPaint::kStroke_Style); |
243 strokeB.setStrokeWidth(2.f); | 273 strokeB.setStrokeWidth(2.f); |
244 setter(&strokeB, b); | 274 setter(&strokeB, b); |
245 | 275 |
246 TestCase strokeACase(geo, strokeA); | 276 TestCase strokeACase(geo, strokeA, reporter); |
247 TestCase strokeBCase(geo, strokeB); | 277 TestCase strokeBCase(geo, strokeB, reporter); |
248 strokeACase.compare(reporter, strokeBCase, TestCase::kSameUpToStroke_Compari
sonExpecation); | 278 strokeACase.compare(reporter, strokeBCase, TestCase::kSameUpToStroke_Compari
sonExpecation); |
249 | 279 |
250 // Make sure stroking params don't affect fill style. | 280 // Make sure stroking params don't affect fill style. |
251 SkPaint fillA = strokeA, fillB = strokeB; | 281 SkPaint fillA = strokeA, fillB = strokeB; |
252 fillA.setStyle(SkPaint::kFill_Style); | 282 fillA.setStyle(SkPaint::kFill_Style); |
253 fillB.setStyle(SkPaint::kFill_Style); | 283 fillB.setStyle(SkPaint::kFill_Style); |
254 TestCase fillACase(geo, fillA); | 284 TestCase fillACase(geo, fillA, reporter); |
255 TestCase fillBCase(geo, fillB); | 285 TestCase fillBCase(geo, fillB, reporter); |
256 fillACase.compare(reporter, fillBCase, TestCase::kAllSame_ComparisonExpecati
on); | 286 fillACase.compare(reporter, fillBCase, TestCase::kAllSame_ComparisonExpecati
on); |
257 | 287 |
258 // Make sure just applying the dash but not stroke gives the same key for bo
th stroking | 288 // Make sure just applying the dash but not stroke gives the same key for bo
th stroking |
259 // variations. | 289 // variations. |
260 SkPaint dashA = strokeA, dashB = strokeB; | 290 SkPaint dashA = strokeA, dashB = strokeB; |
261 dashA.setPathEffect(make_dash()); | 291 dashA.setPathEffect(make_dash()); |
262 dashB.setPathEffect(make_dash()); | 292 dashB.setPathEffect(make_dash()); |
263 TestCase dashACase(geo, dashA); | 293 TestCase dashACase(geo, dashA, reporter); |
264 TestCase dashBCase(geo, dashB); | 294 TestCase dashBCase(geo, dashB, reporter); |
265 dashACase.compare(reporter, dashBCase, TestCase::kSameUpToStroke_ComparisonE
xpecation); | 295 dashACase.compare(reporter, dashBCase, TestCase::kSameUpToStroke_ComparisonE
xpecation); |
266 } | 296 } |
267 | 297 |
268 template <typename GEO> | 298 template <typename GEO> |
269 static void test_miter_limit(skiatest::Reporter* reporter, const GEO& geo) { | 299 static void test_miter_limit(skiatest::Reporter* reporter, const GEO& geo) { |
270 // Miter limit should only matter when stroking with miter joins. It shouldn
't affect other | 300 // Miter limit should only matter when stroking with miter joins. It shouldn
't affect other |
271 // joins or fills. | 301 // joins or fills. |
272 SkPaint miterA; | 302 SkPaint miterA; |
273 miterA.setStyle(SkPaint::kStroke_Style); | 303 miterA.setStyle(SkPaint::kStroke_Style); |
274 miterA.setStrokeWidth(2.f); | 304 miterA.setStrokeWidth(2.f); |
275 miterA.setStrokeJoin(SkPaint::kMiter_Join); | 305 miterA.setStrokeJoin(SkPaint::kMiter_Join); |
276 miterA.setStrokeMiter(0.5f); | 306 miterA.setStrokeMiter(0.5f); |
277 SkPaint miterB = miterA; | 307 SkPaint miterB = miterA; |
278 miterA.setStrokeMiter(0.6f); | 308 miterA.setStrokeMiter(0.6f); |
279 | 309 |
280 TestCase miterACase(geo, miterA); | 310 TestCase miterACase(geo, miterA, reporter); |
281 TestCase miterBCase(geo, miterB); | 311 TestCase miterBCase(geo, miterB, reporter); |
282 miterACase.compare(reporter, miterBCase, TestCase::kSameUpToStroke_Compariso
nExpecation); | 312 miterACase.compare(reporter, miterBCase, TestCase::kSameUpToStroke_Compariso
nExpecation); |
283 | 313 |
284 SkPaint noMiterA = miterA, noMiterB = miterB; | 314 SkPaint noMiterA = miterA, noMiterB = miterB; |
285 noMiterA.setStrokeJoin(SkPaint::kRound_Join); | 315 noMiterA.setStrokeJoin(SkPaint::kRound_Join); |
286 noMiterB.setStrokeJoin(SkPaint::kRound_Join); | 316 noMiterB.setStrokeJoin(SkPaint::kRound_Join); |
287 TestCase noMiterACase(geo, noMiterA); | 317 TestCase noMiterACase(geo, noMiterA, reporter); |
288 TestCase noMiterBCase(geo, noMiterB); | 318 TestCase noMiterBCase(geo, noMiterB, reporter); |
289 noMiterACase.compare(reporter, noMiterBCase, TestCase::kAllSame_ComparisonEx
pecation); | 319 noMiterACase.compare(reporter, noMiterBCase, TestCase::kAllSame_ComparisonEx
pecation); |
290 | 320 |
291 SkPaint fillA = miterA, fillB = miterB; | 321 SkPaint fillA = miterA, fillB = miterB; |
292 fillA.setStyle(SkPaint::kFill_Style); | 322 fillA.setStyle(SkPaint::kFill_Style); |
293 fillB.setStyle(SkPaint::kFill_Style); | 323 fillB.setStyle(SkPaint::kFill_Style); |
294 TestCase fillACase(geo, fillA); | 324 TestCase fillACase(geo, fillA, reporter); |
295 TestCase fillBCase(geo, fillB); | 325 TestCase fillBCase(geo, fillB, reporter); |
296 fillACase.compare(reporter, fillBCase, TestCase::kAllSame_ComparisonExpecati
on); | 326 fillACase.compare(reporter, fillBCase, TestCase::kAllSame_ComparisonExpecati
on); |
297 } | 327 } |
298 | 328 |
299 template<typename GEO> | 329 template<typename GEO> |
300 static void test_dash_fill(skiatest::Reporter* reporter, const GEO& geo) { | 330 static void test_dash_fill(skiatest::Reporter* reporter, const GEO& geo) { |
301 // A dash with no stroke should have no effect | 331 // A dash with no stroke should have no effect |
302 using DashFactoryFn = sk_sp<SkPathEffect>(*)(); | 332 using DashFactoryFn = sk_sp<SkPathEffect>(*)(); |
303 for (DashFactoryFn md : {&make_dash, &make_null_dash}) { | 333 for (DashFactoryFn md : {&make_dash, &make_null_dash}) { |
304 SkPaint dashFill; | 334 SkPaint dashFill; |
305 dashFill.setPathEffect((*md)()); | 335 dashFill.setPathEffect((*md)()); |
306 TestCase dashFillCase(geo, dashFill); | 336 TestCase dashFillCase(geo, dashFill, reporter); |
307 | 337 |
308 TestCase fillCase(geo, SkPaint()); | 338 TestCase fillCase(geo, SkPaint(), reporter); |
309 dashFillCase.compare(reporter, fillCase, TestCase::kAllSame_ComparisonEx
pecation); | 339 dashFillCase.compare(reporter, fillCase, TestCase::kAllSame_ComparisonEx
pecation); |
310 } | 340 } |
311 } | 341 } |
312 | 342 |
313 template<typename GEO> | 343 template<typename GEO> |
314 void test_null_dash(skiatest::Reporter* reporter, const GEO& geo) { | 344 void test_null_dash(skiatest::Reporter* reporter, const GEO& geo) { |
315 SkPaint fill; | 345 SkPaint fill; |
316 SkPaint stroke; | 346 SkPaint stroke; |
317 stroke.setStyle(SkPaint::kStroke_Style); | 347 stroke.setStyle(SkPaint::kStroke_Style); |
318 stroke.setStrokeWidth(1.f); | 348 stroke.setStrokeWidth(1.f); |
319 SkPaint dash; | 349 SkPaint dash; |
320 dash.setStyle(SkPaint::kStroke_Style); | 350 dash.setStyle(SkPaint::kStroke_Style); |
321 dash.setStrokeWidth(1.f); | 351 dash.setStrokeWidth(1.f); |
322 dash.setPathEffect(make_dash()); | 352 dash.setPathEffect(make_dash()); |
323 SkPaint nullDash; | 353 SkPaint nullDash; |
324 nullDash.setStyle(SkPaint::kStroke_Style); | 354 nullDash.setStyle(SkPaint::kStroke_Style); |
325 nullDash.setStrokeWidth(1.f); | 355 nullDash.setStrokeWidth(1.f); |
326 nullDash.setPathEffect(make_null_dash()); | 356 nullDash.setPathEffect(make_null_dash()); |
327 | 357 |
328 TestCase fillCase(geo, fill); | 358 TestCase fillCase(geo, fill, reporter); |
329 TestCase strokeCase(geo, stroke); | 359 TestCase strokeCase(geo, stroke, reporter); |
330 TestCase dashCase(geo, dash); | 360 TestCase dashCase(geo, dash, reporter); |
331 TestCase nullDashCase(geo, nullDash); | 361 TestCase nullDashCase(geo, nullDash, reporter); |
332 | 362 |
333 nullDashCase.compare(reporter, fillCase, TestCase::kSameUpToStroke_Compariso
nExpecation); | 363 nullDashCase.compare(reporter, fillCase, TestCase::kSameUpToStroke_Compariso
nExpecation); |
334 nullDashCase.compare(reporter, strokeCase, TestCase::kAllSame_ComparisonExpe
cation); | 364 nullDashCase.compare(reporter, strokeCase, TestCase::kAllSame_ComparisonExpe
cation); |
335 nullDashCase.compare(reporter, dashCase, TestCase::kSameUpToPE_ComparisonExp
ecation); | 365 nullDashCase.compare(reporter, dashCase, TestCase::kSameUpToPE_ComparisonExp
ecation); |
336 } | 366 } |
337 | 367 |
338 template <typename GEO> | 368 template <typename GEO> |
339 void test_path_effect_makes_rrect(skiatest::Reporter* reporter, const GEO& geo)
{ | 369 void test_path_effect_makes_rrect(skiatest::Reporter* reporter, const GEO& geo)
{ |
340 /** | 370 /** |
341 * This path effect takes any input path and turns it into a rrect. It passe
s through stroke | 371 * This path effect takes any input path and turns it into a rrect. It passe
s through stroke |
(...skipping 16 matching lines...) Expand all Loading... |
358 *dst = RRect().getBounds(); | 388 *dst = RRect().getBounds(); |
359 } | 389 } |
360 static sk_sp<SkPathEffect> Make() { return sk_sp<SkPathEffect>(new RRect
PathEffect); } | 390 static sk_sp<SkPathEffect> Make() { return sk_sp<SkPathEffect>(new RRect
PathEffect); } |
361 Factory getFactory() const override { return nullptr; } | 391 Factory getFactory() const override { return nullptr; } |
362 void toString(SkString*) const override {} | 392 void toString(SkString*) const override {} |
363 private: | 393 private: |
364 RRectPathEffect() {} | 394 RRectPathEffect() {} |
365 }; | 395 }; |
366 | 396 |
367 SkPaint fill; | 397 SkPaint fill; |
368 TestCase fillGeoCase(geo, fill); | 398 TestCase fillGeoCase(geo, fill, reporter); |
369 | 399 |
370 SkPaint pe; | 400 SkPaint pe; |
371 pe.setPathEffect(RRectPathEffect::Make()); | 401 pe.setPathEffect(RRectPathEffect::Make()); |
372 TestCase geoPECase(geo, pe); | 402 TestCase geoPECase(geo, pe, reporter); |
373 | 403 |
374 SkPaint peStroke; | 404 SkPaint peStroke; |
375 peStroke.setPathEffect(RRectPathEffect::Make()); | 405 peStroke.setPathEffect(RRectPathEffect::Make()); |
376 peStroke.setStrokeWidth(2.f); | 406 peStroke.setStrokeWidth(2.f); |
377 peStroke.setStyle(SkPaint::kStroke_Style); | 407 peStroke.setStyle(SkPaint::kStroke_Style); |
378 TestCase geoPEStrokeCase(geo, peStroke); | 408 TestCase geoPEStrokeCase(geo, peStroke, reporter); |
379 | 409 |
380 fillGeoCase.compare(reporter, geoPECase, TestCase::kSameUpToPE_ComparisonExp
ecation); | 410 fillGeoCase.compare(reporter, geoPECase, TestCase::kSameUpToPE_ComparisonExp
ecation); |
381 fillGeoCase.compare(reporter, geoPEStrokeCase, TestCase::kSameUpToPE_Compari
sonExpecation); | 411 fillGeoCase.compare(reporter, geoPEStrokeCase, TestCase::kSameUpToPE_Compari
sonExpecation); |
382 geoPECase.compare(reporter, geoPEStrokeCase, | 412 geoPECase.compare(reporter, geoPEStrokeCase, |
383 TestCase::kSameUpToStroke_ComparisonExpecation); | 413 TestCase::kSameUpToStroke_ComparisonExpecation); |
384 | 414 |
385 TestCase rrectFillCase(RRectPathEffect::RRect(), fill); | 415 TestCase rrectFillCase(RRectPathEffect::RRect(), fill, reporter); |
386 SkPaint stroke = peStroke; | 416 SkPaint stroke = peStroke; |
387 stroke.setPathEffect(nullptr); | 417 stroke.setPathEffect(nullptr); |
388 TestCase rrectStrokeCase(RRectPathEffect::RRect(), stroke); | 418 TestCase rrectStrokeCase(RRectPathEffect::RRect(), stroke, reporter); |
389 | 419 |
390 SkRRect rrect; | 420 SkRRect rrect; |
391 // Applying the path effect should make a SkRRect shape. There is no further
stroking in the | 421 // Applying the path effect should make a SkRRect shape. There is no further
stroking in the |
392 // geoPECase, so the full style should be the same as just the PE. | 422 // geoPECase, so the full style should be the same as just the PE. |
393 REPORTER_ASSERT(reporter, geoPECase.appliedPathEffectShape().asRRect(&rrect)
); | 423 REPORTER_ASSERT(reporter, geoPECase.appliedPathEffectShape().asRRect(&rrect)
); |
394 REPORTER_ASSERT(reporter, rrect == RRectPathEffect::RRect()); | 424 REPORTER_ASSERT(reporter, rrect == RRectPathEffect::RRect()); |
395 REPORTER_ASSERT(reporter, geoPECase.appliedPathEffectKey() == rrectFillCase.
baseKey()); | 425 REPORTER_ASSERT(reporter, geoPECase.appliedPathEffectKey() == rrectFillCase.
baseKey()); |
396 | 426 |
397 REPORTER_ASSERT(reporter, geoPECase.appliedFullStyleShape().asRRect(&rrect))
; | 427 REPORTER_ASSERT(reporter, geoPECase.appliedFullStyleShape().asRRect(&rrect))
; |
398 REPORTER_ASSERT(reporter, rrect == RRectPathEffect::RRect()); | 428 REPORTER_ASSERT(reporter, rrect == RRectPathEffect::RRect()); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
434 AddLineTosPathEffect() {} | 464 AddLineTosPathEffect() {} |
435 }; | 465 }; |
436 | 466 |
437 // This path effect should make the keys invalid when it is applied. We onl
y produce a pathe | 467 // This path effect should make the keys invalid when it is applied. We onl
y produce a pathe |
438 // effect key for dash path effects. So the only way another arbitrary path
effect can produce | 468 // effect key for dash path effects. So the only way another arbitrary path
effect can produce |
439 // a styled result with a key is to produce a non-path shape that has a pur
ely geometric key. | 469 // a styled result with a key is to produce a non-path shape that has a pur
ely geometric key. |
440 SkPaint peStroke; | 470 SkPaint peStroke; |
441 peStroke.setPathEffect(AddLineTosPathEffect::Make()); | 471 peStroke.setPathEffect(AddLineTosPathEffect::Make()); |
442 peStroke.setStrokeWidth(2.f); | 472 peStroke.setStrokeWidth(2.f); |
443 peStroke.setStyle(SkPaint::kStroke_Style); | 473 peStroke.setStyle(SkPaint::kStroke_Style); |
444 TestCase geoPEStrokeCase(geo, peStroke); | 474 TestCase geoPEStrokeCase(geo, peStroke, reporter); |
445 TestCase::SelfExpectations expectations; | 475 TestCase::SelfExpectations expectations; |
446 expectations.fPEHasEffect = true; | 476 expectations.fPEHasEffect = true; |
447 expectations.fPEHasValidKey = false; | 477 expectations.fPEHasValidKey = false; |
448 expectations.fStrokeApplies = true; | 478 expectations.fStrokeApplies = true; |
449 geoPEStrokeCase.testExpectations(reporter, expectations); | 479 geoPEStrokeCase.testExpectations(reporter, expectations); |
450 } | 480 } |
451 | 481 |
452 /** | 482 /** |
453 * isNonPath indicates whether the initial shape made from the path is expected
to be recognized | 483 * isNonPath indicates whether the initial shape made from the path is expected
to be recognized |
454 * as a simpler shape type (e.g. rrect) | 484 * as a simpler shape type (e.g. rrect) |
455 */ | 485 */ |
456 void test_volatile_path(skiatest::Reporter* reporter, const SkPath& path, | 486 void test_volatile_path(skiatest::Reporter* reporter, const SkPath& path, |
457 bool isNonPath) { | 487 bool isNonPath) { |
458 SkPath vPath(path); | 488 SkPath vPath(path); |
459 vPath.setIsVolatile(true); | 489 vPath.setIsVolatile(true); |
460 | 490 |
461 SkPaint dashAndStroke; | 491 SkPaint dashAndStroke; |
462 dashAndStroke.setPathEffect(make_dash()); | 492 dashAndStroke.setPathEffect(make_dash()); |
463 dashAndStroke.setStrokeWidth(2.f); | 493 dashAndStroke.setStrokeWidth(2.f); |
464 dashAndStroke.setStyle(SkPaint::kStroke_Style); | 494 dashAndStroke.setStyle(SkPaint::kStroke_Style); |
465 TestCase volatileCase(vPath, dashAndStroke); | 495 TestCase volatileCase(vPath, dashAndStroke, reporter); |
466 // We expect a shape made from a volatile path to have a key iff the shape i
s recognized | 496 // We expect a shape made from a volatile path to have a key iff the shape i
s recognized |
467 // as a specialized geometry. | 497 // as a specialized geometry. |
468 if (isNonPath) { | 498 if (isNonPath) { |
469 REPORTER_ASSERT(reporter, SkToBool(volatileCase.baseKey().count())); | 499 REPORTER_ASSERT(reporter, SkToBool(volatileCase.baseKey().count())); |
470 // In this case all the keys should be identical to the non-volatile cas
e. | 500 // In this case all the keys should be identical to the non-volatile cas
e. |
471 TestCase nonVolatileCase(path, dashAndStroke); | 501 TestCase nonVolatileCase(path, dashAndStroke, reporter); |
472 volatileCase.compare(reporter, nonVolatileCase, TestCase::kAllSame_Compa
risonExpecation); | 502 volatileCase.compare(reporter, nonVolatileCase, TestCase::kAllSame_Compa
risonExpecation); |
473 } else { | 503 } else { |
474 // None of the keys should be valid. | 504 // None of the keys should be valid. |
475 REPORTER_ASSERT(reporter, !SkToBool(volatileCase.baseKey().count())); | 505 REPORTER_ASSERT(reporter, !SkToBool(volatileCase.baseKey().count())); |
476 REPORTER_ASSERT(reporter, !SkToBool(volatileCase.appliedPathEffectKey().
count())); | 506 REPORTER_ASSERT(reporter, !SkToBool(volatileCase.appliedPathEffectKey().
count())); |
477 REPORTER_ASSERT(reporter, !SkToBool(volatileCase.appliedFullStyleKey().c
ount())); | 507 REPORTER_ASSERT(reporter, !SkToBool(volatileCase.appliedFullStyleKey().c
ount())); |
478 REPORTER_ASSERT(reporter, !SkToBool(volatileCase.appliedPathEffectThenSt
rokeKey().count())); | 508 REPORTER_ASSERT(reporter, !SkToBool(volatileCase.appliedPathEffectThenSt
rokeKey().count())); |
479 } | 509 } |
480 } | 510 } |
481 | 511 |
(...skipping 19 matching lines...) Expand all Loading... |
501 EmptyPathEffect() {} | 531 EmptyPathEffect() {} |
502 }; | 532 }; |
503 | 533 |
504 SkPath emptyPath; | 534 SkPath emptyPath; |
505 GrShape emptyShape(emptyPath); | 535 GrShape emptyShape(emptyPath); |
506 Key emptyKey; | 536 Key emptyKey; |
507 make_key(&emptyKey, emptyShape); | 537 make_key(&emptyKey, emptyShape); |
508 | 538 |
509 SkPaint pe; | 539 SkPaint pe; |
510 pe.setPathEffect(EmptyPathEffect::Make()); | 540 pe.setPathEffect(EmptyPathEffect::Make()); |
511 TestCase geoCase(geo, pe); | 541 TestCase geoCase(geo, pe, reporter); |
512 REPORTER_ASSERT(reporter, geoCase.appliedFullStyleKey() == emptyKey); | 542 REPORTER_ASSERT(reporter, geoCase.appliedFullStyleKey() == emptyKey); |
513 REPORTER_ASSERT(reporter, geoCase.appliedPathEffectKey() == emptyKey); | 543 REPORTER_ASSERT(reporter, geoCase.appliedPathEffectKey() == emptyKey); |
514 REPORTER_ASSERT(reporter, geoCase.appliedPathEffectThenStrokeKey() == emptyK
ey); | 544 REPORTER_ASSERT(reporter, geoCase.appliedPathEffectThenStrokeKey() == emptyK
ey); |
515 | 545 |
516 SkPaint peStroke; | 546 SkPaint peStroke; |
517 peStroke.setPathEffect(EmptyPathEffect::Make()); | 547 peStroke.setPathEffect(EmptyPathEffect::Make()); |
518 peStroke.setStrokeWidth(2.f); | 548 peStroke.setStrokeWidth(2.f); |
519 peStroke.setStyle(SkPaint::kStroke_Style); | 549 peStroke.setStyle(SkPaint::kStroke_Style); |
520 TestCase geoPEStrokeCase(geo, peStroke); | 550 TestCase geoPEStrokeCase(geo, peStroke, reporter); |
521 REPORTER_ASSERT(reporter, geoPEStrokeCase.appliedFullStyleKey() == emptyKey)
; | 551 REPORTER_ASSERT(reporter, geoPEStrokeCase.appliedFullStyleKey() == emptyKey)
; |
522 REPORTER_ASSERT(reporter, geoPEStrokeCase.appliedPathEffectKey() == emptyKey
); | 552 REPORTER_ASSERT(reporter, geoPEStrokeCase.appliedPathEffectKey() == emptyKey
); |
523 REPORTER_ASSERT(reporter, geoPEStrokeCase.appliedPathEffectThenStrokeKey() =
= emptyKey); | 553 REPORTER_ASSERT(reporter, geoPEStrokeCase.appliedPathEffectThenStrokeKey() =
= emptyKey); |
524 } | 554 } |
525 | 555 |
526 void test_empty_shape(skiatest::Reporter* reporter) { | 556 void test_empty_shape(skiatest::Reporter* reporter) { |
527 SkPath emptyPath; | 557 SkPath emptyPath; |
528 SkPaint fill; | 558 SkPaint fill; |
529 TestCase fillEmptyCase(emptyPath, fill); | 559 TestCase fillEmptyCase(emptyPath, fill, reporter); |
530 | 560 |
531 Key emptyKey(fillEmptyCase.baseKey()); | 561 Key emptyKey(fillEmptyCase.baseKey()); |
532 REPORTER_ASSERT(reporter, emptyKey.count()); | 562 REPORTER_ASSERT(reporter, emptyKey.count()); |
533 TestCase::SelfExpectations expectations; | 563 TestCase::SelfExpectations expectations; |
534 expectations.fStrokeApplies = false; | 564 expectations.fStrokeApplies = false; |
535 expectations.fPEHasEffect = false; | 565 expectations.fPEHasEffect = false; |
536 // This will test whether applying style preserves emptiness | 566 // This will test whether applying style preserves emptiness |
537 fillEmptyCase.testExpectations(reporter, expectations); | 567 fillEmptyCase.testExpectations(reporter, expectations); |
538 | 568 |
539 // Stroking an empty path should have no effect | 569 // Stroking an empty path should have no effect |
540 SkPath emptyPath2; | 570 SkPath emptyPath2; |
541 SkPaint stroke; | 571 SkPaint stroke; |
542 stroke.setStrokeWidth(2.f); | 572 stroke.setStrokeWidth(2.f); |
543 stroke.setStyle(SkPaint::kStroke_Style); | 573 stroke.setStyle(SkPaint::kStroke_Style); |
544 TestCase strokeEmptyCase(emptyPath2, stroke); | 574 TestCase strokeEmptyCase(emptyPath2, stroke, reporter); |
545 strokeEmptyCase.compare(reporter, fillEmptyCase, TestCase::kAllSame_Comparis
onExpecation); | 575 strokeEmptyCase.compare(reporter, fillEmptyCase, TestCase::kAllSame_Comparis
onExpecation); |
546 | 576 |
547 // Dashing and stroking an empty path should have no effect | 577 // Dashing and stroking an empty path should have no effect |
548 SkPath emptyPath3; | 578 SkPath emptyPath3; |
549 SkPaint dashAndStroke; | 579 SkPaint dashAndStroke; |
550 dashAndStroke.setPathEffect(make_dash()); | 580 dashAndStroke.setPathEffect(make_dash()); |
551 dashAndStroke.setStrokeWidth(2.f); | 581 dashAndStroke.setStrokeWidth(2.f); |
552 dashAndStroke.setStyle(SkPaint::kStroke_Style); | 582 dashAndStroke.setStyle(SkPaint::kStroke_Style); |
553 TestCase dashAndStrokeEmptyCase(emptyPath3, dashAndStroke); | 583 TestCase dashAndStrokeEmptyCase(emptyPath3, dashAndStroke, reporter); |
554 dashAndStrokeEmptyCase.compare(reporter, fillEmptyCase, | 584 dashAndStrokeEmptyCase.compare(reporter, fillEmptyCase, |
555 TestCase::kAllSame_ComparisonExpecation); | 585 TestCase::kAllSame_ComparisonExpecation); |
556 | 586 |
557 // A shape made from an empty rrect should behave the same as an empty path. | 587 // A shape made from an empty rrect should behave the same as an empty path. |
558 SkRRect emptyRRect = SkRRect::MakeRect(SkRect::MakeEmpty()); | 588 SkRRect emptyRRect = SkRRect::MakeRect(SkRect::MakeEmpty()); |
559 REPORTER_ASSERT(reporter, emptyRRect.getType() == SkRRect::kEmpty_Type); | 589 REPORTER_ASSERT(reporter, emptyRRect.getType() == SkRRect::kEmpty_Type); |
560 TestCase dashAndStrokeEmptyRRectCase(emptyRRect, dashAndStroke); | 590 TestCase dashAndStrokeEmptyRRectCase(emptyRRect, dashAndStroke, reporter); |
561 dashAndStrokeEmptyRRectCase.compare(reporter, fillEmptyCase, | 591 dashAndStrokeEmptyRRectCase.compare(reporter, fillEmptyCase, |
562 TestCase::kAllSame_ComparisonExpecation)
; | 592 TestCase::kAllSame_ComparisonExpecation)
; |
563 | 593 |
564 // Same for a rect. | 594 // Same for a rect. |
565 SkRect emptyRect = SkRect::MakeEmpty(); | 595 SkRect emptyRect = SkRect::MakeEmpty(); |
566 TestCase dashAndStrokeEmptyRectCase(emptyRect, dashAndStroke); | 596 TestCase dashAndStrokeEmptyRectCase(emptyRect, dashAndStroke, reporter); |
567 dashAndStrokeEmptyRectCase.compare(reporter, fillEmptyCase, | 597 dashAndStrokeEmptyRectCase.compare(reporter, fillEmptyCase, |
568 TestCase::kAllSame_ComparisonExpecation); | 598 TestCase::kAllSame_ComparisonExpecation); |
569 } | 599 } |
570 | 600 |
571 DEF_TEST(GrShape, reporter) { | 601 DEF_TEST(GrShape, reporter) { |
572 sk_sp<SkPathEffect> dashPE = make_dash(); | 602 sk_sp<SkPathEffect> dashPE = make_dash(); |
573 | 603 |
574 for (auto rr : { SkRRect::MakeRect(SkRect::MakeWH(10, 10)), | 604 for (auto rr : { SkRRect::MakeRect(SkRect::MakeWH(10, 10)), |
575 SkRRect::MakeRectXY(SkRect::MakeWH(10, 10), 3, 4)}) { | 605 SkRRect::MakeRectXY(SkRect::MakeWH(10, 10), 3, 4)}) { |
576 test_basic(reporter, rr); | 606 test_basic(reporter, rr); |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
651 SkPaint::kButt_Cap, SkPaint::kRound_Cap); | 681 SkPaint::kButt_Cap, SkPaint::kRound_Cap); |
652 test_stroke_param<SkPath, SkPaint::Join>( | 682 test_stroke_param<SkPath, SkPaint::Join>( |
653 reporter, path, | 683 reporter, path, |
654 [](SkPaint* p, SkPaint::Join j) { p->setStrokeJoin(j);}, | 684 [](SkPaint* p, SkPaint::Join j) { p->setStrokeJoin(j);}, |
655 SkPaint::kMiter_Join, SkPaint::kRound_Join); | 685 SkPaint::kMiter_Join, SkPaint::kRound_Join); |
656 test_miter_limit(reporter, path); | 686 test_miter_limit(reporter, path); |
657 test_unknown_path_effect(reporter, path); | 687 test_unknown_path_effect(reporter, path); |
658 test_path_effect_makes_empty_shape(reporter, path); | 688 test_path_effect_makes_empty_shape(reporter, path); |
659 | 689 |
660 SkPaint fillPaint; | 690 SkPaint fillPaint; |
661 TestCase fillPathCase(path, fillPaint); | 691 TestCase fillPathCase(path, fillPaint, reporter); |
662 SkRRect rrect; | 692 SkRRect rrect; |
663 REPORTER_ASSERT(reporter, testPath.fIsRRectForFill == | 693 REPORTER_ASSERT(reporter, testPath.fIsRRectForFill == |
664 fillPathCase.baseShape().asRRect(&rrect)); | 694 fillPathCase.baseShape().asRRect(&rrect)); |
665 if (testPath.fIsRRectForFill) { | 695 if (testPath.fIsRRectForFill) { |
666 REPORTER_ASSERT(reporter, rrect == testPath.fRRect); | 696 REPORTER_ASSERT(reporter, rrect == testPath.fRRect); |
667 TestCase fillRRectCase(rrect, fillPaint); | 697 TestCase fillRRectCase(rrect, fillPaint, reporter); |
668 fillPathCase.compare(reporter, fillRRectCase, TestCase::kAllSame_Com
parisonExpecation); | 698 fillPathCase.compare(reporter, fillRRectCase, TestCase::kAllSame_Com
parisonExpecation); |
669 } | 699 } |
670 | 700 |
671 SkPaint strokePaint; | 701 SkPaint strokePaint; |
672 strokePaint.setStrokeWidth(3.f); | 702 strokePaint.setStrokeWidth(3.f); |
673 strokePaint.setStyle(SkPaint::kStroke_Style); | 703 strokePaint.setStyle(SkPaint::kStroke_Style); |
674 TestCase strokePathCase(path, strokePaint); | 704 TestCase strokePathCase(path, strokePaint, reporter); |
675 REPORTER_ASSERT(reporter, testPath.fIsRRectForStroke == | 705 REPORTER_ASSERT(reporter, testPath.fIsRRectForStroke == |
676 strokePathCase.baseShape().asRRect(&rrect)); | 706 strokePathCase.baseShape().asRRect(&rrect)); |
677 if (testPath.fIsRRectForStroke) { | 707 if (testPath.fIsRRectForStroke) { |
678 REPORTER_ASSERT(reporter, rrect == testPath.fRRect); | 708 REPORTER_ASSERT(reporter, rrect == testPath.fRRect); |
679 TestCase strokeRRectCase(rrect, strokePaint); | 709 TestCase strokeRRectCase(rrect, strokePaint, reporter); |
680 strokePathCase.compare(reporter, strokeRRectCase, | 710 strokePathCase.compare(reporter, strokeRRectCase, |
681 TestCase::kAllSame_ComparisonExpecation); | 711 TestCase::kAllSame_ComparisonExpecation); |
682 } | 712 } |
683 } | 713 } |
684 | 714 |
685 // Test a volatile empty path. | 715 // Test a volatile empty path. |
686 test_volatile_path(reporter, SkPath(), true); | 716 test_volatile_path(reporter, SkPath(), true); |
687 | 717 |
688 test_empty_shape(reporter); | 718 test_empty_shape(reporter); |
689 } | 719 } |
690 | 720 |
691 #endif | 721 #endif |
OLD | NEW |