Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(98)

Unified Diff: ui/gfx/transform.cc

Issue 11434027: Check for identity before doing matrix math in more places in gfx::Transform (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698