From 42dcc46d9df6f6eea90dd93a56749b78fc6f1cdd Mon Sep 17 00:00:00 2001 From: Brandon DeRosier Date: Wed, 31 Aug 2022 17:43:38 -0700 Subject: [PATCH 1/2] Ignore all translations in Matrix::TransformDirection --- impeller/geometry/geometry_unittests.cc | 2 +- impeller/geometry/matrix.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/impeller/geometry/geometry_unittests.cc b/impeller/geometry/geometry_unittests.cc index 0957acf76b23a..c1c92f37e500f 100644 --- a/impeller/geometry/geometry_unittests.cc +++ b/impeller/geometry/geometry_unittests.cc @@ -229,7 +229,7 @@ TEST(GeometryTest, MatrixTransformDirection) { } { - auto matrix = Matrix::MakeTranslation({100, 100, 100}) * + auto matrix = Matrix::MakeTranslation({0, -0.4, 100}) * Matrix::MakeRotationZ(Radians{kPiOver2}) * Matrix::MakeScale({2.0, 2.0, 2.0}); auto vector = Point(10, 20); diff --git a/impeller/geometry/matrix.h b/impeller/geometry/matrix.h index 29bbb949b3918..9be6707f08503 100644 --- a/impeller/geometry/matrix.h +++ b/impeller/geometry/matrix.h @@ -249,7 +249,7 @@ struct Matrix { } constexpr Scalar GetDirectionScale(Vector3 direction) const { - return 1.0 / (this->Invert() * direction.Normalize()).Length() * + return 1.0 / (this->Basis().Invert() * direction.Normalize()).Length() * direction.Length(); } From 2836958b8c44d56e5c9d16d5aef0e65dfeddc8c3 Mon Sep 17 00:00:00 2001 From: Brandon DeRosier Date: Wed, 31 Aug 2022 16:08:28 -0700 Subject: [PATCH 2/2] More agressively optimize gaussian blurs --- .../contents/filters/gaussian_blur_filter_contents.cc | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/impeller/entity/contents/filters/gaussian_blur_filter_contents.cc b/impeller/entity/contents/filters/gaussian_blur_filter_contents.cc index 47dadff5c895a..3e4acc30f7e05 100644 --- a/impeller/entity/contents/filters/gaussian_blur_filter_contents.cc +++ b/impeller/entity/contents/filters/gaussian_blur_filter_contents.cc @@ -226,14 +226,13 @@ std::optional DirectionalGaussianBlurFilterContents::RenderFilter( }; Vector2 scale; + auto scale_curve = [](Scalar radius) { return std::min(1.0, 2.0 / radius); }; { - scale.x = - 1.0 / - std::ceil(std::log2(std::max(2.0f, transformed_blur_radius_length))); + scale.x = scale_curve(transformed_blur_radius_length); Scalar y_radius = std::abs(pass_transform.GetDirectionScale(Vector2( 0, source_override_ ? Radius{secondary_blur_sigma_}.radius : 1))); - scale.y = 1.0 / std::ceil(std::log2(std::max(2.0f, y_radius))); + scale.y = scale_curve(y_radius); } Vector2 scaled_size = pass_texture_rect.size * scale;