Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 6a58ae9

Browse files
committed
[Impeller] Add tests for foreground blends with mask blurs
1 parent 72fd206 commit 6a58ae9

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

impeller/aiks/aiks_unittests.cc

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2448,6 +2448,54 @@ TEST_P(AiksTest, CanRenderClippedBlur) {
24482448
ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
24492449
}
24502450

2451+
TEST_P(AiksTest, CanRenderForegroundBlendWithMaskBlur) {
2452+
// This case triggers the ForegroundPorterDuffBlend path. The color filter
2453+
// should apply to the color only, and respect the alpha mask.
2454+
Canvas canvas;
2455+
canvas.ClipRect(Rect::MakeXYWH(100, 150, 400, 400));
2456+
canvas.DrawCircle({400, 400}, 200,
2457+
{
2458+
.color = Color::White(),
2459+
.color_filter =
2460+
[](const FilterInput::Ref& input) {
2461+
return ColorFilterContents::MakeBlend(
2462+
BlendMode::kSource, {input}, Color::Green());
2463+
},
2464+
.mask_blur_descriptor =
2465+
Paint::MaskBlurDescriptor{
2466+
.style = FilterContents::BlurStyle::kNormal,
2467+
.sigma = Radius(20),
2468+
},
2469+
});
2470+
canvas.Restore();
2471+
2472+
ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
2473+
}
2474+
2475+
TEST_P(AiksTest, CanRenderForegroundAdvancedBlendWithMaskBlur) {
2476+
// This case triggers the ForegroundAdvancedBlend path. The color filter
2477+
// should apply to the color only, and respect the alpha mask.
2478+
Canvas canvas;
2479+
canvas.ClipRect(Rect::MakeXYWH(100, 150, 400, 400));
2480+
canvas.DrawCircle({400, 400}, 200,
2481+
{
2482+
.color = Color::White(),
2483+
.color_filter =
2484+
[](const FilterInput::Ref& input) {
2485+
return ColorFilterContents::MakeBlend(
2486+
BlendMode::kColor, {input}, Color::Green());
2487+
},
2488+
.mask_blur_descriptor =
2489+
Paint::MaskBlurDescriptor{
2490+
.style = FilterContents::BlurStyle::kNormal,
2491+
.sigma = Radius(20),
2492+
},
2493+
});
2494+
canvas.Restore();
2495+
2496+
ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
2497+
}
2498+
24512499
// Regression test for https://github.com/flutter/flutter/issues/126701 .
24522500
TEST_P(AiksTest, CanRenderClippedRuntimeEffects) {
24532501
if (GetParam() != PlaygroundBackend::kMetal) {

0 commit comments

Comments
 (0)