Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,23 @@

namespace impeller {

// This function was derived with polynomial regression when comparing the
// results with Skia. Changing the curve below should invalidate this.
//
// The following data points were used:
// 0 | 1
// 75 | 0.8
// 150 | 0.5
// 300 | 0.22
// 400 | 0.2
// 500 | 0.15
Sigma ScaleSigma(Sigma sigma) {
// Limit the kernel size to 1000x1000 pixels, like Skia does.
Scalar clamped = std::min(sigma.sigma, 500.0f);
Scalar scalar = 1.02 - 3.89e-3 * clamped + 4.36e-06 * clamped * clamped;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TIL you can use scientific notation in C++

return Sigma(clamped * scalar);
}

DirectionalGaussianBlurFilterContents::DirectionalGaussianBlurFilterContents() =
default;

Expand Down Expand Up @@ -76,8 +93,7 @@ std::optional<Entity> DirectionalGaussianBlurFilterContents::RenderFilter(
return std::nullopt;
}

// Limit the kernel size to 1000x1000 pixels, like Skia does.
auto radius = std::min(Radius{blur_sigma_}.radius, 500.0f);
auto radius = Radius{ScaleSigma(blur_sigma_)}.radius;

auto transform = entity.GetTransformation() * effect_transform.Basis();
auto transformed_blur_radius =
Expand Down