Index: ui/gfx/transform.cc |
diff --git a/ui/gfx/transform.cc b/ui/gfx/transform.cc |
index b75bb7fb419113197228c69c6e699521fb904188..3dc339cd7bb67da6c1a20a873b11383fb5d6b296 100644 |
--- a/ui/gfx/transform.cc |
+++ b/ui/gfx/transform.cc |
@@ -207,13 +207,17 @@ void Transform::ApplyPerspectiveDepth(double depth) { |
} |
void Transform::PreconcatTransform(const Transform& transform) { |
- if (!transform.matrix_.isIdentity()) { |
+ if (matrix_.isIdentity()) { |
+ *this = transform; |
danakj
2012/11/30 01:29:26
matrix_ = transform.matrix_; like below?
|
+ } else if (!transform.matrix_.isIdentity()) { |
matrix_.preConcat(transform.matrix_); |
} |
} |
void Transform::ConcatTransform(const Transform& transform) { |
- if (!transform.matrix_.isIdentity()) { |
+ if (matrix_.isIdentity()) { |
+ matrix_ = transform.matrix_; |
+ } else if (!transform.matrix_.isIdentity()) { |
matrix_.postConcat(transform.matrix_); |
} |
} |
@@ -223,6 +227,9 @@ bool Transform::IsIdentity() const { |
} |
bool Transform::IsIdentityOrTranslation() const { |
+ if (matrix_.isIdentity()) |
+ return true; |
+ |
bool has_no_perspective = !matrix_.getDouble(3, 0) && |
!matrix_.getDouble(3, 1) && |
!matrix_.getDouble(3, 2) && |
@@ -243,6 +250,9 @@ bool Transform::IsIdentityOrTranslation() const { |
} |
bool Transform::IsScaleOrTranslation() const { |
+ if (matrix_.isIdentity()) |
+ return true; |
+ |
bool has_no_perspective = !matrix_.getDouble(3, 0) && |
!matrix_.getDouble(3, 1) && |
!matrix_.getDouble(3, 2) && |
@@ -270,6 +280,9 @@ bool Transform::IsInvertible() const { |
} |
bool Transform::IsBackFaceVisible() const { |
+ if (matrix_.isIdentity()) |
+ return false; |
+ |
// Compute whether a layer with a forward-facing normal of (0, 0, 1) would |
// have its back face visible after applying the transform. |
// |
@@ -368,13 +381,17 @@ bool Transform::Blend(const Transform& from, double progress) { |
} |
Transform Transform::operator*(const Transform& other) const { |
+ if (matrix_.isIdentity()) |
+ return other; |
+ if (other.matrix_.isIdentity()) |
+ return *this; |
Transform to_return; |
to_return.matrix_.setConcat(matrix_, other.matrix_); |
return to_return; |
} |
Transform& Transform::operator*=(const Transform& other) { |
- matrix_.preConcat(other.matrix_); |
+ PreconcatTransform(other); |
return *this; |
} |