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

Side by Side Diff: tests/GrShapeTest.cpp

Issue 1949943003: Stop banning stroke-and-fill for GrStyle and add tests (Closed) Base URL: https://chromium.googlesource.com/skia.git@capfix
Patch Set: Created 4 years, 7 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/gpu/GrStyle.h ('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 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 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 TestCase(geo, stroke2RoundBevelDash, reporter).compare(reporter, stroke2Roun dBevelDashCase, 244 TestCase(geo, stroke2RoundBevelDash, reporter).compare(reporter, stroke2Roun dBevelDashCase,
245 TestCase::kAllSame_Co mparisonExpecation); 245 TestCase::kAllSame_Co mparisonExpecation);
246 246
247 fillCase.compare(reporter, stroke2RoundBevelCase, 247 fillCase.compare(reporter, stroke2RoundBevelCase,
248 TestCase::kSameUpToStroke_ComparisonExpecation); 248 TestCase::kSameUpToStroke_ComparisonExpecation);
249 fillCase.compare(reporter, stroke2RoundBevelDashCase, 249 fillCase.compare(reporter, stroke2RoundBevelDashCase,
250 TestCase::kSameUpToPE_ComparisonExpecation); 250 TestCase::kSameUpToPE_ComparisonExpecation);
251 stroke2RoundBevelCase.compare(reporter, stroke2RoundBevelDashCase, 251 stroke2RoundBevelCase.compare(reporter, stroke2RoundBevelDashCase,
252 TestCase::kSameUpToPE_ComparisonExpecation); 252 TestCase::kSameUpToPE_ComparisonExpecation);
253 253
254 // Stroke and fill cases
255 SkPaint stroke2RoundBevelAndFill = stroke2RoundBevel;
256 stroke2RoundBevelAndFill.setStyle(SkPaint::kStrokeAndFill_Style);
257 TestCase stroke2RoundBevelAndFillCase(geo, stroke2RoundBevelAndFill, reporte r);
258 expectations.fPEHasValidKey = true;
259 expectations.fPEHasEffect = false;
260 expectations.fStrokeApplies = true;
261 stroke2RoundBevelAndFillCase.testExpectations(reporter, expectations);
262 TestCase(geo, stroke2RoundBevelAndFill, reporter).compare(reporter,
263 stroke2RoundBevelAndFillCase, TestCase::kAllSame_ComparisonExpecatio n);
264
265 SkPaint stroke2RoundBevelAndFillDash = stroke2RoundBevelDash;
266 stroke2RoundBevelAndFillDash.setStyle(SkPaint::kStrokeAndFill_Style);
267 TestCase stroke2RoundBevelAndFillDashCase(geo, stroke2RoundBevelAndFillDash, reporter);
268 expectations.fPEHasValidKey = true;
269 expectations.fPEHasEffect = true;
270 expectations.fStrokeApplies = true;
271 stroke2RoundBevelAndFillDashCase.testExpectations(reporter, expectations);
272 TestCase(geo, stroke2RoundBevelAndFillDash, reporter).compare(
273 reporter, stroke2RoundBevelAndFillDashCase, TestCase::kAllSame_Compariso nExpecation);
274
275 stroke2RoundBevelAndFillCase.compare(reporter, stroke2RoundBevelCase,
276 TestCase::kSameUpToStroke_ComparisonExp ecation);
277 stroke2RoundBevelAndFillDashCase.compare(reporter, stroke2RoundBevelDashCase ,
278 TestCase::kSameUpToStroke_Compariso nExpecation);
279 stroke2RoundBevelAndFillCase.compare(reporter, stroke2RoundBevelAndFillDashC ase,
280 TestCase::kSameUpToPE_ComparisonExpecat ion);
281
254 SkPaint hairline; 282 SkPaint hairline;
255 hairline.setStyle(SkPaint::kStroke_Style); 283 hairline.setStyle(SkPaint::kStroke_Style);
256 hairline.setStrokeWidth(0.f); 284 hairline.setStrokeWidth(0.f);
257 TestCase hairlineCase(geo, hairline, reporter); 285 TestCase hairlineCase(geo, hairline, reporter);
258 // Since hairline style doesn't change the SkPath data, it is keyed identica lly to fill. 286 // Since hairline style doesn't change the SkPath data, it is keyed identica lly to fill.
259 hairlineCase.compare(reporter, fillCase, TestCase::kAllSame_ComparisonExpeca tion); 287 hairlineCase.compare(reporter, fillCase, TestCase::kAllSame_ComparisonExpeca tion);
260 REPORTER_ASSERT(reporter, hairlineCase.baseShape().style().isSimpleHairline( )); 288 REPORTER_ASSERT(reporter, hairlineCase.baseShape().style().isSimpleHairline( ));
261 REPORTER_ASSERT(reporter, hairlineCase.appliedFullStyleShape().style().isSim pleHairline()); 289 REPORTER_ASSERT(reporter, hairlineCase.appliedFullStyleShape().style().isSim pleHairline());
262 REPORTER_ASSERT(reporter, hairlineCase.appliedPathEffectShape().style().isSi mpleHairline()); 290 REPORTER_ASSERT(reporter, hairlineCase.appliedPathEffectShape().style().isSi mpleHairline());
263 } 291 }
(...skipping 15 matching lines...) Expand all
279 setter(&strokeB, b); 307 setter(&strokeB, b);
280 308
281 TestCase strokeACase(geo, strokeA, reporter); 309 TestCase strokeACase(geo, strokeA, reporter);
282 TestCase strokeBCase(geo, strokeB, reporter); 310 TestCase strokeBCase(geo, strokeB, reporter);
283 if (paramAffectsStroke) { 311 if (paramAffectsStroke) {
284 strokeACase.compare(reporter, strokeBCase, TestCase::kSameUpToStroke_Com parisonExpecation); 312 strokeACase.compare(reporter, strokeBCase, TestCase::kSameUpToStroke_Com parisonExpecation);
285 } else { 313 } else {
286 strokeACase.compare(reporter, strokeBCase, TestCase::kAllSame_Comparison Expecation); 314 strokeACase.compare(reporter, strokeBCase, TestCase::kAllSame_Comparison Expecation);
287 } 315 }
288 316
317 SkPaint strokeAndFillA = strokeA;
318 SkPaint strokeAndFillB = strokeB;
319 strokeAndFillA.setStyle(SkPaint::kStrokeAndFill_Style);
320 strokeAndFillB.setStyle(SkPaint::kStrokeAndFill_Style);
321 TestCase strokeAndFillACase(geo, strokeAndFillA, reporter);
322 TestCase strokeAndFillBCase(geo, strokeAndFillB, reporter);
323 if (paramAffectsStroke) {
324 strokeAndFillACase.compare(reporter, strokeAndFillBCase,
325 TestCase::kSameUpToStroke_ComparisonExpecatio n);
326 } else {
327 strokeAndFillACase.compare(reporter, strokeAndFillBCase,
328 TestCase::kAllSame_ComparisonExpecation);
329 }
330
289 // Make sure stroking params don't affect fill style. 331 // Make sure stroking params don't affect fill style.
290 SkPaint fillA = strokeA, fillB = strokeB; 332 SkPaint fillA = strokeA, fillB = strokeB;
291 fillA.setStyle(SkPaint::kFill_Style); 333 fillA.setStyle(SkPaint::kFill_Style);
292 fillB.setStyle(SkPaint::kFill_Style); 334 fillB.setStyle(SkPaint::kFill_Style);
293 TestCase fillACase(geo, fillA, reporter); 335 TestCase fillACase(geo, fillA, reporter);
294 TestCase fillBCase(geo, fillB, reporter); 336 TestCase fillBCase(geo, fillB, reporter);
295 fillACase.compare(reporter, fillBCase, TestCase::kAllSame_ComparisonExpecati on); 337 fillACase.compare(reporter, fillBCase, TestCase::kAllSame_ComparisonExpecati on);
296 338
297 // Make sure just applying the dash but not stroke gives the same key for bo th stroking 339 // Make sure just applying the dash but not stroke gives the same key for bo th stroking
298 // variations. 340 // variations.
299 SkPaint dashA = strokeA, dashB = strokeB; 341 SkPaint dashA = strokeA, dashB = strokeB;
300 dashA.setPathEffect(make_dash()); 342 dashA.setPathEffect(make_dash());
301 dashB.setPathEffect(make_dash()); 343 dashB.setPathEffect(make_dash());
302 TestCase dashACase(geo, dashA, reporter); 344 TestCase dashACase(geo, dashA, reporter);
303 TestCase dashBCase(geo, dashB, reporter); 345 TestCase dashBCase(geo, dashB, reporter);
304 if (paramAffectsDashAndStroke) { 346 if (paramAffectsDashAndStroke) {
305 dashACase.compare(reporter, dashBCase, TestCase::kSameUpToStroke_Compari sonExpecation); 347 dashACase.compare(reporter, dashBCase, TestCase::kSameUpToStroke_Compari sonExpecation);
306 } else { 348 } else {
307 dashACase.compare(reporter, dashBCase, TestCase::kAllSame_ComparisonExpe cation); 349 dashACase.compare(reporter, dashBCase, TestCase::kAllSame_ComparisonExpe cation);
308 } 350 }
351
352 SkPaint dashStrokeAndFillA = dashA, dashStrokeAndFillB = dashB;
353 dashStrokeAndFillA.setStyle(SkPaint::kStrokeAndFill_Style);
354 dashStrokeAndFillB.setStyle(SkPaint::kStrokeAndFill_Style);
355 TestCase dashStrokeAndFillACase(geo, dashStrokeAndFillA, reporter);
356 TestCase dashStrokeAndFillBCase(geo, dashStrokeAndFillB, reporter);
357 if (paramAffectsDashAndStroke) {
358 dashStrokeAndFillACase.compare(reporter, dashStrokeAndFillBCase,
359 TestCase::kSameUpToStroke_ComparisonExpec ation);
360 } else {
361 dashStrokeAndFillACase.compare(reporter, dashStrokeAndFillBCase,
362 TestCase::kAllSame_ComparisonExpecation);
363 }
309 } 364 }
310 365
311 template <typename GEO, typename T> 366 template <typename GEO, typename T>
312 static void test_stroke_param(skiatest::Reporter* reporter, const GEO& geo, 367 static void test_stroke_param(skiatest::Reporter* reporter, const GEO& geo,
313 std::function<void(SkPaint*, T)> setter, T a, T b) { 368 std::function<void(SkPaint*, T)> setter, T a, T b) {
314 test_stroke_param_impl(reporter, geo, setter, a, b, true, true); 369 test_stroke_param_impl(reporter, geo, setter, a, b, true, true);
315 }; 370 };
316 371
317 template <typename GEO> 372 template <typename GEO>
318 static void test_stroke_cap(skiatest::Reporter* reporter, const GEO& geo) { 373 static void test_stroke_cap(skiatest::Reporter* reporter, const GEO& geo) {
(...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after
791 } 846 }
792 } 847 }
793 848
794 // Test a volatile empty path. 849 // Test a volatile empty path.
795 test_volatile_path(reporter, SkPath(), true); 850 test_volatile_path(reporter, SkPath(), true);
796 851
797 test_empty_shape(reporter); 852 test_empty_shape(reporter);
798 } 853 }
799 854
800 #endif 855 #endif
OLDNEW
« no previous file with comments | « src/gpu/GrStyle.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698