From 059e4e6d8ff6de39c29441c53e949bfb0bf17972 Mon Sep 17 00:00:00 2001 From: Kevin Chisholm Date: Tue, 10 Sep 2024 14:13:50 -0500 Subject: [PATCH 1/2] [flutter_releases] Flutter beta 3.26.0-0.1.pre Engine Cherrypicks (#55077) # Flutter beta 3.26.0-0.1.pre Engine ## Scheduled Cherrypicks - Roll dart revision: dart-lang/sdk@0ebf221eb --- DEPS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DEPS b/DEPS index fd2887c62abc8..d3ab63e64a36a 100644 --- a/DEPS +++ b/DEPS @@ -56,7 +56,7 @@ vars = { # Dart is: https://github.com/dart-lang/sdk/blob/main/DEPS # You can use //tools/dart/create_updated_flutter_deps.py to produce # updated revision list of existing dependencies. - 'dart_revision': '1a6246225b75aae44a5cba2b98ee6d55ecfc89b6', + 'dart_revision': '0ebf221eba41759d6c1588fe564a4aab2ebdcb4c', # WARNING: DO NOT EDIT MANUALLY # The lines between blank lines above and below are generated by a script. See create_updated_flutter_deps.py From d572fc8a2fb4438bd0c9454d4454ba154a252556 Mon Sep 17 00:00:00 2001 From: gaaclarke <30870216+gaaclarke@users.noreply.github.com> Date: Wed, 16 Oct 2024 13:13:25 -0700 Subject: [PATCH 2/2] Starts looking for the bdf fast path in relation to the snapshot_entity's transform (#55890) fixes https://github.com/flutter/flutter/issues/156871 testing: performance change covered by existing benchmarks. [C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style --- .../filters/gaussian_blur_filter_contents.cc | 2 +- impeller/geometry/matrix.h | 21 +++++++++++++++++++ impeller/geometry/matrix_unittests.cc | 12 +++++++++++ impeller/geometry/scalar.h | 5 +++++ 4 files changed, 39 insertions(+), 1 deletion(-) diff --git a/impeller/entity/contents/filters/gaussian_blur_filter_contents.cc b/impeller/entity/contents/filters/gaussian_blur_filter_contents.cc index c8fda3376c814..1d28bd02f46d9 100644 --- a/impeller/entity/contents/filters/gaussian_blur_filter_contents.cc +++ b/impeller/entity/contents/filters/gaussian_blur_filter_contents.cc @@ -241,7 +241,7 @@ DownsamplePassArgs CalculateDownsamplePassArgs( // .Contains(coverage_hint.value())) std::optional snapshot_coverage = input_snapshot.GetCoverage(); - if (input_snapshot.transform.IsIdentity() && + if (input_snapshot.transform.Equals(snapshot_entity.GetTransform()) && source_expanded_coverage_hint.has_value() && snapshot_coverage.has_value() && snapshot_coverage->Contains(source_expanded_coverage_hint.value())) { diff --git a/impeller/geometry/matrix.h b/impeller/geometry/matrix.h index 5b70ab9870dab..b8d243a8a0001 100644 --- a/impeller/geometry/matrix.h +++ b/impeller/geometry/matrix.h @@ -409,6 +409,27 @@ struct Matrix { std::optional Decompose() const; + bool Equals(const Matrix& matrix, Scalar epsilon = 1e-5f) const { + const Scalar* a = m; + const Scalar* b = matrix.m; + return ScalarNearlyEqual(a[0], b[0], epsilon) && + ScalarNearlyEqual(a[1], b[1], epsilon) && + ScalarNearlyEqual(a[2], b[2], epsilon) && + ScalarNearlyEqual(a[3], b[3], epsilon) && + ScalarNearlyEqual(a[4], b[4], epsilon) && + ScalarNearlyEqual(a[5], b[5], epsilon) && + ScalarNearlyEqual(a[6], b[6], epsilon) && + ScalarNearlyEqual(a[7], b[7], epsilon) && + ScalarNearlyEqual(a[8], b[8], epsilon) && + ScalarNearlyEqual(a[9], b[9], epsilon) && + ScalarNearlyEqual(a[10], b[10], epsilon) && + ScalarNearlyEqual(a[11], b[11], epsilon) && + ScalarNearlyEqual(a[12], b[12], epsilon) && + ScalarNearlyEqual(a[13], b[13], epsilon) && + ScalarNearlyEqual(a[14], b[14], epsilon) && + ScalarNearlyEqual(a[15], b[15], epsilon); + } + constexpr bool operator==(const Matrix& m) const { // clang-format off return vec[0] == m.vec[0] diff --git a/impeller/geometry/matrix_unittests.cc b/impeller/geometry/matrix_unittests.cc index 1cb7930ec52bf..4bebb9ab53aaf 100644 --- a/impeller/geometry/matrix_unittests.cc +++ b/impeller/geometry/matrix_unittests.cc @@ -25,6 +25,18 @@ TEST(MatrixTest, Multiply) { 11.0, 21.0, 0.0, 1.0))); } +TEST(MatrixTest, Equals) { + Matrix x; + Matrix y = x; + EXPECT_TRUE(x.Equals(y)); +} + +TEST(MatrixTest, NotEquals) { + Matrix x; + Matrix y = x.Translate({1, 0, 0}); + EXPECT_FALSE(x.Equals(y)); +} + TEST(MatrixTest, HasPerspective2D) { EXPECT_FALSE(Matrix().HasPerspective2D()); diff --git a/impeller/geometry/scalar.h b/impeller/geometry/scalar.h index 2600a49c42dc5..dadc52850cb5f 100644 --- a/impeller/geometry/scalar.h +++ b/impeller/geometry/scalar.h @@ -22,6 +22,11 @@ constexpr T Absolute(const T& val) { return val >= T{} ? val : -val; } +template <> +constexpr Scalar Absolute(const float& val) { + return fabsf(val); +} + constexpr inline bool ScalarNearlyZero(Scalar x, Scalar tolerance = kEhCloseEnough) { return Absolute(x) <= tolerance;