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