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

Commit a0d8cd6

Browse files
authored
Add a limit to the Gaussian blur downsampling curve (#37550)
1 parent 1c8c237 commit a0d8cd6

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

impeller/display_list/display_list_unittests.cc

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -658,6 +658,9 @@ TEST_P(DisplayListTest, CanDrawZeroLengthLine) {
658658
TEST_P(DisplayListTest, CanDrawShadow) {
659659
flutter::DisplayListBuilder builder;
660660

661+
auto content_scale = GetContentScale() * 0.8;
662+
builder.scale(content_scale.x, content_scale.y);
663+
661664
constexpr size_t star_spikes = 5;
662665
constexpr SkScalar half_spike_rotation = kPi / star_spikes;
663666
constexpr SkScalar radius = 40;
@@ -677,24 +680,24 @@ TEST_P(DisplayListTest, CanDrawShadow) {
677680
std::array<SkPath, 4> paths = {
678681
SkPath{}.addRect(SkRect::MakeXYWH(0, 0, 200, 100)),
679682
SkPath{}.addRRect(
680-
SkRRect::MakeRectXY(SkRect::MakeXYWH(0, 0, 200, 100), 30, 30)),
683+
SkRRect::MakeRectXY(SkRect::MakeXYWH(20, 0, 200, 100), 30, 30)),
681684
SkPath{}.addCircle(100, 50, 50),
682685
SkPath{}.addPoly(star.data(), star.size(), true),
683686
};
684687
builder.setColor(flutter::DlColor::kWhite());
685688
builder.drawPaint();
686689
builder.setColor(flutter::DlColor::kCyan());
687-
builder.translate(100, 100);
690+
builder.translate(100, 50);
688691
for (size_t x = 0; x < paths.size(); x++) {
689692
builder.save();
690-
for (size_t y = 0; y < 5; y++) {
691-
builder.drawShadow(paths[x], flutter::DlColor::kBlack(), 3 + y * 5, false,
693+
for (size_t y = 0; y < 6; y++) {
694+
builder.drawShadow(paths[x], flutter::DlColor::kBlack(), 3 + y * 8, false,
692695
1);
693696
builder.drawPath(paths[x]);
694-
builder.translate(0, 200);
697+
builder.translate(0, 150);
695698
}
696699
builder.restore();
697-
builder.translate(300, 0);
700+
builder.translate(250, 0);
698701
}
699702

700703
ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));

impeller/entity/contents/filters/gaussian_blur_filter_contents.cc

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,8 +228,11 @@ std::optional<Snapshot> DirectionalGaussianBlurFilterContents::RenderFilter(
228228

229229
Vector2 scale;
230230
auto scale_curve = [](Scalar radius) {
231-
const Scalar d = 4.0;
232-
return std::min(1.0, d / (std::max(1.0f, radius) + d - 1.0));
231+
constexpr Scalar decay = 4.0; // Larger is more gradual.
232+
constexpr Scalar limit = 0.95; // The maximum percentage of the scaledown.
233+
const Scalar curve =
234+
std::min(1.0, decay / (std::max(1.0f, radius) + decay - 1.0));
235+
return (curve - 1) * limit + 1;
233236
};
234237
{
235238
scale.x = scale_curve(transformed_blur_radius_length);

0 commit comments

Comments
 (0)