Starts looking for the bdf fast path in relation to the snapshot_entity's transform (flutter/engine#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
This commit is contained in:
@@ -239,7 +239,7 @@ DownsamplePassArgs CalculateDownsamplePassArgs(
|
||||
// .Contains(coverage_hint.value()))
|
||||
|
||||
std::optional<Rect> 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())) {
|
||||
|
||||
@@ -407,6 +407,27 @@ struct Matrix {
|
||||
|
||||
std::optional<MatrixDecomposition> 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]
|
||||
|
||||
@@ -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());
|
||||
|
||||
|
||||
@@ -22,6 +22,11 @@ constexpr T Absolute(const T& val) {
|
||||
return val >= T{} ? val : -val;
|
||||
}
|
||||
|
||||
template <>
|
||||
constexpr Scalar Absolute<Scalar>(const float& val) {
|
||||
return fabsf(val);
|
||||
}
|
||||
|
||||
constexpr inline bool ScalarNearlyZero(Scalar x,
|
||||
Scalar tolerance = kEhCloseEnough) {
|
||||
return Absolute(x) <= tolerance;
|
||||
|
||||
Reference in New Issue
Block a user