@@ -1614,172 +1614,6 @@ TEST_P(AiksTest, SolidColorCirclesOvalsRRectsMaskBlurCorrectly) {
1614
1614
ASSERT_TRUE (OpenPlaygroundHere (canvas.EndRecordingAsPicture ()));
1615
1615
}
1616
1616
1617
- struct MaskBlurTestConfig {
1618
- FilterContents::BlurStyle style = FilterContents::BlurStyle::kNormal ;
1619
- Scalar sigma = 1 .0f ;
1620
- Scalar alpha = 1 .0f ;
1621
- std::shared_ptr<ImageFilter> image_filter;
1622
- bool invert_colors = false ;
1623
- BlendMode blend_mode = BlendMode::kSourceOver ;
1624
- };
1625
-
1626
- static Picture MaskBlurVariantTest (const AiksTest& test_context,
1627
- const MaskBlurTestConfig& config) {
1628
- Canvas canvas;
1629
- canvas.Scale (test_context.GetContentScale ());
1630
- canvas.Scale (Vector2{0 .8f , 0 .8f });
1631
- Paint paint;
1632
- paint.mask_blur_descriptor = Paint::MaskBlurDescriptor{
1633
- .style = FilterContents::BlurStyle::kNormal ,
1634
- .sigma = Sigma{1 },
1635
- };
1636
-
1637
- canvas.DrawPaint ({.color = Color::AntiqueWhite ()});
1638
-
1639
- paint.mask_blur_descriptor ->style = config.style ;
1640
- paint.mask_blur_descriptor ->sigma = Sigma{config.sigma };
1641
- paint.image_filter = config.image_filter ;
1642
- paint.invert_colors = config.invert_colors ;
1643
- paint.blend_mode = config.blend_mode ;
1644
-
1645
- const Scalar x = 50 ;
1646
- const Scalar radius = 20 .0f ;
1647
- const Scalar y_spacing = 100 .0f ;
1648
-
1649
- Scalar y = 50 ;
1650
- paint.color = Color::Crimson ().WithAlpha (config.alpha );
1651
- canvas.DrawRect (Rect::MakeXYWH (x + 25 - radius / 2 , y + radius / 2 , //
1652
- radius, 60 .0f - radius),
1653
- paint);
1654
-
1655
- y += y_spacing;
1656
- paint.color = Color::Blue ().WithAlpha (config.alpha );
1657
- canvas.DrawCircle ({x + 25 , y + 25 }, radius, paint);
1658
-
1659
- y += y_spacing;
1660
- paint.color = Color::Green ().WithAlpha (config.alpha );
1661
- canvas.DrawOval (Rect::MakeXYWH (x + 25 - radius / 2 , y + radius / 2 , //
1662
- radius, 60 .0f - radius),
1663
- paint);
1664
-
1665
- y += y_spacing;
1666
- paint.color = Color::Purple ().WithAlpha (config.alpha );
1667
- canvas.DrawRRect (Rect::MakeXYWH (x, y, 60 .0f , 60 .0f ), //
1668
- {radius, radius}, //
1669
- paint);
1670
-
1671
- y += y_spacing;
1672
- paint.color = Color::Orange ().WithAlpha (config.alpha );
1673
- canvas.DrawRRect (Rect::MakeXYWH (x, y, 60 .0f , 60 .0f ), //
1674
- {radius, 5 .0f }, paint);
1675
-
1676
- y += y_spacing;
1677
- paint.color = Color::Maroon ().WithAlpha (config.alpha );
1678
- canvas.DrawPath (PathBuilder{}
1679
- .MoveTo ({x + 0 , y + 60 })
1680
- .LineTo ({x + 30 , y + 0 })
1681
- .LineTo ({x + 60 , y + 60 })
1682
- .Close ()
1683
- .TakePath (),
1684
- paint);
1685
-
1686
- y += y_spacing;
1687
- paint.color = Color::Maroon ().WithAlpha (config.alpha );
1688
- canvas.DrawPath (PathBuilder{}
1689
- .AddArc (Rect::MakeXYWH (x + 5 , y, 50 , 50 ),
1690
- Radians{kPi / 2 }, Radians{kPi })
1691
- .AddArc (Rect::MakeXYWH (x + 25 , y, 50 , 50 ),
1692
- Radians{kPi / 2 }, Radians{kPi })
1693
- .Close ()
1694
- .TakePath (),
1695
- paint);
1696
-
1697
- return canvas.EndRecordingAsPicture ();
1698
- }
1699
-
1700
- static const std::map<std::string, MaskBlurTestConfig> kPaintVariations = {
1701
- // 1. Normal style, translucent, zero sigma.
1702
- {" NormalTranslucentZeroSigma" ,
1703
- {.style = FilterContents::BlurStyle::kNormal ,
1704
- .sigma = 0 .0f ,
1705
- .alpha = 0 .5f }},
1706
- // 2. Normal style, translucent.
1707
- {" NormalTranslucent" ,
1708
- {.style = FilterContents::BlurStyle::kNormal ,
1709
- .sigma = 8 .0f ,
1710
- .alpha = 0 .5f }},
1711
- // 3. Solid style, translucent.
1712
- {" SolidTranslucent" ,
1713
- {.style = FilterContents::BlurStyle::kSolid ,
1714
- .sigma = 8 .0f ,
1715
- .alpha = 0 .5f }},
1716
- // 4. Solid style, opaque.
1717
- {" SolidOpaque" ,
1718
- {.style = FilterContents::BlurStyle::kSolid , .sigma = 8 .0f }},
1719
- // 5. Solid style, translucent, color & image filtered.
1720
- {" SolidTranslucentWithFilters" ,
1721
- {.style = FilterContents::BlurStyle::kSolid ,
1722
- .sigma = 8 .0f ,
1723
- .alpha = 0 .5f ,
1724
- .image_filter = ImageFilter::MakeBlur (Sigma{3 },
1725
- Sigma{3 },
1726
- FilterContents::BlurStyle::kNormal ,
1727
- Entity::TileMode::kClamp ),
1728
- .invert_colors = true }},
1729
- // 6. Solid style, translucent, exclusion blended.
1730
- {" SolidTranslucentExclusionBlend" ,
1731
- {.style = FilterContents::BlurStyle::kSolid ,
1732
- .sigma = 8 .0f ,
1733
- .alpha = 0 .5f ,
1734
- .blend_mode = BlendMode::kExclusion }},
1735
- // 7. Inner style, translucent.
1736
- {" InnerTranslucent" ,
1737
- {.style = FilterContents::BlurStyle::kInner ,
1738
- .sigma = 8 .0f ,
1739
- .alpha = 0 .5f }},
1740
- // 8. Inner style, translucent, blurred.
1741
- {" InnerTranslucentWithBlurImageFilter" ,
1742
- {.style = FilterContents::BlurStyle::kInner ,
1743
- .sigma = 8 .0f ,
1744
- .alpha = 0 .5f ,
1745
- .image_filter = ImageFilter::MakeBlur (Sigma{3 },
1746
- Sigma{3 },
1747
- FilterContents::BlurStyle::kNormal ,
1748
- Entity::TileMode::kClamp )}},
1749
- // 9. Outer style, translucent.
1750
- {" OuterTranslucent" ,
1751
- {.style = FilterContents::BlurStyle::kOuter ,
1752
- .sigma = 8 .0f ,
1753
- .alpha = 0 .5f }},
1754
- // 10. Outer style, opaque, image filtered.
1755
- {" OuterOpaqueWithBlurImageFilter" ,
1756
- {.style = FilterContents::BlurStyle::kOuter ,
1757
- .sigma = 8 .0f ,
1758
- .image_filter = ImageFilter::MakeBlur (Sigma{3 },
1759
- Sigma{3 },
1760
- FilterContents::BlurStyle::kNormal ,
1761
- Entity::TileMode::kClamp )}},
1762
- };
1763
-
1764
- #define MASK_BLUR_VARIANT_TEST (config ) \
1765
- TEST_P (AiksTest, MaskBlurVariantTest##config) { \
1766
- ASSERT_TRUE (OpenPlaygroundHere ( \
1767
- MaskBlurVariantTest (*this , kPaintVariations .at (#config)))); \
1768
- }
1769
-
1770
- MASK_BLUR_VARIANT_TEST (NormalTranslucentZeroSigma)
1771
- MASK_BLUR_VARIANT_TEST (NormalTranslucent)
1772
- MASK_BLUR_VARIANT_TEST (SolidTranslucent)
1773
- MASK_BLUR_VARIANT_TEST (SolidOpaque)
1774
- MASK_BLUR_VARIANT_TEST (SolidTranslucentWithFilters)
1775
- MASK_BLUR_VARIANT_TEST (SolidTranslucentExclusionBlend)
1776
- MASK_BLUR_VARIANT_TEST (InnerTranslucent)
1777
- MASK_BLUR_VARIANT_TEST (InnerTranslucentWithBlurImageFilter)
1778
- MASK_BLUR_VARIANT_TEST (OuterTranslucent)
1779
- MASK_BLUR_VARIANT_TEST (OuterOpaqueWithBlurImageFilter)
1780
-
1781
- #undef MASK_BLUR_VARIANT_TEST
1782
-
1783
1617
TEST_P (AiksTest, FilledRoundRectPathsRenderCorrectly) {
1784
1618
Canvas canvas;
1785
1619
canvas.Scale (GetContentScale ());
0 commit comments