Skip to content

Commit ccaf7eb

Browse files
authored
[Impeller] Add tests for foreground blends with mask blurs (flutter#42687)
Part of flutter#127232. Both of these tests should be rendering as a clipped and blurred green circle. Making mask blurs interact correctly with color filters is not going to be trivial... These bugs extend beyond the filter graph itself. Want to get some goldens in to compare against. ForegroundPorterDuffBlend: ![Screenshot 2023-06-08 at 4 58 54 PM](https://github.com/flutter/engine/assets/919017/e5592b35-1054-48f3-91e4-c97136a2ecfd) ForegroundAdvancedBlend: ![Screenshot 2023-06-08 at 4 58 38 PM](https://github.com/flutter/engine/assets/919017/8de5d12a-6413-4436-aa35-f3a4ef09615f)
1 parent 1e811a2 commit ccaf7eb

1 file changed

Lines changed: 48 additions & 0 deletions

File tree

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)