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

Commit 414229b

Browse files
authored
[Impeller] shrunk the buffer for the rrect_blur (#53068)
issue flutter/flutter#148496 [C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
1 parent 2feb07c commit 414229b

File tree

2 files changed

+29
-15
lines changed

2 files changed

+29
-15
lines changed

impeller/aiks/aiks_blur_unittests.cc

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -199,19 +199,29 @@ TEST_P(AiksTest, ClearBlendWithBlur) {
199199
}
200200

201201
TEST_P(AiksTest, BlurHasNoEdge) {
202-
Canvas canvas;
203-
canvas.Scale(GetContentScale());
204-
canvas.DrawPaint({});
205-
Paint blur = {
206-
.color = Color::Green(),
207-
.mask_blur_descriptor =
208-
Paint::MaskBlurDescriptor{
209-
.style = FilterContents::BlurStyle::kNormal,
210-
.sigma = Sigma(47.6),
211-
},
202+
Scalar sigma = 47.6;
203+
auto callback = [&](AiksContext& renderer) -> std::optional<Picture> {
204+
if (AiksTest::ImGuiBegin("Controls", nullptr,
205+
ImGuiWindowFlags_AlwaysAutoResize)) {
206+
ImGui::SliderFloat("Sigma", &sigma, 0, 50);
207+
ImGui::End();
208+
}
209+
Canvas canvas;
210+
canvas.Scale(GetContentScale());
211+
canvas.DrawPaint({});
212+
Paint blur = {
213+
.color = Color::Green(),
214+
.mask_blur_descriptor =
215+
Paint::MaskBlurDescriptor{
216+
.style = FilterContents::BlurStyle::kNormal,
217+
.sigma = Sigma(sigma),
218+
},
219+
};
220+
canvas.DrawRect(Rect::MakeXYWH(300, 300, 200, 200), blur);
221+
return canvas.EndRecordingAsPicture();
212222
};
213-
canvas.DrawRect(Rect::MakeXYWH(300, 300, 200, 200), blur);
214-
ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
223+
224+
ASSERT_TRUE(OpenPlaygroundHere(callback));
215225
}
216226

217227
TEST_P(AiksTest, BlurredRectangleWithShader) {

impeller/entity/contents/solid_rrect_blur_contents.cc

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,14 @@
1515
namespace impeller {
1616

1717
namespace {
18-
// Generous padding to make sure blurs with large sigmas are fully visible.
19-
// Used to expand the geometry around the rrect.
18+
// Generous padding to make sure blurs with large sigmas are fully visible. Used
19+
// to expand the geometry around the rrect. Larger sigmas have more subtle
20+
// gradients so they need larger padding to avoid hard cutoffs. Sigma is
21+
// maximized to 3.5 since that should cover 99.95% of all samples. 3.0 should
22+
// cover 99.7% but that was seen to be not enough for large sigmas.
2023
Scalar PadForSigma(Scalar sigma) {
21-
return sigma * 4.0;
24+
Scalar scalar = std::min((1.0f / 47.6f) * sigma + 2.5f, 3.5f);
25+
return sigma * scalar;
2226
}
2327
} // namespace
2428

0 commit comments

Comments
 (0)