|
17 | 17 | #include "flutter/testing/testing.h" |
18 | 18 | #include "third_party/skia/include/core/SkPictureRecorder.h" |
19 | 19 | #include "third_party/skia/include/core/SkSurface.h" |
20 | | -#include "third_party/skia/include/effects/SkDashPathEffect.h" |
21 | | -#include "third_party/skia/include/effects/SkDiscretePathEffect.h" |
22 | | -#include "third_party/skia/include/effects/SkGradientShader.h" |
23 | | -#include "third_party/skia/include/effects/SkImageFilters.h" |
24 | 20 |
|
25 | 21 | namespace flutter { |
26 | 22 | namespace testing { |
@@ -668,21 +664,22 @@ class TestParameters { |
668 | 664 | return false; |
669 | 665 | } |
670 | 666 |
|
| 667 | + bool is_stroked = flags_.is_stroked(attr.getDrawStyle()); |
| 668 | + if (flags_.is_stroked(ref_attr.getDrawStyle()) != is_stroked) { |
| 669 | + return false; |
| 670 | + } |
671 | 671 | DisplayListSpecialGeometryFlags geo_flags = |
672 | | - flags_.WithPathEffect(attr.getPathEffect().get()); |
| 672 | + flags_.WithPathEffect(attr.getPathEffect().get(), is_stroked); |
673 | 673 | if (flags_.applies_path_effect() && // |
674 | 674 | ref_attr.getPathEffect() != attr.getPathEffect()) { |
675 | | - if (attr.getPathEffect()->asDash() == nullptr) { |
676 | | - return false; |
677 | | - } |
678 | | - if (!ignores_dashes()) { |
679 | | - return false; |
| 675 | + switch (attr.getPathEffect()->type()) { |
| 676 | + case DlPathEffectType::kDash: { |
| 677 | + if (is_stroked && !ignores_dashes()) { |
| 678 | + return false; |
| 679 | + } |
| 680 | + } |
680 | 681 | } |
681 | 682 | } |
682 | | - bool is_stroked = flags_.is_stroked(ref_attr.getDrawStyle()); |
683 | | - if (flags_.is_stroked(attr.getDrawStyle()) != is_stroked) { |
684 | | - return false; |
685 | | - } |
686 | 683 | if (!is_stroked) { |
687 | 684 | return true; |
688 | 685 | } |
@@ -766,7 +763,7 @@ class TestParameters { |
766 | 763 | auto path_effect = paint.getPathEffect(); |
767 | 764 |
|
768 | 765 | DisplayListSpecialGeometryFlags geo_flags = |
769 | | - flags_.WithPathEffect(path_effect.get()); |
| 766 | + flags_.WithPathEffect(path_effect.get(), true); |
770 | 767 | if (paint.getStrokeCap() == DlStrokeCap::kButt && |
771 | 768 | !geo_flags.butt_cap_becomes_square()) { |
772 | 769 | adjust = std::max(adjust, half_width); |
@@ -1117,10 +1114,18 @@ class CanvasCompareTester { |
1117 | 1114 | .with_restore(sk_safe_restore, dl_safe_restore, true)); |
1118 | 1115 | } |
1119 | 1116 | } |
| 1117 | + |
1120 | 1118 | { |
1121 | | - sk_sp<SkImageFilter> sk_filter = SkImageFilters::Arithmetic( |
1122 | | - 0.1, 0.1, 0.1, 0.25, true, nullptr, nullptr); |
1123 | | - DlUnknownImageFilter filter(sk_filter); |
| 1119 | + // clang-format off |
| 1120 | + constexpr float color_matrix[20] = { |
| 1121 | + 0.5, 0, 0, 0, 0.5, |
| 1122 | + 0, 0.5, 0, 0, 0.5, |
| 1123 | + 0, 0, 0.5, 0, 0.5, |
| 1124 | + 0, 0, 0, 1, 0, |
| 1125 | + }; |
| 1126 | + // clang-format on |
| 1127 | + DlMatrixColorFilter color_filter(color_matrix); |
| 1128 | + DlColorFilterImageFilter filter(color_filter); |
1124 | 1129 | { |
1125 | 1130 | RenderWith(testP, env, tolerance, |
1126 | 1131 | CaseParameters( |
@@ -1463,67 +1468,6 @@ class CanvasCompareTester { |
1463 | 1468 | } |
1464 | 1469 | } |
1465 | 1470 |
|
1466 | | - { |
1467 | | - sk_sp<SkPathEffect> effect = SkDiscretePathEffect::Make(3, 5); |
1468 | | - { |
1469 | | - // Discrete path effects need a stroke width for drawPointsAsPoints |
1470 | | - // to do something realistic |
1471 | | - // And a Discrete(3, 5) effect produces miters that are near |
1472 | | - // maximal for a miter limit of 3.0. |
1473 | | - BoundsTolerance discrete_tolerance = |
1474 | | - tolerance |
1475 | | - // register the discrete offset so adjusters can compensate |
1476 | | - .addDiscreteOffset(5) |
1477 | | - // the miters in the 3-5 discrete effect don't always fill |
1478 | | - // their conservative bounds, so tolerate a couple of pixels |
1479 | | - .addBoundsPadding(2, 2); |
1480 | | - RenderWith(testP, env, discrete_tolerance, |
1481 | | - CaseParameters( |
1482 | | - "PathEffect == Discrete-3-5", |
1483 | | - [=](SkCanvas*, SkPaint& p) { |
1484 | | - p.setStrokeWidth(5.0); |
1485 | | - p.setStrokeMiter(3.0); |
1486 | | - p.setPathEffect(effect); |
1487 | | - }, |
1488 | | - [=](DlCanvas*, DlPaint& p) { |
1489 | | - p.setStrokeWidth(5.0); |
1490 | | - p.setStrokeMiter(3.0); |
1491 | | - p.setPathEffect(DlPathEffect::From(effect)); |
1492 | | - })); |
1493 | | - } |
1494 | | - EXPECT_TRUE(testP.is_draw_text_blob() || effect->unique()) |
1495 | | - << "PathEffect == Discrete-3-5 Cleanup"; |
1496 | | - effect = SkDiscretePathEffect::Make(2, 3); |
1497 | | - { |
1498 | | - // Discrete path effects need a stroke width for drawPointsAsPoints |
1499 | | - // to do something realistic |
1500 | | - // And a Discrete(2, 3) effect produces miters that are near |
1501 | | - // maximal for a miter limit of 2.5. |
1502 | | - BoundsTolerance discrete_tolerance = |
1503 | | - tolerance |
1504 | | - // register the discrete offset so adjusters can compensate |
1505 | | - .addDiscreteOffset(3) |
1506 | | - // the miters in the 3-5 discrete effect don't always fill |
1507 | | - // their conservative bounds, so tolerate a couple of pixels |
1508 | | - .addBoundsPadding(2, 2); |
1509 | | - RenderWith(testP, env, discrete_tolerance, |
1510 | | - CaseParameters( |
1511 | | - "PathEffect == Discrete-2-3", |
1512 | | - [=](SkCanvas*, SkPaint& p) { |
1513 | | - p.setStrokeWidth(5.0); |
1514 | | - p.setStrokeMiter(2.5); |
1515 | | - p.setPathEffect(effect); |
1516 | | - }, |
1517 | | - [=](DlCanvas*, DlPaint& p) { |
1518 | | - p.setStrokeWidth(5.0); |
1519 | | - p.setStrokeMiter(2.5); |
1520 | | - p.setPathEffect(DlPathEffect::From(effect)); |
1521 | | - })); |
1522 | | - } |
1523 | | - EXPECT_TRUE(testP.is_draw_text_blob() || effect->unique()) |
1524 | | - << "PathEffect == Discrete-2-3 Cleanup"; |
1525 | | - } |
1526 | | - |
1527 | 1471 | { |
1528 | 1472 | const DlBlurMaskFilter filter(kNormal_SkBlurStyle, 5.0); |
1529 | 1473 | BoundsTolerance blur_5_tolerance = tolerance.addBoundsPadding(4, 4); |
@@ -1754,6 +1698,21 @@ class CanvasCompareTester { |
1754 | 1698 | const SkScalar test_dashes_1[] = {29.0, 2.0}; |
1755 | 1699 | const SkScalar test_dashes_2[] = {17.0, 1.5}; |
1756 | 1700 | auto effect = DlDashPathEffect::Make(test_dashes_1, 2, 0.0f); |
| 1701 | + { |
| 1702 | + RenderWith(testP, stroke_base_env, tolerance, |
| 1703 | + CaseParameters( |
| 1704 | + "PathEffect without forced stroking == Dash-29-2", |
| 1705 | + [=](SkCanvas*, SkPaint& p) { |
| 1706 | + // Provide some non-trivial stroke size to get dashed |
| 1707 | + p.setStrokeWidth(5.0); |
| 1708 | + p.setPathEffect(effect->skia_object()); |
| 1709 | + }, |
| 1710 | + [=](DlCanvas*, DlPaint& p) { |
| 1711 | + // Provide some non-trivial stroke size to get dashed |
| 1712 | + p.setStrokeWidth(5.0); |
| 1713 | + p.setPathEffect(effect); |
| 1714 | + })); |
| 1715 | + } |
1757 | 1716 | { |
1758 | 1717 | RenderWith(testP, stroke_base_env, tolerance, |
1759 | 1718 | CaseParameters( |
|
0 commit comments