aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar egdaniel@google.com <egdaniel@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-08-15 21:12:11 +0000
committerGravatar egdaniel@google.com <egdaniel@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-08-15 21:12:11 +0000
commit259fbaf7a464827bc560517988daeb5836e11e98 (patch)
treedffe383235dc80f54a2e3080ed2d20d15b18f3d5 /src
parent0038c12f337b7037ef698e2723099c7e3b19c4ca (diff)
Add homogeneous point mapping to Matrix
Adds mapping of homogeneous points (points with three scalar components, where the last component is not 1). Includes fix for tests when running on 32 bit debug builds BUG= R=bsalomon@google.com Review URL: https://codereview.chromium.org/22816005 git-svn-id: http://skia.googlecode.com/svn/trunk@10755 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src')
-rw-r--r--src/core/SkMatrix.cpp38
1 files changed, 37 insertions, 1 deletions
diff --git a/src/core/SkMatrix.cpp b/src/core/SkMatrix.cpp
index 36e735309b..e5d48f022f 100644
--- a/src/core/SkMatrix.cpp
+++ b/src/core/SkMatrix.cpp
@@ -1218,7 +1218,7 @@ const SkMatrix::MapPtsProc SkMatrix::gMapPtsProcs[] = {
};
void SkMatrix::mapPoints(SkPoint dst[], const SkPoint src[], int count) const {
- SkASSERT((dst && src && count > 0) || count == 0);
+ SkASSERT((dst && src && count > 0) || 0 == count);
// no partial overlap
SkASSERT(src == dst || SkAbs32((int32_t)(src - dst)) >= count);
@@ -1227,6 +1227,42 @@ void SkMatrix::mapPoints(SkPoint dst[], const SkPoint src[], int count) const {
///////////////////////////////////////////////////////////////////////////////
+void SkMatrix::mapHomogeneousPoints(SkScalar dst[], const SkScalar src[], int count) const {
+ SkASSERT((dst && src && count > 0) || 0 == count);
+ // no partial overlap
+ SkASSERT(src == dst || SkAbs32((int32_t)(src - dst)) >= 3*count);
+
+ if (count > 0) {
+ if (this->isIdentity()) {
+ memcpy(dst, src, 3*count*sizeof(SkScalar));
+ return;
+ }
+ do {
+ SkScalar sx = src[0];
+ SkScalar sy = src[1];
+ SkScalar sw = src[2];
+ src += 3;
+
+ SkScalar x = SkScalarMul(sx, fMat[kMScaleX]) +
+ SkScalarMul(sy, fMat[kMSkewX]) +
+ SkScalarMul(sw, fMat[kMTransX]);
+ SkScalar y = SkScalarMul(sx, fMat[kMSkewY]) +
+ SkScalarMul(sy, fMat[kMScaleY]) +
+ SkScalarMul(sw, fMat[kMTransY]);
+ SkScalar w = SkScalarMul(sx, fMat[kMPersp0]) +
+ SkScalarMul(sy, fMat[kMPersp1]) +
+ SkScalarMul(sw, fMat[kMPersp2]);
+
+ dst[0] = x;
+ dst[1] = y;
+ dst[2] = w;
+ dst += 3;
+ } while (--count);
+ }
+}
+
+///////////////////////////////////////////////////////////////////////////////
+
void SkMatrix::mapVectors(SkPoint dst[], const SkPoint src[], int count) const {
if (this->hasPerspective()) {
SkPoint origin;