From c30a6232df03e1efbd9f3b226777b07e087a1122 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Mon, 12 Oct 2020 14:27:29 +0200 Subject: BASELINE: Update Chromium to 85.0.4183.140 Change-Id: Iaa42f4680837c57725b1344f108c0196741f6057 Reviewed-by: Allan Sandfeld Jensen --- chromium/ui/gfx/transform.cc | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) (limited to 'chromium/ui/gfx/transform.cc') diff --git a/chromium/ui/gfx/transform.cc b/chromium/ui/gfx/transform.cc index e0f0b4a3925..58b662123d6 100644 --- a/chromium/ui/gfx/transform.cc +++ b/chromium/ui/gfx/transform.cc @@ -245,19 +245,28 @@ bool Transform::IsApproximatelyIdentityOrTranslation(SkScalar tolerance) const { matrix_.get(3, 3) == 1; } +bool Transform::IsApproximatelyIdentityOrIntegerTranslation( + SkScalar tolerance) const { + if (!IsApproximatelyIdentityOrTranslation(tolerance)) + return false; + + for (float t : {matrix_.get(0, 3), matrix_.get(1, 3), matrix_.get(2, 3)}) { + if (!base::IsValueInRangeForNumericType(t) || + std::abs(std::round(t) - t) > tolerance) + return false; + } + return true; +} + bool Transform::IsIdentityOrIntegerTranslation() const { if (!IsIdentityOrTranslation()) return false; - float t[] = {matrix_.get(0, 3), matrix_.get(1, 3), matrix_.get(2, 3)}; - bool no_fractional_translation = - base::IsValueInRangeForNumericType(t[0]) && - base::IsValueInRangeForNumericType(t[1]) && - base::IsValueInRangeForNumericType(t[2]) && - static_cast(t[0]) == t[0] && static_cast(t[1]) == t[1] && - static_cast(t[2]) == t[2]; - - return no_fractional_translation; + for (float t : {matrix_.get(0, 3), matrix_.get(1, 3), matrix_.get(2, 3)}) { + if (!base::IsValueInRangeForNumericType(t) || static_cast(t) != t) + return false; + } + return true; } bool Transform::IsBackFaceVisible() const { -- cgit v1.2.1