Fixups for clipstack, convexity test for paths.
Review URL http://codereview.appspot.com/4250056/
git-svn-id: http://skia.googlecode.com/svn/trunk@891 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/gpu/include/GrPoint.h b/gpu/include/GrPoint.h
index bb24959..c07543b 100644
--- a/gpu/include/GrPoint.h
+++ b/gpu/include/GrPoint.h
@@ -161,7 +161,47 @@
fX = b.fX - a.fX;
fY = b.fY - a.fY;
}
-
+
+ /**
+ * Make this vector be orthogonal to vec. Looking down vec the
+ * new vector will point left.
+ */
+ void setOrthogLeft(const GrVec& vec) {
+ // vec could be this
+ GrVec v = vec;
+ fX = -v.fY;
+ fY = v.fX;
+ }
+
+ /**
+ * Make this vector be orthogonal to vec. Looking down vec the
+ * new vector will point right.
+ */
+ void setOrthogRight(const GrVec& vec) {
+ // vec could be this
+ GrVec v = vec;
+ fX = v.fY;
+ fY = -v.fX;
+ }
+
+ /**
+ * set orthogonal to vec from a to b. Will be facing left relative to a,b
+ * vec
+ */
+ void setOrthogLeftToVecBetween(const GrPoint& a, const GrPoint& b) {
+ fX = a.fY - b.fY;
+ fY = b.fX - a.fX;
+ }
+
+ /**
+ * set orthogonal to vec from a to b. Will be facing right relative to a,b
+ * vec.
+ */
+ void setOrthogRightToVecBetween(const GrPoint& a, const GrPoint& b) {
+ fX = b.fY - a.fY;
+ fY = a.fX - b.fX;
+ }
+
/**
* length of the vector squared.
*/
@@ -201,6 +241,13 @@
}
/**
+ * Dot product of this vec with vector from (0,0) to a pt.
+ */
+ GrScalar dotWithVecToPt(const GrPoint& pt) const {
+ return GrMul(pt.fX, fX) + GrMul(pt.fY, fY);
+ }
+
+ /**
* z-value of this cross vec.
*/
GrScalar cross(const GrVec& vec) const {