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

Commit 0effece

Browse files
committed
[Impeller] Turned on new blur. (#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 56aa10f commit 0effece

File tree

3 files changed

+9
-38
lines changed

3 files changed

+9
-38
lines changed

impeller/aiks/aiks_unittests.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3767,7 +3767,7 @@ TEST_P(AiksTest, GaussianBlurSetsMipCountOnPass) {
37673767
return true;
37683768
});
37693769

3770-
EXPECT_EQ(1, max_mip_count);
3770+
EXPECT_EQ(4, max_mip_count);
37713771
}
37723772

37733773
TEST_P(AiksTest, GaussianBlurAllocatesCorrectMipCountRenderTarget) {
@@ -3791,7 +3791,7 @@ TEST_P(AiksTest, GaussianBlurAllocatesCorrectMipCountRenderTarget) {
37913791
max_mip_count =
37923792
std::max(it->texture->GetTextureDescriptor().mip_count, max_mip_count);
37933793
}
3794-
EXPECT_EQ(max_mip_count, 1lu);
3794+
EXPECT_EQ(max_mip_count, 4lu);
37953795
}
37963796

37973797
TEST_P(AiksTest, GaussianBlurMipMapNestedLayer) {

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)