Skip to content

Commit d6a1242

Browse files
committed
[Impeller] Turned on new blur. (flutter#48472)
This new blur should perform faster since it scales down the image before blurring it. Jonah did early testing of it and found it to be faster. Scrolling around with the blur perf bug it seems faster. It also has a wider test bed and is hopefully easier to maintain since it contains all of its logic for both directions. testing: There are existing blur tests and we've backfilled more as we've added features to this blur. fixes flutter/flutter#131580 fixes flutter/flutter#138259 - [x] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [x] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [x] I read and followed the [Flutter Style Guide] and the [C++, Objective-C, Java style guides]. - [x] I listed at least one issue that this PR fixes in the description above. - [x] I added new tests to check the change I am making or feature I am adding, or the PR is [test-exempt]. See [testing the engine] for instructions on writing and running engine tests. - [x] I updated/added relevant documentation (doc comments with `///`). - [x] I signed the [CLA]. - [x] All existing and new tests are passing. If you need help, consider asking for advice on the #hackers-new channel on [Discord]. <!-- Links --> [Contributor Guide]: https://github.com/flutter/flutter/wiki/Tree-hygiene#overview [Tree Hygiene]: https://github.com/flutter/flutter/wiki/Tree-hygiene [test-exempt]: https://github.com/flutter/flutter/wiki/Tree-hygiene#tests [Flutter Style Guide]: https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo [C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style [testing the engine]: https://github.com/flutter/flutter/wiki/Testing-the-engine [CLA]: https://cla.developers.google.com/ [flutter/tests]: https://github.com/flutter/tests [breaking change policy]: https://github.com/flutter/flutter/wiki/Tree-hygiene#handling-breaking-changes [Discord]: https://github.com/flutter/flutter/wiki/Chat
1 parent 2d00164 commit d6a1242

File tree

3 files changed

+10
-39
lines changed

3 files changed

+10
-39
lines changed

impeller/aiks/aiks_unittests.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3758,7 +3758,7 @@ TEST_P(AiksTest, GaussianBlurSetsMipCountOnPass) {
37583758
canvas.Restore();
37593759

37603760
Picture picture = canvas.EndRecordingAsPicture();
3761-
EXPECT_EQ(1, picture.pass->GetRequiredMipCount());
3761+
EXPECT_EQ(4, picture.pass->GetRequiredMipCount());
37623762
}
37633763

37643764
TEST_P(AiksTest, GaussianBlurAllocatesCorrectMipCountRenderTarget) {
@@ -3782,7 +3782,7 @@ TEST_P(AiksTest, GaussianBlurAllocatesCorrectMipCountRenderTarget) {
37823782
max_mip_count =
37833783
std::max(it->texture->GetTextureDescriptor().mip_count, max_mip_count);
37843784
}
3785-
EXPECT_EQ(max_mip_count, 1lu);
3785+
EXPECT_EQ(max_mip_count, 4lu);
37863786
}
37873787

37883788
TEST_P(AiksTest, GaussianBlurMipMapNestedLayer) {
@@ -3809,7 +3809,7 @@ TEST_P(AiksTest, GaussianBlurMipMapNestedLayer) {
38093809
max_mip_count =
38103810
std::max(it->texture->GetTextureDescriptor().mip_count, max_mip_count);
38113811
}
3812-
EXPECT_EQ(max_mip_count, 1lu);
3812+
EXPECT_EQ(max_mip_count, 4lu);
38133813
EXPECT_EQ(log_capture.str().find(GaussianBlurFilterContents::kNoMipsError),
38143814
std::string::npos);
38153815
}

impeller/entity/contents/filters/directional_gaussian_blur_filter_contents.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ namespace impeller {
4343
/// - `FilterContents::MakeGaussianBlur`
4444
/// - //flutter/impeller/entity/shaders/gaussian_blur/gaussian_blur.glsl
4545
///
46+
///\deprecated Previously 2 of these were chained to do 2D blurs, use
47+
/// \ref GaussianBlurFilterContents instead since it has better
48+
/// performance.
4649
class DirectionalGaussianBlurFilterContents final : public FilterContents {
4750
public:
4851
DirectionalGaussianBlurFilterContents();

impeller/entity/contents/filters/filter_contents.cc

Lines changed: 4 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -50,50 +50,18 @@ std::shared_ptr<FilterContents> FilterContents::MakeDirectionalGaussianBlur(
5050
return blur;
5151
}
5252

53-
#ifdef IMPELLER_ENABLE_NEW_GAUSSIAN_FILTER
5453
const int32_t FilterContents::kBlurFilterRequiredMipCount = 4;
55-
#else
56-
const int32_t FilterContents::kBlurFilterRequiredMipCount = 1;
57-
#endif
5854

5955
std::shared_ptr<FilterContents> FilterContents::MakeGaussianBlur(
6056
const FilterInput::Ref& input,
6157
Sigma sigma_x,
6258
Sigma sigma_y,
6359
BlurStyle blur_style,
6460
Entity::TileMode tile_mode) {
65-
constexpr bool use_new_filter =
66-
#ifdef IMPELLER_ENABLE_NEW_GAUSSIAN_FILTER
67-
true;
68-
#else
69-
false;
70-
#endif
71-
72-
// TODO(https://github.com/flutter/flutter/issues/131580): Remove once the new
73-
// blur handles all cases.
74-
if (use_new_filter) {
75-
auto blur = std::make_shared<GaussianBlurFilterContents>(
76-
sigma_x.sigma, sigma_y.sigma, tile_mode);
77-
blur->SetInputs({input});
78-
return blur;
79-
}
80-
std::shared_ptr<FilterContents> x_blur = MakeDirectionalGaussianBlur(
81-
/*input=*/input,
82-
/*sigma=*/sigma_x,
83-
/*direction=*/Point(1, 0),
84-
/*blur_style=*/BlurStyle::kNormal,
85-
/*tile_mode=*/tile_mode,
86-
/*is_second_pass=*/false,
87-
/*secondary_sigma=*/{});
88-
std::shared_ptr<FilterContents> y_blur = MakeDirectionalGaussianBlur(
89-
/*input=*/FilterInput::Make(x_blur),
90-
/*sigma=*/sigma_y,
91-
/*direction=*/Point(0, 1),
92-
/*blur_style=*/blur_style,
93-
/*tile_mode=*/tile_mode,
94-
/*is_second_pass=*/true,
95-
/*secondary_sigma=*/sigma_x);
96-
return y_blur;
61+
auto blur = std::make_shared<GaussianBlurFilterContents>(
62+
sigma_x.sigma, sigma_y.sigma, tile_mode);
63+
blur->SetInputs({input});
64+
return blur;
9765
}
9866

9967
std::shared_ptr<FilterContents> FilterContents::MakeBorderMaskBlur(

0 commit comments

Comments
 (0)