forked from firka/flutter
[Impeller] new blur: round downsample to power of two (flutter/engine#50245)
This makes the downsampling step of the new blur round to the nearest power of 2. This makes the changes in downsampling less frequent and the output of downsampling hypothetically higher quality since downsampling by a power of 2 is easier. issue: https://github.com/flutter/flutter/issues/141510 ## before https://github.com/flutter/engine/assets/30870216/73e78f02-1346-4dde-ad6e-8aaa7c910bac ## after https://github.com/flutter/engine/assets/30870216/b4153ada-6a82-4d0a-a4c2-158134c7b74f [C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
This commit is contained in:
@@ -207,7 +207,10 @@ Scalar GaussianBlurFilterContents::CalculateScale(Scalar sigma) {
|
||||
if (sigma <= 4) {
|
||||
return 1.0;
|
||||
}
|
||||
return 4.0 / sigma;
|
||||
Scalar result = 4.0 / sigma;
|
||||
// Round to the nearest 1/(2^n) to get the best quality down scaling.
|
||||
Scalar rounded = pow(2.0f, round(log2(result)));
|
||||
return rounded;
|
||||
};
|
||||
|
||||
std::optional<Rect> GaussianBlurFilterContents::GetFilterSourceCoverage(
|
||||
|
||||
@@ -987,7 +987,8 @@ TEST_P(EntityTest, Filters) {
|
||||
}
|
||||
|
||||
TEST_P(EntityTest, GaussianBlurFilter) {
|
||||
auto boston = CreateTextureForFixture("boston.jpg");
|
||||
auto boston =
|
||||
CreateTextureForFixture("boston.jpg", /*enable_mipmapping=*/true);
|
||||
ASSERT_TRUE(boston);
|
||||
|
||||
auto callback = [&](ContentContext& context, RenderPass& pass) -> bool {
|
||||
|
||||
Reference in New Issue
Block a user