Index: src/core/SkMatrix.cpp |
diff --git a/src/core/SkMatrix.cpp b/src/core/SkMatrix.cpp |
index 13a9ac28f0a715e59cdf3138aef84f3321944353..b32f372bbdcece567e69ba2c57b8e2d08bf50ff6 100644 |
--- a/src/core/SkMatrix.cpp |
+++ b/src/core/SkMatrix.cpp |
@@ -10,6 +10,7 @@ |
#include "SkRSXform.h" |
#include "SkString.h" |
#include "SkNx.h" |
+#include "SkOpts.h" |
#include <stddef.h> |
@@ -445,14 +446,14 @@ SkMatrix& SkMatrix::setRSXform(const SkRSXform& xform) { |
fMat[kMScaleX] = xform.fSCos; |
fMat[kMSkewX] = -xform.fSSin; |
fMat[kMTransX] = xform.fTx; |
- |
+ |
fMat[kMSkewY] = xform.fSSin; |
fMat[kMScaleY] = xform.fSCos; |
fMat[kMTransY] = xform.fTy; |
- |
+ |
fMat[kMPersp0] = fMat[kMPersp1] = 0; |
fMat[kMPersp2] = 1; |
- |
+ |
this->setTypeMask(kUnknown_Mask | kOnlyPerspectiveValid_Mask); |
return *this; |
} |
@@ -907,64 +908,11 @@ void SkMatrix::Identity_pts(const SkMatrix& m, SkPoint dst[], const SkPoint src[ |
} |
void SkMatrix::Trans_pts(const SkMatrix& m, SkPoint dst[], const SkPoint src[], int count) { |
- SkASSERT(m.getType() <= kTranslate_Mask); |
- |
- if (count > 0) { |
- SkScalar tx = m.getTranslateX(); |
- SkScalar ty = m.getTranslateY(); |
- if (count & 1) { |
- dst->fX = src->fX + tx; |
- dst->fY = src->fY + ty; |
- src += 1; |
- dst += 1; |
- } |
- Sk4s trans4(tx, ty, tx, ty); |
- count >>= 1; |
- if (count & 1) { |
- (Sk4s::Load(&src->fX) + trans4).store(&dst->fX); |
- src += 2; |
- dst += 2; |
- } |
- count >>= 1; |
- for (int i = 0; i < count; ++i) { |
- (Sk4s::Load(&src[0].fX) + trans4).store(&dst[0].fX); |
- (Sk4s::Load(&src[2].fX) + trans4).store(&dst[2].fX); |
- src += 4; |
- dst += 4; |
- } |
- } |
+ return SkOpts::matrix_translate(m,dst,src,count); |
} |
void SkMatrix::Scale_pts(const SkMatrix& m, SkPoint dst[], const SkPoint src[], int count) { |
- SkASSERT(m.getType() <= (kScale_Mask | kTranslate_Mask)); |
- |
- if (count > 0) { |
- SkScalar tx = m.getTranslateX(); |
- SkScalar ty = m.getTranslateY(); |
- SkScalar sx = m.getScaleX(); |
- SkScalar sy = m.getScaleY(); |
- if (count & 1) { |
- dst->fX = src->fX * sx + tx; |
- dst->fY = src->fY * sy + ty; |
- src += 1; |
- dst += 1; |
- } |
- Sk4s trans4(tx, ty, tx, ty); |
- Sk4s scale4(sx, sy, sx, sy); |
- count >>= 1; |
- if (count & 1) { |
- (Sk4s::Load(&src->fX) * scale4 + trans4).store(&dst->fX); |
- src += 2; |
- dst += 2; |
- } |
- count >>= 1; |
- for (int i = 0; i < count; ++i) { |
- (Sk4s::Load(&src[0].fX) * scale4 + trans4).store(&dst[0].fX); |
- (Sk4s::Load(&src[2].fX) * scale4 + trans4).store(&dst[2].fX); |
- src += 4; |
- dst += 4; |
- } |
- } |
+ return SkOpts::matrix_scale_translate(m,dst,src,count); |
} |
void SkMatrix::Persp_pts(const SkMatrix& m, SkPoint dst[], |
@@ -996,33 +944,7 @@ void SkMatrix::Persp_pts(const SkMatrix& m, SkPoint dst[], |
} |
void SkMatrix::Affine_vpts(const SkMatrix& m, SkPoint dst[], const SkPoint src[], int count) { |
- SkASSERT(m.getType() != kPerspective_Mask); |
- |
- if (count > 0) { |
- SkScalar tx = m.getTranslateX(); |
- SkScalar ty = m.getTranslateY(); |
- SkScalar sx = m.getScaleX(); |
- SkScalar sy = m.getScaleY(); |
- SkScalar kx = m.getSkewX(); |
- SkScalar ky = m.getSkewY(); |
- if (count & 1) { |
- dst->set(src->fX * sx + src->fY * kx + tx, |
- src->fX * ky + src->fY * sy + ty); |
- src += 1; |
- dst += 1; |
- } |
- Sk4s trans4(tx, ty, tx, ty); |
- Sk4s scale4(sx, sy, sx, sy); |
- Sk4s skew4(kx, ky, kx, ky); // applied to swizzle of src4 |
- count >>= 1; |
- for (int i = 0; i < count; ++i) { |
- Sk4s src4 = Sk4s::Load(&src->fX); |
- Sk4s swz4(src[0].fY, src[0].fX, src[1].fY, src[1].fX); // need ABCD -> BADC |
- (src4 * scale4 + swz4 * skew4 + trans4).store(&dst->fX); |
- src += 2; |
- dst += 2; |
- } |
- } |
+ return SkOpts::matrix_affine(m,dst,src,count); |
} |
const SkMatrix::MapPtsProc SkMatrix::gMapPtsProcs[] = { |