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

Unified Diff: src/utils/SkMatrix44.cpp

Issue 79333002: Fix SkMatrix44::invert(...) for identity matrices and a NULL parameter (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 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: src/utils/SkMatrix44.cpp
diff --git a/src/utils/SkMatrix44.cpp b/src/utils/SkMatrix44.cpp
index 440bf36b62e8cefec9fed415673b48a1be03ae71..a7133ec1a75fb9d8c82fae09aa31197b250e7b12 100644
--- a/src/utils/SkMatrix44.cpp
+++ b/src/utils/SkMatrix44.cpp
@@ -452,39 +452,41 @@ bool SkMatrix44::invert(SkMatrix44* inverse) const {
if (this->isIdentity()) {
if (inverse) {
inverse->setIdentity();
- return true;
}
+ return true;
}
+
if (this->isTranslate()) {
if (inverse) {
inverse->setTranslate(-fMat[3][0], -fMat[3][1], -fMat[3][2]);
}
return true;
}
+
if (this->isScaleTranslate()) {
if (0 == fMat[0][0] * fMat[1][1] * fMat[2][2]) {
return false;
}
- if (inverse) {
- double invXScale = 1 / fMat[0][0];
- double invYScale = 1 / fMat[1][1];
- double invZScale = 1 / fMat[2][2];
+ if (inverse) {
+ double invXScale = 1 / fMat[0][0];
+ double invYScale = 1 / fMat[1][1];
+ double invZScale = 1 / fMat[2][2];
inverse->fMat[0][0] = invXScale;
- inverse->fMat[0][1] = 0;
- inverse->fMat[0][2] = 0;
- inverse->fMat[0][3] = 0;
+ inverse->fMat[0][1] = 0;
+ inverse->fMat[0][2] = 0;
+ inverse->fMat[0][3] = 0;
- inverse->fMat[1][0] = 0;
- inverse->fMat[1][1] = invYScale;
- inverse->fMat[1][2] = 0;
- inverse->fMat[1][3] = 0;
+ inverse->fMat[1][0] = 0;
+ inverse->fMat[1][1] = invYScale;
+ inverse->fMat[1][2] = 0;
+ inverse->fMat[1][3] = 0;
- inverse->fMat[2][0] = 0;
+ inverse->fMat[2][0] = 0;
inverse->fMat[2][1] = 0;
- inverse->fMat[2][2] = invZScale;
- inverse->fMat[2][3] = 0;
+ inverse->fMat[2][2] = invZScale;
+ inverse->fMat[2][3] = 0;
inverse->fMat[3][0] = -fMat[3][0] * invXScale;
inverse->fMat[3][1] = -fMat[3][1] * invYScale;
« 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