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 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
383 expectations.fPEHasEffect = false; | 383 expectations.fPEHasEffect = false; |
384 expectations.fStrokeApplies = true; | 384 expectations.fStrokeApplies = true; |
385 stroke2RoundBevelAndFillCase.testExpectations(reporter, expectations); | 385 stroke2RoundBevelAndFillCase.testExpectations(reporter, expectations); |
386 TestCase(geo, stroke2RoundBevelAndFill, reporter).compare(reporter, | 386 TestCase(geo, stroke2RoundBevelAndFill, reporter).compare(reporter, |
387 stroke2RoundBevelAndFillCase, TestCase::kAllSame_ComparisonExpecatio
n); | 387 stroke2RoundBevelAndFillCase, TestCase::kAllSame_ComparisonExpecatio
n); |
388 | 388 |
389 SkPaint stroke2RoundBevelAndFillDash = stroke2RoundBevelDash; | 389 SkPaint stroke2RoundBevelAndFillDash = stroke2RoundBevelDash; |
390 stroke2RoundBevelAndFillDash.setStyle(SkPaint::kStrokeAndFill_Style); | 390 stroke2RoundBevelAndFillDash.setStyle(SkPaint::kStrokeAndFill_Style); |
391 TestCase stroke2RoundBevelAndFillDashCase(geo, stroke2RoundBevelAndFillDash,
reporter); | 391 TestCase stroke2RoundBevelAndFillDashCase(geo, stroke2RoundBevelAndFillDash,
reporter); |
392 expectations.fPEHasValidKey = true; | 392 expectations.fPEHasValidKey = true; |
393 expectations.fPEHasEffect = true; | 393 expectations.fPEHasEffect = false; |
394 expectations.fStrokeApplies = true; | 394 expectations.fStrokeApplies = true; |
395 stroke2RoundBevelAndFillDashCase.testExpectations(reporter, expectations); | 395 stroke2RoundBevelAndFillDashCase.testExpectations(reporter, expectations); |
396 TestCase(geo, stroke2RoundBevelAndFillDash, reporter).compare( | 396 TestCase(geo, stroke2RoundBevelAndFillDash, reporter).compare( |
397 reporter, stroke2RoundBevelAndFillDashCase, TestCase::kAllSame_Compariso
nExpecation); | 397 reporter, stroke2RoundBevelAndFillDashCase, TestCase::kAllSame_Compariso
nExpecation); |
398 | 398 stroke2RoundBevelAndFillDashCase.compare(reporter, stroke2RoundBevelAndFillC
ase, |
399 stroke2RoundBevelAndFillCase.compare(reporter, stroke2RoundBevelCase, | 399 TestCase::kAllSame_ComparisonExpeca
tion); |
400 TestCase::kSameUpToStroke_ComparisonExp
ecation); | |
401 stroke2RoundBevelAndFillDashCase.compare(reporter, stroke2RoundBevelDashCase
, | |
402 TestCase::kSameUpToStroke_Compariso
nExpecation); | |
403 stroke2RoundBevelAndFillCase.compare(reporter, stroke2RoundBevelAndFillDashC
ase, | |
404 TestCase::kSameUpToPE_ComparisonExpecat
ion); | |
405 | 400 |
406 SkPaint hairline; | 401 SkPaint hairline; |
407 hairline.setStyle(SkPaint::kStroke_Style); | 402 hairline.setStyle(SkPaint::kStroke_Style); |
408 hairline.setStrokeWidth(0.f); | 403 hairline.setStrokeWidth(0.f); |
409 TestCase hairlineCase(geo, hairline, reporter); | 404 TestCase hairlineCase(geo, hairline, reporter); |
410 // Since hairline style doesn't change the SkPath data, it is keyed identica
lly to fill. | 405 // Since hairline style doesn't change the SkPath data, it is keyed identica
lly to fill. |
411 hairlineCase.compare(reporter, fillCase, TestCase::kAllSame_ComparisonExpeca
tion); | 406 hairlineCase.compare(reporter, fillCase, TestCase::kAllSame_ComparisonExpeca
tion); |
412 REPORTER_ASSERT(reporter, hairlineCase.baseShape().style().isSimpleHairline(
)); | 407 REPORTER_ASSERT(reporter, hairlineCase.baseShape().style().isSimpleHairline(
)); |
413 REPORTER_ASSERT(reporter, hairlineCase.appliedFullStyleShape().style().isSim
pleHairline()); | 408 REPORTER_ASSERT(reporter, hairlineCase.appliedFullStyleShape().style().isSim
pleHairline()); |
414 REPORTER_ASSERT(reporter, hairlineCase.appliedPathEffectShape().style().isSi
mpleHairline()); | 409 REPORTER_ASSERT(reporter, hairlineCase.appliedPathEffectShape().style().isSi
mpleHairline()); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
448 TestCase strokeDashCase1(geo, strokeDash, reporter, kS1); | 443 TestCase strokeDashCase1(geo, strokeDash, reporter, kS1); |
449 TestCase strokeDashCase2(geo, strokeDash, reporter, kS2); | 444 TestCase strokeDashCase2(geo, strokeDash, reporter, kS2); |
450 // Scale affects the dash and the stroke. | 445 // Scale affects the dash and the stroke. |
451 strokeDashCase1.compare(reporter, strokeDashCase2, TestCase::kSameUpToPE_Co
mparisonExpecation); | 446 strokeDashCase1.compare(reporter, strokeDashCase2, TestCase::kSameUpToPE_Co
mparisonExpecation); |
452 | 447 |
453 // Stroke and fill cases | 448 // Stroke and fill cases |
454 SkPaint strokeAndFill = stroke; | 449 SkPaint strokeAndFill = stroke; |
455 strokeAndFill.setStyle(SkPaint::kStrokeAndFill_Style); | 450 strokeAndFill.setStyle(SkPaint::kStrokeAndFill_Style); |
456 TestCase strokeAndFillCase1(geo, strokeAndFill, reporter, kS1); | 451 TestCase strokeAndFillCase1(geo, strokeAndFill, reporter, kS1); |
457 TestCase strokeAndFillCase2(geo, strokeAndFill, reporter, kS2); | 452 TestCase strokeAndFillCase2(geo, strokeAndFill, reporter, kS2); |
| 453 SkPaint strokeAndFillDash = strokeDash; |
| 454 strokeAndFillDash.setStyle(SkPaint::kStrokeAndFill_Style); |
| 455 // Dash is ignored for stroke and fill |
| 456 TestCase strokeAndFillDashCase1(geo, strokeAndFillDash, reporter, kS1); |
| 457 TestCase strokeAndFillDashCase2(geo, strokeAndFillDash, reporter, kS2); |
458 // Scale affects the stroke. Though, this can wind up creating a rect when t
he input is a rect. | 458 // Scale affects the stroke. Though, this can wind up creating a rect when t
he input is a rect. |
459 // In that case we wind up with a pure geometry key and the geometries are t
he same. | 459 // In that case we wind up with a pure geometry key and the geometries are t
he same. |
460 SkRRect rrect; | 460 SkRRect rrect; |
461 if (strokeAndFillCase1.appliedFullStyleShape().asRRect(&rrect, nullptr, null
ptr)) { | 461 if (strokeAndFillCase1.appliedFullStyleShape().asRRect(&rrect, nullptr, null
ptr)) { |
462 // We currently only expect to get here in the rect->rect case. | 462 // We currently only expect to get here in the rect->rect case. |
463 REPORTER_ASSERT(reporter, rrect.isRect()); | 463 REPORTER_ASSERT(reporter, rrect.isRect()); |
464 REPORTER_ASSERT(reporter, | 464 REPORTER_ASSERT(reporter, |
465 strokeAndFillCase1.baseShape().asRRect(&rrect, nullptr,
nullptr) && | 465 strokeAndFillCase1.baseShape().asRRect(&rrect, nullptr,
nullptr) && |
466 rrect.isRect()); | 466 rrect.isRect()); |
467 strokeAndFillCase1.compare(reporter, strokeAndFillCase2, | 467 strokeAndFillCase1.compare(reporter, strokeAndFillCase2, |
468 TestCase::kAllSame_ComparisonExpecation); | 468 TestCase::kAllSame_ComparisonExpecation); |
469 } else { | 469 } else { |
470 strokeAndFillCase1.compare(reporter, strokeAndFillCase2, | 470 strokeAndFillCase1.compare(reporter, strokeAndFillCase2, |
471 TestCase::kSameUpToStroke_ComparisonExpecatio
n); | 471 TestCase::kSameUpToStroke_ComparisonExpecatio
n); |
| 472 strokeAndFillDashCase1.compare(reporter, strokeAndFillDashCase2, |
| 473 TestCase::kSameUpToStroke_ComparisonExpec
ation); |
472 } | 474 } |
473 | 475 strokeAndFillDashCase1.compare(reporter, strokeAndFillCase1, |
474 SkPaint strokeAndFillDash = strokeDash; | 476 TestCase::kAllSame_ComparisonExpecation); |
475 strokeAndFillDash.setStyle(SkPaint::kStrokeAndFill_Style); | 477 strokeAndFillDashCase2.compare(reporter, strokeAndFillCase2, |
476 TestCase strokeAndFillDashCase1(geo, strokeAndFillDash, reporter, kS1); | 478 TestCase::kAllSame_ComparisonExpecation); |
477 TestCase strokeAndFillDashCase2(geo, strokeAndFillDash, reporter, kS2); | |
478 // Scale affects the path effect and stroke. | |
479 strokeAndFillDashCase1.compare(reporter, strokeAndFillDashCase2, | |
480 TestCase::kSameUpToPE_ComparisonExpecation); | |
481 } | 479 } |
482 | 480 |
483 template <typename GEO, typename T> | 481 template <typename GEO, typename T> |
484 static void test_stroke_param_impl(skiatest::Reporter* reporter, const GEO& geo, | 482 static void test_stroke_param_impl(skiatest::Reporter* reporter, const GEO& geo, |
485 std::function<void(SkPaint*, T)> setter, T a,
T b, | 483 std::function<void(SkPaint*, T)> setter, T a,
T b, |
486 bool paramAffectsStroke, | 484 bool paramAffectsStroke, |
487 bool paramAffectsDashAndStroke) { | 485 bool paramAffectsDashAndStroke) { |
488 // Set the stroke width so that we don't get hairline. However, call the set
ter afterward so | 486 // Set the stroke width so that we don't get hairline. However, call the set
ter afterward so |
489 // that it can override the stroke width. | 487 // that it can override the stroke width. |
490 SkPaint strokeA; | 488 SkPaint strokeA; |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
531 SkPaint dashA = strokeA, dashB = strokeB; | 529 SkPaint dashA = strokeA, dashB = strokeB; |
532 dashA.setPathEffect(make_dash()); | 530 dashA.setPathEffect(make_dash()); |
533 dashB.setPathEffect(make_dash()); | 531 dashB.setPathEffect(make_dash()); |
534 TestCase dashACase(geo, dashA, reporter); | 532 TestCase dashACase(geo, dashA, reporter); |
535 TestCase dashBCase(geo, dashB, reporter); | 533 TestCase dashBCase(geo, dashB, reporter); |
536 if (paramAffectsDashAndStroke) { | 534 if (paramAffectsDashAndStroke) { |
537 dashACase.compare(reporter, dashBCase, TestCase::kSameUpToStroke_Compari
sonExpecation); | 535 dashACase.compare(reporter, dashBCase, TestCase::kSameUpToStroke_Compari
sonExpecation); |
538 } else { | 536 } else { |
539 dashACase.compare(reporter, dashBCase, TestCase::kAllSame_ComparisonExpe
cation); | 537 dashACase.compare(reporter, dashBCase, TestCase::kAllSame_ComparisonExpe
cation); |
540 } | 538 } |
541 | |
542 SkPaint dashStrokeAndFillA = dashA, dashStrokeAndFillB = dashB; | |
543 dashStrokeAndFillA.setStyle(SkPaint::kStrokeAndFill_Style); | |
544 dashStrokeAndFillB.setStyle(SkPaint::kStrokeAndFill_Style); | |
545 TestCase dashStrokeAndFillACase(geo, dashStrokeAndFillA, reporter); | |
546 TestCase dashStrokeAndFillBCase(geo, dashStrokeAndFillB, reporter); | |
547 if (paramAffectsDashAndStroke) { | |
548 dashStrokeAndFillACase.compare(reporter, dashStrokeAndFillBCase, | |
549 TestCase::kSameUpToStroke_ComparisonExpec
ation); | |
550 } else { | |
551 dashStrokeAndFillACase.compare(reporter, dashStrokeAndFillBCase, | |
552 TestCase::kAllSame_ComparisonExpecation); | |
553 } | |
554 } | 539 } |
555 | 540 |
556 template <typename GEO, typename T> | 541 template <typename GEO, typename T> |
557 static void test_stroke_param(skiatest::Reporter* reporter, const GEO& geo, | 542 static void test_stroke_param(skiatest::Reporter* reporter, const GEO& geo, |
558 std::function<void(SkPaint*, T)> setter, T a, T b)
{ | 543 std::function<void(SkPaint*, T)> setter, T a, T b)
{ |
559 test_stroke_param_impl(reporter, geo, setter, a, b, true, true); | 544 test_stroke_param_impl(reporter, geo, setter, a, b, true, true); |
560 }; | 545 }; |
561 | 546 |
562 template <typename GEO> | 547 template <typename GEO> |
563 static void test_stroke_cap(skiatest::Reporter* reporter, const GEO& geo) { | 548 static void test_stroke_cap(skiatest::Reporter* reporter, const GEO& geo) { |
(...skipping 579 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1143 } | 1128 } |
1144 } | 1129 } |
1145 | 1130 |
1146 // Test a volatile empty path. | 1131 // Test a volatile empty path. |
1147 test_volatile_path(reporter, SkPath(), true); | 1132 test_volatile_path(reporter, SkPath(), true); |
1148 | 1133 |
1149 test_empty_shape(reporter); | 1134 test_empty_shape(reporter); |
1150 } | 1135 } |
1151 | 1136 |
1152 #endif | 1137 #endif |
OLD | NEW |