Add perspective support to SkMatrix44 initializers.

I noticed SkMatrix <-> SkMatrix44 conversions were dropping the
perspective values on the floor.  As we use SkMatrix44 heavily in
Chromium, I'm concerned this missing code will cause a bug eventually.
It should be correct to simply use the bottom row of the 4x4 matrix
excluding the third column.

Previously committed and reverted, second attempt with fix for
incorrect use of SkMScalar/SkScalar.

BUG=
R=reed@google.com, caryclark@google.com

Author: aelias@chromium.org

Review URL: https://codereview.chromium.org/25484006

git-svn-id: http://skia.googlecode.com/svn/trunk@11624 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/utils/SkMatrix44.cpp b/src/utils/SkMatrix44.cpp
index 1e48f39..9803b52 100644
--- a/src/utils/SkMatrix44.cpp
+++ b/src/utils/SkMatrix44.cpp
@@ -902,8 +902,6 @@
 
 ///////////////////////////////////////////////////////////////////////////////
 
-// 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 @@
     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 @@
     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 @@
     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;
 }