summaryrefslogtreecommitdiff
path: root/chromium/ui/gfx/transform.cc
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/ui/gfx/transform.cc')
-rw-r--r--chromium/ui/gfx/transform.cc27
1 files changed, 18 insertions, 9 deletions
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<int>(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<int>(t[0]) &&
- base::IsValueInRangeForNumericType<int>(t[1]) &&
- base::IsValueInRangeForNumericType<int>(t[2]) &&
- static_cast<int>(t[0]) == t[0] && static_cast<int>(t[1]) == t[1] &&
- static_cast<int>(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<int>(t) || static_cast<int>(t) != t)
+ return false;
+ }
+ return true;
}
bool Transform::IsBackFaceVisible() const {