From 9ca6bd8786bf9acdeb689d6f375ad3dfa1b89403 Mon Sep 17 00:00:00 2001 From: gaaclarke <30870216+gaaclarke@users.noreply.github.com> Date: Thu, 14 Dec 2023 13:09:32 -0800 Subject: [PATCH] [Impeller] Turned on new blur. (flutter/engine#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 https://github.com/flutter/flutter/issues/131580 fixes https://github.com/flutter/flutter/issues/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]. [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 --- ...irectional_gaussian_blur_filter_contents.h | 3 ++ .../contents/filters/filter_contents.cc | 36 +++---------------- 2 files changed, 7 insertions(+), 32 deletions(-) diff --git a/engine/src/flutter/impeller/entity/contents/filters/directional_gaussian_blur_filter_contents.h b/engine/src/flutter/impeller/entity/contents/filters/directional_gaussian_blur_filter_contents.h index 2ea5df044f2..548d1d409cf 100644 --- a/engine/src/flutter/impeller/entity/contents/filters/directional_gaussian_blur_filter_contents.h +++ b/engine/src/flutter/impeller/entity/contents/filters/directional_gaussian_blur_filter_contents.h @@ -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(); diff --git a/engine/src/flutter/impeller/entity/contents/filters/filter_contents.cc b/engine/src/flutter/impeller/entity/contents/filters/filter_contents.cc index 5f2c310f78d..1122d8632d9 100644 --- a/engine/src/flutter/impeller/entity/contents/filters/filter_contents.cc +++ b/engine/src/flutter/impeller/entity/contents/filters/filter_contents.cc @@ -56,38 +56,10 @@ std::shared_ptr 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( - sigma_x.sigma, sigma_y.sigma, tile_mode); - blur->SetInputs({input}); - return blur; - } - std::shared_ptr 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 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( + sigma_x.sigma, sigma_y.sigma, tile_mode); + blur->SetInputs({input}); + return blur; } std::shared_ptr FilterContents::MakeBorderMaskBlur(