Index: src/utils/SkMatrix44.cpp |
diff --git a/src/utils/SkMatrix44.cpp b/src/utils/SkMatrix44.cpp |
index 658d5c1aa845915a0418371ba7851b66fced6657..eb0819f1df3d57fc6310dc0d51dc6ddb61d1c97e 100644 |
--- a/src/utils/SkMatrix44.cpp |
+++ b/src/utils/SkMatrix44.cpp |
@@ -880,8 +880,6 @@ void SkMatrix44::dump() const { |
/////////////////////////////////////////////////////////////////////////////// |
-// TODO: make this support src' perspective elements |
-// |
static void initFromMatrix(SkMScalar dst[4][4], const SkMatrix& src) { |
sk_bzero(dst, 16 * sizeof(SkMScalar)); |
dst[0][0] = SkScalarToMScalar(src[SkMatrix::kMScaleX]); |
@@ -890,7 +888,10 @@ static void initFromMatrix(SkMScalar dst[4][4], const SkMatrix& src) { |
dst[0][1] = SkScalarToMScalar(src[SkMatrix::kMSkewY]); |
dst[1][1] = SkScalarToMScalar(src[SkMatrix::kMScaleY]); |
dst[3][1] = SkScalarToMScalar(src[SkMatrix::kMTransY]); |
- dst[2][2] = dst[3][3] = 1; |
+ dst[0][3] = SkScalarToMScalar(src[SkMatrix::kMPersp0]); |
+ dst[1][3] = SkScalarToMScalar(src[SkMatrix::kMPersp1]); |
+ dst[3][3] = SkScalarToMScalar(src[SkMatrix::kMPersp2]); |
+ dst[2][2] = 1; |
} |
SkMatrix44::SkMatrix44(const SkMatrix& src) { |
@@ -908,11 +909,8 @@ SkMatrix44& SkMatrix44::operator=(const SkMatrix& src) { |
return *this; |
} |
-// TODO: make this support our perspective elements |
-// |
SkMatrix44::operator SkMatrix() const { |
SkMatrix dst; |
- dst.reset(); // setup our perspective correctly for identity |
dst[SkMatrix::kMScaleX] = SkMScalarToScalar(fMat[0][0]); |
dst[SkMatrix::kMSkewX] = SkMScalarToScalar(fMat[1][0]); |
@@ -922,5 +920,9 @@ SkMatrix44::operator SkMatrix() const { |
dst[SkMatrix::kMScaleY] = SkMScalarToScalar(fMat[1][1]); |
dst[SkMatrix::kMTransY] = SkMScalarToScalar(fMat[3][1]); |
+ dst[SkMatrix::kMPersp0] = SkMScalarToScalar(fMat[0][3]); |
+ dst[SkMatrix::kMPersp1] = SkMScalarToScalar(fMat[1][3]); |
+ dst[SkMatrix::kMPersp2] = SkMScalarToScalar(fMat[3][3]); |
+ |
return dst; |
} |