[Impeller] Limit blur kernel to 1000x1000 pixels (flutter/engine#42154)

Resolves https://github.com/flutter/flutter/issues/127151.

This is the same internal limit that Skia uses.
This commit is contained in:
Brandon DeRosier
2023-05-19 11:34:07 -07:00
committed by GitHub
parent 18f2f79d73
commit d650e423f1
2 changed files with 18 additions and 1 deletions

View File

@@ -2286,6 +2286,22 @@ TEST_P(AiksTest, CanRenderBackdropBlur) {
ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
}
TEST_P(AiksTest, CanRenderBackdropBlurHugeSigma) {
Canvas canvas;
canvas.DrawCircle({400, 400}, 300, {.color = Color::Green()});
canvas.SaveLayer({.blend_mode = BlendMode::kSource}, std::nullopt,
[](const FilterInput::Ref& input,
const Matrix& effect_transform, bool is_subpass) {
return FilterContents::MakeGaussianBlur(
input, Sigma(999999), Sigma(999999),
FilterContents::BlurStyle::kNormal,
Entity::TileMode::kClamp, effect_transform);
});
canvas.Restore();
ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
}
// Regression test for https://github.com/flutter/flutter/issues/126701 .
TEST_P(AiksTest, CanRenderClippedRuntimeEffects) {
if (GetParam() != PlaygroundBackend::kMetal) {

View File

@@ -101,7 +101,8 @@ std::optional<Entity> DirectionalGaussianBlurFilterContents::RenderFilter(
return std::nullopt;
}
auto radius = Radius{blur_sigma_}.radius;
// Limit the kernel size to 1000x1000 pixels, like Skia does.
auto radius = std::min(Radius{blur_sigma_}.radius, 500.0f);
// Input 0 snapshot.