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/core/SkMatrix.cpp

Issue 13521006: First pass at Rect Effect (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: renamed isOrthogonal to preservesRightAngles Created 7 years, 8 months 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 | « include/gpu/GrAARectRenderer.h ('k') | src/gpu/GrAARectRenderer.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkMatrix.cpp
===================================================================
--- src/core/SkMatrix.cpp (revision 8570)
+++ src/core/SkMatrix.cpp (working copy)
@@ -189,6 +189,7 @@
SkScalar sx = fMat[kMSkewX];
SkScalar sy = fMat[kMSkewY];
+ // TODO: I (rphillips) think there should be an || in here (see preservesRightAngles)
// degenerate matrix, non-similarity
if (SkScalarNearlyZero(mx) && SkScalarNearlyZero(my)
&& SkScalarNearlyZero(sx) && SkScalarNearlyZero(sy)) {
@@ -202,9 +203,43 @@
return SkScalarNearlyZero(vec[0].dot(vec[1]), SkScalarSquare(tol)) &&
SkScalarNearlyEqual(vec[0].lengthSqd(), vec[1].lengthSqd(),
- SkScalarSquare(tol));
+ SkScalarSquare(tol));
}
+bool SkMatrix::preservesRightAngles(SkScalar tol) const {
+ TypeMask mask = this->getType();
+
+ if (mask <= (SkMatrix::kTranslate_Mask | SkMatrix::kScale_Mask)) {
+ // identity, translate and/or scale
+ return true;
+ }
+ if (mask & kPerspective_Mask) {
+ return false;
+ }
+
+ SkASSERT(mask & kAffine_Mask);
+
+ SkScalar mx = fMat[kMScaleX];
+ SkScalar my = fMat[kMScaleY];
+ SkScalar sx = fMat[kMSkewX];
+ SkScalar sy = fMat[kMSkewY];
+
+ if ((SkScalarNearlyZero(mx) && SkScalarNearlyZero(sx)) ||
+ (SkScalarNearlyZero(my) && SkScalarNearlyZero(sy))) {
+ // degenerate matrix
+ return false;
+ }
+
+ // it has scales and skews, but it could also be rotation, check it out.
+ SkVector vec[2];
+ vec[0].set(mx, sx);
+ vec[1].set(sy, my);
+
+ return SkScalarNearlyZero(vec[0].dot(vec[1]), SkScalarSquare(tol)) &&
+ SkScalarNearlyEqual(vec[0].lengthSqd(), vec[1].lengthSqd(),
+ SkScalarSquare(tol));
+}
+
///////////////////////////////////////////////////////////////////////////////
void SkMatrix::setTranslate(SkScalar dx, SkScalar dy) {
« no previous file with comments | « include/gpu/GrAARectRenderer.h ('k') | src/gpu/GrAARectRenderer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698