Chromium Code Reviews| Index: src/core/SkMatrix.cpp |
| diff --git a/src/core/SkMatrix.cpp b/src/core/SkMatrix.cpp |
| index 9c9c4375f9e33e36ae2810b379b1c4cd48e632bd..f4de5b506ad48fcf5ec2a437e11a4fcb689b05f7 100644 |
| --- a/src/core/SkMatrix.cpp |
| +++ b/src/core/SkMatrix.cpp |
| @@ -7,6 +7,7 @@ |
| #include "SkMatrix.h" |
| #include "SkFloatBits.h" |
| +#include "SkRSXform.h" |
| #include "SkString.h" |
| #include "SkNx.h" |
| @@ -440,6 +441,22 @@ void SkMatrix::setSinCos(SkScalar sinV, SkScalar cosV, SkScalar px, SkScalar py) |
| this->setTypeMask(kUnknown_Mask | kOnlyPerspectiveValid_Mask); |
| } |
| +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; |
| + |
|
robertphillips
2015/06/15 16:12:55
Seems like we could do better than this.
reed1
2015/06/15 18:52:33
Acknowledged.
|
| + this->setTypeMask(kUnknown_Mask | kOnlyPerspectiveValid_Mask); |
| + return *this; |
| +} |
| + |
| void SkMatrix::setSinCos(SkScalar sinV, SkScalar cosV) { |
| fMat[kMScaleX] = cosV; |
| fMat[kMSkewX] = -sinV; |
| @@ -1800,3 +1817,15 @@ bool SkDecomposeUpper2x2(const SkMatrix& matrix, |
| return true; |
| } |
| + |
| +////////////////////////////////////////////////////////////////////////////////////////////////// |
| + |
| +void SkRSXform::toQuad(SkScalar width, SkScalar height, SkPoint quad[4]) const { |
| + quad[0].set(0, 0); |
| + quad[1].set(width, 0); |
| + quad[2].set(width, height); |
| + quad[3].set(0, height); |
| + SkMatrix m; |
| + m.setRSXform(*this).mapPoints(quad, quad, 4); |
| +} |
| + |