mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
[Impeller] shrunk the buffer for the rrect_blur (flutter/engine#53068)
issue https://github.com/flutter/flutter/issues/148496 [C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
This commit is contained in:
parent
9f29233004
commit
4795bc576d
@ -199,19 +199,29 @@ TEST_P(AiksTest, ClearBlendWithBlur) {
|
||||
}
|
||||
|
||||
TEST_P(AiksTest, BlurHasNoEdge) {
|
||||
Canvas canvas;
|
||||
canvas.Scale(GetContentScale());
|
||||
canvas.DrawPaint({});
|
||||
Paint blur = {
|
||||
.color = Color::Green(),
|
||||
.mask_blur_descriptor =
|
||||
Paint::MaskBlurDescriptor{
|
||||
.style = FilterContents::BlurStyle::kNormal,
|
||||
.sigma = Sigma(47.6),
|
||||
},
|
||||
Scalar sigma = 47.6;
|
||||
auto callback = [&](AiksContext& renderer) -> std::optional<Picture> {
|
||||
if (AiksTest::ImGuiBegin("Controls", nullptr,
|
||||
ImGuiWindowFlags_AlwaysAutoResize)) {
|
||||
ImGui::SliderFloat("Sigma", &sigma, 0, 50);
|
||||
ImGui::End();
|
||||
}
|
||||
Canvas canvas;
|
||||
canvas.Scale(GetContentScale());
|
||||
canvas.DrawPaint({});
|
||||
Paint blur = {
|
||||
.color = Color::Green(),
|
||||
.mask_blur_descriptor =
|
||||
Paint::MaskBlurDescriptor{
|
||||
.style = FilterContents::BlurStyle::kNormal,
|
||||
.sigma = Sigma(sigma),
|
||||
},
|
||||
};
|
||||
canvas.DrawRect(Rect::MakeXYWH(300, 300, 200, 200), blur);
|
||||
return canvas.EndRecordingAsPicture();
|
||||
};
|
||||
canvas.DrawRect(Rect::MakeXYWH(300, 300, 200, 200), blur);
|
||||
ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
|
||||
|
||||
ASSERT_TRUE(OpenPlaygroundHere(callback));
|
||||
}
|
||||
|
||||
TEST_P(AiksTest, BlurredRectangleWithShader) {
|
||||
|
||||
@ -15,10 +15,14 @@
|
||||
namespace impeller {
|
||||
|
||||
namespace {
|
||||
// Generous padding to make sure blurs with large sigmas are fully visible.
|
||||
// Used to expand the geometry around the rrect.
|
||||
// Generous padding to make sure blurs with large sigmas are fully visible. Used
|
||||
// to expand the geometry around the rrect. Larger sigmas have more subtle
|
||||
// gradients so they need larger padding to avoid hard cutoffs. Sigma is
|
||||
// maximized to 3.5 since that should cover 99.95% of all samples. 3.0 should
|
||||
// cover 99.7% but that was seen to be not enough for large sigmas.
|
||||
Scalar PadForSigma(Scalar sigma) {
|
||||
return sigma * 4.0;
|
||||
Scalar scalar = std::min((1.0f / 47.6f) * sigma + 2.5f, 3.5f);
|
||||
return sigma * scalar;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user