remove unreachable perspective code for imageshader

CQ_INCLUDE_TRYBOTS=skia.primary:Test-Debian9-GCC-GCE-CPU-AVX2-x86_64-Release-SKNX_NO_SIMD
Bug: skia:
Change-Id: If9a7df3e1c387098b00bf1cc1a37c36c6d256ef1
Reviewed-on: https://skia-review.googlesource.com/22348
Commit-Queue: Florin Malita <fmalita@chromium.org>
Reviewed-by: Florin Malita <fmalita@chromium.org>
diff --git a/gn/core.gni b/gn/core.gni
index c0eecd9..187a6de 100644
--- a/gn/core.gni
+++ b/gn/core.gni
@@ -221,7 +221,6 @@
   "$_src/core/SkPathMeasure.cpp",
   "$_src/core/SkPathPriv.h",
   "$_src/core/SkPathRef.cpp",
-  "$_src/core/SkPerspIter.h",
   "$_src/core/SkPicture.cpp",
   "$_src/core/SkPictureAnalyzer.cpp",
   "$_src/core/SkPictureCommon.h",
diff --git a/src/core/SkBitmapProcState.cpp b/src/core/SkBitmapProcState.cpp
index 87e3ad8..4df0f58 100644
--- a/src/core/SkBitmapProcState.cpp
+++ b/src/core/SkBitmapProcState.cpp
@@ -90,6 +90,8 @@
 }
 
 bool SkBitmapProcInfo::init(const SkMatrix& inv, const SkPaint& paint) {
+    SkASSERT(!inv.hasPerspective());
+
     fPixmap.reset();
     fInvMatrix = inv;
     fFilterQuality = paint.getFilterQuality();
@@ -648,7 +650,7 @@
     scale/translate     nofilter      Y(4bytes) + N * X
     affine/perspective  nofilter      N * (X Y)
     scale/translate     filter        Y Y + N * (X X)
-    affine/perspective  filter        N * (Y Y X X)
+    affine              filter        N * (Y Y X X)
  */
 int SkBitmapProcState::maxCountForBufferSize(size_t bufferSize) const {
     int32_t size = static_cast<int32_t>(bufferSize);
diff --git a/src/core/SkBitmapProcState_matrix.h b/src/core/SkBitmapProcState_matrix.h
index ea784c6..02dba44 100644
--- a/src/core/SkBitmapProcState_matrix.h
+++ b/src/core/SkBitmapProcState_matrix.h
@@ -10,7 +10,6 @@
 
 #define SCALE_FILTER_NAME       MAKENAME(_filter_scale)
 #define AFFINE_FILTER_NAME      MAKENAME(_filter_affine)
-#define PERSP_FILTER_NAME       MAKENAME(_filter_persp)
 
 #define PACK_FILTER_X_NAME  MAKENAME(_pack_filter_x)
 #define PACK_FILTER_Y_NAME  MAKENAME(_pack_filter_y)
@@ -28,9 +27,6 @@
                               uint32_t xy[], int count, int x, int y);
 void AFFINE_FILTER_NAME(const SkBitmapProcState& s,
                                uint32_t xy[], int count, int x, int y);
-void PERSP_FILTER_NAME(const SkBitmapProcState& s,
-                              uint32_t* SK_RESTRICT xy, int count,
-                              int x, int y);
 
 static inline uint32_t PACK_FILTER_Y_NAME(SkFixed f, unsigned max,
                                           SkFixed one PREAMBLE_PARAM_Y) {
@@ -112,33 +108,6 @@
     } while (--count != 0);
 }
 
-void PERSP_FILTER_NAME(const SkBitmapProcState& s,
-                              uint32_t* SK_RESTRICT xy, int count,
-                              int x, int y) {
-    SkASSERT(s.fInvType & SkMatrix::kPerspective_Mask);
-
-    PREAMBLE(s);
-    unsigned maxX = s.fPixmap.width() - 1;
-    unsigned maxY = s.fPixmap.height() - 1;
-    SkFixed oneX = s.fFilterOneX;
-    SkFixed oneY = s.fFilterOneY;
-
-    SkPerspIter   iter(s.fInvMatrix,
-                       SkIntToScalar(x) + SK_ScalarHalf,
-                       SkIntToScalar(y) + SK_ScalarHalf, count);
-
-    while ((count = iter.next()) != 0) {
-        const SkFixed* SK_RESTRICT srcXY = iter.getXY();
-        do {
-            *xy++ = PACK_FILTER_Y_NAME(srcXY[1] - (oneY >> 1), maxY,
-                                       oneY PREAMBLE_ARG_Y);
-            *xy++ = PACK_FILTER_X_NAME(srcXY[0] - (oneX >> 1), maxX,
-                                       oneX PREAMBLE_ARG_X);
-            srcXY += 2;
-        } while (--count != 0);
-    }
-}
-
 #undef MAKENAME
 #undef TILEX_PROCF
 #undef TILEY_PROCF
@@ -148,7 +117,6 @@
 
 #undef SCALE_FILTER_NAME
 #undef AFFINE_FILTER_NAME
-#undef PERSP_FILTER_NAME
 
 #undef PREAMBLE
 #undef PREAMBLE_PARAM_X
diff --git a/src/core/SkBitmapProcState_matrixProcs.cpp b/src/core/SkBitmapProcState_matrixProcs.cpp
index 08753be..2860e4b 100644
--- a/src/core/SkBitmapProcState_matrixProcs.cpp
+++ b/src/core/SkBitmapProcState_matrixProcs.cpp
@@ -14,7 +14,6 @@
  */
 
 #include "SkBitmapProcState.h"
-#include "SkPerspIter.h"
 #include "SkShader.h"
 #include "SkUtils.h"
 #include "SkUtilsArm.h"
@@ -89,8 +88,6 @@
     ClampX_ClampY_filter_scale,
     ClampX_ClampY_nofilter_affine,
     ClampX_ClampY_filter_affine,
-    NoFilterProc_Persp<ClampTileProcs>,
-    ClampX_ClampY_filter_persp
 };
 
 #define MAKENAME(suffix)         RepeatX_RepeatY ## suffix
@@ -115,8 +112,6 @@
     RepeatX_RepeatY_filter_scale,
     NoFilterProc_Affine<RepeatTileProcs>,
     RepeatX_RepeatY_filter_affine,
-    NoFilterProc_Persp<RepeatTileProcs>,
-    RepeatX_RepeatY_filter_persp
 };
 #endif
 
@@ -146,8 +141,6 @@
     GeneralXY_filter_scale,
     NoFilterProc_Affine<GeneralTileProcs>,
     GeneralXY_filter_affine,
-    NoFilterProc_Persp<GeneralTileProcs>,
-    GeneralXY_filter_persp
 };
 
 ///////////////////////////////////////////////////////////////////////////////
@@ -449,6 +442,8 @@
 ///////////////////////////////////////////////////////////////////////////////
 
 SkBitmapProcState::MatrixProc SkBitmapProcState::chooseMatrixProc(bool trivial_matrix) {
+    SkASSERT((fInvType & SkMatrix::kPerspective_Mask) == 0);
+
 //    test_int_tileprocs();
     // check for our special case when there is no scale/affine/perspective
     if (trivial_matrix && kNone_SkFilterQuality == fFilterQuality) {
@@ -467,9 +462,7 @@
     if (fFilterQuality != kNone_SkFilterQuality) {
         index = 1;
     }
-    if (fInvType & SkMatrix::kPerspective_Mask) {
-        index += 4;
-    } else if (fInvType & SkMatrix::kAffine_Mask) {
+    if (fInvType & SkMatrix::kAffine_Mask) {
         index += 2;
     }
 
diff --git a/src/core/SkBitmapProcState_matrix_template.h b/src/core/SkBitmapProcState_matrix_template.h
index c38610a..772c862 100644
--- a/src/core/SkBitmapProcState_matrix_template.h
+++ b/src/core/SkBitmapProcState_matrix_template.h
@@ -98,26 +98,4 @@
     }
 }
 
-template <typename TileProc>
-void NoFilterProc_Persp(const SkBitmapProcState& s, uint32_t* SK_RESTRICT xy,
-                        int count, int x, int y) {
-    SkASSERT(s.fInvType & SkMatrix::kPerspective_Mask);
-
-    int maxX = s.fPixmap.width() - 1;
-    int maxY = s.fPixmap.height() - 1;
-
-    SkPerspIter   iter(s.fInvMatrix,
-                       SkIntToScalar(x) + SK_ScalarHalf,
-                       SkIntToScalar(y) + SK_ScalarHalf, count);
-
-    while ((count = iter.next()) != 0) {
-        const SkFixed* SK_RESTRICT srcXY = iter.getXY();
-        while (--count >= 0) {
-            *xy++ = (TileProc::Y(s, srcXY[1], maxY) << 16) |
-                     TileProc::X(s, srcXY[0], maxX);
-            srcXY += 2;
-        }
-    }
-}
-
 #endif
diff --git a/src/core/SkMatrix.cpp b/src/core/SkMatrix.cpp
index 8517d87..5feee12 100644
--- a/src/core/SkMatrix.cpp
+++ b/src/core/SkMatrix.cpp
@@ -1268,57 +1268,6 @@
 
 ///////////////////////////////////////////////////////////////////////////////
 
-#include "SkPerspIter.h"
-
-SkPerspIter::SkPerspIter(const SkMatrix& m, SkScalar x0, SkScalar y0, int count)
-        : fMatrix(m), fSX(x0), fSY(y0), fCount(count) {
-    SkPoint pt;
-
-    SkMatrix::Persp_xy(m, x0, y0, &pt);
-    fX = SkScalarToFixed(pt.fX);
-    fY = SkScalarToFixed(pt.fY);
-}
-
-int SkPerspIter::next() {
-    int n = fCount;
-
-    if (0 == n) {
-        return 0;
-    }
-    SkPoint pt;
-    SkFixed x = fX;
-    SkFixed y = fY;
-    SkFixed dx, dy;
-
-    if (n >= kCount) {
-        n = kCount;
-        fSX += SkIntToScalar(kCount);
-        SkMatrix::Persp_xy(fMatrix, fSX, fSY, &pt);
-        fX = SkScalarToFixed(pt.fX);
-        fY = SkScalarToFixed(pt.fY);
-        dx = (fX - x) >> kShift;
-        dy = (fY - y) >> kShift;
-    } else {
-        fSX += SkIntToScalar(n);
-        SkMatrix::Persp_xy(fMatrix, fSX, fSY, &pt);
-        fX = SkScalarToFixed(pt.fX);
-        fY = SkScalarToFixed(pt.fY);
-        dx = (fX - x) / n;
-        dy = (fY - y) / n;
-    }
-
-    SkFixed* p = fStorage;
-    for (int i = 0; i < n; i++) {
-        *p++ = x; x += dx;
-        *p++ = y; y += dy;
-    }
-
-    fCount -= n;
-    return n;
-}
-
-///////////////////////////////////////////////////////////////////////////////
-
 static inline bool checkForZero(float x) {
     return x*x == 0;
 }
diff --git a/src/core/SkPerspIter.h b/src/core/SkPerspIter.h
deleted file mode 100644
index c0a9083..0000000
--- a/src/core/SkPerspIter.h
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Copyright 2006 The Android Open Source Project
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-
-#ifndef SkPerspIter_DEFINED
-#define SkPerspIter_DEFINED
-
-#include "SkFixed.h"
-#include "SkMatrix.h"
-
-class SkPerspIter {
-public:
-    /** Iterate a line through the matrix [x,y] ... [x+count-1, y].
-        @param m    The matrix we will be iterating a line through
-        @param x    The initial X coordinate to be mapped through the matrix
-        @param y    The initial Y coordinate to be mapped through the matrix
-        @param count The number of points (x,y) (x+1,y) (x+2,y) ... we will eventually map
-    */
-    SkPerspIter(const SkMatrix& m, SkScalar x, SkScalar y, int count);
-
-    /** Return the buffer of [x,y] fixed point values we will be filling.
-        This always returns the same value, so it can be saved across calls to
-        next().
-    */
-    const SkFixed* getXY() const { return fStorage; }
-
-    /** Return the number of [x,y] pairs that have been filled in the getXY() buffer.
-        When this returns 0, the iterator is finished.
-    */
-    int next();
-
-private:
-    enum {
-        kShift  = 4,
-        kCount  = (1 << kShift)
-    };
-    const SkMatrix& fMatrix;
-    SkFixed         fStorage[kCount * 2];
-    SkFixed         fX, fY;
-    SkScalar        fSX, fSY;
-    int             fCount;
-};
-
-#endif
diff --git a/src/opts/SkBitmapProcState_matrixProcs_neon.cpp b/src/opts/SkBitmapProcState_matrixProcs_neon.cpp
index 612ef04..1efd1ed 100644
--- a/src/opts/SkBitmapProcState_matrixProcs_neon.cpp
+++ b/src/opts/SkBitmapProcState_matrixProcs_neon.cpp
@@ -5,7 +5,6 @@
  */
 
 #include "SkBitmapProcState.h"
-#include "SkPerspIter.h"
 #include "SkShader.h"
 #include "SkUtilsArm.h"
 #include "SkBitmapProcState_utils.h"
diff --git a/src/opts/SkBitmapProcState_matrix_neon.h b/src/opts/SkBitmapProcState_matrix_neon.h
index fb91547..fabe45d 100644
--- a/src/opts/SkBitmapProcState_matrix_neon.h
+++ b/src/opts/SkBitmapProcState_matrix_neon.h
@@ -11,8 +11,6 @@
 #define SCALE_FILTER_NAME       MAKENAME(_filter_scale)
 #define AFFINE_NOFILTER_NAME    MAKENAME(_nofilter_affine)
 #define AFFINE_FILTER_NAME      MAKENAME(_filter_affine)
-#define PERSP_NOFILTER_NAME     MAKENAME(_nofilter_persp)
-#define PERSP_FILTER_NAME       MAKENAME(_filter_persp)
 
 #define PACK_FILTER_X_NAME  MAKENAME(_pack_filter_x)
 #define PACK_FILTER_Y_NAME  MAKENAME(_pack_filter_y)
@@ -180,55 +178,6 @@
     }
 }
 
-static void PERSP_NOFILTER_NAME(const SkBitmapProcState& s,
-                                uint32_t* SK_RESTRICT xy,
-                                int count, int x, int y) {
-    SkASSERT(s.fInvType & SkMatrix::kPerspective_Mask);
-
-    PREAMBLE(s);
-    // max{X,Y} are int here, but later shown/assumed to fit in 16 bits
-    int maxX = s.fPixmap.width() - 1;
-    int maxY = s.fPixmap.height() - 1;
-
-    SkPerspIter iter(s.fInvMatrix,
-                     SkIntToScalar(x) + SK_ScalarHalf,
-                     SkIntToScalar(y) + SK_ScalarHalf, count);
-
-    while ((count = iter.next()) != 0) {
-        const SkFixed* SK_RESTRICT srcXY = iter.getXY();
-
-        if (count >= 8) {
-            int32_t *mysrc = (int32_t *) srcXY;
-            int16_t *mydst = (int16_t *) xy;
-            do {
-                int16x8x2_t hi16;
-                int32x4x2_t xy1, xy2;
-
-                xy1 = vld2q_s32(mysrc);
-                xy2 = vld2q_s32(mysrc+8);
-
-                hi16.val[0] = TILEX_PROCF_NEON8(xy1.val[0], xy2.val[0], maxX);
-                hi16.val[1] = TILEY_PROCF_NEON8(xy1.val[1], xy2.val[1], maxY);
-
-                vst2q_s16(mydst, hi16);
-
-                count -= 8;  // 8 iterations
-                mysrc += 16; // 16 longs
-                mydst += 16; // 16 shorts, aka 8 longs
-            } while (count >= 8);
-            // get xy and srcXY fixed up
-            srcXY = (const SkFixed *) mysrc;
-            xy = (uint32_t *) mydst;
-        }
-
-        while (--count >= 0) {
-            *xy++ = (TILEY_PROCF(srcXY[1], maxY) << 16) |
-                     TILEX_PROCF(srcXY[0], maxX);
-            srcXY += 2;
-        }
-    }
-}
-
 static inline uint32_t PACK_FILTER_Y_NAME(SkFixed f, unsigned max,
                                           SkFixed one PREAMBLE_PARAM_Y) {
     unsigned i = TILEY_PROCF(f, max);
@@ -410,65 +359,11 @@
     }
 }
 
-static void PERSP_FILTER_NAME(const SkBitmapProcState& s,
-                              uint32_t* SK_RESTRICT xy, int count,
-                              int x, int y) {
-    SkASSERT(s.fInvType & SkMatrix::kPerspective_Mask);
-
-    PREAMBLE(s);
-    unsigned maxX = s.fPixmap.width() - 1;
-    unsigned maxY = s.fPixmap.height() - 1;
-    SkFixed oneX = s.fFilterOneX;
-    SkFixed oneY = s.fFilterOneY;
-
-    SkPerspIter iter(s.fInvMatrix,
-                     SkIntToScalar(x) + SK_ScalarHalf,
-                     SkIntToScalar(y) + SK_ScalarHalf, count);
-
-    while ((count = iter.next()) != 0) {
-        const SkFixed* SK_RESTRICT srcXY = iter.getXY();
-
-        while (count >= 4) {
-            int32x4_t wide_x, wide_y;
-            int32x4x2_t vxy, vresyx;
-
-            // load src:  x-y-x-y-x-y-x-y
-            vxy = vld2q_s32(srcXY);
-
-            // do the X side, then the Y side, then interleave them
-            wide_x = vsubq_s32(vxy.val[0], vdupq_n_s32(oneX>>1));
-            wide_y = vsubq_s32(vxy.val[1], vdupq_n_s32(oneY>>1));
-
-            vresyx.val[0] = PACK_FILTER_Y4_NAME(wide_y, maxY, oneY PREAMBLE_ARG_Y);
-            vresyx.val[1] = PACK_FILTER_X4_NAME(wide_x, maxX, oneX PREAMBLE_ARG_X);
-
-            // store interleaved as y-x-y-x-y-x-y-x (NB != read order)
-            vst2q_s32((int32_t*)xy, vresyx);
-
-            // on to the next iteration
-            srcXY += 2*4;
-            count -= 4;
-            xy += 2*4;
-        }
-
-        while (--count >= 0) {
-            // NB: we read x/y, we write y/x
-            *xy++ = PACK_FILTER_Y_NAME(srcXY[1] - (oneY >> 1), maxY,
-                                       oneY PREAMBLE_ARG_Y);
-            *xy++ = PACK_FILTER_X_NAME(srcXY[0] - (oneX >> 1), maxX,
-                                       oneX PREAMBLE_ARG_X);
-            srcXY += 2;
-        }
-    }
-}
-
 const SkBitmapProcState::MatrixProc MAKENAME(_Procs)[] = {
     SCALE_NOFILTER_NAME,
     SCALE_FILTER_NAME,
     AFFINE_NOFILTER_NAME,
     AFFINE_FILTER_NAME,
-    PERSP_NOFILTER_NAME,
-    PERSP_FILTER_NAME
 };
 
 #undef TILEX_PROCF_NEON8
@@ -488,8 +383,6 @@
 #undef SCALE_FILTER_NAME
 #undef AFFINE_NOFILTER_NAME
 #undef AFFINE_FILTER_NAME
-#undef PERSP_NOFILTER_NAME
-#undef PERSP_FILTER_NAME
 
 #undef PREAMBLE
 #undef PREAMBLE_PARAM_X