Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 2ad45d5

Browse files
authored
[CP] Starts looking for the bdf fast path in relation to the snapshot_entity's transform (#55890) (#55917)
cherry-picks #55890 [C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
1 parent af0f0d5 commit 2ad45d5

File tree

4 files changed

+39
-1
lines changed

4 files changed

+39
-1
lines changed

impeller/entity/contents/filters/gaussian_blur_filter_contents.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ DownsamplePassArgs CalculateDownsamplePassArgs(
239239
// .Contains(coverage_hint.value()))
240240

241241
std::optional<Rect> snapshot_coverage = input_snapshot.GetCoverage();
242-
if (input_snapshot.transform.IsIdentity() &&
242+
if (input_snapshot.transform.Equals(snapshot_entity.GetTransform()) &&
243243
source_expanded_coverage_hint.has_value() &&
244244
snapshot_coverage.has_value() &&
245245
snapshot_coverage->Contains(source_expanded_coverage_hint.value())) {

impeller/geometry/matrix.h

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,27 @@ struct Matrix {
407407

408408
std::optional<MatrixDecomposition> Decompose() const;
409409

410+
bool Equals(const Matrix& matrix, Scalar epsilon = 1e-5f) const {
411+
const Scalar* a = m;
412+
const Scalar* b = matrix.m;
413+
return ScalarNearlyEqual(a[0], b[0], epsilon) &&
414+
ScalarNearlyEqual(a[1], b[1], epsilon) &&
415+
ScalarNearlyEqual(a[2], b[2], epsilon) &&
416+
ScalarNearlyEqual(a[3], b[3], epsilon) &&
417+
ScalarNearlyEqual(a[4], b[4], epsilon) &&
418+
ScalarNearlyEqual(a[5], b[5], epsilon) &&
419+
ScalarNearlyEqual(a[6], b[6], epsilon) &&
420+
ScalarNearlyEqual(a[7], b[7], epsilon) &&
421+
ScalarNearlyEqual(a[8], b[8], epsilon) &&
422+
ScalarNearlyEqual(a[9], b[9], epsilon) &&
423+
ScalarNearlyEqual(a[10], b[10], epsilon) &&
424+
ScalarNearlyEqual(a[11], b[11], epsilon) &&
425+
ScalarNearlyEqual(a[12], b[12], epsilon) &&
426+
ScalarNearlyEqual(a[13], b[13], epsilon) &&
427+
ScalarNearlyEqual(a[14], b[14], epsilon) &&
428+
ScalarNearlyEqual(a[15], b[15], epsilon);
429+
}
430+
410431
constexpr bool operator==(const Matrix& m) const {
411432
// clang-format off
412433
return vec[0] == m.vec[0]

impeller/geometry/matrix_unittests.cc

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,18 @@ TEST(MatrixTest, Multiply) {
2525
11.0, 21.0, 0.0, 1.0)));
2626
}
2727

28+
TEST(MatrixTest, Equals) {
29+
Matrix x;
30+
Matrix y = x;
31+
EXPECT_TRUE(x.Equals(y));
32+
}
33+
34+
TEST(MatrixTest, NotEquals) {
35+
Matrix x;
36+
Matrix y = x.Translate({1, 0, 0});
37+
EXPECT_FALSE(x.Equals(y));
38+
}
39+
2840
TEST(MatrixTest, HasPerspective2D) {
2941
EXPECT_FALSE(Matrix().HasPerspective2D());
3042

impeller/geometry/scalar.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@ constexpr T Absolute(const T& val) {
2222
return val >= T{} ? val : -val;
2323
}
2424

25+
template <>
26+
constexpr Scalar Absolute<Scalar>(const float& val) {
27+
return fabsf(val);
28+
}
29+
2530
constexpr inline bool ScalarNearlyZero(Scalar x,
2631
Scalar tolerance = kEhCloseEnough) {
2732
return Absolute(x) <= tolerance;

0 commit comments

Comments
 (0)