Skip to content

Commit

Permalink
[Impeller] Turned on new blur. (flutter#48472)
Browse files Browse the repository at this point in the history
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

## Pre-launch Checklist

- [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
  • Loading branch information
gaaclarke authored Dec 14, 2023
1 parent 6fa8e76 commit d0464cf
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ namespace impeller {
/// - `FilterContents::MakeGaussianBlur`
/// - //flutter/impeller/entity/shaders/gaussian_blur/gaussian_blur.glsl
///
///\deprecated Previously 2 of these were chained to do 2D blurs, use
/// \ref GaussianBlurFilterContents instead since it has better
/// performance.
class DirectionalGaussianBlurFilterContents final : public FilterContents {
public:
DirectionalGaussianBlurFilterContents();
Expand Down
36 changes: 4 additions & 32 deletions impeller/entity/contents/filters/filter_contents.cc
Original file line number Diff line number Diff line change
Expand Up @@ -56,38 +56,10 @@ std::shared_ptr<FilterContents> FilterContents::MakeGaussianBlur(
Sigma sigma_y,
BlurStyle blur_style,
Entity::TileMode tile_mode) {
constexpr bool use_new_filter =
#ifdef IMPELLER_ENABLE_NEW_GAUSSIAN_FILTER
true;
#else
false;
#endif

// TODO(https://github.com/flutter/flutter/issues/131580): Remove once the new
// blur handles all cases.
if (use_new_filter) {
auto blur = std::make_shared<GaussianBlurFilterContents>(
sigma_x.sigma, sigma_y.sigma, tile_mode);
blur->SetInputs({input});
return blur;
}
std::shared_ptr<FilterContents> x_blur = MakeDirectionalGaussianBlur(
/*input=*/input,
/*sigma=*/sigma_x,
/*direction=*/Point(1, 0),
/*blur_style=*/BlurStyle::kNormal,
/*tile_mode=*/tile_mode,
/*is_second_pass=*/false,
/*secondary_sigma=*/{});
std::shared_ptr<FilterContents> y_blur = MakeDirectionalGaussianBlur(
/*input=*/FilterInput::Make(x_blur),
/*sigma=*/sigma_y,
/*direction=*/Point(0, 1),
/*blur_style=*/blur_style,
/*tile_mode=*/tile_mode,
/*is_second_pass=*/true,
/*secondary_sigma=*/sigma_x);
return y_blur;
auto blur = std::make_shared<GaussianBlurFilterContents>(
sigma_x.sigma, sigma_y.sigma, tile_mode);
blur->SetInputs({input});
return blur;
}

std::shared_ptr<FilterContents> FilterContents::MakeBorderMaskBlur(
Expand Down

0 comments on commit d0464cf

Please sign in to comment.