perspective matrix

Nothing too tricky.  The path of least resistance was to keep the matrix row-major when in perspective.  It should make no difference in the end.

GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=4983
CQ_INCLUDE_TRYBOTS=master.client.skia:Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Release-SKNX_NO_SIMD-Trybot

Change-Id: I48bb9de0265e7873c465874cc37076a8111f5ea1
Reviewed-on: https://skia-review.googlesource.com/4983
Reviewed-by: Herb Derby <herb@google.com>
Commit-Queue: Mike Klein <mtklein@chromium.org>
diff --git a/src/image/SkImageShader.cpp b/src/image/SkImageShader.cpp
index 5adf908..a791e9c 100644
--- a/src/image/SkImageShader.cpp
+++ b/src/image/SkImageShader.cpp
@@ -280,11 +280,6 @@
         return false;
     }
 
-    // TODO: perspective
-    if (!matrix.asAffine(nullptr)) {
-        return false;
-    }
-
     // TODO: all formats
     switch (info.colorType()) {
         case kRGBA_8888_SkColorType:
@@ -329,7 +324,7 @@
         int         stride;
         int         width;
         int         height;
-        float       matrix[6];
+        float       matrix[9];
     };
     auto ctx = scratch->make<context>();
 
@@ -337,9 +332,12 @@
     ctx->stride   = pm.rowBytesAsPixels();
     ctx->width    = pm.width();
     ctx->height   = pm.height();
-    SkAssertResult(matrix.asAffine(ctx->matrix));
-
-    p->append(SkRasterPipeline::matrix_2x3, &ctx->matrix);
+    if (matrix.asAffine(ctx->matrix)) {
+        p->append(SkRasterPipeline::matrix_2x3, ctx->matrix);
+    } else {
+        matrix.get9(ctx->matrix);
+        p->append(SkRasterPipeline::matrix_perspective, ctx->matrix);
+    }
 
     switch (fTileModeX) {
         case kClamp_TileMode:  p->append(SkRasterPipeline::clamp_x,  &ctx->width); break;