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

Unified Diff: src/core/SkMatrix.cpp

Issue 22330004: Add a map homogenous points to SkMatrix (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years, 4 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
« include/core/SkMatrix.h ('K') | « include/core/SkMatrix.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkMatrix.cpp
diff --git a/src/core/SkMatrix.cpp b/src/core/SkMatrix.cpp
index 36e735309bb4739bf66ead50fd2571dd8af75cf3..29d0bc1d734f51b9d7b693923866fa5d27835117 100644
--- a/src/core/SkMatrix.cpp
+++ b/src/core/SkMatrix.cpp
@@ -1227,6 +1227,43 @@ void SkMatrix::mapPoints(SkPoint dst[], const SkPoint src[], int count) const {
///////////////////////////////////////////////////////////////////////////////
+void SkMatrix::Homogeneous_pts(const SkMatrix& m, SkScalar dst[],
+ const SkScalar src[], int count) {
+ if (count > 0) {
+ do {
+ SkScalar sx = src[0];
+ SkScalar sy = src[1];
+ SkScalar sw = src[2];
+ src += 3;
+
+ SkScalar x = SkScalarMul(sx, m.fMat[kMScaleX]) +
+ SkScalarMul(sy, m.fMat[kMSkewX]) +
+ SkScalarMul(sw, m.fMat[kMTransX]);
+ SkScalar y = SkScalarMul(sx, m.fMat[kMSkewY]) +
+ SkScalarMul(sy, m.fMat[kMScaleY]) +
+ SkScalarMul(sw, m.fMat[kMTransY]);
+ SkScalar w = SkScalarMul(sx, m.fMat[kMPersp0]) +
+ SkScalarMul(sy, m.fMat[kMPersp1]) +
+ SkScalarMul(sw, m.fMat[kMPersp2]);
+
+ dst[0] = x;
+ dst[1] = y;
+ dst[2] = w;
+ dst += 3;
+ } while (--count);
+ }
+}
+
+void SkMatrix::mapHomogeneousPoints(SkScalar dst[], const SkScalar src[], int count) const {
+ SkASSERT((dst && src && count > 0) || count == 0);
+ // no partial overlap
+ SkASSERT(src == dst || SkAbs32((int32_t)(src - dst)) >= 3*count);
+
+ SkMatrix::Homogeneous_pts(*this, dst, src, count);
+}
+
+///////////////////////////////////////////////////////////////////////////////
+
void SkMatrix::mapVectors(SkPoint dst[], const SkPoint src[], int count) const {
if (this->hasPerspective()) {
SkPoint origin;
« include/core/SkMatrix.h ('K') | « include/core/SkMatrix.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698