Index: src/utils/SkMatrix44.cpp |
diff --git a/src/utils/SkMatrix44.cpp b/src/utils/SkMatrix44.cpp |
index 1e48f393ac6fd372faf781cd86af63122eb90466..9803b520950cf80310443613940098fcdb5f665d 100644 |
--- a/src/utils/SkMatrix44.cpp |
+++ b/src/utils/SkMatrix44.cpp |
@@ -902,8 +902,6 @@ void SkMatrix44::dump() const { |
/////////////////////////////////////////////////////////////////////////////// |
-// TODO: make this support src' perspective elements |
-// |
static void initFromMatrix(SkMScalar dst[4][4], const SkMatrix& src) { |
dst[0][0] = SkScalarToMScalar(src[SkMatrix::kMScaleX]); |
dst[1][0] = SkScalarToMScalar(src[SkMatrix::kMSkewX]); |
@@ -917,10 +915,10 @@ static void initFromMatrix(SkMScalar dst[4][4], const SkMatrix& src) { |
dst[1][2] = 0; |
dst[2][2] = 1; |
dst[3][2] = 0; |
- dst[0][3] = 0; |
- dst[1][3] = 0; |
+ dst[0][3] = SkScalarToMScalar(src[SkMatrix::kMPersp0]); |
+ dst[1][3] = SkScalarToMScalar(src[SkMatrix::kMPersp1]); |
dst[2][3] = 0; |
- dst[3][3] = 1; |
+ dst[3][3] = SkScalarToMScalar(src[SkMatrix::kMPersp2]); |
} |
SkMatrix44::SkMatrix44(const SkMatrix& src) { |
@@ -938,11 +936,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]); |
@@ -952,5 +947,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; |
} |